Skip to content
Open
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 @@ -49,6 +49,7 @@ dependencies {
testImplementation group: 'com.amazonaws', name: 'aws-java-sdk-sqs', version: '[1.11,1.11.106]'
testImplementation group: 'com.amazonaws', name: 'aws-java-sdk-sns', version: '[1.11,1.11.106]'
testImplementation group: 'com.amazonaws', name: 'aws-java-sdk-dynamodb', version: '[1.11,1.11.106]'
testImplementation group: 'com.amazonaws', name: 'aws-java-sdk-stepfunctions', version: '[1.11,1.11.106]'

// needed for kinesis:
testImplementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-cbor', version: null
Expand Down Expand Up @@ -90,6 +91,13 @@ dependencies {
strictly '1.11.0'
}
}
// aws-java-sdk-stepfunctions (test dependency below 1.11.106) only exists from 1.11.63 and would
// otherwise pull a newer core than the 1.11.0 clients pinned above.
test_before_1_11_106Implementation(group: 'com.amazonaws', name: 'aws-java-sdk-core') {
version {
strictly '1.11.0'
}
}

dsmTestImplementation group: 'com.amazonaws', name: 'aws-java-sdk-kinesis', version: '1.12.366'
// no batch publish before v1.12
Expand All @@ -104,6 +112,7 @@ dependencies {
latestDepTestImplementation group: 'com.amazonaws', name: 'aws-java-sdk-sqs', version: '+'
latestDepTestImplementation group: 'com.amazonaws', name: 'aws-java-sdk-sns', version: '+'
latestDepTestImplementation group: 'com.amazonaws', name: 'aws-java-sdk-dynamodb', version: '+'
latestDepTestImplementation group: 'com.amazonaws', name: 'aws-java-sdk-stepfunctions', version: '+'
}

tasks.named("test", Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ protected void doOnRequest(final AgentSpan span, final Request request) {
String topicName = null;
String topicArn = access.getTopicArn(originalRequest);
if (null != topicArn) {
span.setTag(InstrumentationTags.AWS_TOPIC_ARN, topicArn);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we skip v1 since it was EOLed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to keep at least part of v1 if you are open to it. v1 is EOL from AWS but the tracer still ships and tests this instrumentation, and the users still on it are the ones most likely to have cross-account SNS topics where the bare name is ambiguous. The SNS and Kinesis half of the v1 change is a few lines with no new dependencies and the decorator already reads the ARN and discards it. The Step Functions and Lambda half is what pulled in the stepfunctions test dependency and the core pin, so if the concern is that surface I am happy to drop those two from v1 and keep SNS and Kinesis. But anyways if the team's stance is absolutely no new features on v1 at all, tell me and I will drop v1 entirely here and in #12602.

span.setTag(InstrumentationTags.SNS_TOPIC_ARN, topicArn);
topicName = topicArn.substring(topicArn.lastIndexOf(':') + 1);
span.setTag(InstrumentationTags.AWS_TOPIC_NAME, topicName);
span.setTag(InstrumentationTags.TOPIC_NAME, topicName);
Expand All @@ -168,6 +170,7 @@ protected void doOnRequest(final AgentSpan span, final Request request) {
}
String streamArn = access.getStreamARN(originalRequest);
if (null != streamArn) {
span.setTag(InstrumentationTags.AWS_STREAM_ARN, streamArn);
int streamNameStart = streamArn.indexOf(":stream/");
if (streamNameStart >= 0) {
streamName = streamArn.substring(streamNameStart + 8);
Expand All @@ -184,6 +187,22 @@ protected void doOnRequest(final AgentSpan span, final Request request) {
bestPrecursor = InstrumentationTags.AWS_TABLE_NAME;
bestPeerService = tableName;
}
String stateMachineArn = access.getStateMachineArn(originalRequest);
if (null != stateMachineArn) {
span.setTag(InstrumentationTags.AWS_STATE_MACHINE_ARN, stateMachineArn);
span.setTag(InstrumentationTags.STATE_MACHINE_ARN, stateMachineArn);
}
String executionArn = access.getExecutionArn(originalRequest);
if (null != executionArn) {
span.setTag(InstrumentationTags.AWS_EXECUTION_ARN, executionArn);
}
if ("AWSLambda".equalsIgnoreCase(awsServiceName)) {
String functionName = access.getFunctionName(originalRequest);
if (null != functionName) {
span.setTag(InstrumentationTags.AWS_FUNCTION_NAME, functionName);
span.setTag(InstrumentationTags.FUNCTION_NAME, functionName);
}
}

// Set peer.service based on Config for serverless functions
if (Config.get().isAwsServerless()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ static GetterAccess of(final Object request) {
private final MethodHandle getPublishBatchRequestEntries;
private final MethodHandle getApproximateArrivalTimestamp;
private final MethodHandle getTableName;
private final MethodHandle getStateMachineArn;
private final MethodHandle getExecutionArn;
private final MethodHandle getFunctionName;

private GetterAccess(final Class<?> objectType) {
operationName =
Expand All @@ -55,6 +58,9 @@ private GetterAccess(final Class<?> objectType) {
getApproximateArrivalTimestamp =
findGetter(objectType, "getApproximateArrivalTimestamp", Date.class);
getTableName = findStringGetter(objectType, "getTableName");
getStateMachineArn = findStringGetter(objectType, "getStateMachineArn");
getExecutionArn = findStringGetter(objectType, "getExecutionArn");
getFunctionName = findStringGetter(objectType, "getFunctionName");
}

String getOperationNameFromType() {
Expand Down Expand Up @@ -101,6 +107,18 @@ String getTableName(final Object object) {
return invokeForString(getTableName, object);
}

String getStateMachineArn(final Object object) {
return invokeForString(getStateMachineArn, object);
}

String getExecutionArn(final Object object) {
return invokeForString(getExecutionArn, object);
}

String getFunctionName(final Object object) {
return invokeForString(getFunctionName, object);
}

Date getApproximateArrivalTimestamp(final Object object) {
return invoke(getApproximateArrivalTimestamp, object);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import com.amazonaws.services.rds.model.DeleteOptionGroupRequest
import com.amazonaws.services.s3.AmazonS3Client
import com.amazonaws.services.s3.AmazonS3ClientBuilder
import com.amazonaws.services.sns.AmazonSNSClientBuilder
import com.amazonaws.services.stepfunctions.AWSStepFunctionsClientBuilder
import com.amazonaws.services.stepfunctions.model.DescribeExecutionRequest
import com.amazonaws.services.stepfunctions.model.StartExecutionRequest
import com.amazonaws.services.sns.model.PublishRequest
import com.amazonaws.services.sqs.AmazonSQSClientBuilder
import com.amazonaws.services.sqs.model.CreateQueueRequest
Expand Down Expand Up @@ -176,7 +179,7 @@ abstract class AWS1ClientTest extends VersionedNamingTestBase {
"$Tags.PEER_PORT" server.address.port
"$Tags.PEER_HOSTNAME" "localhost"
"aws.service" { it.contains(service) }
"aws_service" { it.contains(service.toLowerCase()) }
"aws_service" { it.toLowerCase().contains(service.toLowerCase()) }
"aws.endpoint" "$server.address"
"aws.operation" "${operation}Request"
"aws.agent" "java-aws-sdk"
Expand Down Expand Up @@ -211,6 +214,8 @@ abstract class AWS1ClientTest extends VersionedNamingTestBase {
"DynamoDBv2" | "CreateTable" | "POST" | "/" | AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.createTable(new CreateTableRequest("sometable", null)) } | ["aws.table.name": "sometable", "tablename": "sometable"] | "" | "aws.table.name" | null
"DynamoDBv2" | "GetItem" | "POST" | "/" | AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.getItem(new GetItemRequest("sometable", ["attribute": new AttributeValue("somevalue")])) } | ["aws.table.name": "sometable", "tablename": "sometable"] | "" | "aws.table.name" | null
"Kinesis" | "DeleteStream" | "POST" | "/" | AmazonKinesisClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.deleteStream(new DeleteStreamRequest().withStreamName("somestream")) } | ["aws.stream.name": "somestream", "streamname": "somestream"] | "" | "aws.stream.name" | null
"AWSStepFunctions" | "StartExecution" | "POST" | "/" | AWSStepFunctionsClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.startExecution(new StartExecutionRequest().withStateMachineArn("arn:aws:states:us-east-1:123456789012:stateMachine:somestatemachine")) } | ["aws.state_machine.arn": "arn:aws:states:us-east-1:123456789012:stateMachine:somestatemachine", "statemachinearn": "arn:aws:states:us-east-1:123456789012:stateMachine:somestatemachine"] | "" | null | null
"AWSStepFunctions" | "DescribeExecution" | "POST" | "/" | AWSStepFunctionsClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.describeExecution(new DescribeExecutionRequest().withExecutionArn("arn:aws:states:us-east-1:123456789012:execution:somestatemachine:someexecution")) } | ["aws.execution.arn": "arn:aws:states:us-east-1:123456789012:execution:somestatemachine:someexecution"] | "" | null | null
"SQS" | "CreateQueue" | "POST" | "/" | AmazonSQSClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.createQueue(new CreateQueueRequest("somequeue")) } | ["aws.queue.name": "somequeue", "queuename": "somequeue"] | """

<CreateQueueResponse>
Expand All @@ -228,7 +233,7 @@ abstract class AWS1ClientTest extends VersionedNamingTestBase {
<ResponseMetadata><RequestId>27daac76-34dd-47df-bd01-1f6e873584a0</RequestId></ResponseMetadata>
</SendMessageResponse>
""" | "aws.queue.url" | "/SendMessageResponse/SendMessageResult"
"SNS" | "Publish" | "POST" | "/" | AmazonSNSClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.publish(new PublishRequest("arn:aws:sns::123:some-topic", "")) } | ["aws.topic.name": "some-topic", "topicname": "some-topic"] | """
"SNS" | "Publish" | "POST" | "/" | AmazonSNSClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.publish(new PublishRequest("arn:aws:sns::123:some-topic", "")) } | ["aws.topic.name": "some-topic", "topicname": "some-topic", "aws.topic.arn": "arn:aws:sns::123:some-topic", "aws.sns.topic_arn": "arn:aws:sns::123:some-topic"] | """
<PublishResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/">
<PublishResult>
<MessageId>567910cd-659e-55d4-8ccb-5aaf14679dc0</MessageId>
Expand Down Expand Up @@ -280,7 +285,7 @@ abstract class AWS1ClientTest extends VersionedNamingTestBase {
"$Tags.PEER_HOSTNAME" "localhost"
"$Tags.PEER_PORT" 61
"aws.service" { it.contains(service) }
"aws_service" { it.contains(service.toLowerCase()) }
"aws_service" { it.toLowerCase().contains(service.toLowerCase()) }
"aws.endpoint" "http://localhost:${UNUSABLE_PORT}"
"aws.operation" "${operation}Request"
"aws.agent" "java-aws-sdk"
Expand Down Expand Up @@ -453,7 +458,7 @@ abstract class AWS1ClientTest extends VersionedNamingTestBase {
"$Tags.PEER_PORT" server.address.port
"$Tags.PEER_HOSTNAME" "localhost"
"aws.service" { it.contains(service) }
"aws_service" { it.contains(service.toLowerCase()) }
"aws_service" { it.toLowerCase().contains(service.toLowerCase()) }
"aws.endpoint" "$server.address"
"aws.operation" "${operation}Request"
"aws.agent" "java-aws-sdk"
Expand Down Expand Up @@ -490,7 +495,7 @@ abstract class AWS1ClientTest extends VersionedNamingTestBase {
"S3" | "CreateBucket" | "PUT" | "/test-bucket/" | AmazonS3ClientBuilder.standard().withPathStyleAccessEnabled(true).withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.createBucket("test-bucket") } | ["aws.bucket.name": "test-bucket", "bucketname": "test-bucket"] | "" | null
"SQS" | "CreateQueue" | "POST" | "/" | AmazonSQSClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.createQueue(new CreateQueueRequest("test-queue")) } | ["aws.queue.name": "test-queue", "queuename": "test-queue"] | """<CreateQueueResponse><CreateQueueResult><QueueUrl>https://queue.amazonaws.com/123456789012/test-queue</QueueUrl></CreateQueueResult><ResponseMetadata><RequestId>test-request-id</RequestId></ResponseMetadata></CreateQueueResponse>""" | "/CreateQueueResponse/CreateQueueResult"
"SQS" | "SendMessage" | "POST" | "/test-queue-url" | AmazonSQSClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.sendMessage(new SendMessageRequest("test-queue-url", "test")) } | ["aws.queue.url": "test-queue-url"] | """<SendMessageResponse><SendMessageResult><MD5OfMessageBody>098f6bcd4621d373cade4e832627b4f6</MD5OfMessageBody><MessageId>test-msg-id</MessageId></SendMessageResult><ResponseMetadata><RequestId>test-request-id</RequestId></ResponseMetadata></SendMessageResponse>""" | "/SendMessageResponse/SendMessageResult"
"SNS" | "Publish" | "POST" | "/" | AmazonSNSClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.publish(new PublishRequest("arn:aws:sns::123:test-topic", "test")) } | ["aws.topic.name": "test-topic", "topicname": "test-topic"] | """<PublishResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/"><PublishResult><MessageId>test-msg-id</MessageId></PublishResult><ResponseMetadata><RequestId>test-request-id</RequestId></ResponseMetadata></PublishResponse>""" | "/PublishResponse/PublishResult"
"SNS" | "Publish" | "POST" | "/" | AmazonSNSClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.publish(new PublishRequest("arn:aws:sns::123:test-topic", "test")) } | ["aws.topic.name": "test-topic", "topicname": "test-topic", "aws.topic.arn": "arn:aws:sns::123:test-topic", "aws.sns.topic_arn": "arn:aws:sns::123:test-topic"] | """<PublishResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/"><PublishResult><MessageId>test-msg-id</MessageId></PublishResult><ResponseMetadata><RequestId>test-request-id</RequestId></ResponseMetadata></PublishResponse>""" | "/PublishResponse/PublishResult"
"DynamoDBv2" | "CreateTable" | "POST" | "/" | AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.createTable(new CreateTableRequest("test-table", null)) } | ["aws.table.name": "test-table", "tablename": "test-table"] | "" | null
"Kinesis" | "DeleteStream" | "POST" | "/" | AmazonKinesisClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.deleteStream(new DeleteStreamRequest().withStreamName("test-stream")) } | ["aws.stream.name": "test-stream", "streamname": "test-stream"] | "" | null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class LegacyAWS1ClientForkedTest extends InstrumentationSpecification {
<ResponseMetadata><RequestId>27daac76-34dd-47df-bd01-1f6e873584a0</RequestId></ResponseMetadata>
</SendMessageResponse>
""" | "/SendMessageResponse/SendMessageResult"
"SNS" | "Publish" | "sns" | "POST" | "/" | AmazonSNSClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.publish(new PublishRequest("arn:aws:sns::123:some-topic", "")) } | ["aws.topic.name": "some-topic", "topicname": "some-topic"] | """
"SNS" | "Publish" | "sns" | "POST" | "/" | AmazonSNSClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build() | { c -> c.publish(new PublishRequest("arn:aws:sns::123:some-topic", "")) } | ["aws.topic.name": "some-topic", "topicname": "some-topic", "aws.topic.arn": "arn:aws:sns::123:some-topic", "aws.sns.topic_arn": "arn:aws:sns::123:some-topic"] | """
<PublishResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/">
<PublishResult>
<MessageId>567910cd-659e-55d4-8ccb-5aaf14679dc0</MessageId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ dependencies {
testImplementation group: 'software.amazon.awssdk', name: 'sns', version: '2.2.0'
testImplementation group: 'software.amazon.awssdk', name: 'dynamodb', version: '2.2.0'
testImplementation group: 'software.amazon.awssdk', name: 'kinesis', version: '2.2.0'
testImplementation group: 'software.amazon.awssdk', name: 'sfn', version: '2.2.0'
testImplementation group: 'software.amazon.awssdk', name: 'lambda', version: '2.2.0'
testImplementation group: 'org.eclipse.jetty.http2', name: 'http2-server', version: '9.4.56.v20240826'

testImplementation libs.testcontainers.localstack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ abstract class Aws2KinesisDataStreamsTest extends VersionedNamingTestBase {
"aws.requestId" "$requestId"
"aws.stream.name" "somestream"
"streamname" "somestream"
"aws.stream.arn" "arnprefix:stream/somestream"
"$DDTags.PATHWAY_HASH" {
String
}
Expand Down Expand Up @@ -347,6 +348,7 @@ abstract class Aws2KinesisDataStreamsTest extends VersionedNamingTestBase {
"aws.requestId" "$requestId"
"aws.stream.name" "somestream"
"streamname" "somestream"
"aws.stream.arn" "arnprefix:stream/somestream"
"$DDTags.PATHWAY_HASH" {
String
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ abstract class Aws2SnsDataStreamsTest extends VersionedNamingTestBase {
"aws.requestId" "$requestId"
"aws.topic.name" "mytopic"
"topicname" "mytopic"
"aws.topic.arn" "arnprefix:mytopic"
"aws.sns.topic_arn" "arnprefix:mytopic"
"$DDTags.PATHWAY_HASH" {
String
}
Expand Down Expand Up @@ -296,6 +298,8 @@ abstract class Aws2SnsDataStreamsTest extends VersionedNamingTestBase {
"aws.requestId" "$requestId"
"aws.topic.name" "mytopic"
"topicname" "mytopic"
"aws.topic.arn" "arnprefix:mytopic"
"aws.sns.topic_arn" "arnprefix:mytopic"
"$DDTags.PATHWAY_HASH" {
String
}
Expand Down
Loading
Loading