-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Migrate XRax inject calls to new API
- Loading branch information
1 parent
09144b5
commit ddb0406
Showing
6 changed files
with
64 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
dd-trace-core/src/main/java/datadog/trace/core/propagation/XRayPropagator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package datadog.trace.core.propagation; | ||
|
||
import static datadog.trace.bootstrap.instrumentation.api.AgentSpan.fromContext; | ||
|
||
import datadog.context.Context; | ||
import datadog.context.propagation.CarrierSetter; | ||
import datadog.context.propagation.CarrierVisitor; | ||
import datadog.context.propagation.Propagator; | ||
import datadog.trace.api.Config; | ||
import datadog.trace.bootstrap.instrumentation.api.AgentSpan; | ||
import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; | ||
import datadog.trace.core.DDSpanContext; | ||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
@ParametersAreNonnullByDefault | ||
public class XRayPropagator implements Propagator { | ||
public static final Propagator INSTANCE = new XRayPropagator(); | ||
private final HttpCodec.Injector injector; | ||
|
||
public XRayPropagator() { | ||
this.injector = XRayHttpCodec.newInjector(Config.get().getBaggageMapping()); | ||
} | ||
|
||
@Override | ||
public <C> void inject(Context context, C carrier, CarrierSetter<C> setter) { | ||
AgentSpan span; | ||
//noinspection ConstantValue | ||
if (context == null | ||
|| carrier == null | ||
|| setter == null | ||
|| (span = fromContext(context)) == null) { | ||
return; | ||
} | ||
AgentSpanContext spanContext = span.context(); | ||
if (spanContext instanceof DDSpanContext) { | ||
DDSpanContext ddSpanContext = (DDSpanContext) context; | ||
this.injector.inject(ddSpanContext, carrier, setter::set); | ||
} | ||
} | ||
|
||
@Override | ||
public <C> Context extract(Context context, C carrier, CarrierVisitor<C> visitor) { | ||
return context; | ||
} | ||
} |