From da78f8ca5a60b1bb8a262d01bffdaec2a89c75a4 Mon Sep 17 00:00:00 2001 From: philip pittle Date: Thu, 5 Dec 2024 13:54:10 -0800 Subject: [PATCH] Move string literals to AWS Semnatic Conventions class --- src/OpenTelemetry.Resources.AWS/AWSEBSDetector.cs | 6 +++--- src/OpenTelemetry.Resources.AWS/AWSEC2Detector.cs | 4 ++-- src/OpenTelemetry.Resources.AWS/AWSECSDetector.cs | 4 ++-- src/OpenTelemetry.Resources.AWS/AWSEKSDetector.cs | 4 ++-- src/OpenTelemetry.Resources.AWS/AWSSemanticConventions.cs | 6 ++++++ 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/OpenTelemetry.Resources.AWS/AWSEBSDetector.cs b/src/OpenTelemetry.Resources.AWS/AWSEBSDetector.cs index 80acea1404..be18b19080 100644 --- a/src/OpenTelemetry.Resources.AWS/AWSEBSDetector.cs +++ b/src/OpenTelemetry.Resources.AWS/AWSEBSDetector.cs @@ -56,9 +56,9 @@ internal static List> ExtractResourceAttributes(AWS { var resourceAttributes = new List>() { - new(AWSSemanticConventions.AttributeCloudProvider, "aws"), - new(AWSSemanticConventions.AttributeCloudPlatform, "aws_elastic_beanstalk"), - new(AWSSemanticConventions.AttributeServiceName, "aws_elastic_beanstalk"), + new(AWSSemanticConventions.AttributeCloudProvider, AWSSemanticConventions.CloudProviderValuesAws), + new(AWSSemanticConventions.AttributeCloudPlatform, AWSSemanticConventions.CloudPlatformValuesAwsElasticBeanstalk), + new(AWSSemanticConventions.AttributeServiceName, AWSSemanticConventions.ServiceNameValuesAwsElasticBeanstalk), }; if (metadata != null) diff --git a/src/OpenTelemetry.Resources.AWS/AWSEC2Detector.cs b/src/OpenTelemetry.Resources.AWS/AWSEC2Detector.cs index 076adbf48d..d93ed52611 100644 --- a/src/OpenTelemetry.Resources.AWS/AWSEC2Detector.cs +++ b/src/OpenTelemetry.Resources.AWS/AWSEC2Detector.cs @@ -45,8 +45,8 @@ internal static List> ExtractResourceAttributes(AWS { var resourceAttributes = new List>() { - new(AWSSemanticConventions.AttributeCloudProvider, "aws"), - new(AWSSemanticConventions.AttributeCloudPlatform, "aws_ec2"), + new(AWSSemanticConventions.AttributeCloudProvider, AWSSemanticConventions.CloudProviderValuesAws), + new(AWSSemanticConventions.AttributeCloudPlatform, AWSSemanticConventions.CloudPlatformValuesAwsEc2), new(AWSSemanticConventions.AttributeHostName, hostName), }; diff --git a/src/OpenTelemetry.Resources.AWS/AWSECSDetector.cs b/src/OpenTelemetry.Resources.AWS/AWSECSDetector.cs index ac43f694ff..0f527f6a84 100644 --- a/src/OpenTelemetry.Resources.AWS/AWSECSDetector.cs +++ b/src/OpenTelemetry.Resources.AWS/AWSECSDetector.cs @@ -29,8 +29,8 @@ public Resource Detect() var resourceAttributes = new List>() { - new(AWSSemanticConventions.AttributeCloudProvider, "aws"), - new(AWSSemanticConventions.AttributeCloudPlatform, "aws_ecs"), + new(AWSSemanticConventions.AttributeCloudProvider, AWSSemanticConventions.CloudProviderValuesAws), + new(AWSSemanticConventions.AttributeCloudPlatform, AWSSemanticConventions.CloudPlatformValuesAwsEcs), }; try diff --git a/src/OpenTelemetry.Resources.AWS/AWSEKSDetector.cs b/src/OpenTelemetry.Resources.AWS/AWSEKSDetector.cs index adf4a59632..8d0860c4af 100644 --- a/src/OpenTelemetry.Resources.AWS/AWSEKSDetector.cs +++ b/src/OpenTelemetry.Resources.AWS/AWSEKSDetector.cs @@ -38,8 +38,8 @@ internal static List> ExtractResourceAttributes(str { var resourceAttributes = new List>() { - new(AWSSemanticConventions.AttributeCloudProvider, "aws"), - new(AWSSemanticConventions.AttributeCloudPlatform, "aws_eks"), + new(AWSSemanticConventions.AttributeCloudProvider, AWSSemanticConventions.CloudProviderValuesAws), + new(AWSSemanticConventions.AttributeCloudPlatform, AWSSemanticConventions.CloudPlatformValuesAwsEks), }; if (!string.IsNullOrEmpty(clusterName)) diff --git a/src/OpenTelemetry.Resources.AWS/AWSSemanticConventions.cs b/src/OpenTelemetry.Resources.AWS/AWSSemanticConventions.cs index 1f5cd829d8..049047ea70 100644 --- a/src/OpenTelemetry.Resources.AWS/AWSSemanticConventions.cs +++ b/src/OpenTelemetry.Resources.AWS/AWSSemanticConventions.cs @@ -11,6 +11,11 @@ internal static class AWSSemanticConventions public const string AttributeCloudProvider = "cloud.provider"; public const string AttributeCloudRegion = "cloud.region"; public const string AttributeCloudResourceId = "cloud.resource_id"; + public const string CloudPlatformValuesAwsEc2 = "aws_ec2"; + public const string CloudPlatformValuesAwsEcs = "aws_ecs"; + public const string CloudPlatformValuesAwsEks = "aws_eks"; + public const string CloudPlatformValuesAwsElasticBeanstalk = "aws_elastic_beanstalk"; + public const string CloudProviderValuesAws = "aws"; public const string AttributeContainerID = "container.id"; @@ -43,4 +48,5 @@ internal static class AWSSemanticConventions public const string AttributeServiceNamespace = "service.namespace"; public const string AttributeServiceInstanceID = "service.instance.id"; public const string AttributeServiceVersion = "service.version"; + public const string ServiceNameValuesAwsElasticBeanstalk = "aws_elastic_beanstalk"; }