Skip to content

Commit 27b6c2b

Browse files
committed
add support for SNS TopicArn and Secrets Manager SecretArn attributes
1 parent 07ace1f commit 27b6c2b

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

src/AWS.Distro.OpenTelemetry.AutoInstrumentation/AwsAttributeKeys.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ internal sealed class AwsAttributeKeys
4747
internal static readonly string AttributeAWSSQSQueueUrl = "aws.queue_url";
4848

4949
internal static readonly string AttributeAWSS3Bucket = "aws.s3.bucket";
50+
internal static readonly string AttributeAWSSecretsManagerSecretArn = "aws.secretsmanager.secret.arn";
51+
internal static readonly string AttributeAWSSNSTopicArn = "aws.sns.topic.arn";
5052

5153
internal static readonly string AttributeAWSBedrockGuardrailId = "aws.bedrock.guardrail.id";
5254
internal static readonly string AttributeAWSBedrockAgentId = "aws.bedrock.agent.id";

src/AWS.Distro.OpenTelemetry.AutoInstrumentation/AwsMetricAttributeGenerator.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ internal class AwsMetricAttributeGenerator : IMetricAttributeGenerator
4242
private static readonly string NormalizedDynamoDBServiceName = "AWS::DynamoDB";
4343
private static readonly string NormalizedKinesisServiceName = "AWS::Kinesis";
4444
private static readonly string NormalizedS3ServiceName = "AWS::S3";
45+
private static readonly string NormalizedSecretsManagerServiceName = "AWS::SecretsManager";
46+
private static readonly string NormalizedSNSServiceName = "AWS::SNS";
4547
private static readonly string NormalizedSQSServiceName = "AWS::SQS";
4648
private static readonly string NormalizedBedrockServiceName = "AWS::Bedrock";
4749
private static readonly string NormalizedBedrockRuntimeServiceName = "AWS::BedrockRuntime";
@@ -364,6 +366,10 @@ private static string NormalizeRemoteServiceName(Activity span, string serviceNa
364366
case "Amazon S3": // AWS SDK v1
365367
case "S3": // AWS SDK v2
366368
return NormalizedS3ServiceName;
369+
case "Secrets Manager":
370+
return NormalizedSecretsManagerServiceName;
371+
case "SNS":
372+
return NormalizedSNSServiceName;
367373
case "AmazonSQS": // AWS SDK v1
368374
case "Sqs": // AWS SDK v2
369375
return NormalizedSQSServiceName;
@@ -405,6 +411,16 @@ private static void SetRemoteResourceTypeAndIdentifier(Activity span, ActivityTa
405411
remoteResourceType = NormalizedS3ServiceName + "::Bucket";
406412
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSS3Bucket));
407413
}
414+
else if (IsKeyPresent(span, AttributeAWSSecretsManagerSecretArn))
415+
{
416+
remoteResourceType = NormalizedSecretsManagerServiceName + "::Secret";
417+
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSecretsManagerSecretArn));
418+
}
419+
else if (IsKeyPresent(span, AttributeAWSSNSTopicArn))
420+
{
421+
remoteResourceType = NormalizedSNSServiceName + "::Topic";
422+
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSNSTopicArn));
423+
}
408424
else if (IsKeyPresent(span, AttributeAWSSQSQueueName))
409425
{
410426
remoteResourceType = NormalizedSQSServiceName + "::Queue";

src/OpenTelemetry.Instrumentation.AWS/Implementation/AWSSemanticConventions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ internal static class AWSSemanticConventions
1515
public const string AttributeAWSSQSQueueName = "aws.sqs.queue_name";
1616
public const string AttributeAWSS3BucketName = "aws.s3.bucket";
1717
public const string AttributeAWSKinesisStreamName = "aws.kinesis.stream_name";
18+
public const string AttributeAWSSecretsManagerSecretArn = "aws.secretsmanager.secret.arn";
19+
public const string AttributeAWSSnsTopicArn = "aws.sns.topic.arn";
1820

1921
// AWS Bedrock service attributes not yet defined in semantic conventions
2022
public const string AttributeAWSBedrockGuardrailId = "aws.bedrock.guardrail.id";

src/OpenTelemetry.Instrumentation.AWS/Implementation/AWSServiceHelper.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ internal class AWSServiceHelper
1313
{ AWSServiceType.SQSService, new List<string> { "QueueUrl", "QueueName" } },
1414
{ AWSServiceType.S3Service, new List<string> { "BucketName" } },
1515
{ AWSServiceType.KinesisService, new List<string> { "StreamName" } },
16+
{ AWSServiceType.SNSService, new List<string> { "TopicArn" } },
1617
{ AWSServiceType.BedrockRuntimeService, new List<string> { "ModelId" } },
1718
{ AWSServiceType.BedrockAgentService, new List<string> { "AgentId", "KnowledgeBaseId", "DataSourceId" } },
1819
{ AWSServiceType.BedrockAgentRuntimeService, new List<string> { "AgentId", "KnowledgeBaseId" } },
1920
};
2021

2122
internal static IReadOnlyDictionary<string, List<string>> ServiceResponseParameterMap = new Dictionary<string, List<string>>()
2223
{
24+
{ AWSServiceType.SecretsManagerService, new List<string> { "ARN" } },
2325
{ AWSServiceType.BedrockService, new List<string> { "GuardrailId" } },
2426
{ AWSServiceType.BedrockAgentService, new List<string> { "AgentId", "DataSourceId" } },
2527
};
@@ -31,6 +33,8 @@ internal class AWSServiceHelper
3133
{ "QueueName", AWSSemanticConventions.AttributeAWSSQSQueueName },
3234
{ "BucketName", AWSSemanticConventions.AttributeAWSS3BucketName },
3335
{ "StreamName", AWSSemanticConventions.AttributeAWSKinesisStreamName },
36+
{ "TopicArn", AWSSemanticConventions.AttributeAWSSnsTopicArn },
37+
{ "ARN", AWSSemanticConventions.AttributeAWSSecretsManagerSecretArn },
3438
{ "ModelId", AWSSemanticConventions.AttributeGenAiModelId },
3539
{ "GuardrailId", AWSSemanticConventions.AttributeAWSBedrockGuardrailId },
3640
{ "AgentId", AWSSemanticConventions.AttributeAWSBedrockAgentId },

src/OpenTelemetry.Instrumentation.AWS/Implementation/AWSServiceType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace OpenTelemetry.Instrumentation.AWS.Implementation;
66
internal class AWSServiceType
77
{
88
internal const string DynamoDbService = "DynamoDB";
9+
internal const string SecretsManagerService = "Secrets Manager";
910
internal const string SQSService = "SQS";
1011
internal const string SNSService = "SNS";
1112
internal const string S3Service = "S3";

0 commit comments

Comments
 (0)