@@ -24,8 +24,16 @@ import {
24
24
} from '@opentelemetry/resources' ;
25
25
import { getEnv } from '@opentelemetry/core' ;
26
26
import {
27
- CloudProviderValues ,
28
- SemanticResourceAttributes ,
27
+ CLOUDPROVIDERVALUES_GCP ,
28
+ SEMRESATTRS_CLOUD_ACCOUNT_ID ,
29
+ SEMRESATTRS_CLOUD_AVAILABILITY_ZONE ,
30
+ SEMRESATTRS_CLOUD_PROVIDER ,
31
+ SEMRESATTRS_CONTAINER_NAME ,
32
+ SEMRESATTRS_HOST_ID ,
33
+ SEMRESATTRS_HOST_NAME ,
34
+ SEMRESATTRS_K8S_CLUSTER_NAME ,
35
+ SEMRESATTRS_K8S_NAMESPACE_NAME ,
36
+ SEMRESATTRS_K8S_POD_NAME ,
29
37
} from '@opentelemetry/semantic-conventions' ;
30
38
31
39
/**
@@ -58,12 +66,11 @@ class GcpDetector implements Detector {
58
66
] ) ;
59
67
60
68
const attributes : ResourceAttributes = { } ;
61
- attributes [ SemanticResourceAttributes . CLOUD_ACCOUNT_ID ] = projectId ;
62
- attributes [ SemanticResourceAttributes . HOST_ID ] = instanceId ;
63
- attributes [ SemanticResourceAttributes . HOST_NAME ] = hostname ;
64
- attributes [ SemanticResourceAttributes . CLOUD_AVAILABILITY_ZONE ] = zoneId ;
65
- attributes [ SemanticResourceAttributes . CLOUD_PROVIDER ] =
66
- CloudProviderValues . GCP ;
69
+ attributes [ SEMRESATTRS_CLOUD_ACCOUNT_ID ] = projectId ;
70
+ attributes [ SEMRESATTRS_HOST_ID ] = instanceId ;
71
+ attributes [ SEMRESATTRS_HOST_NAME ] = hostname ;
72
+ attributes [ SEMRESATTRS_CLOUD_AVAILABILITY_ZONE ] = zoneId ;
73
+ attributes [ SEMRESATTRS_CLOUD_PROVIDER ] = CLOUDPROVIDERVALUES_GCP ;
67
74
68
75
if ( getEnv ( ) . KUBERNETES_SERVICE_HOST )
69
76
this . _addK8sAttributes ( attributes , clusterName ) ;
@@ -78,10 +85,10 @@ class GcpDetector implements Detector {
78
85
) : void {
79
86
const env = getEnv ( ) ;
80
87
81
- attributes [ SemanticResourceAttributes . K8S_CLUSTER_NAME ] = clusterName ;
82
- attributes [ SemanticResourceAttributes . K8S_NAMESPACE_NAME ] = env . NAMESPACE ;
83
- attributes [ SemanticResourceAttributes . K8S_POD_NAME ] = env . HOSTNAME ;
84
- attributes [ SemanticResourceAttributes . CONTAINER_NAME ] = env . CONTAINER_NAME ;
88
+ attributes [ SEMRESATTRS_K8S_CLUSTER_NAME ] = clusterName ;
89
+ attributes [ SEMRESATTRS_K8S_NAMESPACE_NAME ] = env . NAMESPACE ;
90
+ attributes [ SEMRESATTRS_K8S_POD_NAME ] = env . HOSTNAME ;
91
+ attributes [ SEMRESATTRS_CONTAINER_NAME ] = env . CONTAINER_NAME ;
85
92
}
86
93
87
94
/** Gets project id from GCP project metadata. */
0 commit comments