Skip to content
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

Fix invalid SQS propagation introduced with #3206 #3254

Merged
merged 2 commits into from Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.asciidoc
Expand Up @@ -36,6 +36,10 @@ Use subheadings with the "=====" level for adding notes for unreleased changes:
* Added W3C baggage propagation - {pull}3236[#3236]
* Added support for baggage in OpenTelemetry bridge - {pull}3249[#3249]

[float]
===== Bug fixes
* Fixed SQS NoClassDefFoundError in AWS SDK instrumentation - {pull}3254[#3254]

[[release-notes-1.x]]
=== Java Agent version 1.x

Expand Down
Expand Up @@ -54,7 +54,7 @@
public class BaseSyncClientHandlerInstrumentation extends ElasticApmInstrumentation {

private static final Tracer tracer = GlobalTracer.get();

//Coretto causes sigsegv crashes when you try to access a throwable if it thinks
//it went out of scope, which it seems to for the instrumented throwable access
//package access and non-final so that tests can replace this
Expand Down Expand Up @@ -90,19 +90,23 @@ public static Object enterDoExecute(@Advice.Argument(value = 0) ClientExecutionP
SdkRequest sdkRequest = clientExecutionParams.getInput();
URI uri = clientConfiguration.option(SdkClientOption.ENDPOINT);
Span<?> span = null;
boolean isSqs = false;
if ("S3".equalsIgnoreCase(awsService)) {
span = S3Helper.getInstance().startSpan(sdkRequest, uri, executionContext);
} else if ("DynamoDb".equalsIgnoreCase(awsService)) {
span = DynamoDbHelper.getInstance().startSpan(sdkRequest, uri, executionContext);
} else if ("Sqs".equalsIgnoreCase(awsService)) {
span = SQSHelper.getInstance().startSpan(sdkRequest, uri, executionContext);
isSqs = true;
}

if (span != null) {
span.activate();
}

SQSHelper.getInstance().modifyRequestObject(tracer.currentContext(), clientExecutionParams, executionContext);
if (isSqs) {
SQSHelper.getInstance().modifyRequestObject(tracer.currentContext(), clientExecutionParams, executionContext);
}

return span;
}
Expand Down