@opentelemetry/resource-detector-azure 0.11.0 → 0.13.1

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.
package/README.md CHANGED
@@ -27,18 +27,18 @@ const tracerProvider = new NodeTracerProvider({ resource });
27
27
 
28
28
  ## Available Detectors
29
29
 
30
- This package implements Semantic Convention [Version 1.19.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.19.0/semantic_conventions/README.md).
30
+ This package implements Semantic Convention [Version 1.37.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.37.0/semantic_conventions/README.md).
31
31
 
32
32
  ### App Service Resource Detector
33
33
 
34
34
  | Resource Attribute | Description |
35
35
  |-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
36
36
  | azure.app.service.stamp | The specific "stamp" cluster within Azure where the App Service is running, e.g., "waws-prod-sn1-001". Value of Process Environment Variable `APP_SERVICE_ATTRIBUTE_ENV_VARS`. |
37
- | cloud.platform | The cloud platform. Here, it's always "azure_app_service". |
37
+ | cloud.platform | The cloud platform. Here, it's always "azure.app_service". |
38
38
  | cloud.provider | The cloud service provider. In this context, it's always "azure". |
39
39
  | cloud.region | The Azure region where the App Service is hosted, e.g., "East US", "West Europe", etc. Value of Process Environment Variable `REGION_NAME`. |
40
40
  | cloud.resource_id | The Azure Resource Manager URI uniquely identifying the Azure App Service. Typically in the format `/subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Web/sites/{siteName}`. |
41
- | deployment.environment | The deployment slot where the Azure App Service is running, such as "staging", "production", etc. Value of Process Environment Variable `WEBSITE_SLOT_NAME`. |
41
+ | deployment.environment.name | The deployment slot where the Azure App Service is running, such as "staging", "production", etc. Value of Process Environment Variable `WEBSITE_SLOT_NAME`. |
42
42
  | host.id | The primary hostname for the app, excluding any custom hostnames. Value of Process Environment Variable `WEBSITE_HOSTNAME`. |
43
43
  | service.instance.id | The specific instance of the Azure App Service, useful in a scaled-out configuration. Value of Process Environment Variable `WEBSITE_INSTANCE_ID`. |
44
44
  | service.name | The name of the Azure App Service. Value of Process Environment Variable `WEBSITE_SITE_NAME`. |
@@ -49,7 +49,7 @@ This package implements Semantic Convention [Version 1.19.0](https://github.com/
49
49
  |--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
50
50
  | azure.vm.scaleset.name | The name of the Virtual Machine Scale Set if the VM is part of one. Value from `vmScaleSetName` key on `/metadata/instance/compute` request. |
51
51
  | azure.vm.sku | The SKU of the Azure Virtual Machine's operating system. For instance, for a VM running Windows Server 2019 Datacenter edition, this value would be "2019-Datacenter". Value from `sku` key on `/metadata/instance/compute` request. |
52
- | cloud.platform | The cloud platform, which is always set to "azure_vm" in this context. |
52
+ | cloud.platform | The cloud platform, which is always set to "azure.vm" in this context. |
53
53
  | cloud.provider | The cloud service provider, which is always set to "azure" in this context. |
54
54
  | cloud.region | The Azure region where the Virtual Machine is hosted, such as "East US", "West Europe", etc. Value from `location` key on `/metadata/instance/compute` request. |
55
55
  | cloud.resource_id | The Azure Resource Manager URI uniquely identifying the Azure Virtual Machine. It typically follows this format: `/subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Compute/virtualMachines/{vmName}`. Value from `resourceId` key on `/metadata/instance/compute` request.|
@@ -62,7 +62,7 @@ This package implements Semantic Convention [Version 1.19.0](https://github.com/
62
62
 
63
63
  | Resource Attribute | Description |
64
64
  |-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
65
- | cloud.platform | The cloud platform. Here, it's always "azure_functions". |
65
+ | cloud.platform | The cloud platform. Here, it's always "azure.functions". |
66
66
  | cloud.provider | The cloud service provider. In this context, it's always "azure". |
67
67
  | cloud.region | The Azure region where the Azure Function is hosted, e.g., "East US", "West Europe", etc. Value of Process Environment Variable `REGION_NAME`. |
68
68
  | faas.instance | The specific instance of the Azure App Service, useful in a scaled-out configuration. Value from Process Environment Variable `WEBSITE_INSTANCE_ID`. |
@@ -85,4 +85,4 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
85
85
  [license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE
86
86
  [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
87
87
  [npm-url]: https://www.npmjs.com/package/@opentelemetry/resource-detector-azure
88
- [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fresource-detector-azure.svg
88
+ [npm-img]: https://img.shields.io/npm/v/%40opentelemetry%2Fresource-detector-azure.svg
@@ -14,13 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE, REGION_NAME, WEBSITE_HOME_STAMPNAME, WEBSITE_HOSTNAME, WEBSITE_INSTANCE_ID, WEBSITE_SITE_NAME, WEBSITE_SLOT_NAME, CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE, } from '../types';
17
- import { SEMRESATTRS_CLOUD_REGION, SEMRESATTRS_DEPLOYMENT_ENVIRONMENT, SEMRESATTRS_HOST_ID, SEMRESATTRS_SERVICE_INSTANCE_ID, SEMRESATTRS_SERVICE_NAME, SEMRESATTRS_CLOUD_PROVIDER, SEMRESATTRS_CLOUD_PLATFORM, CLOUDPROVIDERVALUES_AZURE, CLOUDPLATFORMVALUES_AZURE_APP_SERVICE, } from '@opentelemetry/semantic-conventions';
17
+ import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
18
+ import { ATTR_CLOUD_REGION, ATTR_DEPLOYMENT_ENVIRONMENT_NAME, ATTR_HOST_ID, ATTR_SERVICE_INSTANCE_ID, ATTR_CLOUD_PROVIDER, CLOUD_PROVIDER_VALUE_AZURE, ATTR_CLOUD_PLATFORM, CLOUD_PLATFORM_VALUE_AZURE_APP_SERVICE, } from '../semconv';
18
19
  import { getAzureResourceUri, isAzureFunction } from '../utils';
19
20
  const APP_SERVICE_ATTRIBUTE_ENV_VARS = {
20
- [SEMRESATTRS_CLOUD_REGION]: REGION_NAME,
21
- [SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: WEBSITE_SLOT_NAME,
22
- [SEMRESATTRS_HOST_ID]: WEBSITE_HOSTNAME,
23
- [SEMRESATTRS_SERVICE_INSTANCE_ID]: WEBSITE_INSTANCE_ID,
21
+ [ATTR_CLOUD_REGION]: REGION_NAME,
22
+ [ATTR_DEPLOYMENT_ENVIRONMENT_NAME]: WEBSITE_SLOT_NAME,
23
+ [ATTR_HOST_ID]: WEBSITE_HOSTNAME,
24
+ [ATTR_SERVICE_INSTANCE_ID]: WEBSITE_INSTANCE_ID,
24
25
  [AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE]: WEBSITE_HOME_STAMPNAME,
25
26
  };
26
27
  /**
@@ -34,15 +35,15 @@ class AzureAppServiceDetector {
34
35
  if (websiteSiteName && !isAzureFunction()) {
35
36
  attributes = {
36
37
  ...attributes,
37
- [SEMRESATTRS_SERVICE_NAME]: websiteSiteName,
38
+ [ATTR_SERVICE_NAME]: websiteSiteName,
38
39
  };
39
40
  attributes = {
40
41
  ...attributes,
41
- [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AZURE,
42
+ [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AZURE,
42
43
  };
43
44
  attributes = {
44
45
  ...attributes,
45
- [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AZURE_APP_SERVICE,
46
+ [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AZURE_APP_SERVICE,
46
47
  };
47
48
  const azureResourceUri = getAzureResourceUri(websiteSiteName);
48
49
  if (azureResourceUri) {
@@ -1 +1 @@
1
- {"version":3,"file":"AzureAppServiceDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureAppServiceDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACL,0CAA0C,EAC1C,WAAW,EACX,sBAAsB,EACt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;YAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CACvC,8BAA8B,CAC/B,EAAE;gBACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAClC,IAAI,MAAM,EAAE;oBACV,UAAU,GAAG,EAAE,GAAG,UAAU,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;iBACtD;aACF;SACF;QACD,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,uBAAuB,EAAE,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\nimport { ResourceDetector, DetectedResource } from '@opentelemetry/resources';\nimport {\n AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE,\n REGION_NAME,\n WEBSITE_HOME_STAMPNAME,\n WEBSITE_HOSTNAME,\n WEBSITE_INSTANCE_ID,\n WEBSITE_SITE_NAME,\n WEBSITE_SLOT_NAME,\n CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,\n} from '../types';\nimport {\n SEMRESATTRS_CLOUD_REGION,\n SEMRESATTRS_DEPLOYMENT_ENVIRONMENT,\n SEMRESATTRS_HOST_ID,\n SEMRESATTRS_SERVICE_INSTANCE_ID,\n SEMRESATTRS_SERVICE_NAME,\n SEMRESATTRS_CLOUD_PROVIDER,\n SEMRESATTRS_CLOUD_PLATFORM,\n CLOUDPROVIDERVALUES_AZURE,\n CLOUDPLATFORMVALUES_AZURE_APP_SERVICE,\n} from '@opentelemetry/semantic-conventions';\nimport { getAzureResourceUri, isAzureFunction } from '../utils';\n\nconst APP_SERVICE_ATTRIBUTE_ENV_VARS = {\n [SEMRESATTRS_CLOUD_REGION]: REGION_NAME,\n [SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: WEBSITE_SLOT_NAME,\n [SEMRESATTRS_HOST_ID]: WEBSITE_HOSTNAME,\n [SEMRESATTRS_SERVICE_INSTANCE_ID]: WEBSITE_INSTANCE_ID,\n [AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE]: WEBSITE_HOME_STAMPNAME,\n};\n\n/**\n * The AzureAppServiceDetector can be used to detect if a process is running in an Azure App Service\n * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails.\n */\nclass AzureAppServiceDetector implements ResourceDetector {\n detect(): DetectedResource {\n let attributes = {};\n const websiteSiteName = process.env[WEBSITE_SITE_NAME];\n if (websiteSiteName && !isAzureFunction()) {\n attributes = {\n ...attributes,\n [SEMRESATTRS_SERVICE_NAME]: websiteSiteName,\n };\n attributes = {\n ...attributes,\n [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AZURE,\n };\n attributes = {\n ...attributes,\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AZURE_APP_SERVICE,\n };\n\n const azureResourceUri = getAzureResourceUri(websiteSiteName);\n if (azureResourceUri) {\n attributes = {\n ...attributes,\n ...{ [CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: azureResourceUri },\n };\n }\n\n for (const [key, value] of Object.entries(\n APP_SERVICE_ATTRIBUTE_ENV_VARS\n )) {\n const envVar = process.env[value];\n if (envVar) {\n attributes = { ...attributes, ...{ [key]: envVar } };\n }\n }\n }\n return { attributes };\n }\n}\n\nexport const azureAppServiceDetector = new AzureAppServiceDetector();\n"]}
1
+ {"version":3,"file":"AzureAppServiceDetector.js","sourceRoot":"","sources":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Ae,CAAC,CAAC;YAC9D,IAAI,gBAAgB,EAAE;gBACpB,UAAU,GAAG;oBACX,GAAG,UAAU;oBACb,GAAG,EAAE,CAAC,oCAAoC,CAAC,EAAE,gBAAgB,EAAE;iBAChE,CAAC;aACH;YAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CACvC,8BAA8B,CAC/B,EAAE;gBACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAClC,IAAI,MAAM,EAAE;oBACV,UAAU,GAAG,EAAE,GAAG,UAAU,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;iBACtD;aACF;SACF;QACD,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,uBAAuB,EAAE,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\nimport { ResourceDetector, DetectedResource } from '@opentelemetry/resources';\nimport {\n AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE,\n REGION_NAME,\n WEBSITE_HOME_STAMPNAME,\n WEBSITE_HOSTNAME,\n WEBSITE_INSTANCE_ID,\n WEBSITE_SITE_NAME,\n WEBSITE_SLOT_NAME,\n CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,\n} from '../types';\nimport { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';\nimport {\n ATTR_CLOUD_REGION,\n ATTR_DEPLOYMENT_ENVIRONMENT_NAME,\n ATTR_HOST_ID,\n ATTR_SERVICE_INSTANCE_ID,\n ATTR_CLOUD_PROVIDER,\n CLOUD_PROVIDER_VALUE_AZURE,\n ATTR_CLOUD_PLATFORM,\n CLOUD_PLATFORM_VALUE_AZURE_APP_SERVICE,\n} from '../semconv';\nimport { getAzureResourceUri, isAzureFunction } from '../utils';\n\nconst APP_SERVICE_ATTRIBUTE_ENV_VARS = {\n [ATTR_CLOUD_REGION]: REGION_NAME,\n [ATTR_DEPLOYMENT_ENVIRONMENT_NAME]: WEBSITE_SLOT_NAME,\n [ATTR_HOST_ID]: WEBSITE_HOSTNAME,\n [ATTR_SERVICE_INSTANCE_ID]: WEBSITE_INSTANCE_ID,\n [AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE]: WEBSITE_HOME_STAMPNAME,\n};\n\n/**\n * The AzureAppServiceDetector can be used to detect if a process is running in an Azure App Service\n * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails.\n */\nclass AzureAppServiceDetector implements ResourceDetector {\n detect(): DetectedResource {\n let attributes = {};\n const websiteSiteName = process.env[WEBSITE_SITE_NAME];\n if (websiteSiteName && !isAzureFunction()) {\n attributes = {\n ...attributes,\n [ATTR_SERVICE_NAME]: websiteSiteName,\n };\n attributes = {\n ...attributes,\n [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AZURE,\n };\n attributes = {\n ...attributes,\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AZURE_APP_SERVICE,\n };\n\n const azureResourceUri = getAzureResourceUri(websiteSiteName);\n if (azureResourceUri) {\n attributes = {\n ...attributes,\n ...{ [CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: azureResourceUri },\n };\n }\n\n for (const [key, value] of Object.entries(\n APP_SERVICE_ATTRIBUTE_ENV_VARS\n )) {\n const envVar = process.env[value];\n if (envVar) {\n attributes = { ...attributes, ...{ [key]: envVar } };\n }\n }\n }\n return { attributes };\n }\n}\n\nexport const azureAppServiceDetector = new AzureAppServiceDetector();\n"]}
@@ -13,13 +13,14 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { SEMRESATTRS_FAAS_MAX_MEMORY, SEMRESATTRS_FAAS_INSTANCE, SEMRESATTRS_CLOUD_PROVIDER, SEMRESATTRS_CLOUD_PLATFORM, SEMRESATTRS_CLOUD_REGION, CLOUDPROVIDERVALUES_AZURE, CLOUDPLATFORMVALUES_AZURE_FUNCTIONS, SEMRESATTRS_SERVICE_NAME, SEMRESATTRS_PROCESS_PID, } from '@opentelemetry/semantic-conventions';
16
+ import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
17
+ import { ATTR_FAAS_MAX_MEMORY, ATTR_FAAS_INSTANCE, ATTR_CLOUD_PROVIDER, CLOUD_PROVIDER_VALUE_AZURE, ATTR_CLOUD_PLATFORM, CLOUD_PLATFORM_VALUE_AZURE_FUNCTIONS, ATTR_CLOUD_REGION, ATTR_PROCESS_PID, } from '../semconv';
17
18
  import { WEBSITE_SITE_NAME, WEBSITE_INSTANCE_ID, FUNCTIONS_MEM_LIMIT, REGION_NAME, CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE, } from '../types';
18
19
  import { getAzureResourceUri, isAzureFunction } from '../utils';
19
20
  const AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = {
20
- [SEMRESATTRS_SERVICE_NAME]: WEBSITE_SITE_NAME,
21
- [SEMRESATTRS_FAAS_INSTANCE]: WEBSITE_INSTANCE_ID,
22
- [SEMRESATTRS_FAAS_MAX_MEMORY]: FUNCTIONS_MEM_LIMIT,
21
+ [ATTR_SERVICE_NAME]: WEBSITE_SITE_NAME,
22
+ [ATTR_FAAS_INSTANCE]: WEBSITE_INSTANCE_ID,
23
+ [ATTR_FAAS_MAX_MEMORY]: FUNCTIONS_MEM_LIMIT,
23
24
  };
24
25
  /**
25
26
  * The AzureFunctionsDetector can be used to detect if a process is running in Azure Functions
@@ -38,27 +39,27 @@ class AzureFunctionsDetector {
38
39
  const functionInstance = process.env[WEBSITE_INSTANCE_ID];
39
40
  const functionMemLimit = process.env[FUNCTIONS_MEM_LIMIT];
40
41
  attributes = {
41
- [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AZURE,
42
- [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AZURE_FUNCTIONS,
43
- [SEMRESATTRS_CLOUD_REGION]: process.env[REGION_NAME],
44
- [SEMRESATTRS_PROCESS_PID]: process.pid,
42
+ [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AZURE,
43
+ [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AZURE_FUNCTIONS,
44
+ [ATTR_CLOUD_REGION]: process.env[REGION_NAME],
45
+ [ATTR_PROCESS_PID]: process.pid,
45
46
  };
46
47
  if (serviceName) {
47
48
  attributes = {
48
49
  ...attributes,
49
- [SEMRESATTRS_SERVICE_NAME]: serviceName,
50
+ [ATTR_SERVICE_NAME]: serviceName,
50
51
  };
51
52
  }
52
53
  if (functionInstance) {
53
54
  attributes = {
54
55
  ...attributes,
55
- [SEMRESATTRS_FAAS_INSTANCE]: functionInstance,
56
+ [ATTR_FAAS_INSTANCE]: functionInstance,
56
57
  };
57
58
  }
58
59
  if (functionMemLimit) {
59
60
  attributes = {
60
61
  ...attributes,
61
- [SEMRESATTRS_FAAS_MAX_MEMORY]: functionMemLimit,
62
+ [ATTR_FAAS_MAX_MEMORY]: functionMemLimit,
62
63
  };
63
64
  }
64
65
  const azureResourceUri = getAzureResourceUri(serviceName);
@@ -1 +1 @@
1
- {"version":3,"file":"AzureFunctionsDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureFunctionsDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B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gBAAgB;iBAC9C,CAAC;aACH;YACD,IAAI,gBAAgB,EAAE;gBACpB,UAAU,GAAG;oBACX,GAAG,UAAU;oBACb,CAAC,2BAA2B,CAAC,EAAE,gBAAgB;iBAChD,CAAC;aACH;YACD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;YAC1D,IAAI,gBAAgB,EAAE;gBACpB,UAAU,GAAG;oBACX,GAAG,UAAU;oBACb,GAAG,EAAE,CAAC,oCAAoC,CAAC,EAAE,gBAAgB,EAAE;iBAChE,CAAC;aACH;YAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CACvC,kCAAkC,CACnC,EAAE;gBACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAClC,IAAI,MAAM,EAAE;oBACV,UAAU,GAAG,EAAE,GAAG,UAAU,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;iBACtD;aACF;SACF;QACD,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,sBAAsB,EAAE,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\nimport { ResourceDetector, DetectedResource } from '@opentelemetry/resources';\nimport {\n SEMRESATTRS_FAAS_MAX_MEMORY,\n SEMRESATTRS_FAAS_INSTANCE,\n SEMRESATTRS_CLOUD_PROVIDER,\n SEMRESATTRS_CLOUD_PLATFORM,\n SEMRESATTRS_CLOUD_REGION,\n CLOUDPROVIDERVALUES_AZURE,\n CLOUDPLATFORMVALUES_AZURE_FUNCTIONS,\n SEMRESATTRS_SERVICE_NAME,\n SEMRESATTRS_PROCESS_PID,\n} from '@opentelemetry/semantic-conventions';\nimport {\n WEBSITE_SITE_NAME,\n WEBSITE_INSTANCE_ID,\n FUNCTIONS_MEM_LIMIT,\n REGION_NAME,\n CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,\n} from '../types';\nimport { getAzureResourceUri, isAzureFunction } from '../utils';\n\nconst AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = {\n [SEMRESATTRS_SERVICE_NAME]: WEBSITE_SITE_NAME,\n [SEMRESATTRS_FAAS_INSTANCE]: WEBSITE_INSTANCE_ID,\n [SEMRESATTRS_FAAS_MAX_MEMORY]: FUNCTIONS_MEM_LIMIT,\n};\n\n/**\n * The AzureFunctionsDetector can be used to detect if a process is running in Azure Functions\n * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails.\n */\nclass AzureFunctionsDetector implements ResourceDetector {\n detect(): DetectedResource {\n let attributes = {};\n const serviceName = process.env[WEBSITE_SITE_NAME];\n\n /**\n * Checks that we are operating within an Azure Function using the function version since WEBSITE_SITE_NAME\n * will exist in Azure App Service as well and detectors should be mutually exclusive.\n * If the function version is not present, we check for the website sku to determine if it is a function.\n */\n if (serviceName && isAzureFunction()) {\n const functionInstance = process.env[WEBSITE_INSTANCE_ID];\n const functionMemLimit = process.env[FUNCTIONS_MEM_LIMIT];\n\n attributes = {\n [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AZURE,\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AZURE_FUNCTIONS,\n [SEMRESATTRS_CLOUD_REGION]: process.env[REGION_NAME],\n [SEMRESATTRS_PROCESS_PID]: process.pid,\n };\n\n if (serviceName) {\n attributes = {\n ...attributes,\n [SEMRESATTRS_SERVICE_NAME]: serviceName,\n };\n }\n if (functionInstance) {\n attributes = {\n ...attributes,\n [SEMRESATTRS_FAAS_INSTANCE]: functionInstance,\n };\n }\n if (functionMemLimit) {\n attributes = {\n ...attributes,\n [SEMRESATTRS_FAAS_MAX_MEMORY]: functionMemLimit,\n };\n }\n const azureResourceUri = getAzureResourceUri(serviceName);\n if (azureResourceUri) {\n attributes = {\n ...attributes,\n ...{ [CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: azureResourceUri },\n };\n }\n\n for (const [key, value] of Object.entries(\n AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS\n )) {\n const envVar = process.env[value];\n if (envVar) {\n attributes = { ...attributes, ...{ [key]: envVar } };\n }\n }\n }\n return { attributes };\n }\n}\n\nexport const azureFunctionsDetector = new AzureFunctionsDetector();\n"]}
1
+ {"version":3,"file":"AzureFunctionsDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureFunctionsDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACnB,oCAAoC,EACpC,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,oCAAoC,GACrC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhE,MAAM,kCAAkC,GAAG;IACzC,CAAC,iBAAiB,CAAC,EAAE,iBAAiB;IACtC,CAAC,kBAAkB,CAAC,EAAE,mBAAmB;IACzC,CAAC,oBAAoB,CAAC,EAAE,mBAAmB;CAC5C,CAAC;AAEF;;;GAGG;AACH,MAAM,sBAAsB;IAC1B,MAAM;QACJ,IAAI,UAAU,GA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K,CAAC,CAAC;gBAClC,IAAI,MAAM,EAAE;oBACV,UAAU,GAAG,EAAE,GAAG,UAAU,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;iBACtD;aACF;SACF;QACD,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,sBAAsB,EAAE,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\nimport { ResourceDetector, DetectedResource } from '@opentelemetry/resources';\nimport { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';\nimport {\n ATTR_FAAS_MAX_MEMORY,\n ATTR_FAAS_INSTANCE,\n ATTR_CLOUD_PROVIDER,\n CLOUD_PROVIDER_VALUE_AZURE,\n ATTR_CLOUD_PLATFORM,\n CLOUD_PLATFORM_VALUE_AZURE_FUNCTIONS,\n ATTR_CLOUD_REGION,\n ATTR_PROCESS_PID,\n} from '../semconv';\nimport {\n WEBSITE_SITE_NAME,\n WEBSITE_INSTANCE_ID,\n FUNCTIONS_MEM_LIMIT,\n REGION_NAME,\n CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,\n} from '../types';\nimport { getAzureResourceUri, isAzureFunction } from '../utils';\n\nconst AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = {\n [ATTR_SERVICE_NAME]: WEBSITE_SITE_NAME,\n [ATTR_FAAS_INSTANCE]: WEBSITE_INSTANCE_ID,\n [ATTR_FAAS_MAX_MEMORY]: FUNCTIONS_MEM_LIMIT,\n};\n\n/**\n * The AzureFunctionsDetector can be used to detect if a process is running in Azure Functions\n * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails.\n */\nclass AzureFunctionsDetector implements ResourceDetector {\n detect(): DetectedResource {\n let attributes = {};\n const serviceName = process.env[WEBSITE_SITE_NAME];\n\n /**\n * Checks that we are operating within an Azure Function using the function version since WEBSITE_SITE_NAME\n * will exist in Azure App Service as well and detectors should be mutually exclusive.\n * If the function version is not present, we check for the website sku to determine if it is a function.\n */\n if (serviceName && isAzureFunction()) {\n const functionInstance = process.env[WEBSITE_INSTANCE_ID];\n const functionMemLimit = process.env[FUNCTIONS_MEM_LIMIT];\n\n attributes = {\n [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AZURE,\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AZURE_FUNCTIONS,\n [ATTR_CLOUD_REGION]: process.env[REGION_NAME],\n [ATTR_PROCESS_PID]: process.pid,\n };\n\n if (serviceName) {\n attributes = {\n ...attributes,\n [ATTR_SERVICE_NAME]: serviceName,\n };\n }\n if (functionInstance) {\n attributes = {\n ...attributes,\n [ATTR_FAAS_INSTANCE]: functionInstance,\n };\n }\n if (functionMemLimit) {\n attributes = {\n ...attributes,\n [ATTR_FAAS_MAX_MEMORY]: functionMemLimit,\n };\n }\n const azureResourceUri = getAzureResourceUri(serviceName);\n if (azureResourceUri) {\n attributes = {\n ...attributes,\n ...{ [CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: azureResourceUri },\n };\n }\n\n for (const [key, value] of Object.entries(\n AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS\n )) {\n const envVar = process.env[value];\n if (envVar) {\n attributes = { ...attributes, ...{ [key]: envVar } };\n }\n }\n }\n return { attributes };\n }\n}\n\nexport const azureFunctionsDetector = new AzureFunctionsDetector();\n"]}
@@ -16,7 +16,7 @@
16
16
  import * as http from 'http';
17
17
  import { context, diag } from '@opentelemetry/api';
18
18
  import { suppressTracing } from '@opentelemetry/core';
19
- import { CLOUDPLATFORMVALUES_AZURE_VM, CLOUDPROVIDERVALUES_AZURE, SEMRESATTRS_CLOUD_PLATFORM, SEMRESATTRS_CLOUD_PROVIDER, SEMRESATTRS_CLOUD_REGION, SEMRESATTRS_HOST_ID, SEMRESATTRS_HOST_NAME, SEMRESATTRS_HOST_TYPE, SEMRESATTRS_OS_VERSION, } from '@opentelemetry/semantic-conventions';
19
+ import { ATTR_CLOUD_PLATFORM, CLOUD_PLATFORM_VALUE_AZURE_VM, ATTR_CLOUD_PROVIDER, CLOUD_PROVIDER_VALUE_AZURE, ATTR_CLOUD_REGION, ATTR_HOST_ID, ATTR_HOST_NAME, ATTR_HOST_TYPE, ATTR_OS_VERSION, } from '../semconv';
20
20
  import { CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE, AZURE_VM_METADATA_HOST, AZURE_VM_METADATA_PATH, AZURE_VM_SCALE_SET_NAME_ATTRIBUTE, AZURE_VM_SKU_ATTRIBUTE, } from '../types';
21
21
  /**
22
22
  * The AzureVmDetector can be used to detect if a process is running in an Azure VM.
@@ -28,14 +28,14 @@ class AzureVmResourceDetector {
28
28
  const attrNames = [
29
29
  AZURE_VM_SCALE_SET_NAME_ATTRIBUTE,
30
30
  AZURE_VM_SKU_ATTRIBUTE,
31
- SEMRESATTRS_CLOUD_PLATFORM,
32
- SEMRESATTRS_CLOUD_PROVIDER,
33
- SEMRESATTRS_CLOUD_REGION,
31
+ ATTR_CLOUD_PLATFORM,
32
+ ATTR_CLOUD_PROVIDER,
33
+ ATTR_CLOUD_REGION,
34
34
  CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,
35
- SEMRESATTRS_HOST_ID,
36
- SEMRESATTRS_HOST_NAME,
37
- SEMRESATTRS_HOST_TYPE,
38
- SEMRESATTRS_OS_VERSION,
35
+ ATTR_HOST_ID,
36
+ ATTR_HOST_NAME,
37
+ ATTR_HOST_TYPE,
38
+ ATTR_OS_VERSION,
39
39
  ];
40
40
  const attributes = {};
41
41
  attrNames.forEach(name => {
@@ -89,14 +89,14 @@ class AzureVmResourceDetector {
89
89
  const attributes = {
90
90
  [AZURE_VM_SCALE_SET_NAME_ATTRIBUTE]: metadata['vmScaleSetName'],
91
91
  [AZURE_VM_SKU_ATTRIBUTE]: metadata['sku'],
92
- [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AZURE_VM,
93
- [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AZURE,
94
- [SEMRESATTRS_CLOUD_REGION]: metadata['location'],
92
+ [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AZURE_VM,
93
+ [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AZURE,
94
+ [ATTR_CLOUD_REGION]: metadata['location'],
95
95
  [CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: metadata['resourceId'],
96
- [SEMRESATTRS_HOST_ID]: metadata['vmId'],
97
- [SEMRESATTRS_HOST_NAME]: metadata['name'],
98
- [SEMRESATTRS_HOST_TYPE]: metadata['vmSize'],
99
- [SEMRESATTRS_OS_VERSION]: metadata['version'],
96
+ [ATTR_HOST_ID]: metadata['vmId'],
97
+ [ATTR_HOST_NAME]: metadata['name'],
98
+ [ATTR_HOST_TYPE]: metadata['vmSize'],
99
+ [ATTR_OS_VERSION]: metadata['version'],
100
100
  };
101
101
  return attributes;
102
102
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AzureVmDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureVmDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAMtD,OAAO,EACL,4BAA4B,EAC5B,yBAAy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,iCAAiC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC;gBAC/D,CAAC,sBAAsB,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC;gBACzC,CAAC,0BAA0B,CAAC,EAAE,4BAA4B;gBAC1D,CAAC,0BAA0B,CAAC,EAAE,yBAAyB;gBACvD,CAAC,wBAAwB,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC;gBAChD,CAAC,oCAAoC,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC;gBAC9D,CAAC,mBAAmB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;gBACvC,CAAC,qBAAqB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;gBACzC,CAAC,qBAAqB,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC;gBAC3C,CAAC,sBAAsB,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;aAC9C,CAAC;YACF,OAAO,UAAU,CAAC;SACnB;QAAC,OAAO,GAAQ,EAAE;YACjB,IAAI,CAAC,KAAK,CACR,sDAAsD,EACtD,GAAG,CAAC,OAAO,CACZ,CAAC;YACF,OAAO,EAAE,CAAC;SACX;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,uBAAuB,EAAE,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\nimport * as http from 'http';\n\nimport { context, diag } from '@opentelemetry/api';\nimport { suppressTracing } from '@opentelemetry/core';\nimport {\n ResourceDetector,\n DetectedResource,\n DetectedResourceAttributes,\n} from '@opentelemetry/resources';\nimport {\n CLOUDPLATFORMVALUES_AZURE_VM,\n CLOUDPROVIDERVALUES_AZURE,\n SEMRESATTRS_CLOUD_PLATFORM,\n SEMRESATTRS_CLOUD_PROVIDER,\n SEMRESATTRS_CLOUD_REGION,\n SEMRESATTRS_HOST_ID,\n SEMRESATTRS_HOST_NAME,\n SEMRESATTRS_HOST_TYPE,\n SEMRESATTRS_OS_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport {\n CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,\n AZURE_VM_METADATA_HOST,\n AZURE_VM_METADATA_PATH,\n AZURE_VM_SCALE_SET_NAME_ATTRIBUTE,\n AZURE_VM_SKU_ATTRIBUTE,\n AzureVmMetadata,\n} from '../types';\n\n/**\n * The AzureVmDetector can be used to detect if a process is running in an Azure VM.\n * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails.\n */\nclass AzureVmResourceDetector implements ResourceDetector {\n detect(): DetectedResource {\n const dataPromise = context.with(suppressTracing(context.active()), () =>\n this.getAzureVmMetadata()\n );\n\n const attrNames = [\n AZURE_VM_SCALE_SET_NAME_ATTRIBUTE,\n AZURE_VM_SKU_ATTRIBUTE,\n SEMRESATTRS_CLOUD_PLATFORM,\n SEMRESATTRS_CLOUD_PROVIDER,\n SEMRESATTRS_CLOUD_REGION,\n CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,\n SEMRESATTRS_HOST_ID,\n SEMRESATTRS_HOST_NAME,\n SEMRESATTRS_HOST_TYPE,\n SEMRESATTRS_OS_VERSION,\n ];\n\n const attributes = {} as DetectedResourceAttributes;\n attrNames.forEach(name => {\n // Each resource attribute is determined asynchronously in _gatherData().\n attributes[name] = dataPromise.then(data => data[name]);\n });\n\n return { attributes };\n }\n\n async getAzureVmMetadata(): Promise<DetectedResourceAttributes> {\n try {\n const options = {\n host: AZURE_VM_METADATA_HOST,\n path: AZURE_VM_METADATA_PATH,\n method: 'GET',\n timeout: 5000,\n headers: {\n Metadata: 'True',\n },\n };\n const metadata: AzureVmMetadata = await new Promise((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n req.destroy();\n reject(new Error('Azure metadata service request timed out.'));\n }, 1000);\n\n const req = http.request(options, res => {\n clearTimeout(timeoutId);\n const { statusCode } = res;\n res.setEncoding('utf8');\n let rawData = '';\n res.on('data', chunk => (rawData += chunk));\n res.on('end', () => {\n if (statusCode && statusCode >= 200 && statusCode < 300) {\n try {\n resolve(JSON.parse(rawData));\n } catch (error) {\n reject(error);\n }\n } else {\n reject(\n new Error('Failed to load page, status code: ' + statusCode)\n );\n }\n });\n });\n req.on('error', err => {\n clearTimeout(timeoutId);\n reject(err);\n });\n req.end();\n });\n\n const attributes = {\n [AZURE_VM_SCALE_SET_NAME_ATTRIBUTE]: metadata['vmScaleSetName'],\n [AZURE_VM_SKU_ATTRIBUTE]: metadata['sku'],\n [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AZURE_VM,\n [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AZURE,\n [SEMRESATTRS_CLOUD_REGION]: metadata['location'],\n [CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: metadata['resourceId'],\n [SEMRESATTRS_HOST_ID]: metadata['vmId'],\n [SEMRESATTRS_HOST_NAME]: metadata['name'],\n [SEMRESATTRS_HOST_TYPE]: metadata['vmSize'],\n [SEMRESATTRS_OS_VERSION]: metadata['version'],\n };\n return attributes;\n } catch (err: any) {\n diag.debug(\n 'AzureVmResourceDetector: not running in an Azure VM:',\n err.message\n );\n return {};\n }\n }\n}\n\nexport const azureVmDetector = new AzureVmResourceDetector();\n"]}
1
+ {"version":3,"file":"AzureVmDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureVmDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oB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AAE,CAAC;YACZ,CAAC,CAAC,CAAC;YAEH,MAAM,UAAU,GAAG;gBACjB,CAAC,iCAAiC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC;gBAC/D,CAAC,sBAAsB,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC;gBACzC,CAAC,mBAAmB,CAAC,EAAE,6BAA6B;gBACpD,CAAC,mBAAmB,CAAC,EAAE,0BAA0B;gBACjD,CAAC,iBAAiB,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC;gBACzC,CAAC,oCAAoC,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC;gBAC9D,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;gBAChC,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;gBAClC,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC;gBACpC,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;aACvC,CAAC;YACF,OAAO,UAAU,CAAC;SACnB;QAAC,OAAO,GAAQ,EAAE;YACjB,IAAI,CAAC,KAAK,CACR,sDAAsD,EACtD,GAAG,CAAC,OAAO,CACZ,CAAC;YACF,OAAO,EAAE,CAAC;SACX;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,uBAAuB,EAAE,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\nimport * as http from 'http';\n\nimport { context, diag } from '@opentelemetry/api';\nimport { suppressTracing } from '@opentelemetry/core';\nimport {\n ResourceDetector,\n DetectedResource,\n DetectedResourceAttributes,\n} from '@opentelemetry/resources';\nimport {\n ATTR_CLOUD_PLATFORM,\n CLOUD_PLATFORM_VALUE_AZURE_VM,\n ATTR_CLOUD_PROVIDER,\n CLOUD_PROVIDER_VALUE_AZURE,\n ATTR_CLOUD_REGION,\n ATTR_HOST_ID,\n ATTR_HOST_NAME,\n ATTR_HOST_TYPE,\n ATTR_OS_VERSION,\n} from '../semconv';\nimport {\n CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,\n AZURE_VM_METADATA_HOST,\n AZURE_VM_METADATA_PATH,\n AZURE_VM_SCALE_SET_NAME_ATTRIBUTE,\n AZURE_VM_SKU_ATTRIBUTE,\n AzureVmMetadata,\n} from '../types';\n\n/**\n * The AzureVmDetector can be used to detect if a process is running in an Azure VM.\n * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails.\n */\nclass AzureVmResourceDetector implements ResourceDetector {\n detect(): DetectedResource {\n const dataPromise = context.with(suppressTracing(context.active()), () =>\n this.getAzureVmMetadata()\n );\n\n const attrNames = [\n AZURE_VM_SCALE_SET_NAME_ATTRIBUTE,\n AZURE_VM_SKU_ATTRIBUTE,\n ATTR_CLOUD_PLATFORM,\n ATTR_CLOUD_PROVIDER,\n ATTR_CLOUD_REGION,\n CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,\n ATTR_HOST_ID,\n ATTR_HOST_NAME,\n ATTR_HOST_TYPE,\n ATTR_OS_VERSION,\n ];\n\n const attributes = {} as DetectedResourceAttributes;\n attrNames.forEach(name => {\n // Each resource attribute is determined asynchronously in _gatherData().\n attributes[name] = dataPromise.then(data => data[name]);\n });\n\n return { attributes };\n }\n\n async getAzureVmMetadata(): Promise<DetectedResourceAttributes> {\n try {\n const options = {\n host: AZURE_VM_METADATA_HOST,\n path: AZURE_VM_METADATA_PATH,\n method: 'GET',\n timeout: 5000,\n headers: {\n Metadata: 'True',\n },\n };\n const metadata: AzureVmMetadata = await new Promise((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n req.destroy();\n reject(new Error('Azure metadata service request timed out.'));\n }, 1000);\n\n const req = http.request(options, res => {\n clearTimeout(timeoutId);\n const { statusCode } = res;\n res.setEncoding('utf8');\n let rawData = '';\n res.on('data', chunk => (rawData += chunk));\n res.on('end', () => {\n if (statusCode && statusCode >= 200 && statusCode < 300) {\n try {\n resolve(JSON.parse(rawData));\n } catch (error) {\n reject(error);\n }\n } else {\n reject(\n new Error('Failed to load page, status code: ' + statusCode)\n );\n }\n });\n });\n req.on('error', err => {\n clearTimeout(timeoutId);\n reject(err);\n });\n req.end();\n });\n\n const attributes = {\n [AZURE_VM_SCALE_SET_NAME_ATTRIBUTE]: metadata['vmScaleSetName'],\n [AZURE_VM_SKU_ATTRIBUTE]: metadata['sku'],\n [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AZURE_VM,\n [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AZURE,\n [ATTR_CLOUD_REGION]: metadata['location'],\n [CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: metadata['resourceId'],\n [ATTR_HOST_ID]: metadata['vmId'],\n [ATTR_HOST_NAME]: metadata['name'],\n [ATTR_HOST_TYPE]: metadata['vmSize'],\n [ATTR_OS_VERSION]: metadata['version'],\n };\n return attributes;\n } catch (err: any) {\n diag.debug(\n 'AzureVmResourceDetector: not running in an Azure VM:',\n err.message\n );\n return {};\n }\n }\n}\n\nexport const azureVmDetector = new AzureVmResourceDetector();\n"]}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * The cloud platform in use.
3
+ *
4
+ * @note The prefix of the service **SHOULD** match the one specified in `cloud.provider`.
5
+ *
6
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
7
+ */
8
+ export declare const ATTR_CLOUD_PLATFORM: "cloud.platform";
9
+ /**
10
+ * Name of the cloud provider.
11
+ *
12
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
13
+ */
14
+ export declare const ATTR_CLOUD_PROVIDER: "cloud.provider";
15
+ /**
16
+ * 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.
17
+ *
18
+ * @example us-central1
19
+ * @example us-east-1
20
+ *
21
+ * @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).
22
+ *
23
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
24
+ */
25
+ export declare const ATTR_CLOUD_REGION: "cloud.region";
26
+ /**
27
+ * Name of the [deployment environment](https://wikipedia.org/wiki/Deployment_environment) (aka deployment tier).
28
+ *
29
+ * @example staging
30
+ * @example production
31
+ *
32
+ * @note `deployment.environment.name` does not affect the uniqueness constraints defined through
33
+ * the `service.namespace`, `service.name` and `service.instance.id` resource attributes.
34
+ * This implies that resources carrying the following attribute combinations **MUST** be
35
+ * considered to be identifying the same service:
36
+ *
37
+ * - `service.name=frontend`, `deployment.environment.name=production`
38
+ * - `service.name=frontend`, `deployment.environment.name=staging`.
39
+ *
40
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
41
+ */
42
+ export declare const ATTR_DEPLOYMENT_ENVIRONMENT_NAME: "deployment.environment.name";
43
+ /**
44
+ * The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version.
45
+ *
46
+ * @example 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de
47
+ *
48
+ * @note - **AWS Lambda:** Use the (full) log stream name.
49
+ *
50
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
51
+ */
52
+ export declare const ATTR_FAAS_INSTANCE: "faas.instance";
53
+ /**
54
+ * The amount of memory available to the serverless function converted to Bytes.
55
+ *
56
+ * @example 134217728
57
+ *
58
+ * @note It's recommended to set this attribute since e.g. too little memory can easily stop a Java AWS Lambda function from working correctly. On AWS Lambda, the environment variable `AWS_LAMBDA_FUNCTION_MEMORY_SIZE` provides this information (which must be multiplied by 1,048,576).
59
+ *
60
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
61
+ */
62
+ export declare const ATTR_FAAS_MAX_MEMORY: "faas.max_memory";
63
+ /**
64
+ * 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.
65
+ *
66
+ * @example fdbf79e8af94cb7f9e8df36789187052
67
+ *
68
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
69
+ */
70
+ export declare const ATTR_HOST_ID: "host.id";
71
+ /**
72
+ * 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.
73
+ *
74
+ * @example opentelemetry-test
75
+ *
76
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
77
+ */
78
+ export declare const ATTR_HOST_NAME: "host.name";
79
+ /**
80
+ * Type of host. For Cloud, this must be the machine type.
81
+ *
82
+ * @example n1-standard-1
83
+ *
84
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
85
+ */
86
+ export declare const ATTR_HOST_TYPE: "host.type";
87
+ /**
88
+ * The version string of the operating system as defined in [Version Attributes](/docs/resource/README.md#version-attributes).
89
+ *
90
+ * @example 14.2.1
91
+ * @example 18.04.1
92
+ *
93
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
94
+ */
95
+ export declare const ATTR_OS_VERSION: "os.version";
96
+ /**
97
+ * Process identifier (PID).
98
+ *
99
+ * @example 1234
100
+ *
101
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
102
+ */
103
+ export declare const ATTR_PROCESS_PID: "process.pid";
104
+ /**
105
+ * The string ID of the service instance.
106
+ *
107
+ * @example 627cc493-f310-47de-96bd-71410b7dec09
108
+ *
109
+ * @note **MUST** be unique for each instance of the same `service.namespace,service.name` pair (in other words
110
+ * `service.namespace,service.name,service.instance.id` triplet **MUST** be globally unique). The ID helps to
111
+ * distinguish instances of the same service that exist at the same time (e.g. instances of a horizontally scaled
112
+ * service).
113
+ *
114
+ * Implementations, such as SDKs, are recommended to generate a random Version 1 or Version 4 [RFC
115
+ * 4122](https://www.ietf.org/rfc/rfc4122.txt) UUID, but are free to use an inherent unique ID as the source of
116
+ * this value if stability is desirable. In that case, the ID **SHOULD** be used as source of a UUID Version 5 and
117
+ * **SHOULD** use the following UUID as the namespace: `4d63009a-8d0f-11ee-aad7-4c796ed8e320`.
118
+ *
119
+ * UUIDs are typically recommended, as only an opaque value for the purposes of identifying a service instance is
120
+ * needed. Similar to what can be seen in the man page for the
121
+ * [`/etc/machine-id`](https://www.freedesktop.org/software/systemd/man/latest/machine-id.html) file, the underlying
122
+ * data, such as pod name and namespace should be treated as confidential, being the user's choice to expose it
123
+ * or not via another resource attribute.
124
+ *
125
+ * For applications running behind an application server (like unicorn), we do not recommend using one identifier
126
+ * for all processes participating in the application. Instead, it's recommended each division (e.g. a worker
127
+ * thread in unicorn) to have its own instance.id.
128
+ *
129
+ * It's not recommended for a Collector to set `service.instance.id` if it can't unambiguously determine the
130
+ * service instance that is generating that telemetry. For instance, creating an UUID based on `pod.name` will
131
+ * likely be wrong, as the Collector might not know from which container within that pod the telemetry originated.
132
+ * However, Collectors can set the `service.instance.id` if they can unambiguously determine the service instance
133
+ * for that telemetry. This is typically the case for scraping receivers, as they know the target address and
134
+ * port.
135
+ *
136
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
137
+ */
138
+ export declare const ATTR_SERVICE_INSTANCE_ID: "service.instance.id";
139
+ /**
140
+ * Enum value "azure.app_service" for attribute {@link ATTR_CLOUD_PLATFORM}.
141
+ *
142
+ * Azure App Service
143
+ *
144
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
145
+ */
146
+ export declare const CLOUD_PLATFORM_VALUE_AZURE_APP_SERVICE: "azure.app_service";
147
+ /**
148
+ * Enum value "azure.functions" for attribute {@link ATTR_CLOUD_PLATFORM}.
149
+ *
150
+ * Azure Functions
151
+ *
152
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
153
+ */
154
+ export declare const CLOUD_PLATFORM_VALUE_AZURE_FUNCTIONS: "azure.functions";
155
+ /**
156
+ * Enum value "azure.vm" for attribute {@link ATTR_CLOUD_PLATFORM}.
157
+ *
158
+ * Azure Virtual Machines
159
+ *
160
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
161
+ */
162
+ export declare const CLOUD_PLATFORM_VALUE_AZURE_VM: "azure.vm";
163
+ /**
164
+ * Enum value "azure" for attribute {@link ATTR_CLOUD_PROVIDER}.
165
+ *
166
+ * Microsoft Azure
167
+ *
168
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
169
+ */
170
+ export declare const CLOUD_PROVIDER_VALUE_AZURE: "azure";
171
+ //# sourceMappingURL=semconv.d.ts.map