Skip to content

Commit

Permalink
Promote span.kind as RED metrics (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
yzheqing authored Feb 21, 2020
1 parent 517cc1e commit 6dfb15d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions proxy/src/main/java/com/wavefront/agent/ProxyConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import static com.wavefront.common.Utils.getLocalHostName;
import static com.wavefront.common.Utils.getBuildVersion;

import static io.opentracing.tag.Tags.SPAN_KIND;

/**
* Proxy configuration (refactored from {@link com.wavefront.agent.AbstractAgent}).
*
Expand All @@ -52,6 +54,7 @@ public class ProxyConfig extends Configuration {
private static final double MAX_RETRY_BACKOFF_BASE_SECONDS = 60.0;
private static final int GRAPHITE_LISTENING_PORT = 2878;


@Parameter(names = {"--help"}, help = true)
boolean help = false;

Expand Down Expand Up @@ -1174,8 +1177,10 @@ public Integer getTraceSamplingDuration() {
}

public Set<String> getTraceDerivedCustomTagKeys() {
return new HashSet<>(Splitter.on(",").trimResults().omitEmptyStrings().
splitToList(ObjectUtils.firstNonNull(traceDerivedCustomTagKeys, "")));
Set<String> customTagKeys = new HashSet<>(Splitter.on(",").trimResults().omitEmptyStrings().
splitToList(ObjectUtils.firstNonNull(traceDerivedCustomTagKeys, "")));
customTagKeys.add(SPAN_KIND.getKey()); // add span.kind tag by default
return customTagKeys;
}

public boolean isTraceAlwaysSampleErrors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
import static com.wavefront.sdk.common.Constants.SERVICE_TAG_KEY;
import static com.wavefront.sdk.common.Constants.SHARD_TAG_KEY;
import static com.wavefront.sdk.common.Constants.SOURCE_KEY;
import static com.wavefront.sdk.common.Constants.NULL_TAG_VAL;
import static com.wavefront.sdk.common.Utils.sanitizeWithoutQuotes;

import static io.opentracing.tag.Tags.SPAN_KIND;

/**
* Util methods to generate data (metrics/histograms/heartbeats) from tracing spans
*
Expand Down Expand Up @@ -140,15 +143,17 @@ static void reportHeartbeats(String component,
Iterator<HeartbeatMetricKey> iter = discoveredHeartbeatMetrics.keySet().iterator();
while (iter.hasNext()) {
HeartbeatMetricKey key = iter.next();
wavefrontSender.sendMetric(HEART_BEAT_METRIC, 1.0, Clock.now(),
key.getSource(), new HashMap<String, String>() {{
Map<String, String> tags = new HashMap<String, String>() {{
put(APPLICATION_TAG_KEY, key.getApplication());
put(SERVICE_TAG_KEY, key.getService());
put(CLUSTER_TAG_KEY, key.getCluster());
put(SHARD_TAG_KEY, key.getShard());
put(COMPONENT_TAG_KEY, component);
putAll(key.getCustomTags());
}});
}};
tags.putIfAbsent(SPAN_KIND.getKey(), NULL_TAG_VAL);
wavefrontSender.sendMetric(HEART_BEAT_METRIC, 1.0, Clock.now(),
key.getSource(), tags);
// remove from discovered list so that it is only reported on subsequent discovery
discoveredHeartbeatMetrics.remove(key);
}
Expand Down

0 comments on commit 6dfb15d

Please sign in to comment.