@opentelemetry/resource-detector-azure 0.2.5 → 0.2.7

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/LICENSE CHANGED
@@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright [2020] OpenTelemetry Authors
189
+ Copyright [yyyy] [name of copyright owner]
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -27,48 +27,48 @@ 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).
31
+
30
32
  ### App Service Resource Detector
31
33
 
32
- | Attribute | Description |
34
+ | Resource Attribute | Description |
33
35
  |-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
34
- | azure.app.service.stamp | The specific "stamp" cluster within Azure where the App Service is running, e.g., "waws-prod-sn1-001". |
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`. |
35
37
  | cloud.platform | The cloud platform. Here, it's always "azure_app_service". |
36
38
  | cloud.provider | The cloud service provider. In this context, it's always "azure". |
37
- | 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}". |
38
- | cloud.region | The Azure region where the App Service is hosted, e.g., "East US", "West Europe", etc. |
39
- | deployment.environment | The deployment slot where the Azure App Service is running, such as "staging", "production", etc. |
40
- | host.id | The primary hostname for the app, excluding any custom hostnames. |
41
- | service.instance.id | The specific instance of the Azure App Service, useful in a scaled-out configuration. |
42
- | service.name | The name of the Azure App Service. |
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
+ | 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`. |
42
+ | host.id | The primary hostname for the app, excluding any custom hostnames. Value of Process Environment Variable `WEBSITE_HOSTNAME`. |
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
+ | service.name | The name of the Azure App Service. Value of Process Environment Variable `WEBSITE_SITE_NAME`. |
43
45
 
44
46
  ### VM Resource Detector
45
47
 
46
- | Attribute | Description |
47
- |--------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
48
- | azure.vm.scaleset.name | The name of the Virtual Machine Scale Set if the VM is part of one. |
49
- | 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". |
50
- | cloud.platform | The cloud platform, which is always set to "azure_vm" in this context. |
51
- | cloud.provider | The cloud service provider, which is always set to "azure" in this context. |
52
- | cloud.region | The Azure region where the Virtual Machine is hosted, such as "East US", "West Europe", etc. |
53
- | 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}". |
54
- | host.id | A unique identifier for the VM host, for instance, "02aab8a4-74ef-476e-8182-f6d2ba4166a6". |
55
- | host.name | The name of the host machine. |
56
- | host.type | The size of the VM instance, for example, "Standard_D2s_v3". |
57
- | os.type | The type of operating system running on the VM, such as "Linux" or "Windows". |
58
- | os.version | The version of the operating system running on the VM. |
59
- | service.instance.id | An identifier for a specific instance of the service running on the Azure VM, for example, "02aab8a4-74ef-476e-8182-f6d2ba4166a6". |
48
+ | Resource Attribute | Description |
49
+ |--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
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
+ | 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. |
53
+ | cloud.provider | The cloud service provider, which is always set to "azure" in this context. |
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
+ | 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.|
56
+ | host.id | A unique identifier for the VM host, for instance, "02aab8a4-74ef-476e-8182-f6d2ba4166a6". Value from `vmId` key on `/metadata/instance/compute` request. |
57
+ | host.name | The name of the host machine. Value from `name` key on `/metadata/instance/compute` request. |
58
+ | host.type | The size of the VM instance, for example, "Standard_D2s_v3". Value from `vmSize` key on `/metadata/instance/compute` request. |
59
+ | os.version | The version of the operating system running on the VM. Value from `version` key on `/metadata/instance/compute` request. |
60
60
 
61
61
  ### Azure Functions Resource Detector
62
62
 
63
- | Attribute | Description |
64
- |-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
65
- | cloud.platform | The cloud platform. Here, it's always "azure_functions". |
66
- | cloud.provider | The cloud service provider. In this context, it's always "azure". |
67
- | cloud.region | The Azure region where the Azure Function is hosted, e.g., "East US", "West Europe", etc. |
68
- | faas.instance | The specific instance of the Azure App Service, useful in a scaled-out configuration. |
69
- | faas.name | The name of the Azure App Service. |
70
- | faas.version | The version of the Azure Function being executed, e.g., "~4". |
71
- | faas.max_memory | The amount of memory available to the Azure Function expressed in MiB. |
63
+ | Resource Attribute | Description |
64
+ |-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
65
+ | cloud.platform | The cloud platform. Here, it's always "azure_functions". |
66
+ | cloud.provider | The cloud service provider. In this context, it's always "azure". |
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
+ | faas.instance | The specific instance of the Azure App Service, useful in a scaled-out configuration. Value from Process Environment Variable `WEBSITE_INSTANCE_ID`. |
69
+ | faas.max_memory | The amount of memory available to the Azure Function expressed in MiB. value from Process Environment Variable `WEBSITE_MEMORY_LIMIT_MB`. |
70
+ | faas.name | The name of the Azure App Service. Value from Process Environment Variable `WEBSITE_SITE_NAME`. |
71
+ | faas.version | The version of the Azure Function being executed, e.g., "~4". value from Process Environment Variable `FUNCTIONS_EXTENSION_VERSION`. |
72
72
 
73
73
  ## Useful links
74
74
 
@@ -20,10 +20,10 @@ const resources_1 = require("@opentelemetry/resources");
20
20
  const types_1 = require("../types");
21
21
  const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
22
22
  const APP_SERVICE_ATTRIBUTE_ENV_VARS = {
23
- [semantic_conventions_1.SemanticResourceAttributes.CLOUD_REGION]: types_1.REGION_NAME,
24
- [semantic_conventions_1.SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: types_1.WEBSITE_SLOT_NAME,
25
- [semantic_conventions_1.SemanticResourceAttributes.HOST_ID]: types_1.WEBSITE_HOSTNAME,
26
- [semantic_conventions_1.SemanticResourceAttributes.SERVICE_INSTANCE_ID]: types_1.WEBSITE_INSTANCE_ID,
23
+ [semantic_conventions_1.SEMRESATTRS_CLOUD_REGION]: types_1.REGION_NAME,
24
+ [semantic_conventions_1.SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: types_1.WEBSITE_SLOT_NAME,
25
+ [semantic_conventions_1.SEMRESATTRS_HOST_ID]: types_1.WEBSITE_HOSTNAME,
26
+ [semantic_conventions_1.SEMRESATTRS_SERVICE_INSTANCE_ID]: types_1.WEBSITE_INSTANCE_ID,
27
27
  [types_1.AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE]: types_1.WEBSITE_HOME_STAMPNAME,
28
28
  };
29
29
  /**
@@ -36,9 +36,9 @@ class AzureAppServiceDetector {
36
36
  const websiteSiteName = process.env[types_1.WEBSITE_SITE_NAME];
37
37
  const isAzureFunction = !!process.env[types_1.FUNCTIONS_VERSION];
38
38
  if (websiteSiteName && !isAzureFunction) {
39
- attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: websiteSiteName });
40
- attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SemanticResourceAttributes.CLOUD_PROVIDER]: semantic_conventions_1.CloudProviderValues.AZURE });
41
- attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SemanticResourceAttributes.CLOUD_PLATFORM]: semantic_conventions_1.CloudPlatformValues.AZURE_APP_SERVICE });
39
+ attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SEMRESATTRS_SERVICE_NAME]: websiteSiteName });
40
+ attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SEMRESATTRS_CLOUD_PROVIDER]: semantic_conventions_1.CLOUDPROVIDERVALUES_AZURE });
41
+ attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM]: semantic_conventions_1.CLOUDPLATFORMVALUES_AZURE_APP_SERVICE });
42
42
  const azureResourceUri = this.getAzureResourceUri(websiteSiteName);
43
43
  if (azureResourceUri) {
44
44
  attributes = Object.assign(Object.assign({}, attributes), { [types_1.CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: azureResourceUri });
@@ -1 +1 @@
1
- {"version":3,"file":"AzureAppServiceDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureAppServiceDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,wDAA6E;AAC7E,oCAYkB;AAClB,8EAI6C;AAE7C,MAAM,8BAA8B,GAAG;IACrC,CAAC,iDAA0B,CAAC,YAAY,CAAC,EAAE,mBAAW;IACtD,CAAC,iDAA0B,CAAC,sBAAsB,CAAC,EAAE,yBAAiB;IACtE,CAAC,iDAA0B,CAAC,OAAO,CAAC,EAAE,wBAAgB;IACtD,CAAC,iDAA0B,CAAC,mBAAmB,CAAC,EAAE,2BAAmB;IACrE,CAAC,kDAA0C,CAAC,EAAE,8BAAsB;CACrE,CAAC;AAEF;;;GAGG;AACH,MAAM,uBAAuB;IAC3B,MAAM;QACJ,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;QACvD,MAAM,eAAe,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;QACzD,IAAI,eAAe,IAAI,CAAC,eAAe,EAAE;YACvC,UAAU,mCACL,UAAU,KACb,CAAC,iDAA0B,CAAC,YAAY,CAAC,EAAE,eAAe,GAC3D,CAAC;YACF,UAAU,mCACL,UAAU,KACb,CAAC,iDAA0B,CAAC,cAAc,CAAC,EAAE,0CAAmB,CAAC,KAAK,GACvE,CAAC;YACF,UAAU,mCACL,UAAU,KACb,CAAC,iDAA0B,CAAC,cAAc,CAAC,EACzC,0CAAmB,CAAC,iBAAiB,GACxC,CAAC;YAEF,MAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;YACnE,IAAI,gBAAgB,EAAE;gBACpB,UAAU,mCACL,UAAU,GACV,EAAE,CAAC,4CAAoC,CAAC,EAAE,gBAAgB,EAAE,CAChE,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,mCAAQ,UAAU,GAAK,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAE,CAAC;iBACtD;aACF;SACF;QACD,OAAO,IAAI,oBAAQ,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;IAEO,mBAAmB,CAAC,eAAuB;QACjD,MAAM,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,8BAAsB,CAAC,CAAC;QACjE,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,0BAAkB,CAAC,CAAC;QAEzD,IAAI,cAAc,GAAG,gBAAgB,CAAC;QACtC,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;YAC5D,cAAc,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACjD;QAED,IAAI,CAAC,cAAc,IAAI,CAAC,gBAAgB,EAAE;YACxC,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,kBAAkB,cAAc,mBAAmB,oBAAoB,kCAAkC,eAAe,EAAE,CAAC;IACpI,CAAC;CACF;AAEY,QAAA,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 { DetectorSync, IResource, Resource } 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_OWNER_NAME,\n WEBSITE_RESOURCE_GROUP,\n WEBSITE_SITE_NAME,\n WEBSITE_SLOT_NAME,\n CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,\n FUNCTIONS_VERSION,\n} from '../types';\nimport {\n CloudProviderValues,\n CloudPlatformValues,\n SemanticResourceAttributes,\n} from '@opentelemetry/semantic-conventions';\n\nconst APP_SERVICE_ATTRIBUTE_ENV_VARS = {\n [SemanticResourceAttributes.CLOUD_REGION]: REGION_NAME,\n [SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: WEBSITE_SLOT_NAME,\n [SemanticResourceAttributes.HOST_ID]: WEBSITE_HOSTNAME,\n [SemanticResourceAttributes.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 DetectorSync {\n detect(): IResource {\n let attributes = {};\n const websiteSiteName = process.env[WEBSITE_SITE_NAME];\n const isAzureFunction = !!process.env[FUNCTIONS_VERSION];\n if (websiteSiteName && !isAzureFunction) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.SERVICE_NAME]: websiteSiteName,\n };\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AZURE,\n };\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.CLOUD_PLATFORM]:\n CloudPlatformValues.AZURE_APP_SERVICE,\n };\n\n const azureResourceUri = this.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 new Resource(attributes);\n }\n\n private getAzureResourceUri(websiteSiteName: string): string | undefined {\n const websiteResourceGroup = process.env[WEBSITE_RESOURCE_GROUP];\n const websiteOwnerName = process.env[WEBSITE_OWNER_NAME];\n\n let subscriptionId = websiteOwnerName;\n if (websiteOwnerName && websiteOwnerName.indexOf('+') !== -1) {\n subscriptionId = websiteOwnerName.split('+')[0];\n }\n\n if (!subscriptionId && !websiteOwnerName) {\n return undefined;\n }\n\n return `/subscriptions/${subscriptionId}/resourceGroups/${websiteResourceGroup}/providers/Microsoft.Web/sites/${websiteSiteName}`;\n }\n}\n\nexport const azureAppServiceDetector = new AzureAppServiceDetector();\n"]}
1
+ {"version":3,"file":"AzureAppServiceDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureAppServiceDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,wDAA6E;AAC7E,oCAYkB;AAClB,8EAU6C;AAE7C,MAAM,8BAA8B,GAAG;IACrC,CAAC,+CAAwB,CAAC,EAAE,mBAAW;IACvC,CAAC,yDAAkC,CAAC,EAAE,yBAAiB;IACvD,CAAC,0CAAmB,CAAC,EAAE,wBAAgB;IACvC,CAAC,sDAA+B,CAAC,EAAE,2BAAmB;IACtD,CAAC,kDAA0C,CAAC,EAAE,8BAAsB;CACrE,CAAC;AAEF;;;GAGG;AACH,MAAM,uBAAuB;IAC3B,MAAM;QACJ,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,MAAM,eAAe,GAAG,OAAO,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C5D,cAAc,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACjD;QAED,IAAI,CAAC,cAAc,IAAI,CAAC,gBAAgB,EAAE;YACxC,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,kBAAkB,cAAc,mBAAmB,oBAAoB,kCAAkC,eAAe,EAAE,CAAC;IACpI,CAAC;CACF;AAEY,QAAA,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 { DetectorSync, IResource, Resource } 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_OWNER_NAME,\n WEBSITE_RESOURCE_GROUP,\n WEBSITE_SITE_NAME,\n WEBSITE_SLOT_NAME,\n CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,\n FUNCTIONS_VERSION,\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';\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 DetectorSync {\n detect(): IResource {\n let attributes = {};\n const websiteSiteName = process.env[WEBSITE_SITE_NAME];\n const isAzureFunction = !!process.env[FUNCTIONS_VERSION];\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 = this.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 new Resource(attributes);\n }\n\n private getAzureResourceUri(websiteSiteName: string): string | undefined {\n const websiteResourceGroup = process.env[WEBSITE_RESOURCE_GROUP];\n const websiteOwnerName = process.env[WEBSITE_OWNER_NAME];\n\n let subscriptionId = websiteOwnerName;\n if (websiteOwnerName && websiteOwnerName.indexOf('+') !== -1) {\n subscriptionId = websiteOwnerName.split('+')[0];\n }\n\n if (!subscriptionId && !websiteOwnerName) {\n return undefined;\n }\n\n return `/subscriptions/${subscriptionId}/resourceGroups/${websiteResourceGroup}/providers/Microsoft.Web/sites/${websiteSiteName}`;\n }\n}\n\nexport const azureAppServiceDetector = new AzureAppServiceDetector();\n"]}
@@ -20,10 +20,10 @@ const resources_1 = require("@opentelemetry/resources");
20
20
  const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
21
21
  const types_1 = require("../types");
22
22
  const AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = {
23
- [semantic_conventions_1.SemanticResourceAttributes.FAAS_NAME]: types_1.WEBSITE_SITE_NAME,
24
- [semantic_conventions_1.SemanticResourceAttributes.FAAS_VERSION]: types_1.FUNCTIONS_VERSION,
25
- [semantic_conventions_1.SemanticResourceAttributes.FAAS_INSTANCE]: types_1.WEBSITE_INSTANCE_ID,
26
- [semantic_conventions_1.SemanticResourceAttributes.FAAS_MAX_MEMORY]: types_1.FUNCTIONS_MEM_LIMIT,
23
+ [semantic_conventions_1.SEMRESATTRS_FAAS_NAME]: types_1.WEBSITE_SITE_NAME,
24
+ [semantic_conventions_1.SEMRESATTRS_FAAS_VERSION]: types_1.FUNCTIONS_VERSION,
25
+ [semantic_conventions_1.SEMRESATTRS_FAAS_INSTANCE]: types_1.WEBSITE_INSTANCE_ID,
26
+ [semantic_conventions_1.SEMRESATTRS_FAAS_MAX_MEMORY]: types_1.FUNCTIONS_MEM_LIMIT,
27
27
  };
28
28
  /**
29
29
  * The AzureFunctionsDetector can be used to detect if a process is running in Azure Functions
@@ -38,21 +38,21 @@ class AzureFunctionsDetector {
38
38
  const functionInstance = process.env[types_1.WEBSITE_INSTANCE_ID];
39
39
  const functionMemLimit = process.env[types_1.FUNCTIONS_MEM_LIMIT];
40
40
  attributes = {
41
- [semantic_conventions_1.SemanticResourceAttributes.CLOUD_PROVIDER]: semantic_conventions_1.CloudProviderValues.AZURE,
42
- [semantic_conventions_1.SemanticResourceAttributes.CLOUD_PLATFORM]: semantic_conventions_1.CloudPlatformValues.AZURE_FUNCTIONS,
43
- [semantic_conventions_1.SemanticResourceAttributes.CLOUD_REGION]: process.env[types_1.REGION_NAME],
41
+ [semantic_conventions_1.SEMRESATTRS_CLOUD_PROVIDER]: semantic_conventions_1.CLOUDPROVIDERVALUES_AZURE,
42
+ [semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM]: semantic_conventions_1.CLOUDPLATFORMVALUES_AZURE_FUNCTIONS,
43
+ [semantic_conventions_1.SEMRESATTRS_CLOUD_REGION]: process.env[types_1.REGION_NAME],
44
44
  };
45
45
  if (functionName) {
46
- attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SemanticResourceAttributes.FAAS_NAME]: functionName });
46
+ attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SEMRESATTRS_FAAS_NAME]: functionName });
47
47
  }
48
48
  if (functionVersion) {
49
- attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SemanticResourceAttributes.FAAS_VERSION]: functionVersion });
49
+ attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SEMRESATTRS_FAAS_VERSION]: functionVersion });
50
50
  }
51
51
  if (functionInstance) {
52
- attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SemanticResourceAttributes.FAAS_INSTANCE]: functionInstance });
52
+ attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SEMRESATTRS_FAAS_INSTANCE]: functionInstance });
53
53
  }
54
54
  if (functionMemLimit) {
55
- attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SemanticResourceAttributes.FAAS_MAX_MEMORY]: functionMemLimit });
55
+ attributes = Object.assign(Object.assign({}, attributes), { [semantic_conventions_1.SEMRESATTRS_FAAS_MAX_MEMORY]: functionMemLimit });
56
56
  }
57
57
  for (const [key, value] of Object.entries(AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS)) {
58
58
  const envVar = process.env[value];
@@ -1 +1 @@
1
- {"version":3,"file":"AzureFunctionsDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureFunctionsDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,wDAA6E;AAE7E,8EAI6C;AAC7C,oCAMkB;AAElB,MAAM,kCAAkC,GAAG;IACzC,CAAC,iDAA0B,CAAC,SAAS,CAAC,EAAE,yBAAiB;IACzD,CAAC,iDAA0B,CAAC,YAAY,CAAC,EAAE,yBAAiB;IAC5D,CAAC,iDAA0B,CAAC,aAAa,CAAC,EAAE,2BAAmB;IAC/D,CAAC,iDAA0B,CAAC,eAAe,CAAC,EAAE,2BAAmB;CAClE,CAAC;AAEF;;;GAGG;AACH,MAAM,sBAAsB;IAC1B,MAAM;QACJ,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;QACpD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;QACvD,IAAI,YAAY,IAAI,eAAe,EAAE;YACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,2BAAmB,CAAC,CAAC;YAC1D,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,2BAAmB,CAAC,CAAC;YAE1D,UAAU,GAAG;gBACX,CAAC,iDAA0B,CAAC,cAAc,CAAC,EAAE,0CAAmB,CAAC,KAAK;gBACtE,CAAC,iDAA0B,CAAC,cAAc,CAAC,EACzC,0CAAmB,CAAC,eAAe;gBACrC,CAAC,iDAA0B,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAW,CAAC;aACpE,CAAC;YAEF,IAAI,YAAY,EAAE;gBAChB,UAAU,mCACL,UAAU,KACb,CAAC,iDAA0B,CAAC,SAAS,CAAC,EAAE,YAAY,GACrD,CAAC;aACH;YACD,IAAI,eAAe,EAAE;gBACnB,UAAU,mCACL,UAAU,KACb,CAAC,iDAA0B,CAAC,YAAY,CAAC,EAAE,eAAe,GAC3D,CAAC;aACH;YACD,IAAI,gBAAgB,EAAE;gBACpB,UAAU,mCACL,UAAU,KACb,CAAC,iDAA0B,CAAC,aAAa,CAAC,EAAE,gBAAgB,GAC7D,CAAC;aACH;YACD,IAAI,gBAAgB,EAAE;gBACpB,UAAU,mCACL,UAAU,KACb,CAAC,iDAA0B,CAAC,eAAe,CAAC,EAAE,gBAAgB,GAC/D,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,mCAAQ,UAAU,GAAK,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAE,CAAC;iBACtD;aACF;SACF;QACD,OAAO,IAAI,oBAAQ,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;CACF;AAEY,QAAA,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 { DetectorSync, IResource, Resource } from '@opentelemetry/resources';\n\nimport {\n CloudProviderValues,\n CloudPlatformValues,\n SemanticResourceAttributes,\n} from '@opentelemetry/semantic-conventions';\nimport {\n WEBSITE_SITE_NAME,\n FUNCTIONS_VERSION,\n WEBSITE_INSTANCE_ID,\n FUNCTIONS_MEM_LIMIT,\n REGION_NAME,\n} from '../types';\n\nconst AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = {\n [SemanticResourceAttributes.FAAS_NAME]: WEBSITE_SITE_NAME,\n [SemanticResourceAttributes.FAAS_VERSION]: FUNCTIONS_VERSION,\n [SemanticResourceAttributes.FAAS_INSTANCE]: WEBSITE_INSTANCE_ID,\n [SemanticResourceAttributes.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 DetectorSync {\n detect(): IResource {\n let attributes = {};\n const functionName = process.env[WEBSITE_SITE_NAME];\n const functionVersion = process.env[FUNCTIONS_VERSION];\n if (functionName && functionVersion) {\n const functionInstance = process.env[WEBSITE_INSTANCE_ID];\n const functionMemLimit = process.env[FUNCTIONS_MEM_LIMIT];\n\n attributes = {\n [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AZURE,\n [SemanticResourceAttributes.CLOUD_PLATFORM]:\n CloudPlatformValues.AZURE_FUNCTIONS,\n [SemanticResourceAttributes.CLOUD_REGION]: process.env[REGION_NAME],\n };\n\n if (functionName) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_NAME]: functionName,\n };\n }\n if (functionVersion) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_VERSION]: functionVersion,\n };\n }\n if (functionInstance) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_INSTANCE]: functionInstance,\n };\n }\n if (functionMemLimit) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_MAX_MEMORY]: functionMemLimit,\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 new Resource(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;;;AAEH,wDAA6E;AAE7E,8EAU6C;AAC7C,oCAMkB;AAElB,MAAM,kCAAkC,GAAG;IACzC,CAAC,4CAAqB,CAAC,EAAE,yBAAiB;IAC1C,CAAC,+CAAwB,CAAC,EAAE,yBAAiB;IAC7C,CAAC,gDAAyB,CAAC,EAAE,2BAAmB;IAChD,CAAC,kDAA2B,CAAC,EAAE,2BAAmB;CACnD,CAAC;AAEF;;;GAGG;AACH,MAAM,sBAAsB;IAC1B,MAAM;QACJ,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;QACpD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;QACvD,IAAI,YAAY,IAAI,eAAe,EAAE;YACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,2BAAmB,CAAC,CAAC;YAC1D,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,2BAAmB,CAAC,CAAC;YAE1D,UAAU,GAAG;gBACX,CAAC,iDAA0B,CAAC,EAAE,gDAAyB;gBACvD,CAAC,iDAA0B,CAAC,EAAE,0DAAmC;gBACjE,CAAC,+CAAwB,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAW,CAAC;aACrD,CAAC;YAEF,IAAI,YAAY,EAAE;gBAChB,UAAU,mCACL,UAAU,KACb,CAAC,4CAAqB,CAAC,EAAE,YAAY,GACtC,CAAC;aACH;YACD,IAAI,eAAe,EAAE;gBACnB,UAAU,mCACL,UAAU,KACb,CAAC,+CAAwB,CAAC,EAAE,eAAe,GAC5C,CAAC;aACH;YACD,IAAI,gBAAgB,EAAE;gBACpB,UAAU,mCACL,UAAU,KACb,CAAC,gDAAyB,CAAC,EAAE,gBAAgB,GAC9C,CAAC;aACH;YACD,IAAI,gBAAgB,EAAE;gBACpB,UAAU,mCACL,UAAU,KACb,CAAC,kDAA2B,CAAC,EAAE,gBAAgB,GAChD,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,mCAAQ,UAAU,GAAK,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAE,CAAC;iBACtD;aACF;SACF;QACD,OAAO,IAAI,oBAAQ,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;CACF;AAEY,QAAA,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 { DetectorSync, IResource, Resource } from '@opentelemetry/resources';\n\nimport {\n SEMRESATTRS_FAAS_NAME,\n SEMRESATTRS_FAAS_VERSION,\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} from '@opentelemetry/semantic-conventions';\nimport {\n WEBSITE_SITE_NAME,\n FUNCTIONS_VERSION,\n WEBSITE_INSTANCE_ID,\n FUNCTIONS_MEM_LIMIT,\n REGION_NAME,\n} from '../types';\n\nconst AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = {\n [SEMRESATTRS_FAAS_NAME]: WEBSITE_SITE_NAME,\n [SEMRESATTRS_FAAS_VERSION]: FUNCTIONS_VERSION,\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 DetectorSync {\n detect(): IResource {\n let attributes = {};\n const functionName = process.env[WEBSITE_SITE_NAME];\n const functionVersion = process.env[FUNCTIONS_VERSION];\n if (functionName && functionVersion) {\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 };\n\n if (functionName) {\n attributes = {\n ...attributes,\n [SEMRESATTRS_FAAS_NAME]: functionName,\n };\n }\n if (functionVersion) {\n attributes = {\n ...attributes,\n [SEMRESATTRS_FAAS_VERSION]: functionVersion,\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\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 new Resource(attributes);\n }\n}\n\nexport const azureFunctionsDetector = new AzureFunctionsDetector();\n"]}
@@ -72,14 +72,14 @@ class AzureVmResourceDetector {
72
72
  const attributes = {
73
73
  [types_1.AZURE_VM_SCALE_SET_NAME_ATTRIBUTE]: metadata['vmScaleSetName'],
74
74
  [types_1.AZURE_VM_SKU_ATTRIBUTE]: metadata['sku'],
75
- [semantic_conventions_1.SemanticResourceAttributes.CLOUD_PLATFORM]: semantic_conventions_1.CloudPlatformValues.AZURE_VM,
76
- [semantic_conventions_1.SemanticResourceAttributes.CLOUD_PROVIDER]: semantic_conventions_1.CloudProviderValues.AZURE,
77
- [semantic_conventions_1.SemanticResourceAttributes.CLOUD_REGION]: metadata['location'],
75
+ [semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM]: semantic_conventions_1.CLOUDPLATFORMVALUES_AZURE_VM,
76
+ [semantic_conventions_1.SEMRESATTRS_CLOUD_PROVIDER]: semantic_conventions_1.CLOUDPROVIDERVALUES_AZURE,
77
+ [semantic_conventions_1.SEMRESATTRS_CLOUD_REGION]: metadata['location'],
78
78
  [types_1.CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: metadata['resourceId'],
79
- [semantic_conventions_1.SemanticResourceAttributes.HOST_ID]: metadata['vmId'],
80
- [semantic_conventions_1.SemanticResourceAttributes.HOST_NAME]: metadata['name'],
81
- [semantic_conventions_1.SemanticResourceAttributes.HOST_TYPE]: metadata['vmSize'],
82
- [semantic_conventions_1.SemanticResourceAttributes.OS_VERSION]: metadata['version'],
79
+ [semantic_conventions_1.SEMRESATTRS_HOST_ID]: metadata['vmId'],
80
+ [semantic_conventions_1.SEMRESATTRS_HOST_NAME]: metadata['name'],
81
+ [semantic_conventions_1.SEMRESATTRS_HOST_TYPE]: metadata['vmSize'],
82
+ [semantic_conventions_1.SEMRESATTRS_OS_VERSION]: metadata['version'],
83
83
  };
84
84
  return attributes;
85
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AzureVmDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureVmDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,6BAA6B;AAC7B,wDAKkC;AAClC,8EAI6C;AAC7C,oCAOkB;AAElB;;;GAGG;AACH,MAAM,uBAAuB;IAC3B,MAAM;QACJ,OAAO,IAAI,oBAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,MAAM,OAAO,GAAG;YACd,IAAI,EAAE,8BAAsB;YAC5B,IAAI,EAAE,8BAAsB;YAC5B,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,IAAI;YACb,OAAO,EAAE;gBACP,QAAQ,EAAE,MAAM;aACjB;SACF,CAAC;QACF,MAAM,QAAQ,GAAoB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtE,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;gBAChC,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,MAAM,CAAC,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,CAAC;YACjE,CAAC,EAAE,IAAI,CAAC,CAAC;YAET,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;gBACtC,YAAY,CAAC,SAAS,CAAC,CAAC;gBACxB,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;gBAC3B,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,IAAI,OAAO,GAAG,EAAE,CAAC;gBACjB,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,C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,CAAC,iDAA0B,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC;YAC1D,CAAC,iDAA0B,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;SAC7D,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAEY,QAAA,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';\nimport {\n DetectorSync,\n IResource,\n Resource,\n ResourceAttributes,\n} from '@opentelemetry/resources';\nimport {\n CloudPlatformValues,\n CloudProviderValues,\n SemanticResourceAttributes,\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 DetectorSync {\n detect(): IResource {\n return new Resource({}, this.getAzureVmMetadata());\n }\n\n async getAzureVmMetadata(): Promise<ResourceAttributes> {\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 [SemanticResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AZURE_VM,\n [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AZURE,\n [SemanticResourceAttributes.CLOUD_REGION]: metadata['location'],\n [CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: metadata['resourceId'],\n [SemanticResourceAttributes.HOST_ID]: metadata['vmId'],\n [SemanticResourceAttributes.HOST_NAME]: metadata['name'],\n [SemanticResourceAttributes.HOST_TYPE]: metadata['vmSize'],\n [SemanticResourceAttributes.OS_VERSION]: metadata['version'],\n };\n return attributes;\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,6BAA6B;AAC7B,wDAKkC;AAClC,8EAU6C;AAC7C,oCAOkB;AAElB;;;GAGG;AACH,MAAM,uBAAuB;IAC3B,MAAM;QACJ,OAAO,IAAI,oBAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC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,CAAC,CAAC,CAAC;YACH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;gBACpB,YAAY,CAAC,SAAS,CAAC,CAAC;gBACxB,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC,CAAC;YACH,GAAG,CAAC,GAAG,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG;YACjB,CAAC,yCAAiC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC;YAC/D,CAAC,8BAAsB,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC;YACzC,CAAC,iDAA0B,CAAC,EAAE,mDAA4B;YAC1D,CAAC,iDAA0B,CAAC,EAAE,gDAAyB;YACvD,CAAC,+CAAwB,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC;YAChD,CAAC,4CAAoC,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC;YAC9D,CAAC,0CAAmB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;YACvC,CAAC,4CAAqB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;YACzC,CAAC,4CAAqB,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC;YAC3C,CAAC,6CAAsB,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;SAC9C,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAEY,QAAA,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';\nimport {\n DetectorSync,\n IResource,\n Resource,\n ResourceAttributes,\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 DetectorSync {\n detect(): IResource {\n return new Resource({}, this.getAzureVmMetadata());\n }\n\n async getAzureVmMetadata(): Promise<ResourceAttributes> {\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 }\n}\n\nexport const azureVmDetector = new AzureVmResourceDetector();\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/resource-detector-azure",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "OpenTelemetry SDK resource detector for Azure",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@opentelemetry/api": "^1.0.0",
35
- "@opentelemetry/contrib-test-utils": "^0.37.0",
35
+ "@opentelemetry/contrib-test-utils": "^0.39.0",
36
36
  "@types/mocha": "8.2.3",
37
37
  "@types/node": "18.6.5",
38
38
  "@types/sinon": "10.0.18",
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@opentelemetry/resources": "^1.10.1",
51
- "@opentelemetry/semantic-conventions": "^1.0.0"
51
+ "@opentelemetry/semantic-conventions": "^1.22.0"
52
52
  },
53
53
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-azure#readme",
54
- "gitHead": "fcea8ca0c83cb1dcd8ac736e5ea4d22ff20dc982"
54
+ "gitHead": "96a87b48934f0afcf1fe637eed6704f35bd8e973"
55
55
  }