Merge pull request #1361 from DataDog/revert-1336-lpriima/_dd.measured

Revert "add ..."metrics":{"_dd.measured":1}... to every span"
This commit is contained in:
Tyler Benson 2020-04-10 14:28:51 -04:00 committed by GitHub
commit af188c2901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 25 deletions

View File

@ -899,7 +899,7 @@ public class Config {
* @return
* @deprecated This method should only be used internally. Use the explicit getter instead.
*/
private static String getSettingFromEnvironment(final String name, final String defaultValue) {
public static String getSettingFromEnvironment(final String name, final String defaultValue) {
String value;
final String systemPropertyName = propertyNameToSystemPropertyName(name);

View File

@ -25,11 +25,8 @@ public class DDSpanContext implements io.opentracing.SpanContext {
public static final String PRIORITY_SAMPLING_KEY = "_sampling_priority_v1";
public static final String SAMPLE_RATE_KEY = "_sample_rate";
public static final String ORIGIN_KEY = "_dd.origin";
public static final String DD_MEASURED = "_dd.measured";
public static final Number DD_MEASURED_DEFAULT = 1;
private static final Map<String, Number> DEFAULT_METRICS =
Collections.singletonMap(DD_MEASURED, DD_MEASURED_DEFAULT);
private static final Map<String, Number> EMPTY_METRICS = Collections.emptyMap();
// Shared with other span contexts
/** For technical reasons, the ref to the original tracer */
@ -310,12 +307,12 @@ public class DDSpanContext implements io.opentracing.SpanContext {
public Map<String, Number> getMetrics() {
final Map<String, Number> metrics = this.metrics.get();
return metrics == null ? DEFAULT_METRICS : metrics;
return metrics == null ? EMPTY_METRICS : metrics;
}
public void setMetric(final String key, final Number value) {
if (metrics.get() == null) {
metrics.compareAndSet(null, new ConcurrentHashMap<>(DEFAULT_METRICS));
metrics.compareAndSet(null, new ConcurrentHashMap<String, Number>());
}
if (value instanceof Float) {
metrics.get().put(key, value.doubleValue());

View File

@ -20,7 +20,6 @@ class DDSpanSerializationTest extends DDSpecification {
def jsonAdapter = new Moshi.Builder().build().adapter(Map)
final Map<String, Number> metrics = ["_sampling_priority_v1": 1]
metrics.putAll(DDSpanContext.DEFAULT_METRICS)
if (samplingPriority == PrioritySampling.UNSET) { // RateByServiceSampler sets priority
metrics.put("_dd.agent_psr", 1.0d)
}

View File

@ -279,13 +279,10 @@ class SpanDecoratorTest extends DDSpecification {
def "span metrics starts empty but added with rate limiting value of #rate"() {
expect:
span.metrics == DDSpanContext.DEFAULT_METRICS
span.metrics == [:]
when:
span.setTag(ANALYTICS_SAMPLE_RATE, rate)
// these 2 lines to avoid checking for {@code DDSpanContext.DD_MEASURED} for every metric:
span.context().setMetric(DDSpanContext.DD_MEASURED, 42)
span.metrics.remove(DDSpanContext.DD_MEASURED, 42)
then:
span.metrics == result

View File

@ -1,6 +1,5 @@
package datadog.trace
import datadog.opentracing.DDSpanContext
import datadog.opentracing.SpanFactory
import datadog.trace.api.DDTags
import datadog.trace.util.test.DDSpecification
@ -19,7 +18,7 @@ class DDSpanContextTest extends DDSpecification {
context.serviceName == "fakeService"
context.resourceName == "fakeResource"
context.spanType == "fakeType"
context.toString() == "DDSpan [ t_id=1, s_id=1, p_id=0] trace=fakeService/fakeOperation/fakeResource metrics=${defaultMetrics()} *errored* tags={${extra}${tags.containsKey(DDTags.SPAN_TYPE) ? "span.type=${context.getSpanType()}, " : ""}thread.id=${Thread.currentThread().id}, thread.name=${Thread.currentThread().name}}"
context.toString() == "DDSpan [ t_id=1, s_id=1, p_id=0] trace=fakeService/fakeOperation/fakeResource metrics={} *errored* tags={${extra}${tags.containsKey(DDTags.SPAN_TYPE) ? "span.type=${context.getSpanType()}, " : ""}thread.id=${Thread.currentThread().id}, thread.name=${Thread.currentThread().name}}"
where:
name | extra | tags
@ -36,7 +35,7 @@ class DDSpanContextTest extends DDSpecification {
def thread = Thread.currentThread()
def expectedTags = [(DDTags.THREAD_NAME): thread.name, (DDTags.THREAD_ID): thread.id]
def expectedTrace = "DDSpan [ t_id=1, s_id=1, p_id=0] trace=$details metrics=${defaultMetrics()} tags={thread.id=$thread.id, thread.name=$thread.name}"
def expectedTrace = "DDSpan [ t_id=1, s_id=1, p_id=0] trace=$details metrics={} tags={thread.id=$thread.id, thread.name=$thread.name}"
expect:
context.getTags() == expectedTags
@ -62,7 +61,7 @@ class DDSpanContextTest extends DDSpecification {
(DDTags.THREAD_NAME): thread.name,
(DDTags.THREAD_ID) : thread.id
]
context.toString() == "DDSpan [ t_id=1, s_id=1, p_id=0] trace=fakeService/fakeOperation/fakeResource metrics=${defaultMetrics()} tags={$name=$value, thread.id=$thread.id, thread.name=$thread.name}"
context.toString() == "DDSpan [ t_id=1, s_id=1, p_id=0] trace=fakeService/fakeOperation/fakeResource metrics={} tags={$name=$value, thread.id=$thread.id, thread.name=$thread.name}"
where:
name | value
@ -99,8 +98,4 @@ class DDSpanContextTest extends DDSpecification {
Double | 0.5d
Integer | 0x55
}
static String defaultMetrics() {
return DDSpanContext.DEFAULT_METRICS
}
}

View File

@ -2,7 +2,6 @@ package datadog.trace.api.writer
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import datadog.opentracing.DDSpanContext
import datadog.opentracing.SpanFactory
import datadog.trace.common.writer.ddagent.DDAgentApi
import datadog.trace.common.writer.ddagent.DDAgentResponseListener
@ -102,8 +101,7 @@ class DDAgentApiTest extends DDSpecification {
"duration" : 0,
"error" : 0,
"meta" : ["thread.name": Thread.currentThread().getName(), "thread.id": "${Thread.currentThread().id}"],
//TODO : use DDSpanContext.DD_MEASURED as a key
"metrics" : ["_dd.measured": DDSpanContext.DD_MEASURED_DEFAULT],
"metrics" : [:],
"name" : "fakeOperation",
"parent_id": 0,
"resource" : "fakeResource",
@ -117,7 +115,7 @@ class DDAgentApiTest extends DDSpecification {
"duration" : 0,
"error" : 0,
"meta" : ["thread.name": Thread.currentThread().getName(), "thread.id": "${Thread.currentThread().id}"],
"metrics" : ["_dd.measured": DDSpanContext.DD_MEASURED_DEFAULT],
"metrics" : [:],
"name" : "fakeOperation",
"parent_id": 0,
"resource" : "my-resource",

View File

@ -16,6 +16,6 @@ class LoggingWriterTest extends DDSpecification {
def "test toString"() {
expect:
writer.toString(sampleTrace).startsWith('[{"service":"fakeService","name":"fakeOperation","resource":"fakeResource","trace_id":1,"span_id":1,"parent_id":0,"start":1000,"duration":0,"type":"fakeType","error":0,"metrics":{"_dd.measured":1},"meta":{')
writer.toString(sampleTrace).startsWith('[{"service":"fakeService","name":"fakeOperation","resource":"fakeResource","trace_id":1,"span_id":1,"parent_id":0,"start":1000,"duration":0,"type":"fakeType","error":0,"metrics":{},"meta":{')
}
}