@opentelemetry/resource-detector-gcp 0.40.0 → 0.40.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@
16
16
  */
17
17
  import { context } from '@opentelemetry/api';
18
18
  import { suppressTracing } from '@opentelemetry/core';
19
- import { CLOUDPLATFORMVALUES_GCP_APP_ENGINE, CLOUDPLATFORMVALUES_GCP_CLOUD_FUNCTIONS, CLOUDPLATFORMVALUES_GCP_CLOUD_RUN, CLOUDPLATFORMVALUES_GCP_COMPUTE_ENGINE, CLOUDPLATFORMVALUES_GCP_KUBERNETES_ENGINE, CLOUDPROVIDERVALUES_GCP, SEMRESATTRS_CLOUD_ACCOUNT_ID, SEMRESATTRS_CLOUD_AVAILABILITY_ZONE, SEMRESATTRS_CLOUD_PLATFORM, SEMRESATTRS_CLOUD_PROVIDER, SEMRESATTRS_CLOUD_REGION, SEMRESATTRS_FAAS_INSTANCE, SEMRESATTRS_FAAS_NAME, SEMRESATTRS_FAAS_VERSION, SEMRESATTRS_HOST_ID, SEMRESATTRS_HOST_NAME, SEMRESATTRS_HOST_TYPE, SEMRESATTRS_K8S_CLUSTER_NAME, } from '@opentelemetry/semantic-conventions';
19
+ import { CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE, CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS, CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN, CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE, CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE, CLOUD_PROVIDER_VALUE_GCP, ATTR_CLOUD_ACCOUNT_ID, ATTR_CLOUD_AVAILABILITY_ZONE, ATTR_CLOUD_PLATFORM, ATTR_CLOUD_PROVIDER, ATTR_CLOUD_REGION, ATTR_FAAS_INSTANCE, ATTR_FAAS_NAME, ATTR_FAAS_VERSION, ATTR_HOST_ID, ATTR_HOST_NAME, ATTR_HOST_TYPE, ATTR_K8S_CLUSTER_NAME, } from '../semconv';
20
20
  import { emptyResource, resourceFromAttributes, } from '@opentelemetry/resources';
21
21
  import * as metadata from 'gcp-metadata';
22
22
  import * as faas from './faas';
@@ -24,18 +24,18 @@ import * as gae from './gae';
24
24
  import * as gce from './gce';
25
25
  import * as gke from './gke';
26
26
  const ATTRIBUTE_NAMES = [
27
- SEMRESATTRS_CLOUD_PLATFORM,
28
- SEMRESATTRS_CLOUD_AVAILABILITY_ZONE,
29
- SEMRESATTRS_CLOUD_REGION,
30
- SEMRESATTRS_K8S_CLUSTER_NAME,
31
- SEMRESATTRS_HOST_TYPE,
32
- SEMRESATTRS_HOST_ID,
33
- SEMRESATTRS_HOST_NAME,
34
- SEMRESATTRS_CLOUD_PROVIDER,
35
- SEMRESATTRS_CLOUD_ACCOUNT_ID,
36
- SEMRESATTRS_FAAS_NAME,
37
- SEMRESATTRS_FAAS_VERSION,
38
- SEMRESATTRS_FAAS_INSTANCE,
27
+ ATTR_CLOUD_PLATFORM,
28
+ ATTR_CLOUD_AVAILABILITY_ZONE,
29
+ ATTR_CLOUD_REGION,
30
+ ATTR_K8S_CLUSTER_NAME,
31
+ ATTR_HOST_TYPE,
32
+ ATTR_HOST_ID,
33
+ ATTR_HOST_NAME,
34
+ ATTR_CLOUD_PROVIDER,
35
+ ATTR_CLOUD_ACCOUNT_ID,
36
+ ATTR_FAAS_NAME,
37
+ ATTR_FAAS_VERSION,
38
+ ATTR_FAAS_INSTANCE,
39
39
  ];
40
40
  async function detect() {
41
41
  if (!(await metadata.isAvailable())) {
@@ -67,12 +67,12 @@ async function gkeResource() {
67
67
  gke.hostId(),
68
68
  ]);
69
69
  return await makeResource({
70
- [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_KUBERNETES_ENGINE,
70
+ [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE,
71
71
  [zoneOrRegion.type === 'zone'
72
- ? SEMRESATTRS_CLOUD_AVAILABILITY_ZONE
73
- : SEMRESATTRS_CLOUD_REGION]: zoneOrRegion.value,
74
- [SEMRESATTRS_K8S_CLUSTER_NAME]: k8sClusterName,
75
- [SEMRESATTRS_HOST_ID]: hostId,
72
+ ? ATTR_CLOUD_AVAILABILITY_ZONE
73
+ : ATTR_CLOUD_REGION]: zoneOrRegion.value,
74
+ [ATTR_K8S_CLUSTER_NAME]: k8sClusterName,
75
+ [ATTR_HOST_ID]: hostId,
76
76
  });
77
77
  }
78
78
  async function cloudRunResource() {
@@ -83,11 +83,11 @@ async function cloudRunResource() {
83
83
  faas.faasCloudRegion(),
84
84
  ]);
85
85
  return await makeResource({
86
- [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_CLOUD_RUN,
87
- [SEMRESATTRS_FAAS_NAME]: faasName,
88
- [SEMRESATTRS_FAAS_VERSION]: faasVersion,
89
- [SEMRESATTRS_FAAS_INSTANCE]: faasInstance,
90
- [SEMRESATTRS_CLOUD_REGION]: faasCloudRegion,
86
+ [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN,
87
+ [ATTR_FAAS_NAME]: faasName,
88
+ [ATTR_FAAS_VERSION]: faasVersion,
89
+ [ATTR_FAAS_INSTANCE]: faasInstance,
90
+ [ATTR_CLOUD_REGION]: faasCloudRegion,
91
91
  });
92
92
  }
93
93
  async function cloudFunctionsResource() {
@@ -98,11 +98,11 @@ async function cloudFunctionsResource() {
98
98
  faas.faasCloudRegion(),
99
99
  ]);
100
100
  return await makeResource({
101
- [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_CLOUD_FUNCTIONS,
102
- [SEMRESATTRS_FAAS_NAME]: faasName,
103
- [SEMRESATTRS_FAAS_VERSION]: faasVersion,
104
- [SEMRESATTRS_FAAS_INSTANCE]: faasInstance,
105
- [SEMRESATTRS_CLOUD_REGION]: faasCloudRegion,
101
+ [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS,
102
+ [ATTR_FAAS_NAME]: faasName,
103
+ [ATTR_FAAS_VERSION]: faasVersion,
104
+ [ATTR_FAAS_INSTANCE]: faasInstance,
105
+ [ATTR_CLOUD_REGION]: faasCloudRegion,
106
106
  });
107
107
  }
108
108
  async function gaeResource() {
@@ -122,12 +122,12 @@ async function gaeResource() {
122
122
  gae.serviceInstance(),
123
123
  ]);
124
124
  return await makeResource({
125
- [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_APP_ENGINE,
126
- [SEMRESATTRS_FAAS_NAME]: faasName,
127
- [SEMRESATTRS_FAAS_VERSION]: faasVersion,
128
- [SEMRESATTRS_FAAS_INSTANCE]: faasInstance,
129
- [SEMRESATTRS_CLOUD_AVAILABILITY_ZONE]: zone,
130
- [SEMRESATTRS_CLOUD_REGION]: region,
125
+ [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE,
126
+ [ATTR_FAAS_NAME]: faasName,
127
+ [ATTR_FAAS_VERSION]: faasVersion,
128
+ [ATTR_FAAS_INSTANCE]: faasInstance,
129
+ [ATTR_CLOUD_AVAILABILITY_ZONE]: zone,
130
+ [ATTR_CLOUD_REGION]: region,
131
131
  });
132
132
  }
133
133
  async function gceResource() {
@@ -138,19 +138,19 @@ async function gceResource() {
138
138
  gce.hostName(),
139
139
  ]);
140
140
  return await makeResource({
141
- [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_COMPUTE_ENGINE,
142
- [SEMRESATTRS_CLOUD_AVAILABILITY_ZONE]: zoneAndRegion.zone,
143
- [SEMRESATTRS_CLOUD_REGION]: zoneAndRegion.region,
144
- [SEMRESATTRS_HOST_TYPE]: hostType,
145
- [SEMRESATTRS_HOST_ID]: hostId,
146
- [SEMRESATTRS_HOST_NAME]: hostName,
141
+ [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE,
142
+ [ATTR_CLOUD_AVAILABILITY_ZONE]: zoneAndRegion.zone,
143
+ [ATTR_CLOUD_REGION]: zoneAndRegion.region,
144
+ [ATTR_HOST_TYPE]: hostType,
145
+ [ATTR_HOST_ID]: hostId,
146
+ [ATTR_HOST_NAME]: hostName,
147
147
  });
148
148
  }
149
149
  async function makeResource(attrs) {
150
150
  const project = await metadata.project('project-id');
151
151
  return resourceFromAttributes({
152
- [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_GCP,
153
- [SEMRESATTRS_CLOUD_ACCOUNT_ID]: project,
152
+ [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_GCP,
153
+ [ATTR_CLOUD_ACCOUNT_ID]: project,
154
154
  ...attrs,
155
155
  });
156
156
  }
@@ -1 +1 @@
1
- {"version":3,"file":"GcpDetector.js","sourceRoot":"","sources":["../../../src/detectors/GcpDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EACL,kCAAkC,EAClC,uCAAuC,EACvC,iCAAiC,EACjC,sCAAsC,EACtC,yCAAyC,EACzC,uBAAuB,EACvB,4BAA4B,EAC5B,mCAAmC,EACnC,0BAA0B,EAC1B,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAGL,aAAa,EAGb,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,GAAG,MA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WAAW,EAAE,CAAC","sourcesContent":["/*\n * Copyright 2022 Google LLC\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { context } from '@opentelemetry/api';\nimport { suppressTracing } from '@opentelemetry/core';\nimport {\n CLOUDPLATFORMVALUES_GCP_APP_ENGINE,\n CLOUDPLATFORMVALUES_GCP_CLOUD_FUNCTIONS,\n CLOUDPLATFORMVALUES_GCP_CLOUD_RUN,\n CLOUDPLATFORMVALUES_GCP_COMPUTE_ENGINE,\n CLOUDPLATFORMVALUES_GCP_KUBERNETES_ENGINE,\n CLOUDPROVIDERVALUES_GCP,\n SEMRESATTRS_CLOUD_ACCOUNT_ID,\n SEMRESATTRS_CLOUD_AVAILABILITY_ZONE,\n SEMRESATTRS_CLOUD_PLATFORM,\n SEMRESATTRS_CLOUD_PROVIDER,\n SEMRESATTRS_CLOUD_REGION,\n SEMRESATTRS_FAAS_INSTANCE,\n SEMRESATTRS_FAAS_NAME,\n SEMRESATTRS_FAAS_VERSION,\n SEMRESATTRS_HOST_ID,\n SEMRESATTRS_HOST_NAME,\n SEMRESATTRS_HOST_TYPE,\n SEMRESATTRS_K8S_CLUSTER_NAME,\n} from '@opentelemetry/semantic-conventions';\n\nimport { AttributeValue, Attributes } from '@opentelemetry/api';\nimport {\n DetectedResource,\n DetectedResourceAttributes,\n emptyResource,\n Resource,\n ResourceDetector,\n resourceFromAttributes,\n} from '@opentelemetry/resources';\nimport * as metadata from 'gcp-metadata';\nimport * as faas from './faas';\nimport * as gae from './gae';\nimport * as gce from './gce';\nimport * as gke from './gke';\n\nconst ATTRIBUTE_NAMES = [\n SEMRESATTRS_CLOUD_PLATFORM,\n SEMRESATTRS_CLOUD_AVAILABILITY_ZONE,\n SEMRESATTRS_CLOUD_REGION,\n SEMRESATTRS_K8S_CLUSTER_NAME,\n SEMRESATTRS_HOST_TYPE,\n SEMRESATTRS_HOST_ID,\n SEMRESATTRS_HOST_NAME,\n SEMRESATTRS_CLOUD_PROVIDER,\n SEMRESATTRS_CLOUD_ACCOUNT_ID,\n SEMRESATTRS_FAAS_NAME,\n SEMRESATTRS_FAAS_VERSION,\n SEMRESATTRS_FAAS_INSTANCE,\n] as const;\n\n// Ensure that all resource keys are accounted for in ATTRIBUTE_NAMES\ntype GcpResourceAttributeName = (typeof ATTRIBUTE_NAMES)[number];\ntype GcpResourceAttributes = Partial<\n Record<GcpResourceAttributeName, AttributeValue>\n>;\n\nasync function detect(): Promise<Resource> {\n if (!(await metadata.isAvailable())) {\n return emptyResource();\n }\n\n // Note the order of these if checks is significant with more specific resources coming\n // first. E.g. Cloud Functions gen2 are executed in Cloud Run so it must be checked first.\n if (await gke.onGke()) {\n return await gkeResource();\n } else if (await faas.onCloudFunctions()) {\n return await cloudFunctionsResource();\n } else if (await faas.onCloudRun()) {\n return await cloudRunResource();\n } else if (await gae.onAppEngine()) {\n return await gaeResource();\n } else if (await gce.onGce()) {\n return await gceResource();\n }\n\n return emptyResource();\n}\n\nasync function gkeResource(): Promise<Resource> {\n const [zoneOrRegion, k8sClusterName, hostId] = await Promise.all([\n gke.availabilityZoneOrRegion(),\n gke.clusterName(),\n gke.hostId(),\n ]);\n\n return await makeResource({\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_KUBERNETES_ENGINE,\n [zoneOrRegion.type === 'zone'\n ? SEMRESATTRS_CLOUD_AVAILABILITY_ZONE\n : SEMRESATTRS_CLOUD_REGION]: zoneOrRegion.value,\n [SEMRESATTRS_K8S_CLUSTER_NAME]: k8sClusterName,\n [SEMRESATTRS_HOST_ID]: hostId,\n });\n}\n\nasync function cloudRunResource(): Promise<Resource> {\n const [faasName, faasVersion, faasInstance, faasCloudRegion] =\n await Promise.all([\n faas.faasName(),\n faas.faasVersion(),\n faas.faasInstance(),\n faas.faasCloudRegion(),\n ]);\n\n return await makeResource({\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_CLOUD_RUN,\n [SEMRESATTRS_FAAS_NAME]: faasName,\n [SEMRESATTRS_FAAS_VERSION]: faasVersion,\n [SEMRESATTRS_FAAS_INSTANCE]: faasInstance,\n [SEMRESATTRS_CLOUD_REGION]: faasCloudRegion,\n });\n}\n\nasync function cloudFunctionsResource(): Promise<Resource> {\n const [faasName, faasVersion, faasInstance, faasCloudRegion] =\n await Promise.all([\n faas.faasName(),\n faas.faasVersion(),\n faas.faasInstance(),\n faas.faasCloudRegion(),\n ]);\n\n return await makeResource({\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_CLOUD_FUNCTIONS,\n [SEMRESATTRS_FAAS_NAME]: faasName,\n [SEMRESATTRS_FAAS_VERSION]: faasVersion,\n [SEMRESATTRS_FAAS_INSTANCE]: faasInstance,\n [SEMRESATTRS_CLOUD_REGION]: faasCloudRegion,\n });\n}\n\nasync function gaeResource(): Promise<Resource> {\n let zone, region;\n if (await gae.onAppEngineStandard()) {\n [zone, region] = await Promise.all([\n gae.standardAvailabilityZone(),\n gae.standardCloudRegion(),\n ]);\n } else {\n ({ zone, region } = await gce.availabilityZoneAndRegion());\n }\n const [faasName, faasVersion, faasInstance] = await Promise.all([\n gae.serviceName(),\n gae.serviceVersion(),\n gae.serviceInstance(),\n ]);\n\n return await makeResource({\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_APP_ENGINE,\n [SEMRESATTRS_FAAS_NAME]: faasName,\n [SEMRESATTRS_FAAS_VERSION]: faasVersion,\n [SEMRESATTRS_FAAS_INSTANCE]: faasInstance,\n [SEMRESATTRS_CLOUD_AVAILABILITY_ZONE]: zone,\n [SEMRESATTRS_CLOUD_REGION]: region,\n });\n}\n\nasync function gceResource(): Promise<Resource> {\n const [zoneAndRegion, hostType, hostId, hostName] = await Promise.all([\n gce.availabilityZoneAndRegion(),\n gce.hostType(),\n gce.hostId(),\n gce.hostName(),\n ]);\n\n return await makeResource({\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_COMPUTE_ENGINE,\n [SEMRESATTRS_CLOUD_AVAILABILITY_ZONE]: zoneAndRegion.zone,\n [SEMRESATTRS_CLOUD_REGION]: zoneAndRegion.region,\n [SEMRESATTRS_HOST_TYPE]: hostType,\n [SEMRESATTRS_HOST_ID]: hostId,\n [SEMRESATTRS_HOST_NAME]: hostName,\n });\n}\n\nasync function makeResource(attrs: GcpResourceAttributes): Promise<Resource> {\n const project = await metadata.project<string>('project-id');\n\n return resourceFromAttributes({\n [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_GCP,\n [SEMRESATTRS_CLOUD_ACCOUNT_ID]: project,\n ...attrs,\n } satisfies GcpResourceAttributes);\n}\n\n/**\n * Google Cloud resource detector which populates attributes based on the environment this\n * process is running in. If not on GCP, returns an empty resource.\n */\nexport class GcpDetector implements ResourceDetector {\n private async _asyncAttributes(): Promise<Attributes> {\n const resource = await context.with(\n suppressTracing(context.active()),\n detect\n );\n return resource.attributes;\n }\n\n detect(): DetectedResource {\n const asyncAttributes = this._asyncAttributes();\n const attributes = {} as DetectedResourceAttributes;\n ATTRIBUTE_NAMES.forEach(name => {\n // Each resource attribute is determined asynchronously in _gatherData().\n attributes[name] = asyncAttributes.then(data => data[name]);\n });\n\n return { attributes };\n }\n}\n\nexport const gcpDetector = new GcpDetector();\n"]}
1
+ {"version":3,"file":"GcpDetector.js","sourceRoot":"","sources":["../../../src/detectors/GcpDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAo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AM,EAAE,CAAC,EACjC,MAAM,CACP,CAAC;QACF,OAAO,QAAQ,CAAC,UAAU,CAAC;IAC7B,CAAC;IAED,MAAM;QACJ,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAChD,MAAM,UAAU,GAAG,EAAgC,CAAC;QACpD,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC7B,yEAAyE;YACzE,UAAU,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC","sourcesContent":["/*\n * Copyright 2022 Google LLC\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { context } from '@opentelemetry/api';\nimport { suppressTracing } from '@opentelemetry/core';\nimport {\n CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE,\n CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS,\n CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN,\n CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE,\n CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE,\n CLOUD_PROVIDER_VALUE_GCP,\n ATTR_CLOUD_ACCOUNT_ID,\n ATTR_CLOUD_AVAILABILITY_ZONE,\n ATTR_CLOUD_PLATFORM,\n ATTR_CLOUD_PROVIDER,\n ATTR_CLOUD_REGION,\n ATTR_FAAS_INSTANCE,\n ATTR_FAAS_NAME,\n ATTR_FAAS_VERSION,\n ATTR_HOST_ID,\n ATTR_HOST_NAME,\n ATTR_HOST_TYPE,\n ATTR_K8S_CLUSTER_NAME,\n} from '../semconv';\n\nimport { AttributeValue, Attributes } from '@opentelemetry/api';\nimport {\n DetectedResource,\n DetectedResourceAttributes,\n emptyResource,\n Resource,\n ResourceDetector,\n resourceFromAttributes,\n} from '@opentelemetry/resources';\nimport * as metadata from 'gcp-metadata';\nimport * as faas from './faas';\nimport * as gae from './gae';\nimport * as gce from './gce';\nimport * as gke from './gke';\n\nconst ATTRIBUTE_NAMES = [\n ATTR_CLOUD_PLATFORM,\n ATTR_CLOUD_AVAILABILITY_ZONE,\n ATTR_CLOUD_REGION,\n ATTR_K8S_CLUSTER_NAME,\n ATTR_HOST_TYPE,\n ATTR_HOST_ID,\n ATTR_HOST_NAME,\n ATTR_CLOUD_PROVIDER,\n ATTR_CLOUD_ACCOUNT_ID,\n ATTR_FAAS_NAME,\n ATTR_FAAS_VERSION,\n ATTR_FAAS_INSTANCE,\n] as const;\n\n// Ensure that all resource keys are accounted for in ATTRIBUTE_NAMES\ntype GcpResourceAttributeName = (typeof ATTRIBUTE_NAMES)[number];\ntype GcpResourceAttributes = Partial<\n Record<GcpResourceAttributeName, AttributeValue>\n>;\n\nasync function detect(): Promise<Resource> {\n if (!(await metadata.isAvailable())) {\n return emptyResource();\n }\n\n // Note the order of these if checks is significant with more specific resources coming\n // first. E.g. Cloud Functions gen2 are executed in Cloud Run so it must be checked first.\n if (await gke.onGke()) {\n return await gkeResource();\n } else if (await faas.onCloudFunctions()) {\n return await cloudFunctionsResource();\n } else if (await faas.onCloudRun()) {\n return await cloudRunResource();\n } else if (await gae.onAppEngine()) {\n return await gaeResource();\n } else if (await gce.onGce()) {\n return await gceResource();\n }\n\n return emptyResource();\n}\n\nasync function gkeResource(): Promise<Resource> {\n const [zoneOrRegion, k8sClusterName, hostId] = await Promise.all([\n gke.availabilityZoneOrRegion(),\n gke.clusterName(),\n gke.hostId(),\n ]);\n\n return await makeResource({\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE,\n [zoneOrRegion.type === 'zone'\n ? ATTR_CLOUD_AVAILABILITY_ZONE\n : ATTR_CLOUD_REGION]: zoneOrRegion.value,\n [ATTR_K8S_CLUSTER_NAME]: k8sClusterName,\n [ATTR_HOST_ID]: hostId,\n });\n}\n\nasync function cloudRunResource(): Promise<Resource> {\n const [faasName, faasVersion, faasInstance, faasCloudRegion] =\n await Promise.all([\n faas.faasName(),\n faas.faasVersion(),\n faas.faasInstance(),\n faas.faasCloudRegion(),\n ]);\n\n return await makeResource({\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN,\n [ATTR_FAAS_NAME]: faasName,\n [ATTR_FAAS_VERSION]: faasVersion,\n [ATTR_FAAS_INSTANCE]: faasInstance,\n [ATTR_CLOUD_REGION]: faasCloudRegion,\n });\n}\n\nasync function cloudFunctionsResource(): Promise<Resource> {\n const [faasName, faasVersion, faasInstance, faasCloudRegion] =\n await Promise.all([\n faas.faasName(),\n faas.faasVersion(),\n faas.faasInstance(),\n faas.faasCloudRegion(),\n ]);\n\n return await makeResource({\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS,\n [ATTR_FAAS_NAME]: faasName,\n [ATTR_FAAS_VERSION]: faasVersion,\n [ATTR_FAAS_INSTANCE]: faasInstance,\n [ATTR_CLOUD_REGION]: faasCloudRegion,\n });\n}\n\nasync function gaeResource(): Promise<Resource> {\n let zone, region;\n if (await gae.onAppEngineStandard()) {\n [zone, region] = await Promise.all([\n gae.standardAvailabilityZone(),\n gae.standardCloudRegion(),\n ]);\n } else {\n ({ zone, region } = await gce.availabilityZoneAndRegion());\n }\n const [faasName, faasVersion, faasInstance] = await Promise.all([\n gae.serviceName(),\n gae.serviceVersion(),\n gae.serviceInstance(),\n ]);\n\n return await makeResource({\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE,\n [ATTR_FAAS_NAME]: faasName,\n [ATTR_FAAS_VERSION]: faasVersion,\n [ATTR_FAAS_INSTANCE]: faasInstance,\n [ATTR_CLOUD_AVAILABILITY_ZONE]: zone,\n [ATTR_CLOUD_REGION]: region,\n });\n}\n\nasync function gceResource(): Promise<Resource> {\n const [zoneAndRegion, hostType, hostId, hostName] = await Promise.all([\n gce.availabilityZoneAndRegion(),\n gce.hostType(),\n gce.hostId(),\n gce.hostName(),\n ]);\n\n return await makeResource({\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE,\n [ATTR_CLOUD_AVAILABILITY_ZONE]: zoneAndRegion.zone,\n [ATTR_CLOUD_REGION]: zoneAndRegion.region,\n [ATTR_HOST_TYPE]: hostType,\n [ATTR_HOST_ID]: hostId,\n [ATTR_HOST_NAME]: hostName,\n });\n}\n\nasync function makeResource(attrs: GcpResourceAttributes): Promise<Resource> {\n const project = await metadata.project<string>('project-id');\n\n return resourceFromAttributes({\n [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_GCP,\n [ATTR_CLOUD_ACCOUNT_ID]: project,\n ...attrs,\n } satisfies GcpResourceAttributes);\n}\n\n/**\n * Google Cloud resource detector which populates attributes based on the environment this\n * process is running in. If not on GCP, returns an empty resource.\n */\nexport class GcpDetector implements ResourceDetector {\n private async _asyncAttributes(): Promise<Attributes> {\n const resource = await context.with(\n suppressTracing(context.active()),\n detect\n );\n return resource.attributes;\n }\n\n detect(): DetectedResource {\n const asyncAttributes = this._asyncAttributes();\n const attributes = {} as DetectedResourceAttributes;\n ATTRIBUTE_NAMES.forEach(name => {\n // Each resource attribute is determined asynchronously in _gatherData().\n attributes[name] = asyncAttributes.then(data => data[name]);\n });\n\n return { attributes };\n }\n}\n\nexport const gcpDetector = new GcpDetector();\n"]}
@@ -0,0 +1,180 @@
1
+ /**
2
+ * The cloud account ID the resource is assigned to.
3
+ *
4
+ * @example 111111111111
5
+ * @example opentelemetry
6
+ *
7
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
8
+ */
9
+ export declare const ATTR_CLOUD_ACCOUNT_ID: "cloud.account.id";
10
+ /**
11
+ * Cloud regions often have multiple, isolated locations known as zones to increase availability. Availability zone represents the zone where the resource is running.
12
+ *
13
+ * @example us-east-1c
14
+ *
15
+ * @note Availability zones are called "zones" on Alibaba Cloud and Google Cloud.
16
+ *
17
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
18
+ */
19
+ export declare const ATTR_CLOUD_AVAILABILITY_ZONE: "cloud.availability_zone";
20
+ /**
21
+ * The cloud platform in use.
22
+ *
23
+ * @note The prefix of the service **SHOULD** match the one specified in `cloud.provider`.
24
+ *
25
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
26
+ */
27
+ export declare const ATTR_CLOUD_PLATFORM: "cloud.platform";
28
+ /**
29
+ * Name of the cloud provider.
30
+ *
31
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
32
+ */
33
+ export declare const ATTR_CLOUD_PROVIDER: "cloud.provider";
34
+ /**
35
+ * The geographical region within a cloud provider. When associated with a resource, this attribute specifies the region where the resource operates. When calling services or APIs deployed on a cloud, this attribute identifies the region where the called destination is deployed.
36
+ *
37
+ * @example us-central1
38
+ * @example us-east-1
39
+ *
40
+ * @note Refer to your provider's docs to see the available regions, for example [Alibaba Cloud regions](https://www.alibabacloud.com/help/doc-detail/40654.htm), [AWS regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), [Azure regions](https://azure.microsoft.com/global-infrastructure/geographies/), [Google Cloud regions](https://cloud.google.com/about/locations), or [Tencent Cloud regions](https://www.tencentcloud.com/document/product/213/6091).
41
+ *
42
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
43
+ */
44
+ export declare const ATTR_CLOUD_REGION: "cloud.region";
45
+ /**
46
+ * The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version.
47
+ *
48
+ * @example 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de
49
+ *
50
+ * @note - **AWS Lambda:** Use the (full) log stream name.
51
+ *
52
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
53
+ */
54
+ export declare const ATTR_FAAS_INSTANCE: "faas.instance";
55
+ /**
56
+ * The name of the single function that this runtime instance executes.
57
+ *
58
+ * @example my-function
59
+ * @example myazurefunctionapp/some-function-name
60
+ *
61
+ * @note This is the name of the function as configured/deployed on the FaaS
62
+ * platform and is usually different from the name of the callback
63
+ * function (which may be stored in the
64
+ * [`code.namespace`/`code.function.name`](/docs/general/attributes.md#source-code-attributes)
65
+ * span attributes).
66
+ *
67
+ * For some cloud providers, the above definition is ambiguous. The following
68
+ * definition of function name **MUST** be used for this attribute
69
+ * (and consequently the span name) for the listed cloud providers/products:
70
+ *
71
+ * - **Azure:** The full name `<FUNCAPP>/<FUNC>`, i.e., function app name
72
+ * followed by a forward slash followed by the function name (this form
73
+ * can also be seen in the resource JSON for the function).
74
+ * This means that a span attribute **MUST** be used, as an Azure function
75
+ * app can host multiple functions that would usually share
76
+ * a TracerProvider (see also the `cloud.resource_id` attribute).
77
+ *
78
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
79
+ */
80
+ export declare const ATTR_FAAS_NAME: "faas.name";
81
+ /**
82
+ * The immutable version of the function being executed.
83
+ *
84
+ * @example 26
85
+ * @example pinkfroid-00002
86
+ *
87
+ * @note Depending on the cloud provider and platform, use:
88
+ *
89
+ * - **AWS Lambda:** The [function version](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html)
90
+ * (an integer represented as a decimal string).
91
+ * - **Google Cloud Run (Services):** The [revision](https://cloud.google.com/run/docs/managing/revisions)
92
+ * (i.e., the function name plus the revision suffix).
93
+ * - **Google Cloud Functions:** The value of the
94
+ * [`K_REVISION` environment variable](https://cloud.google.com/functions/docs/env-var#runtime_environment_variables_set_automatically).
95
+ * - **Azure Functions:** Not applicable. Do not set this attribute.
96
+ *
97
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
98
+ */
99
+ export declare const ATTR_FAAS_VERSION: "faas.version";
100
+ /**
101
+ * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For non-containerized systems, this should be the `machine-id`. See the table below for the sources to use to determine the `machine-id` based on operating system.
102
+ *
103
+ * @example fdbf79e8af94cb7f9e8df36789187052
104
+ *
105
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
106
+ */
107
+ export declare const ATTR_HOST_ID: "host.id";
108
+ /**
109
+ * Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user.
110
+ *
111
+ * @example opentelemetry-test
112
+ *
113
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
114
+ */
115
+ export declare const ATTR_HOST_NAME: "host.name";
116
+ /**
117
+ * Type of host. For Cloud, this must be the machine type.
118
+ *
119
+ * @example n1-standard-1
120
+ *
121
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
122
+ */
123
+ export declare const ATTR_HOST_TYPE: "host.type";
124
+ /**
125
+ * The name of the cluster.
126
+ *
127
+ * @example opentelemetry-cluster
128
+ *
129
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
130
+ */
131
+ export declare const ATTR_K8S_CLUSTER_NAME: "k8s.cluster.name";
132
+ /**
133
+ * Enum value "gcp_app_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
134
+ *
135
+ * Google Cloud App Engine (GAE)
136
+ *
137
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
138
+ */
139
+ export declare const CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE: "gcp_app_engine";
140
+ /**
141
+ * Enum value "gcp_cloud_functions" for attribute {@link ATTR_CLOUD_PLATFORM}.
142
+ *
143
+ * Google Cloud Functions (GCF)
144
+ *
145
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
146
+ */
147
+ export declare const CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS: "gcp_cloud_functions";
148
+ /**
149
+ * Enum value "gcp_cloud_run" for attribute {@link ATTR_CLOUD_PLATFORM}.
150
+ *
151
+ * Google Cloud Run
152
+ *
153
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
154
+ */
155
+ export declare const CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN: "gcp_cloud_run";
156
+ /**
157
+ * Enum value "gcp_compute_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
158
+ *
159
+ * Google Cloud Compute Engine (GCE)
160
+ *
161
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
162
+ */
163
+ export declare const CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE: "gcp_compute_engine";
164
+ /**
165
+ * Enum value "gcp_kubernetes_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
166
+ *
167
+ * Google Cloud Kubernetes Engine (GKE)
168
+ *
169
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
170
+ */
171
+ export declare const CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE: "gcp_kubernetes_engine";
172
+ /**
173
+ * Enum value "gcp" for attribute {@link ATTR_CLOUD_PROVIDER}.
174
+ *
175
+ * Google Cloud Platform
176
+ *
177
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
178
+ */
179
+ export declare const CLOUD_PROVIDER_VALUE_GCP: "gcp";
180
+ //# sourceMappingURL=semconv.d.ts.map
@@ -0,0 +1,200 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /*
17
+ * This file contains a copy of unstable semantic convention definitions
18
+ * used by this package.
19
+ * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
20
+ */
21
+ /**
22
+ * The cloud account ID the resource is assigned to.
23
+ *
24
+ * @example 111111111111
25
+ * @example opentelemetry
26
+ *
27
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
28
+ */
29
+ export const ATTR_CLOUD_ACCOUNT_ID = 'cloud.account.id';
30
+ /**
31
+ * Cloud regions often have multiple, isolated locations known as zones to increase availability. Availability zone represents the zone where the resource is running.
32
+ *
33
+ * @example us-east-1c
34
+ *
35
+ * @note Availability zones are called "zones" on Alibaba Cloud and Google Cloud.
36
+ *
37
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
38
+ */
39
+ export const ATTR_CLOUD_AVAILABILITY_ZONE = 'cloud.availability_zone';
40
+ /**
41
+ * The cloud platform in use.
42
+ *
43
+ * @note The prefix of the service **SHOULD** match the one specified in `cloud.provider`.
44
+ *
45
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
46
+ */
47
+ export const ATTR_CLOUD_PLATFORM = 'cloud.platform';
48
+ /**
49
+ * Name of the cloud provider.
50
+ *
51
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
52
+ */
53
+ export const ATTR_CLOUD_PROVIDER = 'cloud.provider';
54
+ /**
55
+ * The geographical region within a cloud provider. When associated with a resource, this attribute specifies the region where the resource operates. When calling services or APIs deployed on a cloud, this attribute identifies the region where the called destination is deployed.
56
+ *
57
+ * @example us-central1
58
+ * @example us-east-1
59
+ *
60
+ * @note Refer to your provider's docs to see the available regions, for example [Alibaba Cloud regions](https://www.alibabacloud.com/help/doc-detail/40654.htm), [AWS regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), [Azure regions](https://azure.microsoft.com/global-infrastructure/geographies/), [Google Cloud regions](https://cloud.google.com/about/locations), or [Tencent Cloud regions](https://www.tencentcloud.com/document/product/213/6091).
61
+ *
62
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
63
+ */
64
+ export const ATTR_CLOUD_REGION = 'cloud.region';
65
+ /**
66
+ * The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version.
67
+ *
68
+ * @example 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de
69
+ *
70
+ * @note - **AWS Lambda:** Use the (full) log stream name.
71
+ *
72
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
73
+ */
74
+ export const ATTR_FAAS_INSTANCE = 'faas.instance';
75
+ /**
76
+ * The name of the single function that this runtime instance executes.
77
+ *
78
+ * @example my-function
79
+ * @example myazurefunctionapp/some-function-name
80
+ *
81
+ * @note This is the name of the function as configured/deployed on the FaaS
82
+ * platform and is usually different from the name of the callback
83
+ * function (which may be stored in the
84
+ * [`code.namespace`/`code.function.name`](/docs/general/attributes.md#source-code-attributes)
85
+ * span attributes).
86
+ *
87
+ * For some cloud providers, the above definition is ambiguous. The following
88
+ * definition of function name **MUST** be used for this attribute
89
+ * (and consequently the span name) for the listed cloud providers/products:
90
+ *
91
+ * - **Azure:** The full name `<FUNCAPP>/<FUNC>`, i.e., function app name
92
+ * followed by a forward slash followed by the function name (this form
93
+ * can also be seen in the resource JSON for the function).
94
+ * This means that a span attribute **MUST** be used, as an Azure function
95
+ * app can host multiple functions that would usually share
96
+ * a TracerProvider (see also the `cloud.resource_id` attribute).
97
+ *
98
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
99
+ */
100
+ export const ATTR_FAAS_NAME = 'faas.name';
101
+ /**
102
+ * The immutable version of the function being executed.
103
+ *
104
+ * @example 26
105
+ * @example pinkfroid-00002
106
+ *
107
+ * @note Depending on the cloud provider and platform, use:
108
+ *
109
+ * - **AWS Lambda:** The [function version](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html)
110
+ * (an integer represented as a decimal string).
111
+ * - **Google Cloud Run (Services):** The [revision](https://cloud.google.com/run/docs/managing/revisions)
112
+ * (i.e., the function name plus the revision suffix).
113
+ * - **Google Cloud Functions:** The value of the
114
+ * [`K_REVISION` environment variable](https://cloud.google.com/functions/docs/env-var#runtime_environment_variables_set_automatically).
115
+ * - **Azure Functions:** Not applicable. Do not set this attribute.
116
+ *
117
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
118
+ */
119
+ export const ATTR_FAAS_VERSION = 'faas.version';
120
+ /**
121
+ * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For non-containerized systems, this should be the `machine-id`. See the table below for the sources to use to determine the `machine-id` based on operating system.
122
+ *
123
+ * @example fdbf79e8af94cb7f9e8df36789187052
124
+ *
125
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
126
+ */
127
+ export const ATTR_HOST_ID = 'host.id';
128
+ /**
129
+ * Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user.
130
+ *
131
+ * @example opentelemetry-test
132
+ *
133
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
134
+ */
135
+ export const ATTR_HOST_NAME = 'host.name';
136
+ /**
137
+ * Type of host. For Cloud, this must be the machine type.
138
+ *
139
+ * @example n1-standard-1
140
+ *
141
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
142
+ */
143
+ export const ATTR_HOST_TYPE = 'host.type';
144
+ /**
145
+ * The name of the cluster.
146
+ *
147
+ * @example opentelemetry-cluster
148
+ *
149
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
150
+ */
151
+ export const ATTR_K8S_CLUSTER_NAME = 'k8s.cluster.name';
152
+ /**
153
+ * Enum value "gcp_app_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
154
+ *
155
+ * Google Cloud App Engine (GAE)
156
+ *
157
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
158
+ */
159
+ export const CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE = 'gcp_app_engine';
160
+ /**
161
+ * Enum value "gcp_cloud_functions" for attribute {@link ATTR_CLOUD_PLATFORM}.
162
+ *
163
+ * Google Cloud Functions (GCF)
164
+ *
165
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
166
+ */
167
+ export const CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS = 'gcp_cloud_functions';
168
+ /**
169
+ * Enum value "gcp_cloud_run" for attribute {@link ATTR_CLOUD_PLATFORM}.
170
+ *
171
+ * Google Cloud Run
172
+ *
173
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
174
+ */
175
+ export const CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN = 'gcp_cloud_run';
176
+ /**
177
+ * Enum value "gcp_compute_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
178
+ *
179
+ * Google Cloud Compute Engine (GCE)
180
+ *
181
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
182
+ */
183
+ export const CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE = 'gcp_compute_engine';
184
+ /**
185
+ * Enum value "gcp_kubernetes_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
186
+ *
187
+ * Google Cloud Kubernetes Engine (GKE)
188
+ *
189
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
190
+ */
191
+ export const CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE = 'gcp_kubernetes_engine';
192
+ /**
193
+ * Enum value "gcp" for attribute {@link ATTR_CLOUD_PROVIDER}.
194
+ *
195
+ * Google Cloud Platform
196
+ *
197
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
198
+ */
199
+ export const CLOUD_PROVIDER_VALUE_GCP = 'gcp';
200
+ //# sourceMappingURL=semconv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAA2B,CAAC;AAEjE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,yBAAkC,CAAC;AAE/E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAyB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAyB,CAAC;AAE7D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAuB,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAuB,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,SAAkB,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAA2B,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,gBAAyB,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wCAAwC,GACnD,qBAA8B,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,eAAwB,CAAC;AAE3E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAClD,oBAA6B,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0CAA0C,GACrD,uBAAgC,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAc,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * The cloud account ID the resource is assigned to.\n *\n * @example 111111111111\n * @example opentelemetry\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_ACCOUNT_ID = 'cloud.account.id' as const;\n\n/**\n * Cloud regions often have multiple, isolated locations known as zones to increase availability. Availability zone represents the zone where the resource is running.\n *\n * @example us-east-1c\n *\n * @note Availability zones are called \"zones\" on Alibaba Cloud and Google Cloud.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_AVAILABILITY_ZONE = 'cloud.availability_zone' as const;\n\n/**\n * The cloud platform in use.\n *\n * @note The prefix of the service **SHOULD** match the one specified in `cloud.provider`.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_PLATFORM = 'cloud.platform' as const;\n\n/**\n * Name of the cloud provider.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_PROVIDER = 'cloud.provider' as const;\n\n/**\n * The geographical region within a cloud provider. When associated with a resource, this attribute specifies the region where the resource operates. When calling services or APIs deployed on a cloud, this attribute identifies the region where the called destination is deployed.\n *\n * @example us-central1\n * @example us-east-1\n *\n * @note Refer to your provider's docs to see the available regions, for example [Alibaba Cloud regions](https://www.alibabacloud.com/help/doc-detail/40654.htm), [AWS regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), [Azure regions](https://azure.microsoft.com/global-infrastructure/geographies/), [Google Cloud regions](https://cloud.google.com/about/locations), or [Tencent Cloud regions](https://www.tencentcloud.com/document/product/213/6091).\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_REGION = 'cloud.region' as const;\n\n/**\n * The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version.\n *\n * @example 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de\n *\n * @note - **AWS Lambda:** Use the (full) log stream name.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_INSTANCE = 'faas.instance' as const;\n\n/**\n * The name of the single function that this runtime instance executes.\n *\n * @example my-function\n * @example myazurefunctionapp/some-function-name\n *\n * @note This is the name of the function as configured/deployed on the FaaS\n * platform and is usually different from the name of the callback\n * function (which may be stored in the\n * [`code.namespace`/`code.function.name`](/docs/general/attributes.md#source-code-attributes)\n * span attributes).\n *\n * For some cloud providers, the above definition is ambiguous. The following\n * definition of function name **MUST** be used for this attribute\n * (and consequently the span name) for the listed cloud providers/products:\n *\n * - **Azure:** The full name `<FUNCAPP>/<FUNC>`, i.e., function app name\n * followed by a forward slash followed by the function name (this form\n * can also be seen in the resource JSON for the function).\n * This means that a span attribute **MUST** be used, as an Azure function\n * app can host multiple functions that would usually share\n * a TracerProvider (see also the `cloud.resource_id` attribute).\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_NAME = 'faas.name' as const;\n\n/**\n * The immutable version of the function being executed.\n *\n * @example 26\n * @example pinkfroid-00002\n *\n * @note Depending on the cloud provider and platform, use:\n *\n * - **AWS Lambda:** The [function version](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html)\n * (an integer represented as a decimal string).\n * - **Google Cloud Run (Services):** The [revision](https://cloud.google.com/run/docs/managing/revisions)\n * (i.e., the function name plus the revision suffix).\n * - **Google Cloud Functions:** The value of the\n * [`K_REVISION` environment variable](https://cloud.google.com/functions/docs/env-var#runtime_environment_variables_set_automatically).\n * - **Azure Functions:** Not applicable. Do not set this attribute.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_VERSION = 'faas.version' as const;\n\n/**\n * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For non-containerized systems, this should be the `machine-id`. See the table below for the sources to use to determine the `machine-id` based on operating system.\n *\n * @example fdbf79e8af94cb7f9e8df36789187052\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_HOST_ID = 'host.id' as const;\n\n/**\n * Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user.\n *\n * @example opentelemetry-test\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_HOST_NAME = 'host.name' as const;\n\n/**\n * Type of host. For Cloud, this must be the machine type.\n *\n * @example n1-standard-1\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_HOST_TYPE = 'host.type' as const;\n\n/**\n * The name of the cluster.\n *\n * @example opentelemetry-cluster\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_K8S_CLUSTER_NAME = 'k8s.cluster.name' as const;\n\n/**\n * Enum value \"gcp_app_engine\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Google Cloud App Engine (GAE)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE = 'gcp_app_engine' as const;\n\n/**\n * Enum value \"gcp_cloud_functions\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Google Cloud Functions (GCF)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS =\n 'gcp_cloud_functions' as const;\n\n/**\n * Enum value \"gcp_cloud_run\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Google Cloud Run\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN = 'gcp_cloud_run' as const;\n\n/**\n * Enum value \"gcp_compute_engine\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Google Cloud Compute Engine (GCE)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE =\n 'gcp_compute_engine' as const;\n\n/**\n * Enum value \"gcp_kubernetes_engine\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Google Cloud Kubernetes Engine (GKE)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE =\n 'gcp_kubernetes_engine' as const;\n\n/**\n * Enum value \"gcp\" for attribute {@link ATTR_CLOUD_PROVIDER}.\n *\n * Google Cloud Platform\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PROVIDER_VALUE_GCP = 'gcp' as const;\n"]}
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.gcpDetector = exports.GcpDetector = void 0;
20
20
  const api_1 = require("@opentelemetry/api");
21
21
  const core_1 = require("@opentelemetry/core");
22
- const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
22
+ const semconv_1 = require("../semconv");
23
23
  const resources_1 = require("@opentelemetry/resources");
24
24
  const metadata = require("gcp-metadata");
25
25
  const faas = require("./faas");
@@ -27,18 +27,18 @@ const gae = require("./gae");
27
27
  const gce = require("./gce");
28
28
  const gke = require("./gke");
29
29
  const ATTRIBUTE_NAMES = [
30
- semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM,
31
- semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE,
32
- semantic_conventions_1.SEMRESATTRS_CLOUD_REGION,
33
- semantic_conventions_1.SEMRESATTRS_K8S_CLUSTER_NAME,
34
- semantic_conventions_1.SEMRESATTRS_HOST_TYPE,
35
- semantic_conventions_1.SEMRESATTRS_HOST_ID,
36
- semantic_conventions_1.SEMRESATTRS_HOST_NAME,
37
- semantic_conventions_1.SEMRESATTRS_CLOUD_PROVIDER,
38
- semantic_conventions_1.SEMRESATTRS_CLOUD_ACCOUNT_ID,
39
- semantic_conventions_1.SEMRESATTRS_FAAS_NAME,
40
- semantic_conventions_1.SEMRESATTRS_FAAS_VERSION,
41
- semantic_conventions_1.SEMRESATTRS_FAAS_INSTANCE,
30
+ semconv_1.ATTR_CLOUD_PLATFORM,
31
+ semconv_1.ATTR_CLOUD_AVAILABILITY_ZONE,
32
+ semconv_1.ATTR_CLOUD_REGION,
33
+ semconv_1.ATTR_K8S_CLUSTER_NAME,
34
+ semconv_1.ATTR_HOST_TYPE,
35
+ semconv_1.ATTR_HOST_ID,
36
+ semconv_1.ATTR_HOST_NAME,
37
+ semconv_1.ATTR_CLOUD_PROVIDER,
38
+ semconv_1.ATTR_CLOUD_ACCOUNT_ID,
39
+ semconv_1.ATTR_FAAS_NAME,
40
+ semconv_1.ATTR_FAAS_VERSION,
41
+ semconv_1.ATTR_FAAS_INSTANCE,
42
42
  ];
43
43
  async function detect() {
44
44
  if (!(await metadata.isAvailable())) {
@@ -70,12 +70,12 @@ async function gkeResource() {
70
70
  gke.hostId(),
71
71
  ]);
72
72
  return await makeResource({
73
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM]: semantic_conventions_1.CLOUDPLATFORMVALUES_GCP_KUBERNETES_ENGINE,
73
+ [semconv_1.ATTR_CLOUD_PLATFORM]: semconv_1.CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE,
74
74
  [zoneOrRegion.type === 'zone'
75
- ? semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE
76
- : semantic_conventions_1.SEMRESATTRS_CLOUD_REGION]: zoneOrRegion.value,
77
- [semantic_conventions_1.SEMRESATTRS_K8S_CLUSTER_NAME]: k8sClusterName,
78
- [semantic_conventions_1.SEMRESATTRS_HOST_ID]: hostId,
75
+ ? semconv_1.ATTR_CLOUD_AVAILABILITY_ZONE
76
+ : semconv_1.ATTR_CLOUD_REGION]: zoneOrRegion.value,
77
+ [semconv_1.ATTR_K8S_CLUSTER_NAME]: k8sClusterName,
78
+ [semconv_1.ATTR_HOST_ID]: hostId,
79
79
  });
80
80
  }
81
81
  async function cloudRunResource() {
@@ -86,11 +86,11 @@ async function cloudRunResource() {
86
86
  faas.faasCloudRegion(),
87
87
  ]);
88
88
  return await makeResource({
89
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM]: semantic_conventions_1.CLOUDPLATFORMVALUES_GCP_CLOUD_RUN,
90
- [semantic_conventions_1.SEMRESATTRS_FAAS_NAME]: faasName,
91
- [semantic_conventions_1.SEMRESATTRS_FAAS_VERSION]: faasVersion,
92
- [semantic_conventions_1.SEMRESATTRS_FAAS_INSTANCE]: faasInstance,
93
- [semantic_conventions_1.SEMRESATTRS_CLOUD_REGION]: faasCloudRegion,
89
+ [semconv_1.ATTR_CLOUD_PLATFORM]: semconv_1.CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN,
90
+ [semconv_1.ATTR_FAAS_NAME]: faasName,
91
+ [semconv_1.ATTR_FAAS_VERSION]: faasVersion,
92
+ [semconv_1.ATTR_FAAS_INSTANCE]: faasInstance,
93
+ [semconv_1.ATTR_CLOUD_REGION]: faasCloudRegion,
94
94
  });
95
95
  }
96
96
  async function cloudFunctionsResource() {
@@ -101,11 +101,11 @@ async function cloudFunctionsResource() {
101
101
  faas.faasCloudRegion(),
102
102
  ]);
103
103
  return await makeResource({
104
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM]: semantic_conventions_1.CLOUDPLATFORMVALUES_GCP_CLOUD_FUNCTIONS,
105
- [semantic_conventions_1.SEMRESATTRS_FAAS_NAME]: faasName,
106
- [semantic_conventions_1.SEMRESATTRS_FAAS_VERSION]: faasVersion,
107
- [semantic_conventions_1.SEMRESATTRS_FAAS_INSTANCE]: faasInstance,
108
- [semantic_conventions_1.SEMRESATTRS_CLOUD_REGION]: faasCloudRegion,
104
+ [semconv_1.ATTR_CLOUD_PLATFORM]: semconv_1.CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS,
105
+ [semconv_1.ATTR_FAAS_NAME]: faasName,
106
+ [semconv_1.ATTR_FAAS_VERSION]: faasVersion,
107
+ [semconv_1.ATTR_FAAS_INSTANCE]: faasInstance,
108
+ [semconv_1.ATTR_CLOUD_REGION]: faasCloudRegion,
109
109
  });
110
110
  }
111
111
  async function gaeResource() {
@@ -125,12 +125,12 @@ async function gaeResource() {
125
125
  gae.serviceInstance(),
126
126
  ]);
127
127
  return await makeResource({
128
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM]: semantic_conventions_1.CLOUDPLATFORMVALUES_GCP_APP_ENGINE,
129
- [semantic_conventions_1.SEMRESATTRS_FAAS_NAME]: faasName,
130
- [semantic_conventions_1.SEMRESATTRS_FAAS_VERSION]: faasVersion,
131
- [semantic_conventions_1.SEMRESATTRS_FAAS_INSTANCE]: faasInstance,
132
- [semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE]: zone,
133
- [semantic_conventions_1.SEMRESATTRS_CLOUD_REGION]: region,
128
+ [semconv_1.ATTR_CLOUD_PLATFORM]: semconv_1.CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE,
129
+ [semconv_1.ATTR_FAAS_NAME]: faasName,
130
+ [semconv_1.ATTR_FAAS_VERSION]: faasVersion,
131
+ [semconv_1.ATTR_FAAS_INSTANCE]: faasInstance,
132
+ [semconv_1.ATTR_CLOUD_AVAILABILITY_ZONE]: zone,
133
+ [semconv_1.ATTR_CLOUD_REGION]: region,
134
134
  });
135
135
  }
136
136
  async function gceResource() {
@@ -141,19 +141,19 @@ async function gceResource() {
141
141
  gce.hostName(),
142
142
  ]);
143
143
  return await makeResource({
144
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM]: semantic_conventions_1.CLOUDPLATFORMVALUES_GCP_COMPUTE_ENGINE,
145
- [semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE]: zoneAndRegion.zone,
146
- [semantic_conventions_1.SEMRESATTRS_CLOUD_REGION]: zoneAndRegion.region,
147
- [semantic_conventions_1.SEMRESATTRS_HOST_TYPE]: hostType,
148
- [semantic_conventions_1.SEMRESATTRS_HOST_ID]: hostId,
149
- [semantic_conventions_1.SEMRESATTRS_HOST_NAME]: hostName,
144
+ [semconv_1.ATTR_CLOUD_PLATFORM]: semconv_1.CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE,
145
+ [semconv_1.ATTR_CLOUD_AVAILABILITY_ZONE]: zoneAndRegion.zone,
146
+ [semconv_1.ATTR_CLOUD_REGION]: zoneAndRegion.region,
147
+ [semconv_1.ATTR_HOST_TYPE]: hostType,
148
+ [semconv_1.ATTR_HOST_ID]: hostId,
149
+ [semconv_1.ATTR_HOST_NAME]: hostName,
150
150
  });
151
151
  }
152
152
  async function makeResource(attrs) {
153
153
  const project = await metadata.project('project-id');
154
154
  return (0, resources_1.resourceFromAttributes)({
155
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PROVIDER]: semantic_conventions_1.CLOUDPROVIDERVALUES_GCP,
156
- [semantic_conventions_1.SEMRESATTRS_CLOUD_ACCOUNT_ID]: project,
155
+ [semconv_1.ATTR_CLOUD_PROVIDER]: semconv_1.CLOUD_PROVIDER_VALUE_GCP,
156
+ [semconv_1.ATTR_CLOUD_ACCOUNT_ID]: project,
157
157
  ...attrs,
158
158
  });
159
159
  }
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C,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC;CACF;AAnBD,kCAmBC;AAEY,QAAA,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC","sourcesContent":["/*\n * Copyright 2022 Google LLC\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { context } from '@opentelemetry/api';\nimport { suppressTracing } from '@opentelemetry/core';\nimport {\n CLOUDPLATFORMVALUES_GCP_APP_ENGINE,\n CLOUDPLATFORMVALUES_GCP_CLOUD_FUNCTIONS,\n CLOUDPLATFORMVALUES_GCP_CLOUD_RUN,\n CLOUDPLATFORMVALUES_GCP_COMPUTE_ENGINE,\n CLOUDPLATFORMVALUES_GCP_KUBERNETES_ENGINE,\n CLOUDPROVIDERVALUES_GCP,\n SEMRESATTRS_CLOUD_ACCOUNT_ID,\n SEMRESATTRS_CLOUD_AVAILABILITY_ZONE,\n SEMRESATTRS_CLOUD_PLATFORM,\n SEMRESATTRS_CLOUD_PROVIDER,\n SEMRESATTRS_CLOUD_REGION,\n SEMRESATTRS_FAAS_INSTANCE,\n SEMRESATTRS_FAAS_NAME,\n SEMRESATTRS_FAAS_VERSION,\n SEMRESATTRS_HOST_ID,\n SEMRESATTRS_HOST_NAME,\n SEMRESATTRS_HOST_TYPE,\n SEMRESATTRS_K8S_CLUSTER_NAME,\n} from '@opentelemetry/semantic-conventions';\n\nimport { AttributeValue, Attributes } from '@opentelemetry/api';\nimport {\n DetectedResource,\n DetectedResourceAttributes,\n emptyResource,\n Resource,\n ResourceDetector,\n resourceFromAttributes,\n} from '@opentelemetry/resources';\nimport * as metadata from 'gcp-metadata';\nimport * as faas from './faas';\nimport * as gae from './gae';\nimport * as gce from './gce';\nimport * as gke from './gke';\n\nconst ATTRIBUTE_NAMES = [\n SEMRESATTRS_CLOUD_PLATFORM,\n SEMRESATTRS_CLOUD_AVAILABILITY_ZONE,\n SEMRESATTRS_CLOUD_REGION,\n SEMRESATTRS_K8S_CLUSTER_NAME,\n SEMRESATTRS_HOST_TYPE,\n SEMRESATTRS_HOST_ID,\n SEMRESATTRS_HOST_NAME,\n SEMRESATTRS_CLOUD_PROVIDER,\n SEMRESATTRS_CLOUD_ACCOUNT_ID,\n SEMRESATTRS_FAAS_NAME,\n SEMRESATTRS_FAAS_VERSION,\n SEMRESATTRS_FAAS_INSTANCE,\n] as const;\n\n// Ensure that all resource keys are accounted for in ATTRIBUTE_NAMES\ntype GcpResourceAttributeName = (typeof ATTRIBUTE_NAMES)[number];\ntype GcpResourceAttributes = Partial<\n Record<GcpResourceAttributeName, AttributeValue>\n>;\n\nasync function detect(): Promise<Resource> {\n if (!(await metadata.isAvailable())) {\n return emptyResource();\n }\n\n // Note the order of these if checks is significant with more specific resources coming\n // first. E.g. Cloud Functions gen2 are executed in Cloud Run so it must be checked first.\n if (await gke.onGke()) {\n return await gkeResource();\n } else if (await faas.onCloudFunctions()) {\n return await cloudFunctionsResource();\n } else if (await faas.onCloudRun()) {\n return await cloudRunResource();\n } else if (await gae.onAppEngine()) {\n return await gaeResource();\n } else if (await gce.onGce()) {\n return await gceResource();\n }\n\n return emptyResource();\n}\n\nasync function gkeResource(): Promise<Resource> {\n const [zoneOrRegion, k8sClusterName, hostId] = await Promise.all([\n gke.availabilityZoneOrRegion(),\n gke.clusterName(),\n gke.hostId(),\n ]);\n\n return await makeResource({\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_KUBERNETES_ENGINE,\n [zoneOrRegion.type === 'zone'\n ? SEMRESATTRS_CLOUD_AVAILABILITY_ZONE\n : SEMRESATTRS_CLOUD_REGION]: zoneOrRegion.value,\n [SEMRESATTRS_K8S_CLUSTER_NAME]: k8sClusterName,\n [SEMRESATTRS_HOST_ID]: hostId,\n });\n}\n\nasync function cloudRunResource(): Promise<Resource> {\n const [faasName, faasVersion, faasInstance, faasCloudRegion] =\n await Promise.all([\n faas.faasName(),\n faas.faasVersion(),\n faas.faasInstance(),\n faas.faasCloudRegion(),\n ]);\n\n return await makeResource({\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_CLOUD_RUN,\n [SEMRESATTRS_FAAS_NAME]: faasName,\n [SEMRESATTRS_FAAS_VERSION]: faasVersion,\n [SEMRESATTRS_FAAS_INSTANCE]: faasInstance,\n [SEMRESATTRS_CLOUD_REGION]: faasCloudRegion,\n });\n}\n\nasync function cloudFunctionsResource(): Promise<Resource> {\n const [faasName, faasVersion, faasInstance, faasCloudRegion] =\n await Promise.all([\n faas.faasName(),\n faas.faasVersion(),\n faas.faasInstance(),\n faas.faasCloudRegion(),\n ]);\n\n return await makeResource({\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_CLOUD_FUNCTIONS,\n [SEMRESATTRS_FAAS_NAME]: faasName,\n [SEMRESATTRS_FAAS_VERSION]: faasVersion,\n [SEMRESATTRS_FAAS_INSTANCE]: faasInstance,\n [SEMRESATTRS_CLOUD_REGION]: faasCloudRegion,\n });\n}\n\nasync function gaeResource(): Promise<Resource> {\n let zone, region;\n if (await gae.onAppEngineStandard()) {\n [zone, region] = await Promise.all([\n gae.standardAvailabilityZone(),\n gae.standardCloudRegion(),\n ]);\n } else {\n ({ zone, region } = await gce.availabilityZoneAndRegion());\n }\n const [faasName, faasVersion, faasInstance] = await Promise.all([\n gae.serviceName(),\n gae.serviceVersion(),\n gae.serviceInstance(),\n ]);\n\n return await makeResource({\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_APP_ENGINE,\n [SEMRESATTRS_FAAS_NAME]: faasName,\n [SEMRESATTRS_FAAS_VERSION]: faasVersion,\n [SEMRESATTRS_FAAS_INSTANCE]: faasInstance,\n [SEMRESATTRS_CLOUD_AVAILABILITY_ZONE]: zone,\n [SEMRESATTRS_CLOUD_REGION]: region,\n });\n}\n\nasync function gceResource(): Promise<Resource> {\n const [zoneAndRegion, hostType, hostId, hostName] = await Promise.all([\n gce.availabilityZoneAndRegion(),\n gce.hostType(),\n gce.hostId(),\n gce.hostName(),\n ]);\n\n return await makeResource({\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_GCP_COMPUTE_ENGINE,\n [SEMRESATTRS_CLOUD_AVAILABILITY_ZONE]: zoneAndRegion.zone,\n [SEMRESATTRS_CLOUD_REGION]: zoneAndRegion.region,\n [SEMRESATTRS_HOST_TYPE]: hostType,\n [SEMRESATTRS_HOST_ID]: hostId,\n [SEMRESATTRS_HOST_NAME]: hostName,\n });\n}\n\nasync function makeResource(attrs: GcpResourceAttributes): Promise<Resource> {\n const project = await metadata.project<string>('project-id');\n\n return resourceFromAttributes({\n [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_GCP,\n [SEMRESATTRS_CLOUD_ACCOUNT_ID]: project,\n ...attrs,\n } satisfies GcpResourceAttributes);\n}\n\n/**\n * Google Cloud resource detector which populates attributes based on the environment this\n * process is running in. If not on GCP, returns an empty resource.\n */\nexport class GcpDetector implements ResourceDetector {\n private async _asyncAttributes(): Promise<Attributes> {\n const resource = await context.with(\n suppressTracing(context.active()),\n detect\n );\n return resource.attributes;\n }\n\n detect(): DetectedResource {\n const asyncAttributes = this._asyncAttributes();\n const attributes = {} as DetectedResourceAttributes;\n ATTRIBUTE_NAMES.forEach(name => {\n // Each resource attribute is determined asynchronously in _gatherData().\n attributes[name] = asyncAttributes.then(data => data[name]);\n });\n\n return { attributes };\n }\n}\n\nexport const gcpDetector = new GcpDetector();\n"]}
1
+ {"version":3,"file":"GcpDetector.js","sourceRoot":"","sources":["../../../src/detectors/GcpDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,4CAA6C;AAC7C,8CAAsD;AACtD,wCAmBoB;AAGpB,wDAOkC;AAClC,yCAAyC;AACzC,+BAA+B;AAC/B,6BAA6B;AAC7B,6BAA6B;AAC7B,6BAA6B;AAE7B,MAAM,eAAe,GAAG;IACtB,6BAAmB;IACnB,sCAA4B;IAC5B,2BAAiB;IACjB,+BAAqB;IACrB,wBAAc;IACd,sBAAY;IACZ,wBAAc;IACd,6BAAmB;IACnB,+BAAqB;IACrB,wBAAc;IACd,2BAAiB;IACjB,4BAAkB;CACV,CAAC;AAQX,KAAK,UAAU,MAAM;IACnB,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,EAAE;QACnC,OAAO,IAAA,yBAAa,GAAE,CAAC;KACxB;IAED,uFAAuF;IACvF,0FAA0F;IAC1F,IAAI,MAAM,GAAG,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,MAAM,WAAW,EAAE,CAAC;KAC5B;SAAM,IAAI,MAAM,IAAI,CAAC,gBAAgB,EAAE,EAAE;QACxC,OAAO,MAAM,sBAAsB,EAAE,CAAC;KACvC;SAAM,IAAI,MAAM,IAAI,CAAC,UAAU,EAAE,EAAE;QAClC,OAAO,MAAM,gBAAgB,EAAE,CAAC;KACjC;SAAM,IAAI,MAAM,GAAG,CAAC,WAAW,EAAE,EAAE;QAClC,OAAO,MAAM,WAAW,EAAE,CAAC;KAC5B;SAAM,IAAI,MAAM,GAAG,CAAC,KAAK,EAAE,EAAE;QAC5B,OAAO,MAAM,WAAW,EAAE,CAAC;KAC5B;IAED,OAAO,IAAA,yBAAa,GAAE,CAAC;AACzB,CAAC;AAED,KAAK,UAAU,WAAW;IACxB,MAAM,CAAC,YAAY,EAAE,cAAc,EAAE,MAAM,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I,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC;CACF;AAnBD,kCAmBC;AAEY,QAAA,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC","sourcesContent":["/*\n * Copyright 2022 Google LLC\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { context } from '@opentelemetry/api';\nimport { suppressTracing } from '@opentelemetry/core';\nimport {\n CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE,\n CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS,\n CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN,\n CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE,\n CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE,\n CLOUD_PROVIDER_VALUE_GCP,\n ATTR_CLOUD_ACCOUNT_ID,\n ATTR_CLOUD_AVAILABILITY_ZONE,\n ATTR_CLOUD_PLATFORM,\n ATTR_CLOUD_PROVIDER,\n ATTR_CLOUD_REGION,\n ATTR_FAAS_INSTANCE,\n ATTR_FAAS_NAME,\n ATTR_FAAS_VERSION,\n ATTR_HOST_ID,\n ATTR_HOST_NAME,\n ATTR_HOST_TYPE,\n ATTR_K8S_CLUSTER_NAME,\n} from '../semconv';\n\nimport { AttributeValue, Attributes } from '@opentelemetry/api';\nimport {\n DetectedResource,\n DetectedResourceAttributes,\n emptyResource,\n Resource,\n ResourceDetector,\n resourceFromAttributes,\n} from '@opentelemetry/resources';\nimport * as metadata from 'gcp-metadata';\nimport * as faas from './faas';\nimport * as gae from './gae';\nimport * as gce from './gce';\nimport * as gke from './gke';\n\nconst ATTRIBUTE_NAMES = [\n ATTR_CLOUD_PLATFORM,\n ATTR_CLOUD_AVAILABILITY_ZONE,\n ATTR_CLOUD_REGION,\n ATTR_K8S_CLUSTER_NAME,\n ATTR_HOST_TYPE,\n ATTR_HOST_ID,\n ATTR_HOST_NAME,\n ATTR_CLOUD_PROVIDER,\n ATTR_CLOUD_ACCOUNT_ID,\n ATTR_FAAS_NAME,\n ATTR_FAAS_VERSION,\n ATTR_FAAS_INSTANCE,\n] as const;\n\n// Ensure that all resource keys are accounted for in ATTRIBUTE_NAMES\ntype GcpResourceAttributeName = (typeof ATTRIBUTE_NAMES)[number];\ntype GcpResourceAttributes = Partial<\n Record<GcpResourceAttributeName, AttributeValue>\n>;\n\nasync function detect(): Promise<Resource> {\n if (!(await metadata.isAvailable())) {\n return emptyResource();\n }\n\n // Note the order of these if checks is significant with more specific resources coming\n // first. E.g. Cloud Functions gen2 are executed in Cloud Run so it must be checked first.\n if (await gke.onGke()) {\n return await gkeResource();\n } else if (await faas.onCloudFunctions()) {\n return await cloudFunctionsResource();\n } else if (await faas.onCloudRun()) {\n return await cloudRunResource();\n } else if (await gae.onAppEngine()) {\n return await gaeResource();\n } else if (await gce.onGce()) {\n return await gceResource();\n }\n\n return emptyResource();\n}\n\nasync function gkeResource(): Promise<Resource> {\n const [zoneOrRegion, k8sClusterName, hostId] = await Promise.all([\n gke.availabilityZoneOrRegion(),\n gke.clusterName(),\n gke.hostId(),\n ]);\n\n return await makeResource({\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE,\n [zoneOrRegion.type === 'zone'\n ? ATTR_CLOUD_AVAILABILITY_ZONE\n : ATTR_CLOUD_REGION]: zoneOrRegion.value,\n [ATTR_K8S_CLUSTER_NAME]: k8sClusterName,\n [ATTR_HOST_ID]: hostId,\n });\n}\n\nasync function cloudRunResource(): Promise<Resource> {\n const [faasName, faasVersion, faasInstance, faasCloudRegion] =\n await Promise.all([\n faas.faasName(),\n faas.faasVersion(),\n faas.faasInstance(),\n faas.faasCloudRegion(),\n ]);\n\n return await makeResource({\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN,\n [ATTR_FAAS_NAME]: faasName,\n [ATTR_FAAS_VERSION]: faasVersion,\n [ATTR_FAAS_INSTANCE]: faasInstance,\n [ATTR_CLOUD_REGION]: faasCloudRegion,\n });\n}\n\nasync function cloudFunctionsResource(): Promise<Resource> {\n const [faasName, faasVersion, faasInstance, faasCloudRegion] =\n await Promise.all([\n faas.faasName(),\n faas.faasVersion(),\n faas.faasInstance(),\n faas.faasCloudRegion(),\n ]);\n\n return await makeResource({\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS,\n [ATTR_FAAS_NAME]: faasName,\n [ATTR_FAAS_VERSION]: faasVersion,\n [ATTR_FAAS_INSTANCE]: faasInstance,\n [ATTR_CLOUD_REGION]: faasCloudRegion,\n });\n}\n\nasync function gaeResource(): Promise<Resource> {\n let zone, region;\n if (await gae.onAppEngineStandard()) {\n [zone, region] = await Promise.all([\n gae.standardAvailabilityZone(),\n gae.standardCloudRegion(),\n ]);\n } else {\n ({ zone, region } = await gce.availabilityZoneAndRegion());\n }\n const [faasName, faasVersion, faasInstance] = await Promise.all([\n gae.serviceName(),\n gae.serviceVersion(),\n gae.serviceInstance(),\n ]);\n\n return await makeResource({\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE,\n [ATTR_FAAS_NAME]: faasName,\n [ATTR_FAAS_VERSION]: faasVersion,\n [ATTR_FAAS_INSTANCE]: faasInstance,\n [ATTR_CLOUD_AVAILABILITY_ZONE]: zone,\n [ATTR_CLOUD_REGION]: region,\n });\n}\n\nasync function gceResource(): Promise<Resource> {\n const [zoneAndRegion, hostType, hostId, hostName] = await Promise.all([\n gce.availabilityZoneAndRegion(),\n gce.hostType(),\n gce.hostId(),\n gce.hostName(),\n ]);\n\n return await makeResource({\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE,\n [ATTR_CLOUD_AVAILABILITY_ZONE]: zoneAndRegion.zone,\n [ATTR_CLOUD_REGION]: zoneAndRegion.region,\n [ATTR_HOST_TYPE]: hostType,\n [ATTR_HOST_ID]: hostId,\n [ATTR_HOST_NAME]: hostName,\n });\n}\n\nasync function makeResource(attrs: GcpResourceAttributes): Promise<Resource> {\n const project = await metadata.project<string>('project-id');\n\n return resourceFromAttributes({\n [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_GCP,\n [ATTR_CLOUD_ACCOUNT_ID]: project,\n ...attrs,\n } satisfies GcpResourceAttributes);\n}\n\n/**\n * Google Cloud resource detector which populates attributes based on the environment this\n * process is running in. If not on GCP, returns an empty resource.\n */\nexport class GcpDetector implements ResourceDetector {\n private async _asyncAttributes(): Promise<Attributes> {\n const resource = await context.with(\n suppressTracing(context.active()),\n detect\n );\n return resource.attributes;\n }\n\n detect(): DetectedResource {\n const asyncAttributes = this._asyncAttributes();\n const attributes = {} as DetectedResourceAttributes;\n ATTRIBUTE_NAMES.forEach(name => {\n // Each resource attribute is determined asynchronously in _gatherData().\n attributes[name] = asyncAttributes.then(data => data[name]);\n });\n\n return { attributes };\n }\n}\n\nexport const gcpDetector = new GcpDetector();\n"]}
@@ -0,0 +1,180 @@
1
+ /**
2
+ * The cloud account ID the resource is assigned to.
3
+ *
4
+ * @example 111111111111
5
+ * @example opentelemetry
6
+ *
7
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
8
+ */
9
+ export declare const ATTR_CLOUD_ACCOUNT_ID: "cloud.account.id";
10
+ /**
11
+ * Cloud regions often have multiple, isolated locations known as zones to increase availability. Availability zone represents the zone where the resource is running.
12
+ *
13
+ * @example us-east-1c
14
+ *
15
+ * @note Availability zones are called "zones" on Alibaba Cloud and Google Cloud.
16
+ *
17
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
18
+ */
19
+ export declare const ATTR_CLOUD_AVAILABILITY_ZONE: "cloud.availability_zone";
20
+ /**
21
+ * The cloud platform in use.
22
+ *
23
+ * @note The prefix of the service **SHOULD** match the one specified in `cloud.provider`.
24
+ *
25
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
26
+ */
27
+ export declare const ATTR_CLOUD_PLATFORM: "cloud.platform";
28
+ /**
29
+ * Name of the cloud provider.
30
+ *
31
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
32
+ */
33
+ export declare const ATTR_CLOUD_PROVIDER: "cloud.provider";
34
+ /**
35
+ * The geographical region within a cloud provider. When associated with a resource, this attribute specifies the region where the resource operates. When calling services or APIs deployed on a cloud, this attribute identifies the region where the called destination is deployed.
36
+ *
37
+ * @example us-central1
38
+ * @example us-east-1
39
+ *
40
+ * @note Refer to your provider's docs to see the available regions, for example [Alibaba Cloud regions](https://www.alibabacloud.com/help/doc-detail/40654.htm), [AWS regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), [Azure regions](https://azure.microsoft.com/global-infrastructure/geographies/), [Google Cloud regions](https://cloud.google.com/about/locations), or [Tencent Cloud regions](https://www.tencentcloud.com/document/product/213/6091).
41
+ *
42
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
43
+ */
44
+ export declare const ATTR_CLOUD_REGION: "cloud.region";
45
+ /**
46
+ * The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version.
47
+ *
48
+ * @example 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de
49
+ *
50
+ * @note - **AWS Lambda:** Use the (full) log stream name.
51
+ *
52
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
53
+ */
54
+ export declare const ATTR_FAAS_INSTANCE: "faas.instance";
55
+ /**
56
+ * The name of the single function that this runtime instance executes.
57
+ *
58
+ * @example my-function
59
+ * @example myazurefunctionapp/some-function-name
60
+ *
61
+ * @note This is the name of the function as configured/deployed on the FaaS
62
+ * platform and is usually different from the name of the callback
63
+ * function (which may be stored in the
64
+ * [`code.namespace`/`code.function.name`](/docs/general/attributes.md#source-code-attributes)
65
+ * span attributes).
66
+ *
67
+ * For some cloud providers, the above definition is ambiguous. The following
68
+ * definition of function name **MUST** be used for this attribute
69
+ * (and consequently the span name) for the listed cloud providers/products:
70
+ *
71
+ * - **Azure:** The full name `<FUNCAPP>/<FUNC>`, i.e., function app name
72
+ * followed by a forward slash followed by the function name (this form
73
+ * can also be seen in the resource JSON for the function).
74
+ * This means that a span attribute **MUST** be used, as an Azure function
75
+ * app can host multiple functions that would usually share
76
+ * a TracerProvider (see also the `cloud.resource_id` attribute).
77
+ *
78
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
79
+ */
80
+ export declare const ATTR_FAAS_NAME: "faas.name";
81
+ /**
82
+ * The immutable version of the function being executed.
83
+ *
84
+ * @example 26
85
+ * @example pinkfroid-00002
86
+ *
87
+ * @note Depending on the cloud provider and platform, use:
88
+ *
89
+ * - **AWS Lambda:** The [function version](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html)
90
+ * (an integer represented as a decimal string).
91
+ * - **Google Cloud Run (Services):** The [revision](https://cloud.google.com/run/docs/managing/revisions)
92
+ * (i.e., the function name plus the revision suffix).
93
+ * - **Google Cloud Functions:** The value of the
94
+ * [`K_REVISION` environment variable](https://cloud.google.com/functions/docs/env-var#runtime_environment_variables_set_automatically).
95
+ * - **Azure Functions:** Not applicable. Do not set this attribute.
96
+ *
97
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
98
+ */
99
+ export declare const ATTR_FAAS_VERSION: "faas.version";
100
+ /**
101
+ * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For non-containerized systems, this should be the `machine-id`. See the table below for the sources to use to determine the `machine-id` based on operating system.
102
+ *
103
+ * @example fdbf79e8af94cb7f9e8df36789187052
104
+ *
105
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
106
+ */
107
+ export declare const ATTR_HOST_ID: "host.id";
108
+ /**
109
+ * Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user.
110
+ *
111
+ * @example opentelemetry-test
112
+ *
113
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
114
+ */
115
+ export declare const ATTR_HOST_NAME: "host.name";
116
+ /**
117
+ * Type of host. For Cloud, this must be the machine type.
118
+ *
119
+ * @example n1-standard-1
120
+ *
121
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
122
+ */
123
+ export declare const ATTR_HOST_TYPE: "host.type";
124
+ /**
125
+ * The name of the cluster.
126
+ *
127
+ * @example opentelemetry-cluster
128
+ *
129
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
130
+ */
131
+ export declare const ATTR_K8S_CLUSTER_NAME: "k8s.cluster.name";
132
+ /**
133
+ * Enum value "gcp_app_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
134
+ *
135
+ * Google Cloud App Engine (GAE)
136
+ *
137
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
138
+ */
139
+ export declare const CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE: "gcp_app_engine";
140
+ /**
141
+ * Enum value "gcp_cloud_functions" for attribute {@link ATTR_CLOUD_PLATFORM}.
142
+ *
143
+ * Google Cloud Functions (GCF)
144
+ *
145
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
146
+ */
147
+ export declare const CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS: "gcp_cloud_functions";
148
+ /**
149
+ * Enum value "gcp_cloud_run" for attribute {@link ATTR_CLOUD_PLATFORM}.
150
+ *
151
+ * Google Cloud Run
152
+ *
153
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
154
+ */
155
+ export declare const CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN: "gcp_cloud_run";
156
+ /**
157
+ * Enum value "gcp_compute_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
158
+ *
159
+ * Google Cloud Compute Engine (GCE)
160
+ *
161
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
162
+ */
163
+ export declare const CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE: "gcp_compute_engine";
164
+ /**
165
+ * Enum value "gcp_kubernetes_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
166
+ *
167
+ * Google Cloud Kubernetes Engine (GKE)
168
+ *
169
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
170
+ */
171
+ export declare const CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE: "gcp_kubernetes_engine";
172
+ /**
173
+ * Enum value "gcp" for attribute {@link ATTR_CLOUD_PROVIDER}.
174
+ *
175
+ * Google Cloud Platform
176
+ *
177
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
178
+ */
179
+ export declare const CLOUD_PROVIDER_VALUE_GCP: "gcp";
180
+ //# sourceMappingURL=semconv.d.ts.map
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright The OpenTelemetry Authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CLOUD_PROVIDER_VALUE_GCP = exports.CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE = exports.CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE = exports.CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN = exports.CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS = exports.CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE = exports.ATTR_K8S_CLUSTER_NAME = exports.ATTR_HOST_TYPE = exports.ATTR_HOST_NAME = exports.ATTR_HOST_ID = exports.ATTR_FAAS_VERSION = exports.ATTR_FAAS_NAME = exports.ATTR_FAAS_INSTANCE = exports.ATTR_CLOUD_REGION = exports.ATTR_CLOUD_PROVIDER = exports.ATTR_CLOUD_PLATFORM = exports.ATTR_CLOUD_AVAILABILITY_ZONE = exports.ATTR_CLOUD_ACCOUNT_ID = void 0;
19
+ /*
20
+ * This file contains a copy of unstable semantic convention definitions
21
+ * used by this package.
22
+ * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
23
+ */
24
+ /**
25
+ * The cloud account ID the resource is assigned to.
26
+ *
27
+ * @example 111111111111
28
+ * @example opentelemetry
29
+ *
30
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
31
+ */
32
+ exports.ATTR_CLOUD_ACCOUNT_ID = 'cloud.account.id';
33
+ /**
34
+ * Cloud regions often have multiple, isolated locations known as zones to increase availability. Availability zone represents the zone where the resource is running.
35
+ *
36
+ * @example us-east-1c
37
+ *
38
+ * @note Availability zones are called "zones" on Alibaba Cloud and Google Cloud.
39
+ *
40
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
41
+ */
42
+ exports.ATTR_CLOUD_AVAILABILITY_ZONE = 'cloud.availability_zone';
43
+ /**
44
+ * The cloud platform in use.
45
+ *
46
+ * @note The prefix of the service **SHOULD** match the one specified in `cloud.provider`.
47
+ *
48
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
49
+ */
50
+ exports.ATTR_CLOUD_PLATFORM = 'cloud.platform';
51
+ /**
52
+ * Name of the cloud provider.
53
+ *
54
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
55
+ */
56
+ exports.ATTR_CLOUD_PROVIDER = 'cloud.provider';
57
+ /**
58
+ * The geographical region within a cloud provider. When associated with a resource, this attribute specifies the region where the resource operates. When calling services or APIs deployed on a cloud, this attribute identifies the region where the called destination is deployed.
59
+ *
60
+ * @example us-central1
61
+ * @example us-east-1
62
+ *
63
+ * @note Refer to your provider's docs to see the available regions, for example [Alibaba Cloud regions](https://www.alibabacloud.com/help/doc-detail/40654.htm), [AWS regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), [Azure regions](https://azure.microsoft.com/global-infrastructure/geographies/), [Google Cloud regions](https://cloud.google.com/about/locations), or [Tencent Cloud regions](https://www.tencentcloud.com/document/product/213/6091).
64
+ *
65
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
66
+ */
67
+ exports.ATTR_CLOUD_REGION = 'cloud.region';
68
+ /**
69
+ * The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version.
70
+ *
71
+ * @example 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de
72
+ *
73
+ * @note - **AWS Lambda:** Use the (full) log stream name.
74
+ *
75
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
76
+ */
77
+ exports.ATTR_FAAS_INSTANCE = 'faas.instance';
78
+ /**
79
+ * The name of the single function that this runtime instance executes.
80
+ *
81
+ * @example my-function
82
+ * @example myazurefunctionapp/some-function-name
83
+ *
84
+ * @note This is the name of the function as configured/deployed on the FaaS
85
+ * platform and is usually different from the name of the callback
86
+ * function (which may be stored in the
87
+ * [`code.namespace`/`code.function.name`](/docs/general/attributes.md#source-code-attributes)
88
+ * span attributes).
89
+ *
90
+ * For some cloud providers, the above definition is ambiguous. The following
91
+ * definition of function name **MUST** be used for this attribute
92
+ * (and consequently the span name) for the listed cloud providers/products:
93
+ *
94
+ * - **Azure:** The full name `<FUNCAPP>/<FUNC>`, i.e., function app name
95
+ * followed by a forward slash followed by the function name (this form
96
+ * can also be seen in the resource JSON for the function).
97
+ * This means that a span attribute **MUST** be used, as an Azure function
98
+ * app can host multiple functions that would usually share
99
+ * a TracerProvider (see also the `cloud.resource_id` attribute).
100
+ *
101
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
102
+ */
103
+ exports.ATTR_FAAS_NAME = 'faas.name';
104
+ /**
105
+ * The immutable version of the function being executed.
106
+ *
107
+ * @example 26
108
+ * @example pinkfroid-00002
109
+ *
110
+ * @note Depending on the cloud provider and platform, use:
111
+ *
112
+ * - **AWS Lambda:** The [function version](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html)
113
+ * (an integer represented as a decimal string).
114
+ * - **Google Cloud Run (Services):** The [revision](https://cloud.google.com/run/docs/managing/revisions)
115
+ * (i.e., the function name plus the revision suffix).
116
+ * - **Google Cloud Functions:** The value of the
117
+ * [`K_REVISION` environment variable](https://cloud.google.com/functions/docs/env-var#runtime_environment_variables_set_automatically).
118
+ * - **Azure Functions:** Not applicable. Do not set this attribute.
119
+ *
120
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
121
+ */
122
+ exports.ATTR_FAAS_VERSION = 'faas.version';
123
+ /**
124
+ * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For non-containerized systems, this should be the `machine-id`. See the table below for the sources to use to determine the `machine-id` based on operating system.
125
+ *
126
+ * @example fdbf79e8af94cb7f9e8df36789187052
127
+ *
128
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
129
+ */
130
+ exports.ATTR_HOST_ID = 'host.id';
131
+ /**
132
+ * Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user.
133
+ *
134
+ * @example opentelemetry-test
135
+ *
136
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
137
+ */
138
+ exports.ATTR_HOST_NAME = 'host.name';
139
+ /**
140
+ * Type of host. For Cloud, this must be the machine type.
141
+ *
142
+ * @example n1-standard-1
143
+ *
144
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
145
+ */
146
+ exports.ATTR_HOST_TYPE = 'host.type';
147
+ /**
148
+ * The name of the cluster.
149
+ *
150
+ * @example opentelemetry-cluster
151
+ *
152
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
153
+ */
154
+ exports.ATTR_K8S_CLUSTER_NAME = 'k8s.cluster.name';
155
+ /**
156
+ * Enum value "gcp_app_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
157
+ *
158
+ * Google Cloud App Engine (GAE)
159
+ *
160
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
161
+ */
162
+ exports.CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE = 'gcp_app_engine';
163
+ /**
164
+ * Enum value "gcp_cloud_functions" for attribute {@link ATTR_CLOUD_PLATFORM}.
165
+ *
166
+ * Google Cloud Functions (GCF)
167
+ *
168
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
169
+ */
170
+ exports.CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS = 'gcp_cloud_functions';
171
+ /**
172
+ * Enum value "gcp_cloud_run" for attribute {@link ATTR_CLOUD_PLATFORM}.
173
+ *
174
+ * Google Cloud Run
175
+ *
176
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
177
+ */
178
+ exports.CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN = 'gcp_cloud_run';
179
+ /**
180
+ * Enum value "gcp_compute_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
181
+ *
182
+ * Google Cloud Compute Engine (GCE)
183
+ *
184
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
185
+ */
186
+ exports.CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE = 'gcp_compute_engine';
187
+ /**
188
+ * Enum value "gcp_kubernetes_engine" for attribute {@link ATTR_CLOUD_PLATFORM}.
189
+ *
190
+ * Google Cloud Kubernetes Engine (GKE)
191
+ *
192
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
193
+ */
194
+ exports.CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE = 'gcp_kubernetes_engine';
195
+ /**
196
+ * Enum value "gcp" for attribute {@link ATTR_CLOUD_PROVIDER}.
197
+ *
198
+ * Google Cloud Platform
199
+ *
200
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
201
+ */
202
+ exports.CLOUD_PROVIDER_VALUE_GCP = 'gcp';
203
+ //# sourceMappingURL=semconv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH;;;;;;;GAOG;AACU,QAAA,qBAAqB,GAAG,kBAA2B,CAAC;AAEjE;;;;;;;;GAQG;AACU,QAAA,4BAA4B,GAAG,yBAAkC,CAAC;AAE/E;;;;;;GAMG;AACU,QAAA,mBAAmB,GAAG,gBAAyB,CAAC;AAE7D;;;;GAIG;AACU,QAAA,mBAAmB,GAAG,gBAAyB,CAAC;AAE7D;;;;;;;;;GASG;AACU,QAAA,iBAAiB,GAAG,cAAuB,CAAC;AAEzD;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACU,QAAA,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,iBAAiB,GAAG,cAAuB,CAAC;AAEzD;;;;;;GAMG;AACU,QAAA,YAAY,GAAG,SAAkB,CAAC;AAE/C;;;;;;GAMG;AACU,QAAA,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;GAMG;AACU,QAAA,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;GAMG;AACU,QAAA,qBAAqB,GAAG,kBAA2B,CAAC;AAEjE;;;;;;GAMG;AACU,QAAA,mCAAmC,GAAG,gBAAyB,CAAC;AAE7E;;;;;;GAMG;AACU,QAAA,wCAAwC,GACnD,qBAA8B,CAAC;AAEjC;;;;;;GAMG;AACU,QAAA,kCAAkC,GAAG,eAAwB,CAAC;AAE3E;;;;;;GAMG;AACU,QAAA,uCAAuC,GAClD,oBAA6B,CAAC;AAEhC;;;;;;GAMG;AACU,QAAA,0CAA0C,GACrD,uBAAgC,CAAC;AAEnC;;;;;;GAMG;AACU,QAAA,wBAAwB,GAAG,KAAc,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * The cloud account ID the resource is assigned to.\n *\n * @example 111111111111\n * @example opentelemetry\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_ACCOUNT_ID = 'cloud.account.id' as const;\n\n/**\n * Cloud regions often have multiple, isolated locations known as zones to increase availability. Availability zone represents the zone where the resource is running.\n *\n * @example us-east-1c\n *\n * @note Availability zones are called \"zones\" on Alibaba Cloud and Google Cloud.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_AVAILABILITY_ZONE = 'cloud.availability_zone' as const;\n\n/**\n * The cloud platform in use.\n *\n * @note The prefix of the service **SHOULD** match the one specified in `cloud.provider`.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_PLATFORM = 'cloud.platform' as const;\n\n/**\n * Name of the cloud provider.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_PROVIDER = 'cloud.provider' as const;\n\n/**\n * The geographical region within a cloud provider. When associated with a resource, this attribute specifies the region where the resource operates. When calling services or APIs deployed on a cloud, this attribute identifies the region where the called destination is deployed.\n *\n * @example us-central1\n * @example us-east-1\n *\n * @note Refer to your provider's docs to see the available regions, for example [Alibaba Cloud regions](https://www.alibabacloud.com/help/doc-detail/40654.htm), [AWS regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), [Azure regions](https://azure.microsoft.com/global-infrastructure/geographies/), [Google Cloud regions](https://cloud.google.com/about/locations), or [Tencent Cloud regions](https://www.tencentcloud.com/document/product/213/6091).\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_REGION = 'cloud.region' as const;\n\n/**\n * The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version.\n *\n * @example 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de\n *\n * @note - **AWS Lambda:** Use the (full) log stream name.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_INSTANCE = 'faas.instance' as const;\n\n/**\n * The name of the single function that this runtime instance executes.\n *\n * @example my-function\n * @example myazurefunctionapp/some-function-name\n *\n * @note This is the name of the function as configured/deployed on the FaaS\n * platform and is usually different from the name of the callback\n * function (which may be stored in the\n * [`code.namespace`/`code.function.name`](/docs/general/attributes.md#source-code-attributes)\n * span attributes).\n *\n * For some cloud providers, the above definition is ambiguous. The following\n * definition of function name **MUST** be used for this attribute\n * (and consequently the span name) for the listed cloud providers/products:\n *\n * - **Azure:** The full name `<FUNCAPP>/<FUNC>`, i.e., function app name\n * followed by a forward slash followed by the function name (this form\n * can also be seen in the resource JSON for the function).\n * This means that a span attribute **MUST** be used, as an Azure function\n * app can host multiple functions that would usually share\n * a TracerProvider (see also the `cloud.resource_id` attribute).\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_NAME = 'faas.name' as const;\n\n/**\n * The immutable version of the function being executed.\n *\n * @example 26\n * @example pinkfroid-00002\n *\n * @note Depending on the cloud provider and platform, use:\n *\n * - **AWS Lambda:** The [function version](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html)\n * (an integer represented as a decimal string).\n * - **Google Cloud Run (Services):** The [revision](https://cloud.google.com/run/docs/managing/revisions)\n * (i.e., the function name plus the revision suffix).\n * - **Google Cloud Functions:** The value of the\n * [`K_REVISION` environment variable](https://cloud.google.com/functions/docs/env-var#runtime_environment_variables_set_automatically).\n * - **Azure Functions:** Not applicable. Do not set this attribute.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_VERSION = 'faas.version' as const;\n\n/**\n * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For non-containerized systems, this should be the `machine-id`. See the table below for the sources to use to determine the `machine-id` based on operating system.\n *\n * @example fdbf79e8af94cb7f9e8df36789187052\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_HOST_ID = 'host.id' as const;\n\n/**\n * Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user.\n *\n * @example opentelemetry-test\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_HOST_NAME = 'host.name' as const;\n\n/**\n * Type of host. For Cloud, this must be the machine type.\n *\n * @example n1-standard-1\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_HOST_TYPE = 'host.type' as const;\n\n/**\n * The name of the cluster.\n *\n * @example opentelemetry-cluster\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_K8S_CLUSTER_NAME = 'k8s.cluster.name' as const;\n\n/**\n * Enum value \"gcp_app_engine\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Google Cloud App Engine (GAE)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_GCP_APP_ENGINE = 'gcp_app_engine' as const;\n\n/**\n * Enum value \"gcp_cloud_functions\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Google Cloud Functions (GCF)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_GCP_CLOUD_FUNCTIONS =\n 'gcp_cloud_functions' as const;\n\n/**\n * Enum value \"gcp_cloud_run\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Google Cloud Run\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_GCP_CLOUD_RUN = 'gcp_cloud_run' as const;\n\n/**\n * Enum value \"gcp_compute_engine\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Google Cloud Compute Engine (GCE)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_GCP_COMPUTE_ENGINE =\n 'gcp_compute_engine' as const;\n\n/**\n * Enum value \"gcp_kubernetes_engine\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Google Cloud Kubernetes Engine (GKE)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_GCP_KUBERNETES_ENGINE =\n 'gcp_kubernetes_engine' as const;\n\n/**\n * Enum value \"gcp\" for attribute {@link ATTR_CLOUD_PROVIDER}.\n *\n * Google Cloud Platform\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PROVIDER_VALUE_GCP = 'gcp' as const;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/resource-detector-gcp",
3
- "version": "0.40.0",
3
+ "version": "0.40.3",
4
4
  "description": "OpenTelemetry SDK resource detector for GCP",
5
5
  "main": "build/src/index.js",
6
6
  "module": "build/esm/index.js",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@opentelemetry/api": "^1.0.0",
49
- "@opentelemetry/contrib-test-utils": "^0.51.0",
49
+ "@opentelemetry/contrib-test-utils": "^0.52.2",
50
50
  "@opentelemetry/instrumentation-http": "^0.205.0",
51
51
  "@opentelemetry/sdk-trace-base": "^2.0.0",
52
52
  "@types/mocha": "10.0.10",
@@ -64,10 +64,9 @@
64
64
  "dependencies": {
65
65
  "@opentelemetry/core": "^2.0.0",
66
66
  "@opentelemetry/resources": "^2.0.0",
67
- "@opentelemetry/semantic-conventions": "^1.27.0",
68
67
  "gcp-metadata": "^6.0.0"
69
68
  },
70
69
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/resource-detector-gcp#readme",
71
70
  "sideEffects": false,
72
- "gitHead": "9d689e167e92b09fca91906e20790496a49af384"
71
+ "gitHead": "5a5918fd4f9f16b14c9ef4d3de08ab98c20e5b46"
73
72
  }