From 0e4880067394d6e800f2cef56ebedad995330f59 Mon Sep 17 00:00:00 2001 From: Jay Camp Date: Thu, 25 Mar 2021 18:10:59 -0400 Subject: [PATCH] Updates for cloud semantic conventions cloud.infrastructure_service -> cloud.platform cloud.zone -> cloud.availability_zone These changes were made in: https://github.com/open-telemetry/opentelemetry-specification/pull/1495 https://github.com/open-telemetry/opentelemetry-specification/pull/1530 Will make changes in contrib next. --- internal/goldendataset/resource_generator.go | 4 +- processor/resourceprocessor/README.md | 2 +- processor/resourceprocessor/config_test.go | 2 +- processor/resourceprocessor/factory_test.go | 2 +- .../resource_processor_test.go | 18 +-- .../resourceprocessor/testdata/config.yaml | 6 +- translator/conventions/opentelemetry.go | 146 +++++++++--------- .../internaldata/resource_to_oc_test.go | 44 +++--- 8 files changed, 112 insertions(+), 112 deletions(-) diff --git a/internal/goldendataset/resource_generator.go b/internal/goldendataset/resource_generator.go index b34b58c8798..4a1015b4482 100644 --- a/internal/goldendataset/resource_generator.go +++ b/internal/goldendataset/resource_generator.go @@ -134,7 +134,7 @@ func generateCloudK8sAttributes() map[string]interface{} { attrMap[conventions.AttributeCloudProvider] = "aws" attrMap[conventions.AttributeCloudAccount] = "12345678901" attrMap[conventions.AttributeCloudRegion] = "us-east-1" - attrMap[conventions.AttributeCloudZone] = "us-east-1c" + attrMap[conventions.AttributeCloudAvailabilityZone] = "us-east-1c" return attrMap } @@ -146,7 +146,7 @@ func generateFassAttributes() map[string]interface{} { attrMap[conventions.AttributeCloudProvider] = "gcp" attrMap[conventions.AttributeCloudAccount] = "opentelemetry" attrMap[conventions.AttributeCloudRegion] = "us-central1" - attrMap[conventions.AttributeCloudZone] = "us-central1-a" + attrMap[conventions.AttributeCloudAvailabilityZone] = "us-central1-a" return attrMap } diff --git a/processor/resourceprocessor/README.md b/processor/resourceprocessor/README.md index 222c79fa5ae..faa95acf7a5 100644 --- a/processor/resourceprocessor/README.md +++ b/processor/resourceprocessor/README.md @@ -14,7 +14,7 @@ Examples: processors: resource: attributes: - - key: cloud.zone + - key: cloud.availability_zone value: "zone-1" action: upsert - key: k8s.cluster.name diff --git a/processor/resourceprocessor/config_test.go b/processor/resourceprocessor/config_test.go index 1f59bb6fde8..45b98025156 100644 --- a/processor/resourceprocessor/config_test.go +++ b/processor/resourceprocessor/config_test.go @@ -42,7 +42,7 @@ func TestLoadConfig(t *testing.T) { NameVal: "resource", }, AttributesActions: []processorhelper.ActionKeyValue{ - {Key: "cloud.zone", Value: "zone-1", Action: processorhelper.UPSERT}, + {Key: "cloud.availability_zone", Value: "zone-1", Action: processorhelper.UPSERT}, {Key: "k8s.cluster.name", FromAttribute: "k8s-cluster", Action: processorhelper.INSERT}, {Key: "redundant-attribute", Action: processorhelper.DELETE}, }, diff --git a/processor/resourceprocessor/factory_test.go b/processor/resourceprocessor/factory_test.go index 6f8cabfc90e..78d503b1a72 100644 --- a/processor/resourceprocessor/factory_test.go +++ b/processor/resourceprocessor/factory_test.go @@ -42,7 +42,7 @@ func TestCreateProcessor(t *testing.T) { NameVal: "resource", }, AttributesActions: []processorhelper.ActionKeyValue{ - {Key: "cloud.zone", Value: "zone-1", Action: processorhelper.UPSERT}, + {Key: "cloud.availability_zone", Value: "zone-1", Action: processorhelper.UPSERT}, }, } diff --git a/processor/resourceprocessor/resource_processor_test.go b/processor/resourceprocessor/resource_processor_test.go index bc9b14901ec..50eccd0d79a 100644 --- a/processor/resourceprocessor/resource_processor_test.go +++ b/processor/resourceprocessor/resource_processor_test.go @@ -37,7 +37,7 @@ var ( cfg = &Config{ ProcessorSettings: processorSettings, AttributesActions: []processorhelper.ActionKeyValue{ - {Key: "cloud.zone", Value: "zone-1", Action: processorhelper.UPSERT}, + {Key: "cloud.availability_zone", Value: "zone-1", Action: processorhelper.UPSERT}, {Key: "k8s.cluster.name", FromAttribute: "k8s-cluster", Action: processorhelper.INSERT}, {Key: "redundant-attribute", Action: processorhelper.DELETE}, }, @@ -56,7 +56,7 @@ func TestResourceProcessorAttributesUpsert(t *testing.T) { config: cfg, sourceAttributes: nil, wantAttributes: map[string]string{ - "cloud.zone": "zone-1", + "cloud.availability_zone": "zone-1", }, }, { @@ -64,21 +64,21 @@ func TestResourceProcessorAttributesUpsert(t *testing.T) { config: cfg, sourceAttributes: map[string]string{}, wantAttributes: map[string]string{ - "cloud.zone": "zone-1", + "cloud.availability_zone": "zone-1", }, }, { name: "config_attributes_applied_on_existing_resource_attributes", config: cfg, sourceAttributes: map[string]string{ - "cloud.zone": "to-be-replaced", - "k8s-cluster": "test-cluster", - "redundant-attribute": "to-be-removed", + "cloud.availability_zone": "to-be-replaced", + "k8s-cluster": "test-cluster", + "redundant-attribute": "to-be-removed", }, wantAttributes: map[string]string{ - "cloud.zone": "zone-1", - "k8s-cluster": "test-cluster", - "k8s.cluster.name": "test-cluster", + "cloud.availability_zone": "zone-1", + "k8s-cluster": "test-cluster", + "k8s.cluster.name": "test-cluster", }, }, { diff --git a/processor/resourceprocessor/testdata/config.yaml b/processor/resourceprocessor/testdata/config.yaml index e9e8fcaf2f4..66d1b7031f7 100644 --- a/processor/resourceprocessor/testdata/config.yaml +++ b/processor/resourceprocessor/testdata/config.yaml @@ -3,14 +3,14 @@ receivers: processors: # The following specifies a resource configuration doing the changes on resource attributes: - # 1. Set "cloud.zone" attributes with "zone-1" value ignoring existing values. + # 1. Set "cloud.availability_zone" attributes with "zone-1" value ignoring existing values. # 2. Copy "k8s-cluster" attribute value to "k8s.cluster.name" attribute, nothing happens if "k8s-cluster" not found. # 3. Remove "redundant-attribute" attribute. - # There are many more attribute modification actions supported, + # There are many more attribute modification actions supported, # check processor/attributesprocessor/testdata/config.yaml for reference. resource: attributes: - - key: cloud.zone + - key: cloud.availability_zone value: zone-1 action: upsert - key: k8s.cluster.name diff --git a/translator/conventions/opentelemetry.go b/translator/conventions/opentelemetry.go index cd09172b495..4cd9c363ff9 100644 --- a/translator/conventions/opentelemetry.go +++ b/translator/conventions/opentelemetry.go @@ -17,61 +17,61 @@ package conventions // OpenTelemetry Semantic Convention values for Resource attribute names. // See: https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/resource/semantic_conventions/README.md const ( - AttributeCloudAccount = "cloud.account.id" - AttributeCloudProvider = "cloud.provider" - AttributeCloudRegion = "cloud.region" - AttributeCloudZone = "cloud.zone" - AttributeCloudInfrastructureService = "cloud.infrastructure_service" - AttributeContainerID = "container.id" - AttributeContainerImage = "container.image.name" - AttributeContainerName = "container.name" - AttributeContainerTag = "container.image.tag" - AttributeDeploymentEnvironment = "deployment.environment" - AttributeFaasID = "faas.id" - AttributeFaasInstance = "faas.instance" - AttributeFaasName = "faas.name" - AttributeFaasVersion = "faas.version" - AttributeHostID = "host.id" - AttributeHostImageID = "host.image.id" - AttributeHostImageName = "host.image.name" - AttributeHostImageVersion = "host.image.version" - AttributeHostName = "host.name" - AttributeHostType = "host.type" - AttributeK8sCluster = "k8s.cluster.name" - AttributeK8sContainer = "k8s.container.name" - AttributeK8sCronJob = "k8s.cronjob.name" - AttributeK8sCronJobUID = "k8s.cronjob.uid" - AttributeK8sDaemonSet = "k8s.daemonset.name" - AttributeK8sDaemonSetUID = "k8s.daemonset.uid" - AttributeK8sDeployment = "k8s.deployment.name" - AttributeK8sDeploymentUID = "k8s.deployment.uid" - AttributeK8sJob = "k8s.job.name" - AttributeK8sJobUID = "k8s.job.uid" - AttributeK8sNamespace = "k8s.namespace.name" - AttributeK8sNodeName = "k8s.node.name" - AttributeK8sNodeUID = "k8s.node.uid" - AttributeK8sPod = "k8s.pod.name" - AttributeK8sPodUID = "k8s.pod.uid" - AttributeK8sReplicaSet = "k8s.replicaset.name" - AttributeK8sReplicaSetUID = "k8s.replicaset.uid" - AttributeK8sStatefulSet = "k8s.statefulset.name" - AttributeK8sStatefulSetUID = "k8s.statefulset.uid" - AttributeOSType = "os.type" - AttributeOSDescription = "os.description" - AttributeProcessCommand = "process.command" - AttributeProcessCommandLine = "process.command_line" - AttributeProcessExecutableName = "process.executable.name" - AttributeProcessExecutablePath = "process.executable.path" - AttributeProcessID = "process.pid" - AttributeProcessOwner = "process.owner" - AttributeServiceInstance = "service.instance.id" - AttributeServiceName = "service.name" - AttributeServiceNamespace = "service.namespace" - AttributeServiceVersion = "service.version" - AttributeTelemetryAutoVersion = "telemetry.auto.version" - AttributeTelemetrySDKLanguage = "telemetry.sdk.language" - AttributeTelemetrySDKName = "telemetry.sdk.name" - AttributeTelemetrySDKVersion = "telemetry.sdk.version" + AttributeCloudAccount = "cloud.account.id" + AttributeCloudAvailabilityZone = "cloud.availability_zone" + AttributeCloudPlatform = "cloud.platform" + AttributeCloudProvider = "cloud.provider" + AttributeCloudRegion = "cloud.region" + AttributeContainerID = "container.id" + AttributeContainerImage = "container.image.name" + AttributeContainerName = "container.name" + AttributeContainerTag = "container.image.tag" + AttributeDeploymentEnvironment = "deployment.environment" + AttributeFaasID = "faas.id" + AttributeFaasInstance = "faas.instance" + AttributeFaasName = "faas.name" + AttributeFaasVersion = "faas.version" + AttributeHostID = "host.id" + AttributeHostImageID = "host.image.id" + AttributeHostImageName = "host.image.name" + AttributeHostImageVersion = "host.image.version" + AttributeHostName = "host.name" + AttributeHostType = "host.type" + AttributeK8sCluster = "k8s.cluster.name" + AttributeK8sContainer = "k8s.container.name" + AttributeK8sCronJob = "k8s.cronjob.name" + AttributeK8sCronJobUID = "k8s.cronjob.uid" + AttributeK8sDaemonSet = "k8s.daemonset.name" + AttributeK8sDaemonSetUID = "k8s.daemonset.uid" + AttributeK8sDeployment = "k8s.deployment.name" + AttributeK8sDeploymentUID = "k8s.deployment.uid" + AttributeK8sJob = "k8s.job.name" + AttributeK8sJobUID = "k8s.job.uid" + AttributeK8sNamespace = "k8s.namespace.name" + AttributeK8sNodeName = "k8s.node.name" + AttributeK8sNodeUID = "k8s.node.uid" + AttributeK8sPod = "k8s.pod.name" + AttributeK8sPodUID = "k8s.pod.uid" + AttributeK8sReplicaSet = "k8s.replicaset.name" + AttributeK8sReplicaSetUID = "k8s.replicaset.uid" + AttributeK8sStatefulSet = "k8s.statefulset.name" + AttributeK8sStatefulSetUID = "k8s.statefulset.uid" + AttributeOSDescription = "os.description" + AttributeOSType = "os.type" + AttributeProcessCommand = "process.command" + AttributeProcessCommandLine = "process.command_line" + AttributeProcessExecutableName = "process.executable.name" + AttributeProcessExecutablePath = "process.executable.path" + AttributeProcessID = "process.pid" + AttributeProcessOwner = "process.owner" + AttributeServiceInstance = "service.instance.id" + AttributeServiceName = "service.name" + AttributeServiceNamespace = "service.namespace" + AttributeServiceVersion = "service.version" + AttributeTelemetryAutoVersion = "telemetry.auto.version" + AttributeTelemetrySDKLanguage = "telemetry.sdk.language" + AttributeTelemetrySDKName = "telemetry.sdk.name" + AttributeTelemetrySDKVersion = "telemetry.sdk.version" ) // OpenTelemetry Semantic Convention values for Resource attribute "telemetry.sdk.language" values. @@ -97,24 +97,24 @@ const ( AttributeCloudProviderGCP = "gcp" ) -// OpenTelemetry Semantic Convention values for Resource attribute "cloud.infrastructure_service" values. +// OpenTelemetry Semantic Convention values for Resource attribute "cloud.platform" values. // See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/cloud.md const ( - AttributeCloudProviderAWSEC2 = "aws_ec2" - AttributeCloudProviderAWSECS = "aws_ecs" - AttributeCloudProviderAWSEKS = "aws_eks" - AttributeCloudProviderAWSLambda = "aws_lambda" - AttributeCloudProviderAWSElasticBeanstalk = "aws_elastic_beanstalk" - AttributeCloudProviderAzureVM = "azure_vm" - AttributeCloudProviderAzureContainerInstances = "azure_container_instances" - AttributeCloudProviderAzureAKS = "azure_aks" - AttributeCloudProviderAzureFunctions = "azure_functions" - AttributeCloudProviderAzureAppService = "azure_app_service" - AttributeCloudProviderGCPComputeEngine = "gcp_compute_engine" - AttributeCloudProviderGCPCloudRun = "gcp_cloud_run" - AttributeCloudProviderGCPGKE = "gcp_gke" - AttributeCloudProviderGCPCloudFunctions = "gcp_cloud_functions" - AttributeCloudProviderGCPAppEngine = "gcp_app_engine" + AttributeCloudPlatformAWSEC2 = "aws_ec2" + AttributeCloudPlatformAWSECS = "aws_ecs" + AttributeCloudPlatformAWSEKS = "aws_eks" + AttributeCloudPlatformAWSLambda = "aws_lambda" + AttributeCloudPlatformAWSElasticBeanstalk = "aws_elastic_beanstalk" + AttributeCloudPlatformAzureVM = "azure_vm" + AttributeCloudPlatformAzureContainerInstances = "azure_container_instances" + AttributeCloudPlatformAzureAKS = "azure_aks" + AttributeCloudPlatformAzureFunctions = "azure_functions" + AttributeCloudPlatformAzureAppService = "azure_app_service" + AttributeCloudPlatformGCPComputeEngine = "gcp_compute_engine" + AttributeCloudPlatformGCPCloudRun = "gcp_cloud_run" + AttributeCloudPlatformGCPGKE = "gcp_gke" + AttributeCloudPlatformGCPCloudFunctions = "gcp_cloud_functions" + AttributeCloudPlatformGCPAppEngine = "gcp_app_engine" ) // GetResourceSemanticConventionAttributeNames a slice with all the Resource Semantic Conventions attribute names. @@ -123,8 +123,8 @@ func GetResourceSemanticConventionAttributeNames() []string { AttributeCloudAccount, AttributeCloudProvider, AttributeCloudRegion, - AttributeCloudZone, - AttributeCloudInfrastructureService, + AttributeCloudAvailabilityZone, + AttributeCloudPlatform, AttributeContainerID, AttributeContainerImage, AttributeContainerName, diff --git a/translator/internaldata/resource_to_oc_test.go b/translator/internaldata/resource_to_oc_test.go index 7f90314b99f..a844d69ed7f 100644 --- a/translator/internaldata/resource_to_oc_test.go +++ b/translator/internaldata/resource_to_oc_test.go @@ -86,12 +86,12 @@ func TestResourceToOC(t *testing.T) { func TestContainerResourceToOC(t *testing.T) { resource := pdata.NewResource() resource.Attributes().InitFromMap(map[string]pdata.AttributeValue{ - conventions.AttributeK8sCluster: pdata.NewAttributeValueString("cluster1"), - conventions.AttributeK8sPod: pdata.NewAttributeValueString("pod1"), - conventions.AttributeK8sNamespace: pdata.NewAttributeValueString("namespace1"), - conventions.AttributeContainerName: pdata.NewAttributeValueString("container-name1"), - conventions.AttributeCloudAccount: pdata.NewAttributeValueString("proj1"), - conventions.AttributeCloudZone: pdata.NewAttributeValueString("zone1"), + conventions.AttributeK8sCluster: pdata.NewAttributeValueString("cluster1"), + conventions.AttributeK8sPod: pdata.NewAttributeValueString("pod1"), + conventions.AttributeK8sNamespace: pdata.NewAttributeValueString("namespace1"), + conventions.AttributeContainerName: pdata.NewAttributeValueString("container-name1"), + conventions.AttributeCloudAccount: pdata.NewAttributeValueString("proj1"), + conventions.AttributeCloudAvailabilityZone: pdata.NewAttributeValueString("zone1"), }) want := &ocresource.Resource{ @@ -163,12 +163,12 @@ func TestInferResourceType(t *testing.T) { { name: "container", labels: map[string]string{ - conventions.AttributeK8sCluster: "cluster1", - conventions.AttributeK8sPod: "pod1", - conventions.AttributeK8sNamespace: "namespace1", - conventions.AttributeContainerName: "container-name1", - conventions.AttributeCloudAccount: "proj1", - conventions.AttributeCloudZone: "zone1", + conventions.AttributeK8sCluster: "cluster1", + conventions.AttributeK8sPod: "pod1", + conventions.AttributeK8sNamespace: "namespace1", + conventions.AttributeContainerName: "container-name1", + conventions.AttributeCloudAccount: "proj1", + conventions.AttributeCloudAvailabilityZone: "zone1", }, wantResourceType: resourcekeys.ContainerType, wantOk: true, @@ -176,10 +176,10 @@ func TestInferResourceType(t *testing.T) { { name: "pod", labels: map[string]string{ - conventions.AttributeK8sCluster: "cluster1", - conventions.AttributeK8sPod: "pod1", - conventions.AttributeK8sNamespace: "namespace1", - conventions.AttributeCloudZone: "zone1", + conventions.AttributeK8sCluster: "cluster1", + conventions.AttributeK8sPod: "pod1", + conventions.AttributeK8sNamespace: "namespace1", + conventions.AttributeCloudAvailabilityZone: "zone1", }, wantResourceType: resourcekeys.K8SType, wantOk: true, @@ -187,9 +187,9 @@ func TestInferResourceType(t *testing.T) { { name: "host", labels: map[string]string{ - conventions.AttributeK8sCluster: "cluster1", - conventions.AttributeCloudZone: "zone1", - conventions.AttributeHostName: "node1", + conventions.AttributeK8sCluster: "cluster1", + conventions.AttributeCloudAvailabilityZone: "zone1", + conventions.AttributeHostName: "node1", }, wantResourceType: resourcekeys.HostType, wantOk: true, @@ -197,9 +197,9 @@ func TestInferResourceType(t *testing.T) { { name: "gce", labels: map[string]string{ - conventions.AttributeCloudProvider: "gcp", - conventions.AttributeHostID: "inst1", - conventions.AttributeCloudZone: "zone1", + conventions.AttributeCloudProvider: "gcp", + conventions.AttributeHostID: "inst1", + conventions.AttributeCloudAvailabilityZone: "zone1", }, wantResourceType: resourcekeys.CloudType, wantOk: true,