-
Notifications
You must be signed in to change notification settings - Fork 878
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert aws sdk 2.2 Sqs Suppress Receive Spans Tests (#12895)
- Loading branch information
Showing
14 changed files
with
654 additions
and
796 deletions.
There are no files selected for viewing
27 changes: 0 additions & 27 deletions
27
...tion/aws-sdk/aws-sdk-2.2/javaagent/src/test/groovy/Aws2SqsSuppressReceiveSpansTest.groovy
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
.../opentelemetry/javaagent/instrumentation/awssdk/v2_2/Aws2SqsSuppressReceiveSpansTest.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,40 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.awssdk.v2_2; | ||
|
||
import io.opentelemetry.instrumentation.awssdk.v2_2.AbstractAws2SqsSuppressReceiveSpansTest; | ||
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; | ||
import software.amazon.awssdk.services.sqs.SqsAsyncClient; | ||
import software.amazon.awssdk.services.sqs.SqsClient; | ||
|
||
class Aws2SqsSuppressReceiveSpansTest extends AbstractAws2SqsSuppressReceiveSpansTest { | ||
|
||
@RegisterExtension | ||
static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); | ||
|
||
@Override | ||
protected InstrumentationExtension getTesting() { | ||
return testing; | ||
} | ||
|
||
@Override | ||
protected SqsClient configureSqsClient(SqsClient sqsClient) { | ||
return sqsClient; | ||
} | ||
|
||
@Override | ||
protected SqsAsyncClient configureSqsClient(SqsAsyncClient sqsClient) { | ||
return sqsClient; | ||
} | ||
|
||
@Override | ||
protected ClientOverrideConfiguration.Builder createOverrideConfigurationBuilder() { | ||
return ClientOverrideConfiguration.builder(); | ||
} | ||
} |
109 changes: 0 additions & 109 deletions
109
...roovy/io/opentelemetry/instrumentation/awssdk/v2_2/Aws2SqsSuppressReceiveSpansTest.groovy
This file was deleted.
Oops, something went wrong.
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
48 changes: 48 additions & 0 deletions
48
...lemetry/instrumentation/awssdk/v2_2/Aws2SqsSuppressReceiveSpansDefaultPropagatorTest.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,48 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.awssdk.v2_2; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.net.URISyntaxException; | ||
import org.junit.jupiter.api.Test; | ||
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration; | ||
import software.amazon.awssdk.services.sqs.SqsClient; | ||
import software.amazon.awssdk.services.sqs.SqsClientBuilder; | ||
import software.amazon.awssdk.services.sqs.model.ReceiveMessageResponse; | ||
|
||
class Aws2SqsSuppressReceiveSpansDefaultPropagatorTest extends Aws2SqsSuppressReceiveSpansTest { | ||
|
||
@Override | ||
protected void configure(AwsSdkTelemetryBuilder telemetryBuilder) {} | ||
|
||
@Override | ||
protected boolean isSqsAttributeInjectionEnabled() { | ||
return false; | ||
} | ||
|
||
@Test | ||
void testDuplicateTracingInterceptor() throws URISyntaxException { | ||
SqsClientBuilder builder = SqsClient.builder(); | ||
configureSdkClient(builder); | ||
ClientOverrideConfiguration overrideConfiguration = | ||
ClientOverrideConfiguration.builder() | ||
.addExecutionInterceptor(telemetry.newExecutionInterceptor()) | ||
.addExecutionInterceptor(telemetry.newExecutionInterceptor()) | ||
.build(); | ||
builder.overrideConfiguration(overrideConfiguration); | ||
SqsClient client = configureSqsClient(builder.build()); | ||
|
||
client.createQueue(createQueueRequest); | ||
client.sendMessage(sendMessageRequest); | ||
ReceiveMessageResponse response = client.receiveMessage(receiveMessageRequest); | ||
|
||
assertThat(response.messages().size()).isEqualTo(1); | ||
response.messages().forEach(message -> getTesting().runWithSpan("process child", () -> {})); | ||
|
||
assertSqsTraces(false, false); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...st/java/io/opentelemetry/instrumentation/awssdk/v2_2/Aws2SqsSuppressReceiveSpansTest.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,54 @@ | ||
/* | ||
* 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.BeforeEach; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration; | ||
import software.amazon.awssdk.services.sqs.SqsAsyncClient; | ||
import software.amazon.awssdk.services.sqs.SqsClient; | ||
|
||
public abstract class Aws2SqsSuppressReceiveSpansTest | ||
extends AbstractAws2SqsSuppressReceiveSpansTest { | ||
protected AwsSdkTelemetry telemetry; | ||
|
||
@RegisterExtension | ||
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create(); | ||
|
||
@Override | ||
protected InstrumentationExtension getTesting() { | ||
return testing; | ||
} | ||
|
||
@Override | ||
protected SqsClient configureSqsClient(SqsClient sqsClient) { | ||
return telemetry.wrap(sqsClient); | ||
} | ||
|
||
@Override | ||
protected SqsAsyncClient configureSqsClient(SqsAsyncClient sqsClient) { | ||
return telemetry.wrap(sqsClient); | ||
} | ||
|
||
@Override | ||
protected ClientOverrideConfiguration.Builder createOverrideConfigurationBuilder() { | ||
return ClientOverrideConfiguration.builder() | ||
.addExecutionInterceptor(telemetry.newExecutionInterceptor()); | ||
} | ||
|
||
protected abstract void configure(AwsSdkTelemetryBuilder telemetryBuilder); | ||
|
||
@BeforeEach | ||
void setup() { | ||
AwsSdkTelemetryBuilder telemetryBuilder = | ||
AwsSdkTelemetry.builder(getTesting().getOpenTelemetry()) | ||
.setCaptureExperimentalSpanAttributes(true); | ||
configure(telemetryBuilder); | ||
telemetry = telemetryBuilder.build(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...umentation/awssdk/v2_2/Aws2SqsSuppressReceiveSpansW3cPropagatorAndXrayPropagatorTest.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,25 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.awssdk.v2_2; | ||
|
||
/** | ||
* We want to test the combination of W3C + Xray, as that's what you'll get in prod if you enable | ||
* W3C. | ||
*/ | ||
class Aws2SqsSuppressReceiveSpansW3cPropagatorAndXrayPropagatorTest | ||
extends Aws2SqsSuppressReceiveSpansTest { | ||
|
||
@Override | ||
protected void configure(AwsSdkTelemetryBuilder telemetryBuilder) { | ||
telemetryBuilder.setUseConfiguredPropagatorForMessaging( | ||
isSqsAttributeInjectionEnabled()); // Difference to main test | ||
} | ||
|
||
@Override | ||
protected boolean isSqsAttributeInjectionEnabled() { | ||
return true; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...entelemetry/instrumentation/awssdk/v2_2/Aws2SqsSuppressReceiveSpansW3cPropagatorTest.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,27 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.awssdk.v2_2; | ||
|
||
class Aws2SqsSuppressReceiveSpansW3cPropagatorTest extends Aws2SqsSuppressReceiveSpansTest { | ||
@Override | ||
protected void configure(AwsSdkTelemetryBuilder telemetryBuilder) { | ||
telemetryBuilder | ||
.setUseConfiguredPropagatorForMessaging( | ||
isSqsAttributeInjectionEnabled()) // Difference to main test | ||
.setUseXrayPropagator( | ||
isXrayInjectionEnabled()); // Disable to confirm messaging propagator actually works | ||
} | ||
|
||
@Override | ||
protected boolean isSqsAttributeInjectionEnabled() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected boolean isXrayInjectionEnabled() { | ||
return false; | ||
} | ||
} |
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
Oops, something went wrong.