|
5 | 5 | import static datadog.trace.api.DDTags.ORIGIN_KEY; |
6 | 6 | import static datadog.trace.api.DDTags.SPAN_TYPE; |
7 | 7 | import static datadog.trace.api.sampling.PrioritySampling.USER_DROP; |
| 8 | +import static datadog.trace.api.sampling.PrioritySampling.USER_KEEP; |
8 | 9 | import static datadog.trace.bootstrap.instrumentation.api.Tags.HTTP_METHOD; |
9 | 10 | import static datadog.trace.bootstrap.instrumentation.api.Tags.HTTP_STATUS; |
10 | 11 | import static datadog.trace.bootstrap.instrumentation.api.Tags.HTTP_URL; |
11 | 12 | import static datadog.trace.core.taginterceptor.RuleFlags.Feature.FORCE_MANUAL_DROP; |
| 13 | +import static datadog.trace.core.taginterceptor.RuleFlags.Feature.FORCE_SAMPLING_PRIORITY; |
12 | 14 | import static datadog.trace.core.taginterceptor.RuleFlags.Feature.PEER_SERVICE; |
13 | 15 | import static datadog.trace.core.taginterceptor.RuleFlags.Feature.RESOURCE_NAME; |
14 | 16 | import static datadog.trace.core.taginterceptor.RuleFlags.Feature.SERVICE_NAME; |
@@ -98,6 +100,8 @@ public boolean interceptTag(DDSpanContext span, String tag, Object value) { |
98 | 100 | case DDTags.MANUAL_DROP: |
99 | 101 | return interceptSamplingPriority( |
100 | 102 | FORCE_MANUAL_DROP, USER_DROP, SamplingMechanism.MANUAL, span, value); |
| 103 | + case Tags.SAMPLING_PRIORITY: |
| 104 | + return interceptSamplingPriority(span, value); |
101 | 105 | case InstrumentationTags.SERVLET_CONTEXT: |
102 | 106 | return interceptServletContext(span, value); |
103 | 107 | case SPAN_TYPE: |
@@ -241,6 +245,18 @@ private boolean interceptSamplingPriority( |
241 | 245 | return false; |
242 | 246 | } |
243 | 247 |
|
| 248 | + private boolean interceptSamplingPriority(DDSpanContext span, Object value) { |
| 249 | + if (ruleFlags.isEnabled(FORCE_SAMPLING_PRIORITY)) { |
| 250 | + Number samplingPriority = getOrTryParse(value); |
| 251 | + if (null != samplingPriority) { |
| 252 | + span.setSamplingPriority( |
| 253 | + samplingPriority.intValue() > 0 ? USER_KEEP : USER_DROP, SamplingMechanism.MANUAL); |
| 254 | + } |
| 255 | + return true; |
| 256 | + } |
| 257 | + return false; |
| 258 | + } |
| 259 | + |
244 | 260 | private boolean interceptServletContext(DDSpanContext span, Object value) { |
245 | 261 | // even though this tag is sometimes used to set the service name |
246 | 262 | // (which has the side effect of marking the span as eligible for metrics |
|
0 commit comments