Skip to content

Commit dc7d81e

Browse files
authored
Remove sampling (#17)
1 parent d86632d commit dc7d81e

File tree

56 files changed

+88
-1393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+88
-1393
lines changed

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/instrumentation/api/Tags.java

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class Tags {
1616
public static final String PEER_SERVICE = "peer.service";
1717
public static final String PEER_HOSTNAME = "peer.hostname";
1818
public static final String PEER_PORT = "peer.port";
19-
public static final String SAMPLING_PRIORITY = "sampling.priority";
2019
public static final String SPAN_KIND = "span.kind";
2120
public static final String COMPONENT = "component";
2221
public static final String ERROR = "error";

dd-java-agent/agent-tooling/agent-tooling.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply from: "${rootDir}/gradle/java.gradle"
22

33
minimumBranchCoverage = 0.6
4+
minimumInstructionCoverage = 0.8
45
excludedClassesCoverage += ['datadog.trace.agent.tooling.*']
56

67
configurations {

dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/decorator/BaseDecorator.java

+1-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package datadog.trace.agent.decorator;
22

3-
import datadog.trace.api.Config;
43
import datadog.trace.api.DDTags;
54
import datadog.trace.instrumentation.api.AgentScope;
65
import datadog.trace.instrumentation.api.AgentSpan;
@@ -10,44 +9,24 @@
109
import java.net.Inet6Address;
1110
import java.net.InetAddress;
1211
import java.net.InetSocketAddress;
13-
import java.util.Arrays;
14-
import java.util.TreeSet;
1512
import java.util.concurrent.ExecutionException;
1613

1714
public abstract class BaseDecorator {
1815

19-
protected final boolean traceAnalyticsEnabled;
20-
protected final float traceAnalyticsSampleRate;
21-
22-
protected BaseDecorator() {
23-
final Config config = Config.get();
24-
final String[] instrumentationNames = instrumentationNames();
25-
traceAnalyticsEnabled =
26-
instrumentationNames.length > 0
27-
&& config.isTraceAnalyticsIntegrationEnabled(
28-
new TreeSet<>(Arrays.asList(instrumentationNames)), traceAnalyticsDefault());
29-
traceAnalyticsSampleRate = config.getInstrumentationAnalyticsSampleRate(instrumentationNames);
30-
}
16+
protected BaseDecorator() {}
3117

3218
protected abstract String[] instrumentationNames();
3319

3420
protected abstract String spanType();
3521

3622
protected abstract String component();
3723

38-
protected boolean traceAnalyticsDefault() {
39-
return false;
40-
}
41-
4224
public AgentSpan afterStart(final AgentSpan span) {
4325
assert span != null;
4426
if (spanType() != null) {
4527
span.setTag(DDTags.SPAN_TYPE, spanType());
4628
}
4729
span.setTag(Tags.COMPONENT.getKey(), component());
48-
if (traceAnalyticsEnabled) {
49-
span.setTag(DDTags.ANALYTICS_SAMPLE_RATE, traceAnalyticsSampleRate);
50-
}
5130
return span;
5231
}
5332

dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/decorator/HttpServerDecorator.java

-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ protected String spanType() {
3636
return DDSpanTypes.HTTP_SERVER;
3737
}
3838

39-
@Override
40-
protected boolean traceAnalyticsDefault() {
41-
return Config.get().isTraceAnalyticsEnabled();
42-
}
43-
4439
public AgentSpan onRequest(final AgentSpan span, final REQUEST request) {
4540
assert span != null;
4641
if (request != null) {

dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/decorator/BaseDecoratorTest.groovy

+17-108
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package datadog.trace.agent.decorator
22

3-
import datadog.trace.agent.test.utils.ConfigUtils
3+
44
import datadog.trace.api.DDTags
55
import datadog.trace.instrumentation.api.AgentScope
66
import datadog.trace.instrumentation.api.AgentSpan
@@ -139,51 +139,6 @@ class BaseDecoratorTest extends DDSpecification {
139139
1 * scope.span() >> span
140140
}
141141

142-
def "test analytics rate default disabled"() {
143-
when:
144-
BaseDecorator dec = newDecorator(defaultEnabled, hasConfigNames)
145-
146-
then:
147-
dec.traceAnalyticsEnabled == defaultEnabled
148-
dec.traceAnalyticsSampleRate == sampleRate.floatValue()
149-
150-
where:
151-
defaultEnabled | hasConfigNames | sampleRate
152-
true | false | 1.0
153-
false | false | 1.0
154-
false | true | 1.0
155-
}
156-
157-
def "test analytics rate enabled:#enabled, integration:#integName, sampleRate:#sampleRate"() {
158-
setup:
159-
ConfigUtils.updateConfig {
160-
System.properties.setProperty("dd.${integName}.analytics.enabled", "true")
161-
System.properties.setProperty("dd.${integName}.analytics.sample-rate", "$sampleRate")
162-
}
163-
164-
when:
165-
BaseDecorator dec = newDecorator(enabled)
166-
167-
then:
168-
dec.traceAnalyticsEnabled == expectedEnabled
169-
dec.traceAnalyticsSampleRate == (Float) expectedRate
170-
171-
cleanup:
172-
System.clearProperty("dd.${integName}.analytics.enabled")
173-
System.clearProperty("dd.${integName}.analytics.sample-rate")
174-
175-
where:
176-
enabled | integName | sampleRate | expectedEnabled | expectedRate
177-
false | "" | "" | false | 1.0
178-
true | "" | "" | true | 1.0
179-
false | "test1" | 0.5 | true | 0.5
180-
false | "test2" | 0.75 | true | 0.75
181-
true | "test1" | 0.2 | true | 0.2
182-
true | "test2" | 0.4 | true | 0.4
183-
true | "test1" | "" | true | 1.0
184-
true | "test2" | "" | true | 1.0
185-
}
186-
187142
def "test spanNameForMethod"() {
188143
when:
189144
def result = decorator.spanNameForMethod(method)
@@ -201,68 +156,22 @@ class BaseDecoratorTest extends DDSpecification {
201156
}
202157

203158
def newDecorator() {
204-
return newDecorator(false)
205-
}
206-
207-
def newDecorator(boolean analyticsEnabledDefault, boolean emptyInstrumentationNames = false) {
208-
return emptyInstrumentationNames ?
209-
new BaseDecorator() {
210-
@Override
211-
protected String[] instrumentationNames() {
212-
return []
213-
}
214-
215-
@Override
216-
protected String spanType() {
217-
return "test-type"
218-
}
219-
220-
@Override
221-
protected String component() {
222-
return "test-component"
223-
}
224-
225-
protected boolean traceAnalyticsDefault() {
226-
return true
227-
}
228-
} :
229-
analyticsEnabledDefault ?
230-
new BaseDecorator() {
231-
@Override
232-
protected String[] instrumentationNames() {
233-
return ["test1", "test2"]
234-
}
235-
236-
@Override
237-
protected String spanType() {
238-
return "test-type"
239-
}
240-
241-
@Override
242-
protected String component() {
243-
return "test-component"
244-
}
245-
246-
protected boolean traceAnalyticsDefault() {
247-
return true
248-
}
249-
} :
250-
new BaseDecorator() {
251-
@Override
252-
protected String[] instrumentationNames() {
253-
return ["test1", "test2"]
254-
}
255-
256-
@Override
257-
protected String spanType() {
258-
return "test-type"
259-
}
260-
261-
@Override
262-
protected String component() {
263-
return "test-component"
264-
}
265-
}
159+
return new BaseDecorator() {
160+
@Override
161+
protected String[] instrumentationNames() {
162+
return []
163+
}
164+
165+
@Override
166+
protected String spanType() {
167+
return "test-type"
168+
}
169+
170+
@Override
171+
protected String component() {
172+
return "test-component"
173+
}
174+
}
266175
}
267176

268177
class SomeInnerClass implements Runnable {

dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/decorator/ClientDecoratorTest.groovy

-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class ClientDecoratorTest extends BaseDecoratorTest {
2222
1 * span.setTag(Tags.COMPONENT.key, "test-component")
2323
1 * span.setTag(Tags.SPAN_KIND.key, "client")
2424
1 * span.setTag(DDTags.SPAN_TYPE, decorator.spanType())
25-
1 * span.setTag(DDTags.ANALYTICS_SAMPLE_RATE, 1.0)
2625
_ * span.setTag(_, _) // Want to allow other calls from child implementations.
2726
0 * _
2827

@@ -64,10 +63,6 @@ class ClientDecoratorTest extends BaseDecoratorTest {
6463
protected String component() {
6564
return "test-component"
6665
}
67-
68-
protected boolean traceAnalyticsDefault() {
69-
return true
70-
}
7166
}
7267
}
7368
}

dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/decorator/DatabaseClientDecoratorTest.groovy

-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class DatabaseClientDecoratorTest extends ClientDecoratorTest {
2626
1 * span.setTag(Tags.SPAN_KIND.key, "client")
2727
1 * span.setTag(Tags.DB_TYPE.key, "test-db")
2828
1 * span.setTag(DDTags.SPAN_TYPE, "test-type")
29-
1 * span.setTag(DDTags.ANALYTICS_SAMPLE_RATE, 1.0)
3029
0 * _
3130

3231
where:
@@ -138,10 +137,6 @@ class DatabaseClientDecoratorTest extends ClientDecoratorTest {
138137
protected String dbInstance(Map map) {
139138
return map.instance
140139
}
141-
142-
protected boolean traceAnalyticsDefault() {
143-
return true
144-
}
145140
}
146141
}
147142
}

dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/decorator/HttpClientDecoratorTest.groovy

-4
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@ class HttpClientDecoratorTest extends ClientDecoratorTest {
174174
protected Integer status(Map m) {
175175
return m.status
176176
}
177-
178-
protected boolean traceAnalyticsDefault() {
179-
return true
180-
}
181177
}
182178
}
183179
}

dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/decorator/ServerDecoratorTest.groovy

-7
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ class ServerDecoratorTest extends BaseDecoratorTest {
1919
1 * span.setTag(Tags.COMPONENT.key, "test-component")
2020
1 * span.setTag(Tags.SPAN_KIND.key, "server")
2121
1 * span.setTag(DDTags.SPAN_TYPE, decorator.spanType())
22-
if (decorator.traceAnalyticsEnabled) {
23-
1 * span.setTag(DDTags.ANALYTICS_SAMPLE_RATE, 1.0)
24-
}
2522
0 * _
2623
}
2724

@@ -50,10 +47,6 @@ class ServerDecoratorTest extends BaseDecoratorTest {
5047
protected String component() {
5148
return "test-component"
5249
}
53-
54-
protected boolean traceAnalyticsDefault() {
55-
return true
56-
}
5750
}
5851
}
5952
}

dd-java-agent/instrumentation/ratpack-1.4/src/main/java8/datadog/trace/instrumentation/ratpack/RatpackServerDecorator.java

-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ protected String component() {
2626
return "ratpack";
2727
}
2828

29-
@Override
30-
protected boolean traceAnalyticsDefault() {
31-
return false;
32-
}
33-
3429
@Override
3530
protected String method(final Request request) {
3631
return request.getMethod().getName();

dd-java-agent/instrumentation/spring-webmvc-3.1/src/main/java/datadog/trace/instrumentation/springweb/SpringWebHttpServerDecorator.java

-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ protected String component() {
3838
return "spring-web-controller";
3939
}
4040

41-
@Override
42-
protected boolean traceAnalyticsDefault() {
43-
return false;
44-
}
45-
4641
@Override
4742
protected String method(final HttpServletRequest httpServletRequest) {
4843
return httpServletRequest.getMethod();

dd-java-agent/testing/src/test/groovy/context/FieldBackedProviderTest.groovy

-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ class FieldBackedProviderFieldInjectionDisabledTest extends AgentTestRunner {
215215
}
216216

217217
expect:
218-
Config.get().isPrioritySamplingEnabled() == false
219218
hasField == false
220219
hasMarkerInterface == false
221220
hasAccessorInterface == false

0 commit comments

Comments
 (0)