File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed
detectors/node/opentelemetry-resource-detector-gcp/src/detectors Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ import {
2424 ResourceAttributes ,
2525 IResource ,
2626} from '@opentelemetry/resources' ;
27- import { getEnv } from '@opentelemetry/core' ;
2827import {
2928 CLOUDPROVIDERVALUES_GCP ,
3029 SEMRESATTRS_CLOUD_ACCOUNT_ID ,
@@ -79,7 +78,7 @@ class GcpDetector implements DetectorSync {
7978 attributes [ SEMRESATTRS_CLOUD_AVAILABILITY_ZONE ] = zoneId ;
8079 attributes [ SEMRESATTRS_CLOUD_PROVIDER ] = CLOUDPROVIDERVALUES_GCP ;
8180
82- if ( getEnv ( ) . KUBERNETES_SERVICE_HOST )
81+ if ( process . env . KUBERNETES_SERVICE_HOST )
8382 this . _addK8sAttributes ( attributes , clusterName ) ;
8483
8584 return attributes ;
@@ -90,12 +89,10 @@ class GcpDetector implements DetectorSync {
9089 attributes : ResourceAttributes ,
9190 clusterName : string
9291 ) : void {
93- const env = getEnv ( ) ;
94-
9592 attributes [ SEMRESATTRS_K8S_CLUSTER_NAME ] = clusterName ;
96- attributes [ SEMRESATTRS_K8S_NAMESPACE_NAME ] = env . NAMESPACE ;
97- attributes [ SEMRESATTRS_K8S_POD_NAME ] = env . HOSTNAME ;
98- attributes [ SEMRESATTRS_CONTAINER_NAME ] = env . CONTAINER_NAME ;
93+ attributes [ SEMRESATTRS_K8S_NAMESPACE_NAME ] = process . env . NAMESPACE ?? '' ;
94+ attributes [ SEMRESATTRS_K8S_POD_NAME ] = process . env . HOSTNAME ?? '' ;
95+ attributes [ SEMRESATTRS_CONTAINER_NAME ] = process . env . CONTAINER_NAME ?? '' ;
9996 }
10097
10198 /** Gets project id from GCP project metadata. */
You can’t perform that action at this time.
0 commit comments