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 http attributes of AWS SDK V2 instrumentation #8931

Merged
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.
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 @@ -81,6 +81,7 @@ dependencies {
testLibrary("software.amazon.awssdk:s3:2.2.0")
testLibrary("software.amazon.awssdk:sqs:2.2.0")
testLibrary("software.amazon.awssdk:sns:2.2.0")
testLibrary("software.amazon.awssdk:ses:2.2.0")
}

tasks {
Expand All @@ -95,7 +96,6 @@ tasks {
}

withType<Test>().configureEach {
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
// TODO run tests both with and without experimental span attributes
systemProperty("otel.instrumentation.aws-sdk.experimental-span-attributes", "true")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.awssdk.v2_2.AbstractQueryProtocolModelTest;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import org.junit.jupiter.api.extension.RegisterExtension;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;

class QueryProtocolModelTest extends AbstractQueryProtocolModelTest {
@RegisterExtension
private final AgentInstrumentationExtension testing = AgentInstrumentationExtension.create();

@Override
protected ClientOverrideConfiguration.Builder createClientOverrideConfigurationBuilder() {
return ClientOverrideConfiguration.builder();
}

@Override
protected InstrumentationExtension getTesting() {
return testing;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ dependencies {

tasks {
test {
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
systemProperty("otel.instrumentation.aws-sdk.experimental-span-attributes", true)
systemProperty("otel.instrumentation.aws-sdk.experimental-use-propagator-for-messaging", true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
testLibrary("software.amazon.awssdk:kinesis:2.2.0")
testLibrary("software.amazon.awssdk:rds:2.2.0")
testLibrary("software.amazon.awssdk:s3:2.2.0")
testLibrary("software.amazon.awssdk:ses:2.2.0")
}

testing {
Expand All @@ -42,8 +43,6 @@ testing {

tasks {
withType<Test> {
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)

// NB: If you'd like to change these, there is some cleanup work to be done, as most tests ignore this and
// set the value directly (the "library" does not normally query it, only library-autoconfigure)
systemProperty("otel.instrumentation.aws-sdk.experimental-span-attributes", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,13 @@ public SdkRequest modifyRequest(
}

@Override
public void afterMarshalling(
Context.AfterMarshalling context, ExecutionAttributes executionAttributes) {

public void beforeTransmission(
Context.BeforeTransmission context, ExecutionAttributes executionAttributes) {
// In beforeTransmission we get access to the finalized http request, including modifications
// performed by other interceptors and the message signature.
// It is unlikely that further modifications are performed by the http client performing the
// request given that this would require the signature to be regenerated.
//
// Since we merge the HTTP attributes into an already started span instead of creating a
// full child span, we have to do some dirty work here.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.awssdk.v2_2;

import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension;
import org.junit.jupiter.api.extension.RegisterExtension;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;

class QueryProtocolModelTest extends AbstractQueryProtocolModelTest {
@RegisterExtension
public final LibraryInstrumentationExtension testing = LibraryInstrumentationExtension.create();

@Override
protected ClientOverrideConfiguration.Builder createClientOverrideConfigurationBuilder() {
return ClientOverrideConfiguration.builder()
.addExecutionInterceptor(
AwsSdkTelemetry.builder(testing.getOpenTelemetry()).build().newExecutionInterceptor());
}

@Override
protected InstrumentationExtension getTesting() {
return testing;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
compileOnly("software.amazon.awssdk:s3:2.2.0")
compileOnly("software.amazon.awssdk:sqs:2.2.0")
compileOnly("software.amazon.awssdk:sns:2.2.0")
compileOnly("software.amazon.awssdk:ses:2.2.0")

// needed for SQS - using emq directly as localstack references emq v0.15.7 ie WITHOUT AWS trace header propagation
implementation("org.elasticmq:elasticmq-rest-sqs_2.12:1.0.0")
Expand Down
Loading