Skip to content

Commit b16c769

Browse files
committed
add support for SNS TopicArn and Secrets Manager SecretArn attributes
1 parent bbda41b commit b16c769

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
@@ -49,6 +49,8 @@ internal sealed class AwsAttributeKeys
4949
internal static readonly string AttributeAWSSQSQueueUrl = "aws.queue_url";
5050

5151
internal static readonly string AttributeAWSS3Bucket = "aws.s3.bucket";
52+
internal static readonly string AttributeAWSSecretsManagerSecretArn = "aws.secretsmanager.secret.arn";
53+
internal static readonly string AttributeAWSSNSTopicArn = "aws.sns.topic.arn";
5254

5355
internal static readonly string AttributeAWSBedrockGuardrailId = "aws.bedrock.guardrail.id";
5456
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
@@ -43,6 +43,8 @@ internal class AwsMetricAttributeGenerator : IMetricAttributeGenerator
4343
private static readonly string NormalizedDynamoDBServiceName = "AWS::DynamoDB";
4444
private static readonly string NormalizedKinesisServiceName = "AWS::Kinesis";
4545
private static readonly string NormalizedS3ServiceName = "AWS::S3";
46+
private static readonly string NormalizedSecretsManagerServiceName = "AWS::SecretsManager";
47+
private static readonly string NormalizedSNSServiceName = "AWS::SNS";
4648
private static readonly string NormalizedSQSServiceName = "AWS::SQS";
4749
private static readonly string NormalizedBedrockServiceName = "AWS::Bedrock";
4850
private static readonly string NormalizedBedrockRuntimeServiceName = "AWS::BedrockRuntime";
@@ -361,6 +363,10 @@ private static string NormalizeRemoteServiceName(Activity span, string serviceNa
361363
case "Amazon S3": // AWS SDK v1
362364
case "S3": // AWS SDK v2
363365
return NormalizedS3ServiceName;
366+
case "Secrets Manager":
367+
return NormalizedSecretsManagerServiceName;
368+
case "SNS":
369+
return NormalizedSNSServiceName;
364370
case "AmazonSQS": // AWS SDK v1
365371
case "Sqs": // AWS SDK v2
366372
return NormalizedSQSServiceName;
@@ -403,6 +409,16 @@ private static void SetRemoteResourceTypeAndIdentifier(Activity span, ActivityTa
403409
remoteResourceType = NormalizedS3ServiceName + "::Bucket";
404410
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSS3Bucket));
405411
}
412+
else if (IsKeyPresent(span, AttributeAWSSecretsManagerSecretArn))
413+
{
414+
remoteResourceType = NormalizedSecretsManagerServiceName + "::Secret";
415+
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSecretsManagerSecretArn));
416+
}
417+
else if (IsKeyPresent(span, AttributeAWSSNSTopicArn))
418+
{
419+
remoteResourceType = NormalizedSNSServiceName + "::Topic";
420+
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSNSTopicArn));
421+
}
406422
else if (IsKeyPresent(span, AttributeAWSSQSQueueName))
407423
{
408424
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.SQSService, new List<string> { "QueueUrl" } },
2426
{ AWSServiceType.BedrockService, new List<string> { "GuardrailId" } },
2527
{ AWSServiceType.BedrockAgentService, new List<string> { "AgentId", "DataSourceId" } },
@@ -32,6 +34,8 @@ internal class AWSServiceHelper
3234
{ "QueueName", AWSSemanticConventions.AttributeAWSSQSQueueName },
3335
{ "BucketName", AWSSemanticConventions.AttributeAWSS3BucketName },
3436
{ "StreamName", AWSSemanticConventions.AttributeAWSKinesisStreamName },
37+
{ "TopicArn", AWSSemanticConventions.AttributeAWSSnsTopicArn },
38+
{ "ARN", AWSSemanticConventions.AttributeAWSSecretsManagerSecretArn },
3539
{ "ModelId", AWSSemanticConventions.AttributeGenAiModelId },
3640
{ "GuardrailId", AWSSemanticConventions.AttributeAWSBedrockGuardrailId },
3741
{ "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)