-
Notifications
You must be signed in to change notification settings - Fork 858
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 tracing tests from groovy to java (#11240)
- Loading branch information
Showing
9 changed files
with
813 additions
and
618 deletions.
There are no files selected for viewing
27 changes: 0 additions & 27 deletions
27
instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/test/groovy/Aws2SqsTracingTest.groovy
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
.../test/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/Aws2SqsTracingTest.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.AbstractAws2SqsTracingTest; | ||
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; | ||
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 Aws2SqsTracingTest extends AbstractAws2SqsTracingTest { | ||
|
||
@RegisterExtension | ||
private static final AgentInstrumentationExtension testing = | ||
AgentInstrumentationExtension.create(); | ||
|
||
@Override | ||
protected final AgentInstrumentationExtension getTesting() { | ||
return testing; | ||
} | ||
|
||
@Override | ||
protected ClientOverrideConfiguration.Builder createOverrideConfigurationBuilder() { | ||
return ClientOverrideConfiguration.builder(); | ||
} | ||
|
||
@Override | ||
protected SqsClient configureSqsClient(SqsClient sqsClient) { | ||
return sqsClient; | ||
} | ||
|
||
@Override | ||
protected SqsAsyncClient configureSqsClient(SqsAsyncClient sqsClient) { | ||
return sqsClient; | ||
} | ||
} |
114 changes: 0 additions & 114 deletions
114
...ry/src/test/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/Aws2SqsTracingTest.groovy
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
.../test/java/io/opentelemetry/instrumentation/awssdk/v2_2/Aws2SqsDefaultPropagatorTest.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 Aws2SqsDefaultPropagatorTest extends Aws2SqsTracingTest { | ||
|
||
@Override | ||
void configure(AwsSdkTelemetryBuilder telemetryBuilder) {} | ||
|
||
@Override | ||
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); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ibrary/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/Aws2SqsTracingTest.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,59 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.awssdk.v2_2; | ||
|
||
import static java.util.Collections.singletonList; | ||
|
||
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; | ||
|
||
abstract class Aws2SqsTracingTest extends AbstractAws2SqsTracingTest { | ||
|
||
@RegisterExtension | ||
private static final LibraryInstrumentationExtension testing = | ||
LibraryInstrumentationExtension.create(); | ||
|
||
static AwsSdkTelemetry telemetry; | ||
|
||
@Override | ||
protected final LibraryInstrumentationExtension getTesting() { | ||
return testing; | ||
} | ||
|
||
@BeforeEach | ||
void setup() { | ||
AwsSdkTelemetryBuilder telemetryBuilder = | ||
AwsSdkTelemetry.builder(getTesting().getOpenTelemetry()) | ||
.setCaptureExperimentalSpanAttributes(true) | ||
.setMessagingReceiveInstrumentationEnabled(true) | ||
.setCapturedHeaders(singletonList("test-message-header")); | ||
|
||
configure(telemetryBuilder); | ||
telemetry = telemetryBuilder.build(); | ||
} | ||
|
||
abstract void configure(AwsSdkTelemetryBuilder telemetryBuilder); | ||
|
||
@Override | ||
protected ClientOverrideConfiguration.Builder createOverrideConfigurationBuilder() { | ||
return ClientOverrideConfiguration.builder() | ||
.addExecutionInterceptor(telemetry.newExecutionInterceptor()); | ||
} | ||
|
||
@Override | ||
protected SqsClient configureSqsClient(SqsClient sqsClient) { | ||
return telemetry.wrap(sqsClient); | ||
} | ||
|
||
@Override | ||
protected SqsAsyncClient configureSqsClient(SqsAsyncClient sqsClient) { | ||
return telemetry.wrap(sqsClient); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../opentelemetry/instrumentation/awssdk/v2_2/Aws2SqsW3cPropagatorAndXrayPropagatorTest.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,19 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.awssdk.v2_2; | ||
|
||
class Aws2SqsW3cPropagatorAndXrayPropagatorTest extends Aws2SqsTracingTest { | ||
@Override | ||
void configure(AwsSdkTelemetryBuilder telemetryBuilder) { | ||
telemetryBuilder.setUseConfiguredPropagatorForMessaging( | ||
isSqsAttributeInjectionEnabled()); // Difference to main test | ||
} | ||
|
||
@Override | ||
boolean isSqsAttributeInjectionEnabled() { | ||
return true; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.../src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/Aws2SqsW3cPropagatorTest.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,28 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.awssdk.v2_2; | ||
|
||
class Aws2SqsW3cPropagatorTest extends Aws2SqsTracingTest { | ||
|
||
@Override | ||
void configure(AwsSdkTelemetryBuilder telemetryBuilder) { | ||
telemetryBuilder | ||
.setUseConfiguredPropagatorForMessaging( | ||
isSqsAttributeInjectionEnabled()) // Difference to main test | ||
.setUseXrayPropagator( | ||
isXrayInjectionEnabled()); // Disable to confirm messaging propagator actually works | ||
} | ||
|
||
@Override | ||
boolean isSqsAttributeInjectionEnabled() { | ||
return true; | ||
} | ||
|
||
@Override | ||
boolean isXrayInjectionEnabled() { | ||
return false; | ||
} | ||
} |
Oops, something went wrong.