@graphql-hive/gateway 2.0.0-next-e2698677f10276e29194b5559409235a15f2f324 → 2.0.0-next-5e94f24f7f5aafcf174e196eea428f84953e90ae

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.
@@ -1,843 +0,0 @@
1
- 'use strict';
2
-
3
- var require$$0 = require('@opentelemetry/api');
4
- var require$$1 = require('@opentelemetry/core');
5
- var require$$0$1 = require('os');
6
- var process$1 = require('process');
7
- var crypto = require('crypto');
8
-
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
19
- });
20
- }
21
- });
22
- }
23
- n.default = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var require$$0__namespace = /*#__PURE__*/_interopNamespace(require$$0$1);
28
- var process__namespace = /*#__PURE__*/_interopNamespace(process$1);
29
-
30
- /*
31
- * Copyright The OpenTelemetry Authors
32
- *
33
- * Licensed under the Apache License, Version 2.0 (the "License");
34
- * you may not use this file except in compliance with the License.
35
- * You may obtain a copy of the License at
36
- *
37
- * https://www.apache.org/licenses/LICENSE-2.0
38
- *
39
- * Unless required by applicable law or agreed to in writing, software
40
- * distributed under the License is distributed on an "AS IS" BASIS,
41
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
- * See the License for the specific language governing permissions and
43
- * limitations under the License.
44
- */
45
- //----------------------------------------------------------------------------------------------------------
46
- // DO NOT EDIT, this is an Auto-generated file from scripts/semconv/templates/registry/stable/attributes.ts.j2
47
- //----------------------------------------------------------------------------------------------------------
48
- /**
49
- * ASP.NET Core exception middleware handling result
50
- *
51
- * @example handled
52
- * @example unhandled
53
- */
54
- /**
55
- * Logical name of the service.
56
- *
57
- * @example shoppingcart
58
- *
59
- * @note **MUST** be the same for all instances of horizontally scaled services. If the value was not specified, SDKs **MUST** fallback to `unknown_service:` concatenated with [`process.executable.name`](process.md), e.g. `unknown_service:bash`. If `process.executable.name` is not available, the value **MUST** be set to `unknown_service`.
60
- */
61
- var ATTR_SERVICE_NAME = 'service.name';
62
- /**
63
- * The language of the telemetry SDK.
64
- */
65
- var ATTR_TELEMETRY_SDK_LANGUAGE = 'telemetry.sdk.language';
66
- /**
67
- * The name of the telemetry SDK as defined above.
68
- *
69
- * @example opentelemetry
70
- *
71
- * @note The OpenTelemetry SDK **MUST** set the `telemetry.sdk.name` attribute to `opentelemetry`.
72
- * If another SDK, like a fork or a vendor-provided implementation, is used, this SDK **MUST** set the
73
- * `telemetry.sdk.name` attribute to the fully-qualified class or module name of this SDK's main entry point
74
- * or another suitable identifier depending on the language.
75
- * The identifier `opentelemetry` is reserved and **MUST NOT** be used in this case.
76
- * All custom identifiers **SHOULD** be stable across different versions of an implementation.
77
- */
78
- var ATTR_TELEMETRY_SDK_NAME = 'telemetry.sdk.name';
79
- /**
80
- * The version string of the telemetry SDK.
81
- *
82
- * @example 1.2.3
83
- */
84
- var ATTR_TELEMETRY_SDK_VERSION = 'telemetry.sdk.version';
85
-
86
- /*
87
- * Copyright The OpenTelemetry Authors
88
- *
89
- * Licensed under the Apache License, Version 2.0 (the "License");
90
- * you may not use this file except in compliance with the License.
91
- * You may obtain a copy of the License at
92
- *
93
- * https://www.apache.org/licenses/LICENSE-2.0
94
- *
95
- * Unless required by applicable law or agreed to in writing, software
96
- * distributed under the License is distributed on an "AS IS" BASIS,
97
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
98
- * See the License for the specific language governing permissions and
99
- * limitations under the License.
100
- */
101
- function defaultServiceName() {
102
- return `unknown_service:${process.argv0}`;
103
- }
104
-
105
- /*
106
- * Copyright The OpenTelemetry Authors
107
- *
108
- * Licensed under the Apache License, Version 2.0 (the "License");
109
- * you may not use this file except in compliance with the License.
110
- * You may obtain a copy of the License at
111
- *
112
- * https://www.apache.org/licenses/LICENSE-2.0
113
- *
114
- * Unless required by applicable law or agreed to in writing, software
115
- * distributed under the License is distributed on an "AS IS" BASIS,
116
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
117
- * See the License for the specific language governing permissions and
118
- * limitations under the License.
119
- */
120
- const isPromiseLike = (val) => {
121
- return (val !== null &&
122
- typeof val === 'object' &&
123
- typeof val.then === 'function');
124
- };
125
-
126
- /*
127
- * Copyright The OpenTelemetry Authors
128
- *
129
- * Licensed under the Apache License, Version 2.0 (the "License");
130
- * you may not use this file except in compliance with the License.
131
- * You may obtain a copy of the License at
132
- *
133
- * https://www.apache.org/licenses/LICENSE-2.0
134
- *
135
- * Unless required by applicable law or agreed to in writing, software
136
- * distributed under the License is distributed on an "AS IS" BASIS,
137
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138
- * See the License for the specific language governing permissions and
139
- * limitations under the License.
140
- */
141
- class ResourceImpl {
142
- _rawAttributes;
143
- _asyncAttributesPending = false;
144
- _memoizedAttributes;
145
- static FromAttributeList(attributes) {
146
- const res = new ResourceImpl({});
147
- res._rawAttributes = guardedRawAttributes(attributes);
148
- res._asyncAttributesPending =
149
- attributes.filter(([_, val]) => isPromiseLike(val)).length > 0;
150
- return res;
151
- }
152
- constructor(
153
- /**
154
- * A dictionary of attributes with string keys and values that provide
155
- * information about the entity as numbers, strings or booleans
156
- * TODO: Consider to add check/validation on attributes.
157
- */
158
- resource) {
159
- const attributes = resource.attributes ?? {};
160
- this._rawAttributes = Object.entries(attributes).map(([k, v]) => {
161
- if (isPromiseLike(v)) {
162
- // side-effect
163
- this._asyncAttributesPending = true;
164
- }
165
- return [k, v];
166
- });
167
- this._rawAttributes = guardedRawAttributes(this._rawAttributes);
168
- }
169
- get asyncAttributesPending() {
170
- return this._asyncAttributesPending;
171
- }
172
- async waitForAsyncAttributes() {
173
- if (!this.asyncAttributesPending) {
174
- return;
175
- }
176
- for (let i = 0; i < this._rawAttributes.length; i++) {
177
- const [k, v] = this._rawAttributes[i];
178
- this._rawAttributes[i] = [k, isPromiseLike(v) ? await v : v];
179
- }
180
- this._asyncAttributesPending = false;
181
- }
182
- get attributes() {
183
- if (this.asyncAttributesPending) {
184
- require$$0.diag.error('Accessing resource attributes before async attributes settled');
185
- }
186
- if (this._memoizedAttributes) {
187
- return this._memoizedAttributes;
188
- }
189
- const attrs = {};
190
- for (const [k, v] of this._rawAttributes) {
191
- if (isPromiseLike(v)) {
192
- require$$0.diag.debug(`Unsettled resource attribute ${k} skipped`);
193
- continue;
194
- }
195
- if (v != null) {
196
- attrs[k] ??= v;
197
- }
198
- }
199
- // only memoize output if all attributes are settled
200
- if (!this._asyncAttributesPending) {
201
- this._memoizedAttributes = attrs;
202
- }
203
- return attrs;
204
- }
205
- getRawAttributes() {
206
- return this._rawAttributes;
207
- }
208
- merge(resource) {
209
- if (resource == null)
210
- return this;
211
- // Order is important
212
- // Spec states incoming attributes override existing attributes
213
- return ResourceImpl.FromAttributeList([
214
- ...resource.getRawAttributes(),
215
- ...this.getRawAttributes(),
216
- ]);
217
- }
218
- }
219
- function resourceFromAttributes(attributes) {
220
- return ResourceImpl.FromAttributeList(Object.entries(attributes));
221
- }
222
- function resourceFromDetectedResource(detectedResource) {
223
- return new ResourceImpl(detectedResource);
224
- }
225
- function emptyResource() {
226
- return resourceFromAttributes({});
227
- }
228
- function defaultResource() {
229
- return resourceFromAttributes({
230
- [ATTR_SERVICE_NAME]: defaultServiceName(),
231
- [ATTR_TELEMETRY_SDK_LANGUAGE]: require$$1.SDK_INFO[ATTR_TELEMETRY_SDK_LANGUAGE],
232
- [ATTR_TELEMETRY_SDK_NAME]: require$$1.SDK_INFO[ATTR_TELEMETRY_SDK_NAME],
233
- [ATTR_TELEMETRY_SDK_VERSION]: require$$1.SDK_INFO[ATTR_TELEMETRY_SDK_VERSION],
234
- });
235
- }
236
- function guardedRawAttributes(attributes) {
237
- return attributes.map(([k, v]) => {
238
- if (isPromiseLike(v)) {
239
- return [
240
- k,
241
- v.catch(err => {
242
- require$$0.diag.debug('promise rejection for resource attribute: %s - %s', k, err);
243
- return undefined;
244
- }),
245
- ];
246
- }
247
- return [k, v];
248
- });
249
- }
250
-
251
- /*
252
- * Copyright The OpenTelemetry Authors
253
- *
254
- * Licensed under the Apache License, Version 2.0 (the "License");
255
- * you may not use this file except in compliance with the License.
256
- * You may obtain a copy of the License at
257
- *
258
- * https://www.apache.org/licenses/LICENSE-2.0
259
- *
260
- * Unless required by applicable law or agreed to in writing, software
261
- * distributed under the License is distributed on an "AS IS" BASIS,
262
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
263
- * See the License for the specific language governing permissions and
264
- * limitations under the License.
265
- */
266
- /**
267
- * Runs all resource detectors and returns the results merged into a single Resource.
268
- *
269
- * @param config Configuration for resource detection
270
- */
271
- const detectResources = (config = {}) => {
272
- const resources = (config.detectors || []).map(d => {
273
- try {
274
- const resource = resourceFromDetectedResource(d.detect(config));
275
- require$$0.diag.debug(`${d.constructor.name} found resource.`, resource);
276
- return resource;
277
- }
278
- catch (e) {
279
- require$$0.diag.debug(`${d.constructor.name} failed: ${e.message}`);
280
- return emptyResource();
281
- }
282
- });
283
- return resources.reduce((acc, resource) => acc.merge(resource), emptyResource());
284
- };
285
-
286
- /*
287
- * Copyright The OpenTelemetry Authors
288
- *
289
- * Licensed under the Apache License, Version 2.0 (the "License");
290
- * you may not use this file except in compliance with the License.
291
- * You may obtain a copy of the License at
292
- *
293
- * https://www.apache.org/licenses/LICENSE-2.0
294
- *
295
- * Unless required by applicable law or agreed to in writing, software
296
- * distributed under the License is distributed on an "AS IS" BASIS,
297
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
298
- * See the License for the specific language governing permissions and
299
- * limitations under the License.
300
- */
301
- /**
302
- * EnvDetector can be used to detect the presence of and create a Resource
303
- * from the OTEL_RESOURCE_ATTRIBUTES environment variable.
304
- */
305
- class EnvDetector {
306
- // Type, attribute keys, and attribute values should not exceed 256 characters.
307
- _MAX_LENGTH = 255;
308
- // OTEL_RESOURCE_ATTRIBUTES is a comma-separated list of attributes.
309
- _COMMA_SEPARATOR = ',';
310
- // OTEL_RESOURCE_ATTRIBUTES contains key value pair separated by '='.
311
- _LABEL_KEY_VALUE_SPLITTER = '=';
312
- _ERROR_MESSAGE_INVALID_CHARS = 'should be a ASCII string with a length greater than 0 and not exceed ' +
313
- this._MAX_LENGTH +
314
- ' characters.';
315
- _ERROR_MESSAGE_INVALID_VALUE = 'should be a ASCII string with a length not exceed ' +
316
- this._MAX_LENGTH +
317
- ' characters.';
318
- /**
319
- * Returns a {@link Resource} populated with attributes from the
320
- * OTEL_RESOURCE_ATTRIBUTES environment variable. Note this is an async
321
- * function to conform to the Detector interface.
322
- *
323
- * @param config The resource detection config
324
- */
325
- detect(_config) {
326
- const attributes = {};
327
- const rawAttributes = require$$1.getStringFromEnv('OTEL_RESOURCE_ATTRIBUTES');
328
- const serviceName = require$$1.getStringFromEnv('OTEL_SERVICE_NAME');
329
- if (rawAttributes) {
330
- try {
331
- const parsedAttributes = this._parseResourceAttributes(rawAttributes);
332
- Object.assign(attributes, parsedAttributes);
333
- }
334
- catch (e) {
335
- require$$0.diag.debug(`EnvDetector failed: ${e.message}`);
336
- }
337
- }
338
- if (serviceName) {
339
- attributes[ATTR_SERVICE_NAME] = serviceName;
340
- }
341
- return { attributes };
342
- }
343
- /**
344
- * Creates an attribute map from the OTEL_RESOURCE_ATTRIBUTES environment
345
- * variable.
346
- *
347
- * OTEL_RESOURCE_ATTRIBUTES: A comma-separated list of attributes describing
348
- * the source in more detail, e.g. “key1=val1,key2=val2”. Domain names and
349
- * paths are accepted as attribute keys. Values may be quoted or unquoted in
350
- * general. If a value contains whitespace, =, or " characters, it must
351
- * always be quoted.
352
- *
353
- * @param rawEnvAttributes The resource attributes as a comma-separated list
354
- * of key/value pairs.
355
- * @returns The sanitized resource attributes.
356
- */
357
- _parseResourceAttributes(rawEnvAttributes) {
358
- if (!rawEnvAttributes)
359
- return {};
360
- const attributes = {};
361
- const rawAttributes = rawEnvAttributes.split(this._COMMA_SEPARATOR, -1);
362
- for (const rawAttribute of rawAttributes) {
363
- const keyValuePair = rawAttribute.split(this._LABEL_KEY_VALUE_SPLITTER, -1);
364
- if (keyValuePair.length !== 2) {
365
- continue;
366
- }
367
- let [key, value] = keyValuePair;
368
- // Leading and trailing whitespaces are trimmed.
369
- key = key.trim();
370
- value = value.trim().split(/^"|"$/).join('');
371
- if (!this._isValidAndNotEmpty(key)) {
372
- throw new Error(`Attribute key ${this._ERROR_MESSAGE_INVALID_CHARS}`);
373
- }
374
- if (!this._isValid(value)) {
375
- throw new Error(`Attribute value ${this._ERROR_MESSAGE_INVALID_VALUE}`);
376
- }
377
- attributes[key] = decodeURIComponent(value);
378
- }
379
- return attributes;
380
- }
381
- /**
382
- * Determines whether the given String is a valid printable ASCII string with
383
- * a length not exceed _MAX_LENGTH characters.
384
- *
385
- * @param str The String to be validated.
386
- * @returns Whether the String is valid.
387
- */
388
- _isValid(name) {
389
- return name.length <= this._MAX_LENGTH && this._isBaggageOctetString(name);
390
- }
391
- // https://www.w3.org/TR/baggage/#definition
392
- _isBaggageOctetString(str) {
393
- for (let i = 0; i < str.length; i++) {
394
- const ch = str.charCodeAt(i);
395
- if (ch < 0x21 || ch === 0x2c || ch === 0x3b || ch === 0x5c || ch > 0x7e) {
396
- return false;
397
- }
398
- }
399
- return true;
400
- }
401
- /**
402
- * Determines whether the given String is a valid printable ASCII string with
403
- * a length greater than 0 and not exceed _MAX_LENGTH characters.
404
- *
405
- * @param str The String to be validated.
406
- * @returns Whether the String is valid and not empty.
407
- */
408
- _isValidAndNotEmpty(str) {
409
- return str.length > 0 && this._isValid(str);
410
- }
411
- }
412
- const envDetector = new EnvDetector();
413
-
414
- /*
415
- * Copyright The OpenTelemetry Authors
416
- *
417
- * Licensed under the Apache License, Version 2.0 (the "License");
418
- * you may not use this file except in compliance with the License.
419
- * You may obtain a copy of the License at
420
- *
421
- * https://www.apache.org/licenses/LICENSE-2.0
422
- *
423
- * Unless required by applicable law or agreed to in writing, software
424
- * distributed under the License is distributed on an "AS IS" BASIS,
425
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
426
- * See the License for the specific language governing permissions and
427
- * limitations under the License.
428
- */
429
- /*
430
- * This file contains a copy of unstable semantic convention definitions
431
- * used by this package.
432
- * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
433
- */
434
- /**
435
- * The cloud account ID the resource is assigned to.
436
- *
437
- * @example 111111111111
438
- * @example opentelemetry
439
- *
440
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
441
- */
442
- /**
443
- * The CPU architecture the host system is running on.
444
- *
445
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
446
- */
447
- const ATTR_HOST_ARCH = 'host.arch';
448
- /**
449
- * 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.
450
- *
451
- * @example fdbf79e8af94cb7f9e8df36789187052
452
- *
453
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
454
- */
455
- const ATTR_HOST_ID = 'host.id';
456
- /**
457
- * 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.
458
- *
459
- * @example opentelemetry-test
460
- *
461
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
462
- */
463
- const ATTR_HOST_NAME = 'host.name';
464
- /**
465
- * The operating system type.
466
- *
467
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
468
- */
469
- const ATTR_OS_TYPE = 'os.type';
470
- /**
471
- * The version string of the operating system as defined in [Version Attributes](/docs/resource/README.md#version-attributes).
472
- *
473
- * @example 14.2.1
474
- * @example 18.04.1
475
- *
476
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
477
- */
478
- const ATTR_OS_VERSION = 'os.version';
479
- /**
480
- * The command used to launch the process (i.e. the command name). On Linux based systems, can be set to the zeroth string in `proc/[pid]/cmdline`. On Windows, can be set to the first parameter extracted from `GetCommandLineW`.
481
- *
482
- * @example cmd/otelcol
483
- *
484
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
485
- */
486
- const ATTR_PROCESS_COMMAND = 'process.command';
487
- /**
488
- * All the command arguments (including the command/executable itself) as received by the process. On Linux-based systems (and some other Unixoid systems supporting procfs), can be set according to the list of null-delimited strings extracted from `proc/[pid]/cmdline`. For libc-based executables, this would be the full argv vector passed to `main`.
489
- *
490
- * @example ["cmd/otecol", "--config=config.yaml"]
491
- *
492
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
493
- */
494
- const ATTR_PROCESS_COMMAND_ARGS = 'process.command_args';
495
- /**
496
- * The name of the process executable. On Linux based systems, this **SHOULD** be set to the base name of the target of `/proc/[pid]/exe`. On Windows, this **SHOULD** be set to the base name of `GetProcessImageFileNameW`.
497
- *
498
- * @example otelcol
499
- *
500
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
501
- */
502
- const ATTR_PROCESS_EXECUTABLE_NAME = 'process.executable.name';
503
- /**
504
- * The full path to the process executable. On Linux based systems, can be set to the target of `proc/[pid]/exe`. On Windows, can be set to the result of `GetProcessImageFileNameW`.
505
- *
506
- * @example /usr/bin/cmd/otelcol
507
- *
508
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
509
- */
510
- const ATTR_PROCESS_EXECUTABLE_PATH = 'process.executable.path';
511
- /**
512
- * The username of the user that owns the process.
513
- *
514
- * @example root
515
- *
516
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
517
- */
518
- const ATTR_PROCESS_OWNER = 'process.owner';
519
- /**
520
- * Process identifier (PID).
521
- *
522
- * @example 1234
523
- *
524
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
525
- */
526
- const ATTR_PROCESS_PID = 'process.pid';
527
- /**
528
- * An additional description about the runtime of the process, for example a specific vendor customization of the runtime environment.
529
- *
530
- * @example "Eclipse OpenJ9 Eclipse OpenJ9 VM openj9-0.21.0"
531
- *
532
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
533
- */
534
- const ATTR_PROCESS_RUNTIME_DESCRIPTION = 'process.runtime.description';
535
- /**
536
- * The name of the runtime of this process.
537
- *
538
- * @example OpenJDK Runtime Environment
539
- *
540
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
541
- */
542
- const ATTR_PROCESS_RUNTIME_NAME = 'process.runtime.name';
543
- /**
544
- * The version of the runtime of this process, as returned by the runtime without modification.
545
- *
546
- * @example "14.0.2"
547
- *
548
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
549
- */
550
- const ATTR_PROCESS_RUNTIME_VERSION = 'process.runtime.version';
551
- /**
552
- * The string ID of the service instance.
553
- *
554
- * @example 627cc493-f310-47de-96bd-71410b7dec09
555
- *
556
- * @note **MUST** be unique for each instance of the same `service.namespace,service.name` pair (in other words
557
- * `service.namespace,service.name,service.instance.id` triplet **MUST** be globally unique). The ID helps to
558
- * distinguish instances of the same service that exist at the same time (e.g. instances of a horizontally scaled
559
- * service).
560
- *
561
- * Implementations, such as SDKs, are recommended to generate a random Version 1 or Version 4 [RFC
562
- * 4122](https://www.ietf.org/rfc/rfc4122.txt) UUID, but are free to use an inherent unique ID as the source of
563
- * this value if stability is desirable. In that case, the ID **SHOULD** be used as source of a UUID Version 5 and
564
- * **SHOULD** use the following UUID as the namespace: `4d63009a-8d0f-11ee-aad7-4c796ed8e320`.
565
- *
566
- * UUIDs are typically recommended, as only an opaque value for the purposes of identifying a service instance is
567
- * needed. Similar to what can be seen in the man page for the
568
- * [`/etc/machine-id`](https://www.freedesktop.org/software/systemd/man/latest/machine-id.html) file, the underlying
569
- * data, such as pod name and namespace should be treated as confidential, being the user's choice to expose it
570
- * or not via another resource attribute.
571
- *
572
- * For applications running behind an application server (like unicorn), we do not recommend using one identifier
573
- * for all processes participating in the application. Instead, it's recommended each division (e.g. a worker
574
- * thread in unicorn) to have its own instance.id.
575
- *
576
- * It's not recommended for a Collector to set `service.instance.id` if it can't unambiguously determine the
577
- * service instance that is generating that telemetry. For instance, creating an UUID based on `pod.name` will
578
- * likely be wrong, as the Collector might not know from which container within that pod the telemetry originated.
579
- * However, Collectors can set the `service.instance.id` if they can unambiguously determine the service instance
580
- * for that telemetry. This is typically the case for scraping receivers, as they know the target address and
581
- * port.
582
- *
583
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
584
- */
585
- const ATTR_SERVICE_INSTANCE_ID = 'service.instance.id';
586
-
587
- /*
588
- * Copyright The OpenTelemetry Authors
589
- *
590
- * Licensed under the Apache License, Version 2.0 (the "License");
591
- * you may not use this file except in compliance with the License.
592
- * You may obtain a copy of the License at
593
- *
594
- * https://www.apache.org/licenses/LICENSE-2.0
595
- *
596
- * Unless required by applicable law or agreed to in writing, software
597
- * distributed under the License is distributed on an "AS IS" BASIS,
598
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
599
- * See the License for the specific language governing permissions and
600
- * limitations under the License.
601
- */
602
- let getMachineIdImpl;
603
- async function getMachineId() {
604
- if (!getMachineIdImpl) {
605
- switch (process__namespace.platform) {
606
- case 'darwin':
607
- getMachineIdImpl = (await Promise.resolve().then(function () { return require('./getMachineId-darwin-BDexu45J.cjs'); }))
608
- .getMachineId;
609
- break;
610
- case 'linux':
611
- getMachineIdImpl = (await Promise.resolve().then(function () { return require('./getMachineId-linux-sJzq0whF.cjs'); }))
612
- .getMachineId;
613
- break;
614
- case 'freebsd':
615
- getMachineIdImpl = (await Promise.resolve().then(function () { return require('./getMachineId-bsd-Bm_iwnsS.cjs'); })).getMachineId;
616
- break;
617
- case 'win32':
618
- getMachineIdImpl = (await Promise.resolve().then(function () { return require('./getMachineId-win-5mPgREt3.cjs'); })).getMachineId;
619
- break;
620
- default:
621
- getMachineIdImpl = (await Promise.resolve().then(function () { return require('./getMachineId-unsupported-Cmowwltd.cjs'); }))
622
- .getMachineId;
623
- break;
624
- }
625
- }
626
- return getMachineIdImpl();
627
- }
628
-
629
- /*
630
- * Copyright The OpenTelemetry Authors
631
- *
632
- * Licensed under the Apache License, Version 2.0 (the "License");
633
- * you may not use this file except in compliance with the License.
634
- * You may obtain a copy of the License at
635
- *
636
- * https://www.apache.org/licenses/LICENSE-2.0
637
- *
638
- * Unless required by applicable law or agreed to in writing, software
639
- * distributed under the License is distributed on an "AS IS" BASIS,
640
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
641
- * See the License for the specific language governing permissions and
642
- * limitations under the License.
643
- */
644
- const normalizeArch = (nodeArchString) => {
645
- // Maps from https://nodejs.org/api/os.html#osarch to arch values in spec:
646
- // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/host.md
647
- switch (nodeArchString) {
648
- case 'arm':
649
- return 'arm32';
650
- case 'ppc':
651
- return 'ppc32';
652
- case 'x64':
653
- return 'amd64';
654
- default:
655
- return nodeArchString;
656
- }
657
- };
658
- const normalizeType = (nodePlatform) => {
659
- // Maps from https://nodejs.org/api/os.html#osplatform to arch values in spec:
660
- // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/os.md
661
- switch (nodePlatform) {
662
- case 'sunos':
663
- return 'solaris';
664
- case 'win32':
665
- return 'windows';
666
- default:
667
- return nodePlatform;
668
- }
669
- };
670
-
671
- /*
672
- * Copyright The OpenTelemetry Authors
673
- *
674
- * Licensed under the Apache License, Version 2.0 (the "License");
675
- * you may not use this file except in compliance with the License.
676
- * You may obtain a copy of the License at
677
- *
678
- * https://www.apache.org/licenses/LICENSE-2.0
679
- *
680
- * Unless required by applicable law or agreed to in writing, software
681
- * distributed under the License is distributed on an "AS IS" BASIS,
682
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
683
- * See the License for the specific language governing permissions and
684
- * limitations under the License.
685
- */
686
- /**
687
- * HostDetector detects the resources related to the host current process is
688
- * running on. Currently only non-cloud-based attributes are included.
689
- */
690
- class HostDetector {
691
- detect(_config) {
692
- const attributes = {
693
- [ATTR_HOST_NAME]: require$$0$1.hostname(),
694
- [ATTR_HOST_ARCH]: normalizeArch(require$$0$1.arch()),
695
- [ATTR_HOST_ID]: getMachineId(),
696
- };
697
- return { attributes };
698
- }
699
- }
700
- const hostDetector = new HostDetector();
701
-
702
- /*
703
- * Copyright The OpenTelemetry Authors
704
- *
705
- * Licensed under the Apache License, Version 2.0 (the "License");
706
- * you may not use this file except in compliance with the License.
707
- * You may obtain a copy of the License at
708
- *
709
- * https://www.apache.org/licenses/LICENSE-2.0
710
- *
711
- * Unless required by applicable law or agreed to in writing, software
712
- * distributed under the License is distributed on an "AS IS" BASIS,
713
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
714
- * See the License for the specific language governing permissions and
715
- * limitations under the License.
716
- */
717
- /**
718
- * OSDetector detects the resources related to the operating system (OS) on
719
- * which the process represented by this resource is running.
720
- */
721
- class OSDetector {
722
- detect(_config) {
723
- const attributes = {
724
- [ATTR_OS_TYPE]: normalizeType(require$$0$1.platform()),
725
- [ATTR_OS_VERSION]: require$$0$1.release(),
726
- };
727
- return { attributes };
728
- }
729
- }
730
- const osDetector = new OSDetector();
731
-
732
- /*
733
- * Copyright The OpenTelemetry Authors
734
- *
735
- * Licensed under the Apache License, Version 2.0 (the "License");
736
- * you may not use this file except in compliance with the License.
737
- * You may obtain a copy of the License at
738
- *
739
- * https://www.apache.org/licenses/LICENSE-2.0
740
- *
741
- * Unless required by applicable law or agreed to in writing, software
742
- * distributed under the License is distributed on an "AS IS" BASIS,
743
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
744
- * See the License for the specific language governing permissions and
745
- * limitations under the License.
746
- */
747
- /**
748
- * ProcessDetector will be used to detect the resources related current process running
749
- * and being instrumented from the NodeJS Process module.
750
- */
751
- class ProcessDetector {
752
- detect(_config) {
753
- const attributes = {
754
- [ATTR_PROCESS_PID]: process.pid,
755
- [ATTR_PROCESS_EXECUTABLE_NAME]: process.title,
756
- [ATTR_PROCESS_EXECUTABLE_PATH]: process.execPath,
757
- [ATTR_PROCESS_COMMAND_ARGS]: [
758
- process.argv[0],
759
- ...process.execArgv,
760
- ...process.argv.slice(1),
761
- ],
762
- [ATTR_PROCESS_RUNTIME_VERSION]: process.versions.node,
763
- [ATTR_PROCESS_RUNTIME_NAME]: 'nodejs',
764
- [ATTR_PROCESS_RUNTIME_DESCRIPTION]: 'Node.js',
765
- };
766
- if (process.argv.length > 1) {
767
- attributes[ATTR_PROCESS_COMMAND] = process.argv[1];
768
- }
769
- try {
770
- const userInfo = require$$0__namespace.userInfo();
771
- attributes[ATTR_PROCESS_OWNER] = userInfo.username;
772
- }
773
- catch (e) {
774
- require$$0.diag.debug(`error obtaining process owner: ${e}`);
775
- }
776
- return { attributes };
777
- }
778
- }
779
- const processDetector = new ProcessDetector();
780
-
781
- /*
782
- * Copyright The OpenTelemetry Authors
783
- *
784
- * Licensed under the Apache License, Version 2.0 (the "License");
785
- * you may not use this file except in compliance with the License.
786
- * You may obtain a copy of the License at
787
- *
788
- * https://www.apache.org/licenses/LICENSE-2.0
789
- *
790
- * Unless required by applicable law or agreed to in writing, software
791
- * distributed under the License is distributed on an "AS IS" BASIS,
792
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
793
- * See the License for the specific language governing permissions and
794
- * limitations under the License.
795
- */
796
- /**
797
- * ServiceInstanceIdDetector detects the resources related to the service instance ID.
798
- */
799
- class ServiceInstanceIdDetector {
800
- detect(_config) {
801
- return {
802
- attributes: {
803
- [ATTR_SERVICE_INSTANCE_ID]: crypto.randomUUID(),
804
- },
805
- };
806
- }
807
- }
808
- /**
809
- * @experimental
810
- */
811
- const serviceInstanceIdDetector = new ServiceInstanceIdDetector();
812
-
813
- /*
814
- * Copyright The OpenTelemetry Authors
815
- *
816
- * Licensed under the Apache License, Version 2.0 (the "License");
817
- * you may not use this file except in compliance with the License.
818
- * You may obtain a copy of the License at
819
- *
820
- * https://www.apache.org/licenses/LICENSE-2.0
821
- *
822
- * Unless required by applicable law or agreed to in writing, software
823
- * distributed under the License is distributed on an "AS IS" BASIS,
824
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
825
- * See the License for the specific language governing permissions and
826
- * limitations under the License.
827
- */
828
-
829
- var esm = /*#__PURE__*/Object.freeze({
830
- __proto__: null,
831
- defaultResource: defaultResource,
832
- defaultServiceName: defaultServiceName,
833
- detectResources: detectResources,
834
- emptyResource: emptyResource,
835
- envDetector: envDetector,
836
- hostDetector: hostDetector,
837
- osDetector: osDetector,
838
- processDetector: processDetector,
839
- resourceFromAttributes: resourceFromAttributes,
840
- serviceInstanceIdDetector: serviceInstanceIdDetector
841
- });
842
-
843
- exports.esm = esm;