Skip to content

Commit

Permalink
Updates for cloud semantic conventions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrcamp committed Mar 25, 2021
1 parent 09f29af commit 0e48800
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 112 deletions.
4 changes: 2 additions & 2 deletions internal/goldendataset/resource_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion processor/resourceprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Examples:
processors:
resource:
attributes:
- key: cloud.zone
- key: cloud.availability_zone
value: "zone-1"
action: upsert
- key: k8s.cluster.name
Expand Down
2 changes: 1 addition & 1 deletion processor/resourceprocessor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
Expand Down
2 changes: 1 addition & 1 deletion processor/resourceprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
}

Expand Down
18 changes: 9 additions & 9 deletions processor/resourceprocessor/resource_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
Expand All @@ -56,29 +56,29 @@ func TestResourceProcessorAttributesUpsert(t *testing.T) {
config: cfg,
sourceAttributes: nil,
wantAttributes: map[string]string{
"cloud.zone": "zone-1",
"cloud.availability_zone": "zone-1",
},
},
{
name: "config_with_attributes_applied_on_empty_resource",
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",
},
},
{
Expand Down
6 changes: 3 additions & 3 deletions processor/resourceprocessor/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
146 changes: 73 additions & 73 deletions translator/conventions/opentelemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -123,8 +123,8 @@ func GetResourceSemanticConventionAttributeNames() []string {
AttributeCloudAccount,
AttributeCloudProvider,
AttributeCloudRegion,
AttributeCloudZone,
AttributeCloudInfrastructureService,
AttributeCloudAvailabilityZone,
AttributeCloudPlatform,
AttributeContainerID,
AttributeContainerImage,
AttributeContainerName,
Expand Down
44 changes: 22 additions & 22 deletions translator/internaldata/resource_to_oc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -163,43 +163,43 @@ 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,
},
{
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,
},
{
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,
},
{
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,
Expand Down

0 comments on commit 0e48800

Please sign in to comment.