Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydeluca committed Dec 15, 2024
1 parent 13ff8a0 commit 4399b81
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ boolean isSqsAttributeInjectionEnabled() {
}

@Override
boolean isXrayInjectionEnabled() {
protected boolean isXrayInjectionEnabled() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ boolean isSqsAttributeInjectionEnabled() {
}

@Override
boolean isXrayInjectionEnabled() {
protected boolean isXrayInjectionEnabled() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import software.amazon.awssdk.services.sqs.model.SendMessageRequest;

public abstract class AbstractAws2SqsBaseTest {

protected abstract InstrumentationExtension getTesting();

protected abstract SqsClient configureSqsClient(SqsClient sqsClient);
Expand All @@ -64,13 +63,17 @@ public abstract class AbstractAws2SqsBaseTest {

protected abstract ClientOverrideConfiguration.Builder createOverrideConfigurationBuilder();

protected abstract void assertSqsTraces(Boolean withParent, Boolean captureHeaders);

protected static final StaticCredentialsProvider CREDENTIALS_PROVIDER =
StaticCredentialsProvider.create(
AwsBasicCredentials.create("my-access-key", "my-secret-key"));

protected static int sqsPort;
protected static SQSRestServer sqs;

protected final String queueUrl = "http://localhost:" + sqsPort + "/000000000000/testSdkSqs";

static Map<String, MessageAttributeValue> dummyMessageAttributes(int count) {
Map<String, MessageAttributeValue> map = new HashMap<>();
for (int i = 0; i < count; i++) {
Expand All @@ -80,27 +83,25 @@ static Map<String, MessageAttributeValue> dummyMessageAttributes(int count) {
return map;
}

protected final String queueUrl = "http://localhost:" + sqsPort + "/000000000000/testSdkSqs";

ReceiveMessageRequest receiveMessageRequest =
protected ReceiveMessageRequest receiveMessageRequest =
ReceiveMessageRequest.builder().queueUrl(queueUrl).build();

ReceiveMessageRequest receiveMessageBatchRequest =
protected ReceiveMessageRequest receiveMessageBatchRequest =
ReceiveMessageRequest.builder()
.queueUrl(queueUrl)
.maxNumberOfMessages(3)
.messageAttributeNames("All")
.waitTimeSeconds(5)
.build();

CreateQueueRequest createQueueRequest =
protected CreateQueueRequest createQueueRequest =
CreateQueueRequest.builder().queueName("testSdkSqs").build();

SendMessageRequest sendMessageRequest =
protected SendMessageRequest sendMessageRequest =
SendMessageRequest.builder().queueUrl(queueUrl).messageBody("{\"type\": \"hello\"}").build();

@SuppressWarnings("unchecked")
SendMessageBatchRequest sendMessageBatchRequest =
protected SendMessageBatchRequest sendMessageBatchRequest =
SendMessageBatchRequest.builder()
.queueUrl(queueUrl)
.entries(
Expand All @@ -111,7 +112,7 @@ static Map<String, MessageAttributeValue> dummyMessageAttributes(int count) {
e -> e.messageBody("e3").id("i3").messageAttributes(dummyMessageAttributes(10)))
.build();

boolean isXrayInjectionEnabled() {
protected boolean isXrayInjectionEnabled() {
return true;
}

Expand All @@ -122,21 +123,19 @@ protected void configureSdkClient(SqsClientBuilder builder) throws URISyntaxExce
builder.region(Region.AP_NORTHEAST_1).credentialsProvider(CREDENTIALS_PROVIDER);
}

void configureSdkClient(SqsAsyncClientBuilder builder) throws URISyntaxException {
protected void configureSdkClient(SqsAsyncClientBuilder builder) throws URISyntaxException {
builder
.overrideConfiguration(createOverrideConfigurationBuilder().build())
.endpointOverride(new URI("http://localhost:" + sqsPort));
builder.region(Region.AP_NORTHEAST_1).credentialsProvider(CREDENTIALS_PROVIDER);
}

boolean isSqsAttributeInjectionEnabled() {
protected boolean isSqsAttributeInjectionEnabled() {
// See io.opentelemetry.instrumentation.awssdk.v2_2.autoconfigure.TracingExecutionInterceptor
return ConfigPropertiesUtil.getBoolean(
"otel.instrumentation.aws-sdk.experimental-use-propagator-for-messaging", false);
}

protected abstract void assertSqsTraces(Boolean withParent, Boolean captureHeaders);

@BeforeAll
static void setUp() {
sqs = SQSRestServerBuilder.withPort(0).withInterface("localhost").start();
Expand Down

0 comments on commit 4399b81

Please sign in to comment.