Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes;
import datadog.trace.bootstrap.instrumentation.api.ResourceNamePriorities;
import datadog.trace.config.inversion.ConfigHelper;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
Expand Down Expand Up @@ -126,6 +127,21 @@ static void exit(
String lambdaRequestId = awsContext.getAwsRequestId();

AgentTracer.get().notifyAppSecEnd(span);
// Force the resource name back to the literal placeholder marker right
// before finish so that the Datadog Lambda Extension's filter
// (filter_span_from_lambda_library_or_runtime in
// bottlecap/src/traces/trace_processor.rs, which compares
// span.resource == "dd-tracer-serverless-span") drops the placeholder.
// Other instrumentation (HTTP/JAX-RS) may have overwritten it with the
// route ("POST /") during the invocation, in which case the extension
// would fail to dedup, leading to the placeholder leaking to the backend
// with parent_id=0 and detaching the inferred apigateway root from the
// rest of the trace.
// Use MANUAL_INSTRUMENTATION priority because DDSpanContext.setResourceName
// ignores writes whose priority is below the current resource priority,
// and the HTTP/JAX-RS instrumentation will already have written
// HTTP_FRAMEWORK_ROUTE (3) by this point.
span.setResourceName(INVOCATION_SPAN_NAME, ResourceNamePriorities.MANUAL_INSTRUMENTATION);
Comment thread
rithikanarayan marked this conversation as resolved.
Outdated
span.finish();
AgentTracer.get().notifyExtensionEnd(span, result, null != throwable, lambdaRequestId);
} finally {
Expand Down
Loading