Search in sources :

Example 6 with SamplingStatisticsDocument

use of com.amazonaws.services.xray.model.SamplingStatisticsDocument in project aws-xray-sdk-java by aws.

the class CentralizedManifest method snapshots.

public List<SamplingStatisticsDocument> snapshots(Instant now) {
    List<SamplingStatisticsDocument> snapshots = new ArrayList<>(rules.size() + 1);
    Date date = Date.from(now);
    for (CentralizedRule rule : rules.values()) {
        if (!rule.isStale(now)) {
            continue;
        }
        SamplingStatisticsDocument snapshot = rule.snapshot(date);
        snapshot.withClientID(CentralizedSamplingStrategy.getClientID());
        snapshots.add(snapshot);
    }
    if (defaultRule != null && defaultRule.isStale(now)) {
        SamplingStatisticsDocument snapshot = defaultRule.snapshot(date);
        snapshot.withClientID(CentralizedSamplingStrategy.getClientID());
        snapshots.add(snapshot);
    }
    return snapshots;
}
Also used : SamplingStatisticsDocument(com.amazonaws.services.xray.model.SamplingStatisticsDocument) ArrayList(java.util.ArrayList) CentralizedRule(com.amazonaws.xray.strategy.sampling.rule.CentralizedRule) Date(java.util.Date)

Example 7 with SamplingStatisticsDocument

use of com.amazonaws.services.xray.model.SamplingStatisticsDocument in project aws-xray-sdk-java by aws.

the class TargetPoller method pollManifest.

private void pollManifest() {
    List<SamplingStatisticsDocument> statistics = manifest.snapshots(clock.instant());
    if (statistics.size() == 0) {
        logger.trace("No statistics to report. Not refreshing sampling targets.");
        return;
    }
    logger.debug("Polling sampling targets.");
    GetSamplingTargetsRequest req = new GetSamplingTargetsRequest().withSamplingStatisticsDocuments(statistics);
    GetSamplingTargetsResult result = client.getSamplingTargets(req);
    manifest.putTargets(result.getSamplingTargetDocuments(), clock.instant());
}
Also used : SamplingStatisticsDocument(com.amazonaws.services.xray.model.SamplingStatisticsDocument) GetSamplingTargetsRequest(com.amazonaws.services.xray.model.GetSamplingTargetsRequest) GetSamplingTargetsResult(com.amazonaws.services.xray.model.GetSamplingTargetsResult)

Aggregations

SamplingStatisticsDocument (com.amazonaws.services.xray.model.SamplingStatisticsDocument)7 CentralizedRule (com.amazonaws.xray.strategy.sampling.rule.CentralizedRule)3 GetSamplingTargetsRequest (com.amazonaws.services.xray.model.GetSamplingTargetsRequest)2 GetSamplingTargetsResult (com.amazonaws.services.xray.model.GetSamplingTargetsResult)2 Instant (java.time.Instant)2 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2 SamplingRule (com.amazonaws.services.xray.model.SamplingRule)1 SamplingTargetDocument (com.amazonaws.services.xray.model.SamplingTargetDocument)1 RandImpl (com.amazonaws.xray.strategy.sampling.rand.RandImpl)1 Clock (java.time.Clock)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1