-
Notifications
You must be signed in to change notification settings - Fork 320
Baggage E2E "working" #8699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Baggage E2E "working" #8699
Changes from all commits
56802d6
ff0a3be
2ea2788
210aebe
2fe727e
6bc47ce
c7ba3d4
8ccb7b5
cb6a6f9
4d5ed09
2dab314
c78a5c8
0487371
ea19707
7b258fc
882611b
f3e8a5f
6d2a261
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,25 @@ | ||
| package datadog.trace.instrumentation.akkahttp; | ||
|
|
||
| import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan; | ||
| import static datadog.trace.instrumentation.akkahttp.AkkaHttpServerDecorator.DECORATE; | ||
|
|
||
| import akka.http.scaladsl.model.HttpRequest; | ||
| import akka.http.scaladsl.model.HttpResponse; | ||
| import datadog.context.Context; | ||
| import datadog.trace.bootstrap.instrumentation.api.AgentScope; | ||
| import datadog.trace.bootstrap.instrumentation.api.AgentSpan; | ||
| import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; | ||
|
|
||
| public class DatadogWrapperHelper { | ||
| public static AgentScope createSpan(final HttpRequest request) { | ||
| final AgentSpanContext.Extracted extractedContext = DECORATE.extract(request); | ||
| final AgentSpan span = DECORATE.startSpan(request, extractedContext); | ||
| final Context extractedContext = DECORATE.extract(request); | ||
| AgentSpan extractedSpan = AgentSpan.fromContext(extractedContext); | ||
| AgentSpanContext.Extracted extractedSpanContext = | ||
| extractedSpan == null ? null : (AgentSpanContext.Extracted) extractedSpan.context(); | ||
| final AgentSpan span = DECORATE.startSpan(request, extractedSpanContext); | ||
| DECORATE.afterStart(span); | ||
| DECORATE.onRequest(span, request, request, extractedContext); | ||
| DECORATE.onRequest(span, request, request, extractedSpanContext); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels like |
||
|
|
||
| return activateSpan(span); | ||
| return (AgentScope) extractedContext.with(span).attach(); | ||
| } | ||
|
|
||
| public static void finishSpan(final AgentSpan span, final HttpResponse response) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |||||
|
|
||||||
| import static datadog.trace.api.datastreams.DataStreamsContext.fromTags; | ||||||
| import static datadog.trace.api.gateway.Events.EVENTS; | ||||||
| import static datadog.trace.bootstrap.instrumentation.api.AgentPropagation.extractContextAndGetSpanContext; | ||||||
| import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan; | ||||||
| import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan; | ||||||
| import static datadog.trace.instrumentation.armeria.grpc.server.GrpcExtractAdapter.GETTER; | ||||||
|
|
@@ -11,6 +10,8 @@ | |||||
| import static datadog.trace.instrumentation.armeria.grpc.server.GrpcServerDecorator.GRPC_SERVER; | ||||||
| import static datadog.trace.instrumentation.armeria.grpc.server.GrpcServerDecorator.SERVER_PATHWAY_EDGE_TAGS; | ||||||
|
|
||||||
| import datadog.context.Context; | ||||||
| import datadog.context.propagation.Propagators; | ||||||
| import datadog.trace.api.Config; | ||||||
| import datadog.trace.api.function.TriConsumer; | ||||||
| import datadog.trace.api.function.TriFunction; | ||||||
|
|
@@ -23,6 +24,7 @@ | |||||
| import datadog.trace.bootstrap.instrumentation.api.AgentSpan; | ||||||
| import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; | ||||||
| import datadog.trace.bootstrap.instrumentation.api.AgentTracer; | ||||||
| import datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge; | ||||||
| import datadog.trace.bootstrap.instrumentation.api.TagContext; | ||||||
| import io.grpc.ForwardingServerCall; | ||||||
| import io.grpc.ForwardingServerCallListener; | ||||||
|
|
@@ -62,13 +64,19 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall( | |||||
| return next.startCall(call, headers); | ||||||
| } | ||||||
|
|
||||||
| AgentSpanContext spanContext = extractContextAndGetSpanContext(headers, GETTER); | ||||||
| Context extractedContext = | ||||||
| Propagators.defaultPropagator() | ||||||
| .extract(Java8BytecodeBridge.getCurrentContext(), headers, GETTER); | ||||||
| final AgentSpan extractedSpan = AgentSpan.fromContext(extractedContext); | ||||||
| AgentSpanContext extractedSpanContext = | ||||||
| extractedSpan == null ? null : (AgentSpanContext.Extracted) extractedSpan.context(); | ||||||
| AgentTracer.TracerAPI tracer = tracer(); | ||||||
| spanContext = callIGCallbackRequestStarted(tracer, spanContext); | ||||||
| extractedSpanContext = callIGCallbackRequestStarted(tracer, extractedSpanContext); | ||||||
|
|
||||||
| CallbackProvider cbp = tracer.getCallbackProvider(RequestContextSlot.APPSEC); | ||||||
| final AgentSpan span = | ||||||
| startSpan(DECORATE.instrumentationNames()[0], GRPC_SERVER, spanContext).setMeasured(true); | ||||||
| startSpan(DECORATE.instrumentationNames()[0], GRPC_SERVER, extractedSpanContext) | ||||||
| .setMeasured(true); | ||||||
|
|
||||||
| AgentTracer.get() | ||||||
| .getDataStreamsMonitoring() | ||||||
|
|
@@ -85,7 +93,7 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall( | |||||
| DECORATE.onCall(span, call); | ||||||
|
|
||||||
| final ServerCall.Listener<ReqT> result; | ||||||
| try (AgentScope scope = activateSpan(span)) { | ||||||
| try (AgentScope scope = (AgentScope) extractedContext.with(span).attach()) { | ||||||
|
||||||
| try (AgentScope scope = (AgentScope) extractedContext.with(span).attach()) { | |
| try (AgentScope scope = getAgentScopeFromContext(extractedContext, span)) { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| import datadog.trace.api.datastreams.DataStreamsContext; | ||
| import datadog.trace.bootstrap.ContextStore; | ||
| import datadog.trace.bootstrap.instrumentation.api.AgentSpan; | ||
| import datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge; | ||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.LinkedHashMap; | ||
|
|
@@ -84,7 +85,7 @@ public AmazonWebServiceRequest beforeMarshalling(AmazonWebServiceRequest request | |
| private Context newContext(AmazonWebServiceRequest request, String queueUrl) { | ||
| AgentSpan span = newSpan(request); | ||
| DataStreamsContext dsmContext = DataStreamsContext.fromTags(getTags(queueUrl)); | ||
| return span.with(dsmContext); | ||
| return Java8BytecodeBridge.getCurrentContext().with(span).with(dsmContext); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I did? I don't remember tbh but I can locally revert and see what happens |
||
| } | ||
|
|
||
| private AgentSpan newSpan(AmazonWebServiceRequest request) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| package datadog.trace.instrumentation.aws.v1.sqs; | ||
|
|
||
| import static datadog.trace.api.datastreams.DataStreamsContext.create; | ||
| import static datadog.trace.bootstrap.instrumentation.api.AgentPropagation.extractContextAndGetSpanContext; | ||
| import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateNext; | ||
| import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.closePrevious; | ||
| import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan; | ||
|
|
@@ -19,10 +18,13 @@ | |
| import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
|
|
||
| import com.amazonaws.services.sqs.model.Message; | ||
| import datadog.context.Context; | ||
| import datadog.context.propagation.Propagators; | ||
| import datadog.trace.api.Config; | ||
| import datadog.trace.bootstrap.instrumentation.api.AgentSpan; | ||
| import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; | ||
| import datadog.trace.bootstrap.instrumentation.api.AgentTracer; | ||
| import datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge; | ||
| import java.util.Iterator; | ||
| import java.util.LinkedHashMap; | ||
| import org.slf4j.Logger; | ||
|
|
@@ -62,12 +64,18 @@ protected void startNewMessageSpan(Message message) { | |
| closePrevious(true); | ||
| if (message != null) { | ||
| AgentSpan queueSpan = null; | ||
| Context extractedContext = null; | ||
| if (batchContext == null) { | ||
| // first grab any incoming distributed context | ||
| AgentSpanContext spanContext = | ||
| Config.get().isSqsPropagationEnabled() | ||
| ? extractContextAndGetSpanContext(message, GETTER) | ||
| : null; | ||
| AgentSpanContext spanContext = null; | ||
| if (Config.get().isSqsPropagationEnabled()) { | ||
| extractedContext = | ||
| Propagators.defaultPropagator() | ||
| .extract(Java8BytecodeBridge.getCurrentContext(), message, GETTER); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| final AgentSpan extractedSpan = AgentSpan.fromContext(extractedContext); | ||
| spanContext = | ||
| extractedSpan == null ? null : (AgentSpanContext.Extracted) extractedSpan.context(); | ||
| } | ||
| // next add a time-in-queue span for non-legacy SQS traces | ||
| if (TIME_IN_QUEUE_ENABLED) { | ||
| long timeInQueueStart = GETTER.extractTimeInQueueStart(message); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| import datadog.trace.api.datastreams.DataStreamsContext; | ||
| import datadog.trace.bootstrap.InstanceStore; | ||
| import datadog.trace.bootstrap.instrumentation.api.AgentSpan; | ||
| import datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge; | ||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.LinkedHashMap; | ||
|
|
@@ -96,7 +97,7 @@ private datadog.context.Context getContext( | |
| ExecutionAttributes executionAttributes, String queueUrl) { | ||
| AgentSpan span = executionAttributes.getAttribute(SPAN_ATTRIBUTE); | ||
| DataStreamsContext dsmContext = DataStreamsContext.fromTags(getTags(queueUrl)); | ||
| return span.with(dsmContext); | ||
| return Java8BytecodeBridge.getCurrentContext().with(span).with(dsmContext); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Span seemed to be retrieved from a carrier. Meaning the current context might not apply here. |
||
| } | ||
|
|
||
| private LinkedHashMap<String, String> getTags(String queueUrl) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.