@opentelemetry/resource-detector-azure 0.12.0 → 0.13.2

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.
@@ -0,0 +1,191 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /*
17
+ * This file contains a copy of unstable semantic convention definitions
18
+ * used by this package.
19
+ * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
20
+ */
21
+ /**
22
+ * The cloud platform in use.
23
+ *
24
+ * @note The prefix of the service **SHOULD** match the one specified in `cloud.provider`.
25
+ *
26
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
27
+ */
28
+ export const ATTR_CLOUD_PLATFORM = 'cloud.platform';
29
+ /**
30
+ * Name of the cloud provider.
31
+ *
32
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
33
+ */
34
+ export const ATTR_CLOUD_PROVIDER = 'cloud.provider';
35
+ /**
36
+ * 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.
37
+ *
38
+ * @example us-central1
39
+ * @example us-east-1
40
+ *
41
+ * @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).
42
+ *
43
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
44
+ */
45
+ export const ATTR_CLOUD_REGION = 'cloud.region';
46
+ /**
47
+ * Name of the [deployment environment](https://wikipedia.org/wiki/Deployment_environment) (aka deployment tier).
48
+ *
49
+ * @example staging
50
+ * @example production
51
+ *
52
+ * @note `deployment.environment.name` does not affect the uniqueness constraints defined through
53
+ * the `service.namespace`, `service.name` and `service.instance.id` resource attributes.
54
+ * This implies that resources carrying the following attribute combinations **MUST** be
55
+ * considered to be identifying the same service:
56
+ *
57
+ * - `service.name=frontend`, `deployment.environment.name=production`
58
+ * - `service.name=frontend`, `deployment.environment.name=staging`.
59
+ *
60
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
61
+ */
62
+ export const ATTR_DEPLOYMENT_ENVIRONMENT_NAME = 'deployment.environment.name';
63
+ /**
64
+ * The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version.
65
+ *
66
+ * @example 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de
67
+ *
68
+ * @note - **AWS Lambda:** Use the (full) log stream name.
69
+ *
70
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
71
+ */
72
+ export const ATTR_FAAS_INSTANCE = 'faas.instance';
73
+ /**
74
+ * The amount of memory available to the serverless function converted to Bytes.
75
+ *
76
+ * @example 134217728
77
+ *
78
+ * @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).
79
+ *
80
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
81
+ */
82
+ export const ATTR_FAAS_MAX_MEMORY = 'faas.max_memory';
83
+ /**
84
+ * 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.
85
+ *
86
+ * @example fdbf79e8af94cb7f9e8df36789187052
87
+ *
88
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
89
+ */
90
+ export const ATTR_HOST_ID = 'host.id';
91
+ /**
92
+ * 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.
93
+ *
94
+ * @example opentelemetry-test
95
+ *
96
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
97
+ */
98
+ export const ATTR_HOST_NAME = 'host.name';
99
+ /**
100
+ * Type of host. For Cloud, this must be the machine type.
101
+ *
102
+ * @example n1-standard-1
103
+ *
104
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
105
+ */
106
+ export const ATTR_HOST_TYPE = 'host.type';
107
+ /**
108
+ * The version string of the operating system as defined in [Version Attributes](/docs/resource/README.md#version-attributes).
109
+ *
110
+ * @example 14.2.1
111
+ * @example 18.04.1
112
+ *
113
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
114
+ */
115
+ export const ATTR_OS_VERSION = 'os.version';
116
+ /**
117
+ * Process identifier (PID).
118
+ *
119
+ * @example 1234
120
+ *
121
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
122
+ */
123
+ export const ATTR_PROCESS_PID = 'process.pid';
124
+ /**
125
+ * The string ID of the service instance.
126
+ *
127
+ * @example 627cc493-f310-47de-96bd-71410b7dec09
128
+ *
129
+ * @note **MUST** be unique for each instance of the same `service.namespace,service.name` pair (in other words
130
+ * `service.namespace,service.name,service.instance.id` triplet **MUST** be globally unique). The ID helps to
131
+ * distinguish instances of the same service that exist at the same time (e.g. instances of a horizontally scaled
132
+ * service).
133
+ *
134
+ * Implementations, such as SDKs, are recommended to generate a random Version 1 or Version 4 [RFC
135
+ * 4122](https://www.ietf.org/rfc/rfc4122.txt) UUID, but are free to use an inherent unique ID as the source of
136
+ * this value if stability is desirable. In that case, the ID **SHOULD** be used as source of a UUID Version 5 and
137
+ * **SHOULD** use the following UUID as the namespace: `4d63009a-8d0f-11ee-aad7-4c796ed8e320`.
138
+ *
139
+ * UUIDs are typically recommended, as only an opaque value for the purposes of identifying a service instance is
140
+ * needed. Similar to what can be seen in the man page for the
141
+ * [`/etc/machine-id`](https://www.freedesktop.org/software/systemd/man/latest/machine-id.html) file, the underlying
142
+ * data, such as pod name and namespace should be treated as confidential, being the user's choice to expose it
143
+ * or not via another resource attribute.
144
+ *
145
+ * For applications running behind an application server (like unicorn), we do not recommend using one identifier
146
+ * for all processes participating in the application. Instead, it's recommended each division (e.g. a worker
147
+ * thread in unicorn) to have its own instance.id.
148
+ *
149
+ * It's not recommended for a Collector to set `service.instance.id` if it can't unambiguously determine the
150
+ * service instance that is generating that telemetry. For instance, creating an UUID based on `pod.name` will
151
+ * likely be wrong, as the Collector might not know from which container within that pod the telemetry originated.
152
+ * However, Collectors can set the `service.instance.id` if they can unambiguously determine the service instance
153
+ * for that telemetry. This is typically the case for scraping receivers, as they know the target address and
154
+ * port.
155
+ *
156
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
157
+ */
158
+ export const ATTR_SERVICE_INSTANCE_ID = 'service.instance.id';
159
+ /**
160
+ * Enum value "azure.app_service" for attribute {@link ATTR_CLOUD_PLATFORM}.
161
+ *
162
+ * Azure App Service
163
+ *
164
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
165
+ */
166
+ export const CLOUD_PLATFORM_VALUE_AZURE_APP_SERVICE = 'azure.app_service';
167
+ /**
168
+ * Enum value "azure.functions" for attribute {@link ATTR_CLOUD_PLATFORM}.
169
+ *
170
+ * Azure Functions
171
+ *
172
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
173
+ */
174
+ export const CLOUD_PLATFORM_VALUE_AZURE_FUNCTIONS = 'azure.functions';
175
+ /**
176
+ * Enum value "azure.vm" for attribute {@link ATTR_CLOUD_PLATFORM}.
177
+ *
178
+ * Azure Virtual Machines
179
+ *
180
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
181
+ */
182
+ export const CLOUD_PLATFORM_VALUE_AZURE_VM = 'azure.vm';
183
+ /**
184
+ * Enum value "azure" for attribute {@link ATTR_CLOUD_PROVIDER}.
185
+ *
186
+ * Microsoft Azure
187
+ *
188
+ * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
189
+ */
190
+ export const CLOUD_PROVIDER_VALUE_AZURE = 'azure';
191
+ //# sourceMappingURL=semconv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAyB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAyB,CAAC;AAE7D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAuB,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAC3C,6BAAsC,CAAC;AAEzC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAA0B,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,SAAkB,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,YAAqB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAsB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAA8B,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sCAAsC,GACjD,mBAA4B,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,iBAA0B,CAAC;AAE/E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAmB,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAgB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * The cloud platform in use.\n *\n * @note The prefix of the service **SHOULD** match the one specified in `cloud.provider`.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_PLATFORM = 'cloud.platform' as const;\n\n/**\n * Name of the cloud provider.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_PROVIDER = 'cloud.provider' as const;\n\n/**\n * The geographical region within a cloud provider. When associated with a resource, this attribute specifies the region where the resource operates. When calling services or APIs deployed on a cloud, this attribute identifies the region where the called destination is deployed.\n *\n * @example us-central1\n * @example us-east-1\n *\n * @note Refer to your provider's docs to see the available regions, for example [Alibaba Cloud regions](https://www.alibabacloud.com/help/doc-detail/40654.htm), [AWS regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), [Azure regions](https://azure.microsoft.com/global-infrastructure/geographies/), [Google Cloud regions](https://cloud.google.com/about/locations), or [Tencent Cloud regions](https://www.tencentcloud.com/document/product/213/6091).\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_CLOUD_REGION = 'cloud.region' as const;\n\n/**\n * Name of the [deployment environment](https://wikipedia.org/wiki/Deployment_environment) (aka deployment tier).\n *\n * @example staging\n * @example production\n *\n * @note `deployment.environment.name` does not affect the uniqueness constraints defined through\n * the `service.namespace`, `service.name` and `service.instance.id` resource attributes.\n * This implies that resources carrying the following attribute combinations **MUST** be\n * considered to be identifying the same service:\n *\n * - `service.name=frontend`, `deployment.environment.name=production`\n * - `service.name=frontend`, `deployment.environment.name=staging`.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_DEPLOYMENT_ENVIRONMENT_NAME =\n 'deployment.environment.name' as const;\n\n/**\n * The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version.\n *\n * @example 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de\n *\n * @note - **AWS Lambda:** Use the (full) log stream name.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_INSTANCE = 'faas.instance' as const;\n\n/**\n * The amount of memory available to the serverless function converted to Bytes.\n *\n * @example 134217728\n *\n * @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).\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_MAX_MEMORY = 'faas.max_memory' as const;\n\n/**\n * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For non-containerized systems, this should be the `machine-id`. See the table below for the sources to use to determine the `machine-id` based on operating system.\n *\n * @example fdbf79e8af94cb7f9e8df36789187052\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_HOST_ID = 'host.id' as const;\n\n/**\n * Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user.\n *\n * @example opentelemetry-test\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_HOST_NAME = 'host.name' as const;\n\n/**\n * Type of host. For Cloud, this must be the machine type.\n *\n * @example n1-standard-1\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_HOST_TYPE = 'host.type' as const;\n\n/**\n * The version string of the operating system as defined in [Version Attributes](/docs/resource/README.md#version-attributes).\n *\n * @example 14.2.1\n * @example 18.04.1\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_OS_VERSION = 'os.version' as const;\n\n/**\n * Process identifier (PID).\n *\n * @example 1234\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_PROCESS_PID = 'process.pid' as const;\n\n/**\n * The string ID of the service instance.\n *\n * @example 627cc493-f310-47de-96bd-71410b7dec09\n *\n * @note **MUST** be unique for each instance of the same `service.namespace,service.name` pair (in other words\n * `service.namespace,service.name,service.instance.id` triplet **MUST** be globally unique). The ID helps to\n * distinguish instances of the same service that exist at the same time (e.g. instances of a horizontally scaled\n * service).\n *\n * Implementations, such as SDKs, are recommended to generate a random Version 1 or Version 4 [RFC\n * 4122](https://www.ietf.org/rfc/rfc4122.txt) UUID, but are free to use an inherent unique ID as the source of\n * this value if stability is desirable. In that case, the ID **SHOULD** be used as source of a UUID Version 5 and\n * **SHOULD** use the following UUID as the namespace: `4d63009a-8d0f-11ee-aad7-4c796ed8e320`.\n *\n * UUIDs are typically recommended, as only an opaque value for the purposes of identifying a service instance is\n * needed. Similar to what can be seen in the man page for the\n * [`/etc/machine-id`](https://www.freedesktop.org/software/systemd/man/latest/machine-id.html) file, the underlying\n * data, such as pod name and namespace should be treated as confidential, being the user's choice to expose it\n * or not via another resource attribute.\n *\n * For applications running behind an application server (like unicorn), we do not recommend using one identifier\n * for all processes participating in the application. Instead, it's recommended each division (e.g. a worker\n * thread in unicorn) to have its own instance.id.\n *\n * It's not recommended for a Collector to set `service.instance.id` if it can't unambiguously determine the\n * service instance that is generating that telemetry. For instance, creating an UUID based on `pod.name` will\n * likely be wrong, as the Collector might not know from which container within that pod the telemetry originated.\n * However, Collectors can set the `service.instance.id` if they can unambiguously determine the service instance\n * for that telemetry. This is typically the case for scraping receivers, as they know the target address and\n * port.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_SERVICE_INSTANCE_ID = 'service.instance.id' as const;\n\n/**\n * Enum value \"azure.app_service\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Azure App Service\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_AZURE_APP_SERVICE =\n 'azure.app_service' as const;\n\n/**\n * Enum value \"azure.functions\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Azure Functions\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_AZURE_FUNCTIONS = 'azure.functions' as const;\n\n/**\n * Enum value \"azure.vm\" for attribute {@link ATTR_CLOUD_PLATFORM}.\n *\n * Azure Virtual Machines\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PLATFORM_VALUE_AZURE_VM = 'azure.vm' as const;\n\n/**\n * Enum value \"azure\" for attribute {@link ATTR_CLOUD_PROVIDER}.\n *\n * Microsoft Azure\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const CLOUD_PROVIDER_VALUE_AZURE = 'azure' as const;\n"]}
@@ -18,12 +18,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.azureAppServiceDetector = void 0;
19
19
  const types_1 = require("../types");
20
20
  const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
21
+ const semconv_1 = require("../semconv");
21
22
  const utils_1 = require("../utils");
22
23
  const APP_SERVICE_ATTRIBUTE_ENV_VARS = {
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,
24
+ [semconv_1.ATTR_CLOUD_REGION]: types_1.REGION_NAME,
25
+ [semconv_1.ATTR_DEPLOYMENT_ENVIRONMENT_NAME]: types_1.WEBSITE_SLOT_NAME,
26
+ [semconv_1.ATTR_HOST_ID]: types_1.WEBSITE_HOSTNAME,
27
+ [semconv_1.ATTR_SERVICE_INSTANCE_ID]: types_1.WEBSITE_INSTANCE_ID,
27
28
  [types_1.AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE]: types_1.WEBSITE_HOME_STAMPNAME,
28
29
  };
29
30
  /**
@@ -37,15 +38,15 @@ class AzureAppServiceDetector {
37
38
  if (websiteSiteName && !(0, utils_1.isAzureFunction)()) {
38
39
  attributes = {
39
40
  ...attributes,
40
- [semantic_conventions_1.SEMRESATTRS_SERVICE_NAME]: websiteSiteName,
41
+ [semantic_conventions_1.ATTR_SERVICE_NAME]: websiteSiteName,
41
42
  };
42
43
  attributes = {
43
44
  ...attributes,
44
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PROVIDER]: semantic_conventions_1.CLOUDPROVIDERVALUES_AZURE,
45
+ [semconv_1.ATTR_CLOUD_PROVIDER]: semconv_1.CLOUD_PROVIDER_VALUE_AZURE,
45
46
  };
46
47
  attributes = {
47
48
  ...attributes,
48
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM]: semantic_conventions_1.CLOUDPLATFORMVALUES_AZURE_APP_SERVICE,
49
+ [semconv_1.ATTR_CLOUD_PLATFORM]: semconv_1.CLOUD_PLATFORM_VALUE_AZURE_APP_SERVICE,
49
50
  };
50
51
  const azureResourceUri = (0, utils_1.getAzureResourceUri)(websiteSiteName);
51
52
  if (azureResourceUri) {
@@ -1 +1 @@
1
- {"version":3,"file":"AzureAppServiceDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureAppServiceDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,oCASkB;AAClB,8EAU6C;AAC7C,oCAAgE;AAEhE,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,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;QACvD,IAAI,eAAe,IAAI,CAAC,IAAA,uBAAe,GAAE,EAAE;YACzC,UAAU,GAAG;gBACX,GAAG,UAAU;gBACb,CAAC,+CAAwB,CAAC,EAAE,eAAe;aAC5C,CAAC;YACF,UAAU,GAAG;gBACX,GAAG,UAAU;gBACb,CAAC,iDAA0B,CAAC,EAAE,gDAAyB;aACxD,CAAC;YACF,UAAU,GAAG;gBACX,GAAG,UAAU;gBACb,CAAC,iDAA0B,CAAC,EAAE,4DAAqC;aACpE,CAAC;YAEF,MAAM,gBAAgB,GAAG,IAAA,2BAAmB,EAAC,eAAe,CAAC,CAAC;YAC9D,IAAI,gBAAgB,EAAE;gBACpB,UAAU,GAAG;oBACX,GAAG,UAAU;oBACb,GAAG,EAAE,CAAC,4CAAoC,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;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 { 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":["../../../src/detectors/AzureAppServiceDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,oCASkB;AAClB,8EAAwE;AACxE,wCASoB;AACpB,oCAAgE;AAEhE,MAAM,8BAA8B,GAAG;IACrC,CAAC,2BAAiB,CAAC,EAAE,mBAAW;IAChC,CAAC,0CAAgC,CAAC,EAAE,yBAAiB;IACrD,CAAC,sBAAY,CAAC,EAAE,wBAAgB;IAChC,CAAC,kCAAwB,CAAC,EAAE,2BAAmB;IAC/C,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,IAAI,eAAe,IAAI,CAAC,IAAA,uBAAe,GAAE,EAAE;YACzC,UAAU,GAAG;gBACX,GAAG,UAAU;gBACb,CAAC,wCAAiB,CAAC,EAAE,eAAe;aACrC,CAAC;YACF,UAAU,GAAG;gBACX,GAAG,UAAU;gBACb,CAAC,6BAAmB,CAAC,EAAE,oCAA0B;aAClD,CAAC;YACF,UAAU,GAAG;gBACX,GAAG,UAAU;gBACb,CAAC,6BAAmB,CAAC,EAAE,gDAAsC;aAC9D,CAAC;YAEF,MAAM,gBAAgB,GAAG,IAAA,2BAAmB,EAAC,eAAe,CAAC,CAAC;YAC9D,IAAI,gBAAgB,EAAE;gBACpB,UAAU,GAAG;oBACX,GAAG,UAAU;oBACb,GAAG,EAAE,CAAC,4CAAoC,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;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 { 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"]}
@@ -17,12 +17,13 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.azureFunctionsDetector = void 0;
19
19
  const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
20
+ const semconv_1 = require("../semconv");
20
21
  const types_1 = require("../types");
21
22
  const utils_1 = require("../utils");
22
23
  const AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = {
23
- [semantic_conventions_1.SEMRESATTRS_SERVICE_NAME]: types_1.WEBSITE_SITE_NAME,
24
- [semantic_conventions_1.SEMRESATTRS_FAAS_INSTANCE]: types_1.WEBSITE_INSTANCE_ID,
25
- [semantic_conventions_1.SEMRESATTRS_FAAS_MAX_MEMORY]: types_1.FUNCTIONS_MEM_LIMIT,
24
+ [semantic_conventions_1.ATTR_SERVICE_NAME]: types_1.WEBSITE_SITE_NAME,
25
+ [semconv_1.ATTR_FAAS_INSTANCE]: types_1.WEBSITE_INSTANCE_ID,
26
+ [semconv_1.ATTR_FAAS_MAX_MEMORY]: types_1.FUNCTIONS_MEM_LIMIT,
26
27
  };
27
28
  /**
28
29
  * The AzureFunctionsDetector can be used to detect if a process is running in Azure Functions
@@ -41,27 +42,27 @@ class AzureFunctionsDetector {
41
42
  const functionInstance = process.env[types_1.WEBSITE_INSTANCE_ID];
42
43
  const functionMemLimit = process.env[types_1.FUNCTIONS_MEM_LIMIT];
43
44
  attributes = {
44
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PROVIDER]: semantic_conventions_1.CLOUDPROVIDERVALUES_AZURE,
45
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM]: semantic_conventions_1.CLOUDPLATFORMVALUES_AZURE_FUNCTIONS,
46
- [semantic_conventions_1.SEMRESATTRS_CLOUD_REGION]: process.env[types_1.REGION_NAME],
47
- [semantic_conventions_1.SEMRESATTRS_PROCESS_PID]: process.pid,
45
+ [semconv_1.ATTR_CLOUD_PROVIDER]: semconv_1.CLOUD_PROVIDER_VALUE_AZURE,
46
+ [semconv_1.ATTR_CLOUD_PLATFORM]: semconv_1.CLOUD_PLATFORM_VALUE_AZURE_FUNCTIONS,
47
+ [semconv_1.ATTR_CLOUD_REGION]: process.env[types_1.REGION_NAME],
48
+ [semconv_1.ATTR_PROCESS_PID]: process.pid,
48
49
  };
49
50
  if (serviceName) {
50
51
  attributes = {
51
52
  ...attributes,
52
- [semantic_conventions_1.SEMRESATTRS_SERVICE_NAME]: serviceName,
53
+ [semantic_conventions_1.ATTR_SERVICE_NAME]: serviceName,
53
54
  };
54
55
  }
55
56
  if (functionInstance) {
56
57
  attributes = {
57
58
  ...attributes,
58
- [semantic_conventions_1.SEMRESATTRS_FAAS_INSTANCE]: functionInstance,
59
+ [semconv_1.ATTR_FAAS_INSTANCE]: functionInstance,
59
60
  };
60
61
  }
61
62
  if (functionMemLimit) {
62
63
  attributes = {
63
64
  ...attributes,
64
- [semantic_conventions_1.SEMRESATTRS_FAAS_MAX_MEMORY]: functionMemLimit,
65
+ [semconv_1.ATTR_FAAS_MAX_MEMORY]: functionMemLimit,
65
66
  };
66
67
  }
67
68
  const azureResourceUri = (0, utils_1.getAzureResourceUri)(serviceName);
@@ -1 +1 @@
1
- {"version":3,"file":"AzureFunctionsDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureFunctionsDetector.ts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AAG,IAAA,2BAAmB,EAAC,WAAW,CAAC,CAAC;YAC1D,IAAI,gBAAgB,EAAE;gBACpB,UAAU,GAAG;oBACX,GAAG,UAAU;oBACb,GAAG,EAAE,CAAC,4CAAoC,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;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 { 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,8EAAwE;AACxE,wCASoB;AACpB,oCAMkB;AAClB,oCAAgE;AAEhE,MAAM,kCAAkC,GAAG;IACzC,CAAC,wCAAiB,CAAC,EAAE,yBAAiB;IACtC,CAAC,4BAAkB,CAAC,EAAE,2BAAmB;IACzC,CAAC,8BAAoB,CAAC,EAAE,2BAAmB;CAC5C,CAAC;AAEF;;;GAGG;AACH,MAAM,sBAAsB;IAC1B,MAAM;QACJ,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;QAEnD;;;;WAIG;QACH,IAAI,WAAW,IAAI,IAAA,uBAAe,GAAE,EAAE;YACpC,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,6BAAmB,CAAC,EAAE,oCAA0B;gBACjD,CAAC,6BAAmB,CAAC,EAAE,8CAAoC;gBAC3D,CAAC,2BAAiB,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAW,CAAC;gBAC7C,CAAC,0BAAgB,CAAC,EAAE,OAAO,CAAC,GAAG;aAChC,CAAC;YAEF,IAAI,WAAW,EAAE;gBACf,UAAU,GAAG;oBACX,GAAG,UAAU;oBACb,CAAC,wCAAiB,CAAC,EAAE,WAAW;iBACjC,CAAC;aACH;YACD,IAAI,gBAAgB,EAAE;gBACpB,UAAU,GAAG;oBACX,GAAG,UAAU;oBACb,CAAC,4BAAkB,CAAC,EAAE,gBAAgB;iBACvC,CAAC;aACH;YACD,IAAI,gBAAgB,EAAE;gBACpB,UAAU,GAAG;oBACX,GAAG,UAAU;oBACb,CAAC,8BAAoB,CAAC,EAAE,gBAAgB;iBACzC,CAAC;aACH;YACD,MAAM,gBAAgB,GAAG,IAAA,2BAAmB,EAAC,WAAW,CAAC,CAAC;YAC1D,IAAI,gBAAgB,EAAE;gBACpB,UAAU,GAAG;oBACX,GAAG,UAAU;oBACb,GAAG,EAAE,CAAC,4CAAoC,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;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 { 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"]}
@@ -19,7 +19,7 @@ exports.azureVmDetector = void 0;
19
19
  const http = require("http");
20
20
  const api_1 = require("@opentelemetry/api");
21
21
  const core_1 = require("@opentelemetry/core");
22
- const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
22
+ const semconv_1 = require("../semconv");
23
23
  const types_1 = require("../types");
24
24
  /**
25
25
  * The AzureVmDetector can be used to detect if a process is running in an Azure VM.
@@ -31,14 +31,14 @@ class AzureVmResourceDetector {
31
31
  const attrNames = [
32
32
  types_1.AZURE_VM_SCALE_SET_NAME_ATTRIBUTE,
33
33
  types_1.AZURE_VM_SKU_ATTRIBUTE,
34
- semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM,
35
- semantic_conventions_1.SEMRESATTRS_CLOUD_PROVIDER,
36
- semantic_conventions_1.SEMRESATTRS_CLOUD_REGION,
34
+ semconv_1.ATTR_CLOUD_PLATFORM,
35
+ semconv_1.ATTR_CLOUD_PROVIDER,
36
+ semconv_1.ATTR_CLOUD_REGION,
37
37
  types_1.CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,
38
- semantic_conventions_1.SEMRESATTRS_HOST_ID,
39
- semantic_conventions_1.SEMRESATTRS_HOST_NAME,
40
- semantic_conventions_1.SEMRESATTRS_HOST_TYPE,
41
- semantic_conventions_1.SEMRESATTRS_OS_VERSION,
38
+ semconv_1.ATTR_HOST_ID,
39
+ semconv_1.ATTR_HOST_NAME,
40
+ semconv_1.ATTR_HOST_TYPE,
41
+ semconv_1.ATTR_OS_VERSION,
42
42
  ];
43
43
  const attributes = {};
44
44
  attrNames.forEach(name => {
@@ -92,14 +92,14 @@ class AzureVmResourceDetector {
92
92
  const attributes = {
93
93
  [types_1.AZURE_VM_SCALE_SET_NAME_ATTRIBUTE]: metadata['vmScaleSetName'],
94
94
  [types_1.AZURE_VM_SKU_ATTRIBUTE]: metadata['sku'],
95
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM]: semantic_conventions_1.CLOUDPLATFORMVALUES_AZURE_VM,
96
- [semantic_conventions_1.SEMRESATTRS_CLOUD_PROVIDER]: semantic_conventions_1.CLOUDPROVIDERVALUES_AZURE,
97
- [semantic_conventions_1.SEMRESATTRS_CLOUD_REGION]: metadata['location'],
95
+ [semconv_1.ATTR_CLOUD_PLATFORM]: semconv_1.CLOUD_PLATFORM_VALUE_AZURE_VM,
96
+ [semconv_1.ATTR_CLOUD_PROVIDER]: semconv_1.CLOUD_PROVIDER_VALUE_AZURE,
97
+ [semconv_1.ATTR_CLOUD_REGION]: metadata['location'],
98
98
  [types_1.CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: metadata['resourceId'],
99
- [semantic_conventions_1.SEMRESATTRS_HOST_ID]: metadata['vmId'],
100
- [semantic_conventions_1.SEMRESATTRS_HOST_NAME]: metadata['name'],
101
- [semantic_conventions_1.SEMRESATTRS_HOST_TYPE]: metadata['vmSize'],
102
- [semantic_conventions_1.SEMRESATTRS_OS_VERSION]: metadata['version'],
99
+ [semconv_1.ATTR_HOST_ID]: metadata['vmId'],
100
+ [semconv_1.ATTR_HOST_NAME]: metadata['name'],
101
+ [semconv_1.ATTR_HOST_TYPE]: metadata['vmSize'],
102
+ [semconv_1.ATTR_OS_VERSION]: metadata['version'],
103
103
  };
104
104
  return attributes;
105
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AzureVmDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureVmDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,6BAA6B;AAE7B,4CAAmD;AACnD,8CAAsD;AAMtD,8EAU6C;AAC7C,oCAOkB;AAElB;;;GAGG;AACH,MAAM,uBAAuB;IAC3B,MAAM;QACJ,MAAM,WAAW,GAAG,aAAO,CAAC,IAAI,CAAC,IAAA,sBAAe,EAAC,aAAO,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CACvE,IAAI,CAAC,kBAAkB,EAAE,CAC1B,CAAC;QAEF,MAAM,SAAS,GAAG;YAChB,yCAAiC;YACjC,8BAAsB;YACtB,iDAA0B;YAC1B,iDAA0B;YAC1B,+CAAwB;YACxB,4CAAoC;YACpC,0CAAmB;YACnB,4CAAqB;YACrB,4CAAqB;YACrB,6CAAsB;SACvB,CAAC;QAEF,MAAM,UAAU,GAAG,EAAgC,CAAC;QACpD,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACvB,yEAAyE;YACzE,UAAU,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,IAAI;YACF,MAAM,OAAO,GAAG;gBACd,IAAI,EAAE,8BAAsB;gBAC5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,EAAE,GAAG,CAAC,EAAE;oBACpB,YAAY,CAAC,SAAS,CAAC,CAAC;oBACxB,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,CAAC,CAAC,CAAC;gBACH,GAAG,CAAC,GAAG,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;YAEH,MAAM,UAAU,GAAG;gBACjB,CAAC,yCAAiC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC;gBAC/D,CAAC,8BAAsB,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC;gBACzC,CAAC,iDAA0B,CAAC,EAAE,mDAA4B;gBAC1D,CAAC,iDAA0B,CAAC,EAAE,gDAAyB;gBACvD,CAAC,+CAAwB,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC;gBAChD,CAAC,4CAAoC,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC;gBAC9D,CAAC,0CAAmB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;gBACvC,CAAC,4CAAqB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;gBACzC,CAAC,4CAAqB,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC;gBAC3C,CAAC,6CAAsB,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;aAC9C,CAAC;YACF,OAAO,UAAU,CAAC;SACnB;QAAC,OAAO,GAAQ,EAAE;YACjB,UAAI,CAAC,KAAK,CACR,sDAAsD,EACtD,GAAG,CAAC,OAAO,CACZ,CAAC;YACF,OAAO,EAAE,CAAC;SACX;IACH,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';\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"]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AC/D,CAAC,8BAAsB,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC;gBACzC,CAAC,6BAAmB,CAAC,EAAE,uCAA6B;gBACpD,CAAC,6BAAmB,CAAC,EAAE,oCAA0B;gBACjD,CAAC,2BAAiB,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC;gBACzC,CAAC,4CAAoC,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC;gBAC9D,CAAC,sBAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;gBAChC,CAAC,wBAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;gBAClC,CAAC,wBAAc,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC;gBACpC,CAAC,yBAAe,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;aACvC,CAAC;YACF,OAAO,UAAU,CAAC;SACnB;QAAC,OAAO,GAAQ,EAAE;YACjB,UAAI,CAAC,KAAK,CACR,sDAAsD,EACtD,GAAG,CAAC,OAAO,CACZ,CAAC;YACF,OAAO,EAAE,CAAC;SACX;IACH,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';\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