@@ -315,37 +315,16 @@ public boolean acceptDistributedTracePayload(String payload) {
315
315
}
316
316
}
317
317
318
- public boolean acceptDistributedTracePayload (DistributedTracePayload payload , W3CTraceParent parent ) {
319
- DistributedTracingConfig dtConfig = getAgentConfig ().getDistributedTracingConfig ();
320
- if (dtConfig .isEnabled ()) {
318
+ public boolean acceptDistributedTracePayload (DistributedTracePayload payload ) {
319
+ if (getAgentConfig ().getDistributedTracingConfig ().isEnabled ()) {
321
320
long elapsedMillis = TimeUnit .NANOSECONDS .toMillis (
322
321
System .nanoTime () - this .getTransactionTimer ().getStartTimeInNanos ());
323
322
long txnStartTimeSinceEpochInMillis = System .currentTimeMillis () - elapsedMillis ;
324
323
spanProxy .get ().setTimestamp (txnStartTimeSinceEpochInMillis );
325
324
boolean accepted = spanProxy .get ().acceptDistributedTracePayload (payload );
326
325
if (accepted ) {
327
326
this .transportDurationInMillis = spanProxy .get ().getTransportDurationInMillis ();
328
- if (parent != null ) {
329
- if (parent .sampled ()) { // traceparent exists and sampled is 1
330
- if (DistributedTracingConfig .SAMPLE_ALWAYS_ON .equals (dtConfig .getRemoteParentSampled ())) {
331
- this .setPriorityIfNotNull (2.0f );
332
- } else if (DistributedTracingConfig .SAMPLE_ALWAYS_OFF .equals (dtConfig .getRemoteParentSampled ())) {
333
- this .setPriorityIfNotNull (0.0f );
334
- } else {
335
- this .setPriorityIfNotNull (spanProxy .get ().getInboundDistributedTracePayload ().priority );
336
- }
337
- } else { // traceparent exists and sampled is 0
338
- if (DistributedTracingConfig .SAMPLE_ALWAYS_ON .equals (dtConfig .getRemoteParentNotSampled ())) {
339
- this .setPriorityIfNotNull (2.0f );
340
- } else if (DistributedTracingConfig .SAMPLE_ALWAYS_OFF .equals (dtConfig .getRemoteParentNotSampled ())) {
341
- this .setPriorityIfNotNull (0.0f );
342
- } else {
343
- this .setPriorityIfNotNull (spanProxy .get ().getInboundDistributedTracePayload ().priority );
344
- }
345
- }
346
- } else {
347
- this .setPriorityIfNotNull (spanProxy .get ().getInboundDistributedTracePayload ().priority );
348
- }
327
+ this .setPriorityIfNotNull (spanProxy .get ().getInboundDistributedTracePayload ().priority );
349
328
}
350
329
return accepted ;
351
330
} else {
@@ -354,6 +333,25 @@ public boolean acceptDistributedTracePayload(DistributedTracePayload payload, W3
354
333
}
355
334
}
356
335
336
+ public void applyDistributedTracingSamplerConfig (W3CTraceParent parent ) {
337
+ if (parent != null ) {
338
+ DistributedTracingConfig dtConfig = getAgentConfig ().getDistributedTracingConfig ();
339
+ if (parent .sampled ()) { // traceparent exists and sampled is 1
340
+ if (DistributedTracingConfig .SAMPLE_ALWAYS_ON .equals (dtConfig .getRemoteParentSampled ())) {
341
+ this .setPriorityIfNotNull (2.0f );
342
+ } else if (DistributedTracingConfig .SAMPLE_ALWAYS_OFF .equals (dtConfig .getRemoteParentSampled ())) {
343
+ this .setPriorityIfNotNull (0.0f );
344
+ } // else leave it as it was
345
+ } else { // traceparent exists and sampled is 0
346
+ if (DistributedTracingConfig .SAMPLE_ALWAYS_ON .equals (dtConfig .getRemoteParentNotSampled ())) {
347
+ this .setPriorityIfNotNull (2.0f );
348
+ } else if (DistributedTracingConfig .SAMPLE_ALWAYS_OFF .equals (dtConfig .getRemoteParentNotSampled ())) {
349
+ this .setPriorityIfNotNull (0.0f );
350
+ } // else leave it as it was
351
+ }
352
+ }
353
+ }
354
+
357
355
private void checkAndSetPriority () {
358
356
if (getAgentConfig ().getDistributedTracingConfig ().isEnabled ()) {
359
357
DistributedTraceService distributedTraceService = ServiceFactory .getDistributedTraceService ();
0 commit comments