Skip to content

Commit b132f30

Browse files
committed
Updates for cloud semantic conventions
cloud.infrastructure_service -> cloud.platform cloud.zone -> cloud.availability_zone These changes were made in: open-telemetry/opentelemetry-specification#1495 open-telemetry/opentelemetry-specification#1530 Will make changes in contrib next.
1 parent 09f29af commit b132f30

File tree

6 files changed

+108
-108
lines changed

6 files changed

+108
-108
lines changed

internal/goldendataset/resource_generator.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func generateCloudK8sAttributes() map[string]interface{} {
134134
attrMap[conventions.AttributeCloudProvider] = "aws"
135135
attrMap[conventions.AttributeCloudAccount] = "12345678901"
136136
attrMap[conventions.AttributeCloudRegion] = "us-east-1"
137-
attrMap[conventions.AttributeCloudZone] = "us-east-1c"
137+
attrMap[conventions.AttributeCloudAvailabilityZone] = "us-east-1c"
138138
return attrMap
139139
}
140140

@@ -146,7 +146,7 @@ func generateFassAttributes() map[string]interface{} {
146146
attrMap[conventions.AttributeCloudProvider] = "gcp"
147147
attrMap[conventions.AttributeCloudAccount] = "opentelemetry"
148148
attrMap[conventions.AttributeCloudRegion] = "us-central1"
149-
attrMap[conventions.AttributeCloudZone] = "us-central1-a"
149+
attrMap[conventions.AttributeCloudAvailabilityZone] = "us-central1-a"
150150
return attrMap
151151
}
152152

processor/resourceprocessor/config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestLoadConfig(t *testing.T) {
4242
NameVal: "resource",
4343
},
4444
AttributesActions: []processorhelper.ActionKeyValue{
45-
{Key: "cloud.zone", Value: "zone-1", Action: processorhelper.UPSERT},
45+
{Key: "cloud.availability_zone", Value: "zone-1", Action: processorhelper.UPSERT},
4646
{Key: "k8s.cluster.name", FromAttribute: "k8s-cluster", Action: processorhelper.INSERT},
4747
{Key: "redundant-attribute", Action: processorhelper.DELETE},
4848
},

processor/resourceprocessor/factory_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestCreateProcessor(t *testing.T) {
4242
NameVal: "resource",
4343
},
4444
AttributesActions: []processorhelper.ActionKeyValue{
45-
{Key: "cloud.zone", Value: "zone-1", Action: processorhelper.UPSERT},
45+
{Key: "cloud.availability_zone", Value: "zone-1", Action: processorhelper.UPSERT},
4646
},
4747
}
4848

processor/resourceprocessor/resource_processor_test.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var (
3737
cfg = &Config{
3838
ProcessorSettings: processorSettings,
3939
AttributesActions: []processorhelper.ActionKeyValue{
40-
{Key: "cloud.zone", Value: "zone-1", Action: processorhelper.UPSERT},
40+
{Key: "cloud.availability_zone", Value: "zone-1", Action: processorhelper.UPSERT},
4141
{Key: "k8s.cluster.name", FromAttribute: "k8s-cluster", Action: processorhelper.INSERT},
4242
{Key: "redundant-attribute", Action: processorhelper.DELETE},
4343
},
@@ -56,29 +56,29 @@ func TestResourceProcessorAttributesUpsert(t *testing.T) {
5656
config: cfg,
5757
sourceAttributes: nil,
5858
wantAttributes: map[string]string{
59-
"cloud.zone": "zone-1",
59+
"cloud.availability_zone": "zone-1",
6060
},
6161
},
6262
{
6363
name: "config_with_attributes_applied_on_empty_resource",
6464
config: cfg,
6565
sourceAttributes: map[string]string{},
6666
wantAttributes: map[string]string{
67-
"cloud.zone": "zone-1",
67+
"cloud.availability_zone": "zone-1",
6868
},
6969
},
7070
{
7171
name: "config_attributes_applied_on_existing_resource_attributes",
7272
config: cfg,
7373
sourceAttributes: map[string]string{
74-
"cloud.zone": "to-be-replaced",
75-
"k8s-cluster": "test-cluster",
76-
"redundant-attribute": "to-be-removed",
74+
"cloud.availability_zone": "to-be-replaced",
75+
"k8s-cluster": "test-cluster",
76+
"redundant-attribute": "to-be-removed",
7777
},
7878
wantAttributes: map[string]string{
79-
"cloud.zone": "zone-1",
80-
"k8s-cluster": "test-cluster",
81-
"k8s.cluster.name": "test-cluster",
79+
"cloud.availability_zone": "zone-1",
80+
"k8s-cluster": "test-cluster",
81+
"k8s.cluster.name": "test-cluster",
8282
},
8383
},
8484
{

translator/conventions/opentelemetry.go

+73-73
Original file line numberDiff line numberDiff line change
@@ -17,61 +17,61 @@ package conventions
1717
// OpenTelemetry Semantic Convention values for Resource attribute names.
1818
// See: https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/resource/semantic_conventions/README.md
1919
const (
20-
AttributeCloudAccount = "cloud.account.id"
21-
AttributeCloudProvider = "cloud.provider"
22-
AttributeCloudRegion = "cloud.region"
23-
AttributeCloudZone = "cloud.zone"
24-
AttributeCloudInfrastructureService = "cloud.infrastructure_service"
25-
AttributeContainerID = "container.id"
26-
AttributeContainerImage = "container.image.name"
27-
AttributeContainerName = "container.name"
28-
AttributeContainerTag = "container.image.tag"
29-
AttributeDeploymentEnvironment = "deployment.environment"
30-
AttributeFaasID = "faas.id"
31-
AttributeFaasInstance = "faas.instance"
32-
AttributeFaasName = "faas.name"
33-
AttributeFaasVersion = "faas.version"
34-
AttributeHostID = "host.id"
35-
AttributeHostImageID = "host.image.id"
36-
AttributeHostImageName = "host.image.name"
37-
AttributeHostImageVersion = "host.image.version"
38-
AttributeHostName = "host.name"
39-
AttributeHostType = "host.type"
40-
AttributeK8sCluster = "k8s.cluster.name"
41-
AttributeK8sContainer = "k8s.container.name"
42-
AttributeK8sCronJob = "k8s.cronjob.name"
43-
AttributeK8sCronJobUID = "k8s.cronjob.uid"
44-
AttributeK8sDaemonSet = "k8s.daemonset.name"
45-
AttributeK8sDaemonSetUID = "k8s.daemonset.uid"
46-
AttributeK8sDeployment = "k8s.deployment.name"
47-
AttributeK8sDeploymentUID = "k8s.deployment.uid"
48-
AttributeK8sJob = "k8s.job.name"
49-
AttributeK8sJobUID = "k8s.job.uid"
50-
AttributeK8sNamespace = "k8s.namespace.name"
51-
AttributeK8sNodeName = "k8s.node.name"
52-
AttributeK8sNodeUID = "k8s.node.uid"
53-
AttributeK8sPod = "k8s.pod.name"
54-
AttributeK8sPodUID = "k8s.pod.uid"
55-
AttributeK8sReplicaSet = "k8s.replicaset.name"
56-
AttributeK8sReplicaSetUID = "k8s.replicaset.uid"
57-
AttributeK8sStatefulSet = "k8s.statefulset.name"
58-
AttributeK8sStatefulSetUID = "k8s.statefulset.uid"
59-
AttributeOSType = "os.type"
60-
AttributeOSDescription = "os.description"
61-
AttributeProcessCommand = "process.command"
62-
AttributeProcessCommandLine = "process.command_line"
63-
AttributeProcessExecutableName = "process.executable.name"
64-
AttributeProcessExecutablePath = "process.executable.path"
65-
AttributeProcessID = "process.pid"
66-
AttributeProcessOwner = "process.owner"
67-
AttributeServiceInstance = "service.instance.id"
68-
AttributeServiceName = "service.name"
69-
AttributeServiceNamespace = "service.namespace"
70-
AttributeServiceVersion = "service.version"
71-
AttributeTelemetryAutoVersion = "telemetry.auto.version"
72-
AttributeTelemetrySDKLanguage = "telemetry.sdk.language"
73-
AttributeTelemetrySDKName = "telemetry.sdk.name"
74-
AttributeTelemetrySDKVersion = "telemetry.sdk.version"
20+
AttributeCloudAccount = "cloud.account.id"
21+
AttributeCloudAvailabilityZone = "cloud.availability_zone"
22+
AttributeCloudPlatform = "cloud.platform"
23+
AttributeCloudProvider = "cloud.provider"
24+
AttributeCloudRegion = "cloud.region"
25+
AttributeContainerID = "container.id"
26+
AttributeContainerImage = "container.image.name"
27+
AttributeContainerName = "container.name"
28+
AttributeContainerTag = "container.image.tag"
29+
AttributeDeploymentEnvironment = "deployment.environment"
30+
AttributeFaasID = "faas.id"
31+
AttributeFaasInstance = "faas.instance"
32+
AttributeFaasName = "faas.name"
33+
AttributeFaasVersion = "faas.version"
34+
AttributeHostID = "host.id"
35+
AttributeHostImageID = "host.image.id"
36+
AttributeHostImageName = "host.image.name"
37+
AttributeHostImageVersion = "host.image.version"
38+
AttributeHostName = "host.name"
39+
AttributeHostType = "host.type"
40+
AttributeK8sCluster = "k8s.cluster.name"
41+
AttributeK8sContainer = "k8s.container.name"
42+
AttributeK8sCronJob = "k8s.cronjob.name"
43+
AttributeK8sCronJobUID = "k8s.cronjob.uid"
44+
AttributeK8sDaemonSet = "k8s.daemonset.name"
45+
AttributeK8sDaemonSetUID = "k8s.daemonset.uid"
46+
AttributeK8sDeployment = "k8s.deployment.name"
47+
AttributeK8sDeploymentUID = "k8s.deployment.uid"
48+
AttributeK8sJob = "k8s.job.name"
49+
AttributeK8sJobUID = "k8s.job.uid"
50+
AttributeK8sNamespace = "k8s.namespace.name"
51+
AttributeK8sNodeName = "k8s.node.name"
52+
AttributeK8sNodeUID = "k8s.node.uid"
53+
AttributeK8sPod = "k8s.pod.name"
54+
AttributeK8sPodUID = "k8s.pod.uid"
55+
AttributeK8sReplicaSet = "k8s.replicaset.name"
56+
AttributeK8sReplicaSetUID = "k8s.replicaset.uid"
57+
AttributeK8sStatefulSet = "k8s.statefulset.name"
58+
AttributeK8sStatefulSetUID = "k8s.statefulset.uid"
59+
AttributeOSDescription = "os.description"
60+
AttributeOSType = "os.type"
61+
AttributeProcessCommand = "process.command"
62+
AttributeProcessCommandLine = "process.command_line"
63+
AttributeProcessExecutableName = "process.executable.name"
64+
AttributeProcessExecutablePath = "process.executable.path"
65+
AttributeProcessID = "process.pid"
66+
AttributeProcessOwner = "process.owner"
67+
AttributeServiceInstance = "service.instance.id"
68+
AttributeServiceName = "service.name"
69+
AttributeServiceNamespace = "service.namespace"
70+
AttributeServiceVersion = "service.version"
71+
AttributeTelemetryAutoVersion = "telemetry.auto.version"
72+
AttributeTelemetrySDKLanguage = "telemetry.sdk.language"
73+
AttributeTelemetrySDKName = "telemetry.sdk.name"
74+
AttributeTelemetrySDKVersion = "telemetry.sdk.version"
7575
)
7676

7777
// OpenTelemetry Semantic Convention values for Resource attribute "telemetry.sdk.language" values.
@@ -97,24 +97,24 @@ const (
9797
AttributeCloudProviderGCP = "gcp"
9898
)
9999

100-
// OpenTelemetry Semantic Convention values for Resource attribute "cloud.infrastructure_service" values.
100+
// OpenTelemetry Semantic Convention values for Resource attribute "cloud.platform" values.
101101
// See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/cloud.md
102102
const (
103-
AttributeCloudProviderAWSEC2 = "aws_ec2"
104-
AttributeCloudProviderAWSECS = "aws_ecs"
105-
AttributeCloudProviderAWSEKS = "aws_eks"
106-
AttributeCloudProviderAWSLambda = "aws_lambda"
107-
AttributeCloudProviderAWSElasticBeanstalk = "aws_elastic_beanstalk"
108-
AttributeCloudProviderAzureVM = "azure_vm"
109-
AttributeCloudProviderAzureContainerInstances = "azure_container_instances"
110-
AttributeCloudProviderAzureAKS = "azure_aks"
111-
AttributeCloudProviderAzureFunctions = "azure_functions"
112-
AttributeCloudProviderAzureAppService = "azure_app_service"
113-
AttributeCloudProviderGCPComputeEngine = "gcp_compute_engine"
114-
AttributeCloudProviderGCPCloudRun = "gcp_cloud_run"
115-
AttributeCloudProviderGCPGKE = "gcp_gke"
116-
AttributeCloudProviderGCPCloudFunctions = "gcp_cloud_functions"
117-
AttributeCloudProviderGCPAppEngine = "gcp_app_engine"
103+
AttributeCloudPlatformAWSEC2 = "aws_ec2"
104+
AttributeCloudPlatformAWSECS = "aws_ecs"
105+
AttributeCloudPlatformAWSEKS = "aws_eks"
106+
AttributeCloudPlatformAWSLambda = "aws_lambda"
107+
AttributeCloudPlatformAWSElasticBeanstalk = "aws_elastic_beanstalk"
108+
AttributeCloudPlatformAzureVM = "azure_vm"
109+
AttributeCloudPlatformAzureContainerInstances = "azure_container_instances"
110+
AttributeCloudPlatformAzureAKS = "azure_aks"
111+
AttributeCloudPlatformAzureFunctions = "azure_functions"
112+
AttributeCloudPlatformAzureAppService = "azure_app_service"
113+
AttributeCloudPlatformGCPComputeEngine = "gcp_compute_engine"
114+
AttributeCloudPlatformGCPCloudRun = "gcp_cloud_run"
115+
AttributeCloudPlatformGCPGKE = "gcp_gke"
116+
AttributeCloudPlatformGCPCloudFunctions = "gcp_cloud_functions"
117+
AttributeCloudPlatformGCPAppEngine = "gcp_app_engine"
118118
)
119119

120120
// GetResourceSemanticConventionAttributeNames a slice with all the Resource Semantic Conventions attribute names.
@@ -123,8 +123,8 @@ func GetResourceSemanticConventionAttributeNames() []string {
123123
AttributeCloudAccount,
124124
AttributeCloudProvider,
125125
AttributeCloudRegion,
126-
AttributeCloudZone,
127-
AttributeCloudInfrastructureService,
126+
AttributeCloudAvailabilityZone,
127+
AttributeCloudPlatform,
128128
AttributeContainerID,
129129
AttributeContainerImage,
130130
AttributeContainerName,

translator/internaldata/resource_to_oc_test.go

+22-22
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ func TestResourceToOC(t *testing.T) {
8686
func TestContainerResourceToOC(t *testing.T) {
8787
resource := pdata.NewResource()
8888
resource.Attributes().InitFromMap(map[string]pdata.AttributeValue{
89-
conventions.AttributeK8sCluster: pdata.NewAttributeValueString("cluster1"),
90-
conventions.AttributeK8sPod: pdata.NewAttributeValueString("pod1"),
91-
conventions.AttributeK8sNamespace: pdata.NewAttributeValueString("namespace1"),
92-
conventions.AttributeContainerName: pdata.NewAttributeValueString("container-name1"),
93-
conventions.AttributeCloudAccount: pdata.NewAttributeValueString("proj1"),
94-
conventions.AttributeCloudZone: pdata.NewAttributeValueString("zone1"),
89+
conventions.AttributeK8sCluster: pdata.NewAttributeValueString("cluster1"),
90+
conventions.AttributeK8sPod: pdata.NewAttributeValueString("pod1"),
91+
conventions.AttributeK8sNamespace: pdata.NewAttributeValueString("namespace1"),
92+
conventions.AttributeContainerName: pdata.NewAttributeValueString("container-name1"),
93+
conventions.AttributeCloudAccount: pdata.NewAttributeValueString("proj1"),
94+
conventions.AttributeCloudAvailabilityZone: pdata.NewAttributeValueString("zone1"),
9595
})
9696

9797
want := &ocresource.Resource{
@@ -163,43 +163,43 @@ func TestInferResourceType(t *testing.T) {
163163
{
164164
name: "container",
165165
labels: map[string]string{
166-
conventions.AttributeK8sCluster: "cluster1",
167-
conventions.AttributeK8sPod: "pod1",
168-
conventions.AttributeK8sNamespace: "namespace1",
169-
conventions.AttributeContainerName: "container-name1",
170-
conventions.AttributeCloudAccount: "proj1",
171-
conventions.AttributeCloudZone: "zone1",
166+
conventions.AttributeK8sCluster: "cluster1",
167+
conventions.AttributeK8sPod: "pod1",
168+
conventions.AttributeK8sNamespace: "namespace1",
169+
conventions.AttributeContainerName: "container-name1",
170+
conventions.AttributeCloudAccount: "proj1",
171+
conventions.AttributeCloudAvailabilityZone: "zone1",
172172
},
173173
wantResourceType: resourcekeys.ContainerType,
174174
wantOk: true,
175175
},
176176
{
177177
name: "pod",
178178
labels: map[string]string{
179-
conventions.AttributeK8sCluster: "cluster1",
180-
conventions.AttributeK8sPod: "pod1",
181-
conventions.AttributeK8sNamespace: "namespace1",
182-
conventions.AttributeCloudZone: "zone1",
179+
conventions.AttributeK8sCluster: "cluster1",
180+
conventions.AttributeK8sPod: "pod1",
181+
conventions.AttributeK8sNamespace: "namespace1",
182+
conventions.AttributeCloudAvailabilityZone: "zone1",
183183
},
184184
wantResourceType: resourcekeys.K8SType,
185185
wantOk: true,
186186
},
187187
{
188188
name: "host",
189189
labels: map[string]string{
190-
conventions.AttributeK8sCluster: "cluster1",
191-
conventions.AttributeCloudZone: "zone1",
192-
conventions.AttributeHostName: "node1",
190+
conventions.AttributeK8sCluster: "cluster1",
191+
conventions.AttributeCloudAvailabilityZone: "zone1",
192+
conventions.AttributeHostName: "node1",
193193
},
194194
wantResourceType: resourcekeys.HostType,
195195
wantOk: true,
196196
},
197197
{
198198
name: "gce",
199199
labels: map[string]string{
200-
conventions.AttributeCloudProvider: "gcp",
201-
conventions.AttributeHostID: "inst1",
202-
conventions.AttributeCloudZone: "zone1",
200+
conventions.AttributeCloudProvider: "gcp",
201+
conventions.AttributeHostID: "inst1",
202+
conventions.AttributeCloudAvailabilityZone: "zone1",
203203
},
204204
wantResourceType: resourcekeys.CloudType,
205205
wantOk: true,

0 commit comments

Comments
 (0)