@azure/monitor-opentelemetry 1.20.0 → 1.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/commonjs/index.d.ts.map +1 -1
  2. package/dist/commonjs/index.js +14 -18
  3. package/dist/commonjs/index.js.map +1 -1
  4. package/dist/commonjs/logs/handler.d.ts +2 -1
  5. package/dist/commonjs/logs/handler.d.ts.map +1 -1
  6. package/dist/commonjs/logs/handler.js +10 -5
  7. package/dist/commonjs/logs/handler.js.map +1 -1
  8. package/dist/commonjs/metrics/quickpulse/export/sender.d.ts +1 -1
  9. package/dist/commonjs/metrics/quickpulse/export/sender.d.ts.map +1 -1
  10. package/dist/commonjs/metrics/quickpulse/export/sender.js +21 -16
  11. package/dist/commonjs/metrics/quickpulse/export/sender.js.map +1 -1
  12. package/dist/commonjs/metrics/quickpulse/liveMetrics.d.ts +5 -1
  13. package/dist/commonjs/metrics/quickpulse/liveMetrics.d.ts.map +1 -1
  14. package/dist/commonjs/metrics/quickpulse/liveMetrics.js +86 -75
  15. package/dist/commonjs/metrics/quickpulse/liveMetrics.js.map +1 -1
  16. package/dist/commonjs/package.json +1 -1
  17. package/dist/commonjs/traces/azureSdkInstrumentation.d.ts +12 -0
  18. package/dist/commonjs/traces/azureSdkInstrumentation.d.ts.map +1 -0
  19. package/dist/commonjs/traces/azureSdkInstrumentation.js +64 -0
  20. package/dist/commonjs/traces/azureSdkInstrumentation.js.map +1 -0
  21. package/dist/commonjs/traces/handler.d.ts +2 -13
  22. package/dist/commonjs/traces/handler.d.ts.map +1 -1
  23. package/dist/commonjs/traces/handler.js +13 -36
  24. package/dist/commonjs/traces/handler.js.map +1 -1
  25. package/dist/commonjs/tsdoc-metadata.json +1 -1
  26. package/dist/commonjs/types.d.ts +1 -1
  27. package/dist/commonjs/types.js +1 -1
  28. package/dist/commonjs/types.js.map +1 -1
  29. package/dist/commonjs/utils/azureSdkTracingBridge.d.ts +4 -4
  30. package/dist/commonjs/utils/azureSdkTracingBridge.d.ts.map +1 -1
  31. package/dist/commonjs/utils/azureSdkTracingBridge.js +10 -8
  32. package/dist/commonjs/utils/azureSdkTracingBridge.js.map +1 -1
  33. package/dist/commonjs/utils/instrumentation.d.ts +8 -0
  34. package/dist/commonjs/utils/instrumentation.d.ts.map +1 -0
  35. package/dist/commonjs/utils/instrumentation.js +26 -0
  36. package/dist/commonjs/utils/instrumentation.js.map +1 -0
  37. package/dist/esm/index.d.ts.map +1 -1
  38. package/dist/esm/index.js +14 -18
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/logs/handler.d.ts +2 -1
  41. package/dist/esm/logs/handler.d.ts.map +1 -1
  42. package/dist/esm/logs/handler.js +10 -5
  43. package/dist/esm/logs/handler.js.map +1 -1
  44. package/dist/esm/metrics/quickpulse/export/sender.d.ts +1 -1
  45. package/dist/esm/metrics/quickpulse/export/sender.d.ts.map +1 -1
  46. package/dist/esm/metrics/quickpulse/export/sender.js +21 -16
  47. package/dist/esm/metrics/quickpulse/export/sender.js.map +1 -1
  48. package/dist/esm/metrics/quickpulse/liveMetrics.d.ts +5 -1
  49. package/dist/esm/metrics/quickpulse/liveMetrics.d.ts.map +1 -1
  50. package/dist/esm/metrics/quickpulse/liveMetrics.js +86 -75
  51. package/dist/esm/metrics/quickpulse/liveMetrics.js.map +1 -1
  52. package/dist/esm/package.json +1 -1
  53. package/dist/esm/traces/azureSdkInstrumentation.d.ts +12 -0
  54. package/dist/esm/traces/azureSdkInstrumentation.d.ts.map +1 -0
  55. package/dist/esm/traces/azureSdkInstrumentation.js +60 -0
  56. package/dist/esm/traces/azureSdkInstrumentation.js.map +1 -0
  57. package/dist/esm/traces/handler.d.ts +2 -13
  58. package/dist/esm/traces/handler.d.ts.map +1 -1
  59. package/dist/esm/traces/handler.js +13 -35
  60. package/dist/esm/traces/handler.js.map +1 -1
  61. package/dist/esm/types.d.ts +1 -1
  62. package/dist/esm/types.js +1 -1
  63. package/dist/esm/types.js.map +1 -1
  64. package/dist/esm/utils/azureSdkTracingBridge.d.ts +4 -4
  65. package/dist/esm/utils/azureSdkTracingBridge.d.ts.map +1 -1
  66. package/dist/esm/utils/azureSdkTracingBridge.js +11 -7
  67. package/dist/esm/utils/azureSdkTracingBridge.js.map +1 -1
  68. package/dist/esm/utils/instrumentation.d.ts +8 -0
  69. package/dist/esm/utils/instrumentation.d.ts.map +1 -0
  70. package/dist/esm/utils/instrumentation.js +23 -0
  71. package/dist/esm/utils/instrumentation.js.map +1 -0
  72. package/package.json +8 -5
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.AzureSdkInstrumentation = void 0;
6
+ const opentelemetry_instrumentation_azure_sdk_1 = require("@azure/opentelemetry-instrumentation-azure-sdk");
7
+ const api_1 = require("@opentelemetry/api");
8
+ const nonRecordingSpan = {
9
+ end: () => { },
10
+ isRecording: () => false,
11
+ recordException: () => { },
12
+ setAttribute: () => { },
13
+ setStatus: () => { },
14
+ addEvent: () => { },
15
+ };
16
+ function createLifecycleInstrumenter(isEnabled) {
17
+ const instrumenter = (0, opentelemetry_instrumentation_azure_sdk_1.createOpenTelemetryInstrumenter)();
18
+ return {
19
+ startSpan(name, options) {
20
+ if (!isEnabled()) {
21
+ return {
22
+ span: nonRecordingSpan,
23
+ tracingContext: options.tracingContext ?? api_1.context.active(),
24
+ };
25
+ }
26
+ return instrumenter.startSpan(name, options);
27
+ },
28
+ withContext(tracingContext, callback, ...args) {
29
+ return instrumenter.withContext(tracingContext, callback, ...args);
30
+ },
31
+ parseTraceparentHeader(header) {
32
+ return isEnabled() ? instrumenter.parseTraceparentHeader(header) : undefined;
33
+ },
34
+ createRequestHeaders(tracingContext) {
35
+ return isEnabled() ? instrumenter.createRequestHeaders(tracingContext) : {};
36
+ },
37
+ };
38
+ }
39
+ /**
40
+ * Keep both eager and module-hook bridges tied to the distro's instrumentation
41
+ * lifecycle without changing the shared Azure SDK instrumentation package.
42
+ * Context activation remains available when instrumentation is disabled.
43
+ * @internal
44
+ */
45
+ class AzureSdkInstrumentation extends opentelemetry_instrumentation_azure_sdk_1.AzureSdkInstrumentation {
46
+ init() {
47
+ const definitions = super.init();
48
+ const modules = Array.isArray(definitions) ? definitions : definitions ? [definitions] : [];
49
+ for (const module of modules) {
50
+ if (module.name === "@azure/core-tracing") {
51
+ module.patch = (moduleExports) => {
52
+ if (typeof moduleExports.useInstrumenter === "function") {
53
+ // Disable only this bridge; leave customer-installed instrumenters untouched.
54
+ moduleExports.useInstrumenter(createLifecycleInstrumenter(() => this.isEnabled()));
55
+ }
56
+ return moduleExports;
57
+ };
58
+ }
59
+ }
60
+ return definitions;
61
+ }
62
+ }
63
+ exports.AzureSdkInstrumentation = AzureSdkInstrumentation;
64
+ //# sourceMappingURL=azureSdkInstrumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azureSdkInstrumentation.js","sourceRoot":"","sources":["../../../src/traces/azureSdkInstrumentation.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,4GAGwD;AACxD,4CAA6C;AAG7C,MAAM,gBAAgB,GAAgB;IACpC,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC;IACb,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK;IACxB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;IACzB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC;IACnB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;CACnB,CAAC;AAEF,SAAS,2BAA2B,CAAC,SAAwB;IAC3D,MAAM,YAAY,GAAG,IAAA,yEAA+B,GAAE,CAAC;IACvD,OAAO;QACL,SAAS,CAAC,IAAI,EAAE,OAAO;YACrB,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;gBACjB,OAAO;o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CAAC,2BAA2B,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;oBACrF,CAAC;oBACD,OAAO,aAAa,CAAC;gBACvB,CAAC,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAlBD,0DAkBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Instrumenter, TracingSpan } from \"@azure/core-tracing\";\nimport type * as CoreTracing from \"@azure/core-tracing\";\nimport {\n AzureSdkInstrumentation as BaseAzureSdkInstrumentation,\n createOpenTelemetryInstrumenter,\n} from \"@azure/opentelemetry-instrumentation-azure-sdk\";\nimport { context } from \"@opentelemetry/api\";\nimport type { InstrumentationModuleDefinition } from \"@opentelemetry/instrumentation\";\n\nconst nonRecordingSpan: TracingSpan = {\n end: () => {},\n isRecording: () => false,\n recordException: () => {},\n setAttribute: () => {},\n setStatus: () => {},\n addEvent: () => {},\n};\n\nfunction createLifecycleInstrumenter(isEnabled: () => boolean): Instrumenter {\n const instrumenter = createOpenTelemetryInstrumenter();\n return {\n startSpan(name, options) {\n if (!isEnabled()) {\n return {\n span: nonRecordingSpan,\n tracingContext: options.tracingContext ?? context.active(),\n };\n }\n return instrumenter.startSpan(name, options);\n },\n withContext(tracingContext, callback, ...args) {\n return instrumenter.withContext(tracingContext, callback, ...args);\n },\n parseTraceparentHeader(header) {\n return isEnabled() ? instrumenter.parseTraceparentHeader(header) : undefined;\n },\n createRequestHeaders(tracingContext) {\n return isEnabled() ? instrumenter.createRequestHeaders(tracingContext) : {};\n },\n };\n}\n\n/**\n * Keep both eager and module-hook bridges tied to the distro's instrumentation\n * lifecycle without changing the shared Azure SDK instrumentation package.\n * Context activation remains available when instrumentation is disabled.\n * @internal\n */\nexport class AzureSdkInstrumentation extends BaseAzureSdkInstrumentation {\n protected override init():\n InstrumentationModuleDefinition | InstrumentationModuleDefinition[] | void {\n const definitions = super.init();\n const modules = Array.isArray(definitions) ? definitions : definitions ? [definitions] : [];\n for (const module of modules) {\n if (module.name === \"@azure/core-tracing\") {\n module.patch = (moduleExports: typeof CoreTracing) => {\n if (typeof moduleExports.useInstrumenter === \"function\") {\n // Disable only this bridge; leave customer-installed instrumenters untouched.\n moduleExports.useInstrumenter(createLifecycleInstrumenter(() => this.isEnabled()));\n }\n return moduleExports;\n };\n }\n }\n return definitions;\n }\n}\n"]}
@@ -8,6 +8,7 @@ import type { Instrumentation } from "@opentelemetry/instrumentation";
8
8
  * Azure Monitor OpenTelemetry Trace Handler
9
9
  */
10
10
  export declare class TraceHandler {
11
+ private readonly instrumentationCache?;
11
12
  private _batchSpanProcessor;
12
13
  private _azureSpanProcessor;
13
14
  private _azureExporter;
@@ -21,7 +22,7 @@ export declare class TraceHandler {
21
22
  * @param _config - Configuration.
22
23
  * @param _metricHandler - MetricHandler.
23
24
  */
24
- constructor(config: InternalConfig, metricHandler: MetricHandler);
25
+ constructor(config: InternalConfig, metricHandler: MetricHandler, instrumentationCache?: Map<string, Instrumentation> | undefined);
25
26
  getSampler(): Sampler;
26
27
  getBatchSpanProcessor(): BatchSpanProcessor;
27
28
  getAzureMonitorSpanProcessor(): AzureMonitorSpanProcessor;
@@ -34,17 +35,5 @@ export declare class TraceHandler {
34
35
  * Start auto collection of telemetry
35
36
  */
36
37
  private _initializeInstrumentations;
37
- /**
38
- * Wire the Azure SDK instrumenter into `@azure/core-tracing` directly.
39
- *
40
- * The Azure SDK instrumentation registers its instrumenter through an OpenTelemetry
41
- * module-patch hook that only fires via `require`/`import`-in-the-middle. In ESM hosts
42
- * where the OpenTelemetry loader cannot be registered up front (for example, Azure
43
- * Functions, which controls the Node.js start command), that hook never runs, so Azure
44
- * SDK dependency spans are missing. Because `@azure/core-tracing` resolves its
45
- * instrumenter lazily at span-creation time from shared module-local state, applying
46
- * the same patch directly here enables Azure SDK tracing regardless of module system.
47
- */
48
- private _wireAzureSdkInstrumenter;
49
38
  }
50
39
  //# sourceMappingURL=handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAWnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAIxC;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,mBAAmB,CAA4B;IACvD,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;OAIG;gBACS,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa;IAqBzD,UAAU,IAAI,OAAO;IAIrB,qBAAqB,IAAI,kBAAkB;IAI3C,4BAA4B,IAAI,yBAAyB;IAIzD,mBAAmB,IAAI,eAAe,EAAE;IAI/C;;OAEG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAwDnC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,yBAAyB;CAiBlC"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAWnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAMtE;;GAEG;AACH,qBAAa,YAAY;IAkBrB,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IAjBxC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,mBAAmB,CAA4B;IACvD,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;OAIG;gBAED,MAAM,EAAE,cAAc,EACtB,aAAa,EAAE,aAAa,EACX,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,YAAA;IAsB/D,UAAU,IAAI,OAAO;IAIrB,qBAAqB,IAAI,kBAAkB;IAI3C,4BAA4B,IAAI,yBAAyB;IAIzD,mBAAmB,IAAI,eAAe,EAAE;IAI/C;;OAEG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtC;;OAEG;IACH,OAAO,CAAC,2BAA2B;CAmFpC"}
@@ -3,9 +3,6 @@
3
3
  // Licensed under the MIT License.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.TraceHandler = void 0;
6
- const tslib_1 = require("tslib");
7
- const opentelemetry_instrumentation_azure_sdk_1 = require("@azure/opentelemetry-instrumentation-azure-sdk");
8
- const coreTracing = tslib_1.__importStar(require("@azure/core-tracing"));
9
6
  const monitor_opentelemetry_exporter_1 = require("@azure/monitor-opentelemetry-exporter");
10
7
  const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
11
8
  const instrumentation_http_1 = require("@opentelemetry/instrumentation-http");
@@ -17,11 +14,14 @@ const common_js_1 = require("../utils/common.js");
17
14
  const spanProcessor_js_1 = require("./spanProcessor.js");
18
15
  const azureFnHook_js_1 = require("./azureFnHook.js");
19
16
  const sampler_js_1 = require("./sampler.js");
20
- const index_js_1 = require("../shared/logging/index.js");
17
+ const azureSdkTracingBridge_js_1 = require("../utils/azureSdkTracingBridge.js");
18
+ const instrumentation_js_1 = require("../utils/instrumentation.js");
19
+ const azureSdkInstrumentation_js_1 = require("./azureSdkInstrumentation.js");
21
20
  /**
22
21
  * Azure Monitor OpenTelemetry Trace Handler
23
22
  */
24
23
  class TraceHandler {
24
+ instrumentationCache;
25
25
  _batchSpanProcessor;
26
26
  _azureSpanProcessor;
27
27
  _azureExporter;
@@ -35,7 +35,8 @@ class TraceHandler {
35
35
  * @param _config - Configuration.
36
36
  * @param _metricHandler - MetricHandler.
37
37
  */
38
- constructor(config, metricHandler) {
38
+ constructor(config, metricHandler, instrumentationCache) {
39
+ this.instrumentationCache = instrumentationCache;
39
40
  this._config = config;
40
41
  this._metricHandler = metricHandler;
41
42
  this._instrumentations = [];
@@ -98,49 +99,25 @@ class TraceHandler {
98
99
  return result;
99
100
  };
100
101
  httpinstrumentationOptions.ignoreOutgoingRequestHook = mergedIgnoreOutgoingRequestHook;
101
- this._instrumentations.push(new instrumentation_http_1.HttpInstrumentation(this._config.instrumentationOptions.http));
102
+ this._instrumentations.push((0, instrumentation_js_1.configureInstrumentation)(this.instrumentationCache, "http", httpinstrumentationOptions, (options) => new instrumentation_http_1.HttpInstrumentation(options)));
102
103
  }
103
104
  if (this._config.instrumentationOptions.azureSdk?.enabled) {
104
- const azureSdkInstrumentation = (0, opentelemetry_instrumentation_azure_sdk_1.createAzureSdkInstrumentation)(this._config.instrumentationOptions.azureSdk);
105
+ const azureSdkInstrumentation = (0, instrumentation_js_1.configureInstrumentation)(this.instrumentationCache, "azureSdk", this._config.instrumentationOptions.azureSdk, (options) => new azureSdkInstrumentation_js_1.AzureSdkInstrumentation(options));
105
106
  this._instrumentations.push(azureSdkInstrumentation);
106
- this._wireAzureSdkInstrumenter(azureSdkInstrumentation);
107
+ (0, azureSdkTracingBridge_js_1.ensureAzureSdkTracingBridge)(azureSdkInstrumentation);
107
108
  }
108
109
  if (this._config.instrumentationOptions.mongoDb?.enabled) {
109
- this._instrumentations.push(new instrumentation_mongodb_1.MongoDBInstrumentation(this._config.instrumentationOptions.mongoDb));
110
+ this._instrumentations.push((0, instrumentation_js_1.configureInstrumentation)(this.instrumentationCache, "mongoDb", this._config.instrumentationOptions.mongoDb, (options) => new instrumentation_mongodb_1.MongoDBInstrumentation(options)));
110
111
  }
111
112
  if (this._config.instrumentationOptions.mySql?.enabled) {
112
- this._instrumentations.push(new instrumentation_mysql_1.MySQLInstrumentation(this._config.instrumentationOptions.mySql));
113
+ this._instrumentations.push((0, instrumentation_js_1.configureInstrumentation)(this.instrumentationCache, "mySql", this._config.instrumentationOptions.mySql, (options) => new instrumentation_mysql_1.MySQLInstrumentation(options)));
113
114
  }
114
115
  if (this._config.instrumentationOptions.postgreSql?.enabled) {
115
- this._instrumentations.push(new instrumentation_pg_1.PgInstrumentation(this._config.instrumentationOptions.postgreSql));
116
+ this._instrumentations.push((0, instrumentation_js_1.configureInstrumentation)(this.instrumentationCache, "postgreSql", this._config.instrumentationOptions.postgreSql, (options) => new instrumentation_pg_1.PgInstrumentation(options)));
116
117
  }
117
118
  if (this._config.instrumentationOptions.redis?.enabled ||
118
119
  this._config.instrumentationOptions.redis4?.enabled) {
119
- this._instrumentations.push(new instrumentation_redis_1.RedisInstrumentation(this._config.instrumentationOptions.redis));
120
- }
121
- }
122
- /**
123
- * Wire the Azure SDK instrumenter into `@azure/core-tracing` directly.
124
- *
125
- * The Azure SDK instrumentation registers its instrumenter through an OpenTelemetry
126
- * module-patch hook that only fires via `require`/`import`-in-the-middle. In ESM hosts
127
- * where the OpenTelemetry loader cannot be registered up front (for example, Azure
128
- * Functions, which controls the Node.js start command), that hook never runs, so Azure
129
- * SDK dependency spans are missing. Because `@azure/core-tracing` resolves its
130
- * instrumenter lazily at span-creation time from shared module-local state, applying
131
- * the same patch directly here enables Azure SDK tracing regardless of module system.
132
- */
133
- _wireAzureSdkInstrumenter(instrumentation) {
134
- try {
135
- const moduleDefinitions = instrumentation.getModuleDefinitions?.() ?? [];
136
- for (const moduleDefinition of moduleDefinitions) {
137
- if (moduleDefinition.name === "@azure/core-tracing" && moduleDefinition.patch) {
138
- moduleDefinition.patch(coreTracing);
139
- }
140
- }
141
- }
142
- catch (error) {
143
- index_js_1.Logger.getInstance().warn("Failed to enable Azure SDK tracing for ESM applications", error);
120
+ this._instrumentations.push((0, instrumentation_js_1.configureInstrumentation)(this.instrumentationCache, "redis", this._config.instrumentationOptions.redis ?? {}, (options) => new instrumentation_redis_1.RedisInstrumentation(options)));
144
121
  }
145
122
  }
146
123
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAGlC,4GAA+F;AAC/F,yEAAmD;AACnD,0FAG+C;AAE/C,kEAAmE;AAKnE,8EAA0E;AAC1E,oFAAgF;AAChF,gFAA4E;AAC5E,0EAAsE;AACtE,gFAA4E;AAI5E,kDAA+D;AAC/D,yDAA+D;AAC/D,qDAAsD;AAKtD,6CAA0D;AAC1D,yDAAoD;AAEpD;;GAEG;AACH,MAAa,YAAY;IACf,mBAAmB,CAAqB;IACxC,mBAAmB,CAA4B;IAC/C,cAAc,CAA4B;IAC1C,iBAAiB,CAAoB;IACrC,OAAO,CAAiB;IACxB,cAAc,CAAgB;IAC9B,mBAAmB,CAAqB;IACxC,QAAQ,CAAU;IAE1B;;;;OAIG;IACH,YAAY,MAAsB,EAAE,aAA4B;QAC9D,IAAI,CAA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,KAAK,MAAM,gBAAgB,IAAI,iBAAiB,EAAE,CAAC;gBACjD,IAAI,gBAAgB,CAAC,IAAI,KAAK,qBAAqB,IAAI,gBAAgB,CAAC,KAAK,EAAE,CAAC;oBAC9E,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;gBACtC,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,iBAAM,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,yDAAyD,EAAE,KAAK,CAAC,CAAC;QAC9F,CAAC;IACH,CAAC;CACF;AArJD,oCAqJC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RequestOptions } from \"node:http\";\nimport { createAzureSdkInstrumentation } from \"@azure/opentelemetry-instrumentation-azure-sdk\";\nimport * as coreTracing from \"@azure/core-tracing\";\nimport {\n AzureMonitorTraceExporter,\n RateLimitedSampler,\n} from \"@azure/monitor-opentelemetry-exporter\";\nimport type { Sampler } from \"@opentelemetry/sdk-trace-base\";\nimport { BatchSpanProcessor } from \"@opentelemetry/sdk-trace-base\";\nimport type {\n HttpInstrumentationConfig,\n IgnoreOutgoingRequestFunction,\n} from \"@opentelemetry/instrumentation-http\";\nimport { HttpInstrumentation } from \"@opentelemetry/instrumentation-http\";\nimport { MongoDBInstrumentation } from \"@opentelemetry/instrumentation-mongodb\";\nimport { MySQLInstrumentation } from \"@opentelemetry/instrumentation-mysql\";\nimport { PgInstrumentation } from \"@opentelemetry/instrumentation-pg\";\nimport { RedisInstrumentation } from \"@opentelemetry/instrumentation-redis\";\n\nimport type { InternalConfig } from \"../shared/config.js\";\nimport type { MetricHandler } from \"../metrics/handler.js\";\nimport { ignoreOutgoingRequestHook } from \"../utils/common.js\";\nimport { AzureMonitorSpanProcessor } from \"./spanProcessor.js\";\nimport { AzureFunctionsHook } from \"./azureFnHook.js\";\nimport type {\n Instrumentation,\n InstrumentationModuleDefinition,\n} from \"@opentelemetry/instrumentation\";\nimport { ApplicationInsightsSampler } from \"./sampler.js\";\nimport { Logger } from \"../shared/logging/index.js\";\n\n/**\n * Azure Monitor OpenTelemetry Trace Handler\n */\nexport class TraceHandler {\n private _batchSpanProcessor: BatchSpanProcessor;\n private _azureSpanProcessor: AzureMonitorSpanProcessor;\n private _azureExporter: AzureMonitorTraceExporter;\n private _instrumentations: Instrumentation[];\n private _config: InternalConfig;\n private _metricHandler: MetricHandler;\n private _azureFunctionsHook: AzureFunctionsHook;\n private _sampler: Sampler;\n\n /**\n * Initializes a new instance of the TraceHandler class.\n * @param _config - Configuration.\n * @param _metricHandler - MetricHandler.\n */\n constructor(config: InternalConfig, metricHandler: MetricHandler) {\n this._config = config;\n this._metricHandler = metricHandler;\n this._instrumentations = [];\n // Check sampler precedence\n if (this._config.sampler) {\n this._sampler = this._config.sampler;\n } else if (this._config.tracesPerSecond && this._config.tracesPerSecond > 0) {\n // If tracesPerSecond is set to a positive number, use RateLimitedSampler\n this._sampler = new RateLimitedSampler(this._config.tracesPerSecond);\n } else {\n // Otherwise, use PercentageSampler with samplingRatio\n this._sampler = new ApplicationInsightsSampler(this._config.samplingRatio);\n }\n this._azureExporter = new AzureMonitorTraceExporter(this._config.azureMonitorExporterOptions);\n this._batchSpanProcessor = new BatchSpanProcessor(this._azureExporter);\n this._azureSpanProcessor = new AzureMonitorSpanProcessor(this._metricHandler);\n this._azureFunctionsHook = new AzureFunctionsHook();\n this._initializeInstrumentations();\n }\n\n public getSampler(): Sampler {\n return this._sampler;\n }\n\n public getBatchSpanProcessor(): BatchSpanProcessor {\n return this._batchSpanProcessor;\n }\n\n public getAzureMonitorSpanProcessor(): AzureMonitorSpanProcessor {\n return this._azureSpanProcessor;\n }\n\n public getInstrumentations(): Instrumentation[] {\n return this._instrumentations;\n }\n\n /**\n * Shutdown handler\n */\n public async shutdown(): Promise<void> {\n this._azureFunctionsHook.shutdown();\n await this._batchSpanProcessor.shutdown();\n await this._azureSpanProcessor.shutdown();\n await this._azureExporter.shutdown();\n }\n\n /**\n * Start auto collection of telemetry\n */\n private _initializeInstrumentations(): void {\n if (this._config.instrumentationOptions.http?.enabled) {\n const httpinstrumentationOptions = this._config.instrumentationOptions\n .http as HttpInstrumentationConfig;\n const providedIgnoreOutgoingRequestHook =\n httpinstrumentationOptions.ignoreOutgoingRequestHook;\n const mergedIgnoreOutgoingRequestHook: IgnoreOutgoingRequestFunction = (\n request: RequestOptions,\n ) => {\n const result = ignoreOutgoingRequestHook(request);\n if (!result) {\n // Not internal call\n if (providedIgnoreOutgoingRequestHook) {\n // Provided hook in config\n return providedIgnoreOutgoingRequestHook(request);\n }\n }\n return result;\n };\n httpinstrumentationOptions.ignoreOutgoingRequestHook = mergedIgnoreOutgoingRequestHook;\n this._instrumentations.push(\n new HttpInstrumentation(this._config.instrumentationOptions.http),\n );\n }\n if (this._config.instrumentationOptions.azureSdk?.enabled) {\n const azureSdkInstrumentation = createAzureSdkInstrumentation(\n this._config.instrumentationOptions.azureSdk,\n );\n this._instrumentations.push(azureSdkInstrumentation);\n this._wireAzureSdkInstrumenter(azureSdkInstrumentation);\n }\n if (this._config.instrumentationOptions.mongoDb?.enabled) {\n this._instrumentations.push(\n new MongoDBInstrumentation(this._config.instrumentationOptions.mongoDb),\n );\n }\n if (this._config.instrumentationOptions.mySql?.enabled) {\n this._instrumentations.push(\n new MySQLInstrumentation(this._config.instrumentationOptions.mySql),\n );\n }\n if (this._config.instrumentationOptions.postgreSql?.enabled) {\n this._instrumentations.push(\n new PgInstrumentation(this._config.instrumentationOptions.postgreSql),\n );\n }\n if (\n this._config.instrumentationOptions.redis?.enabled ||\n this._config.instrumentationOptions.redis4?.enabled\n ) {\n this._instrumentations.push(\n new RedisInstrumentation(this._config.instrumentationOptions.redis),\n );\n }\n }\n\n /**\n * Wire the Azure SDK instrumenter into `@azure/core-tracing` directly.\n *\n * The Azure SDK instrumentation registers its instrumenter through an OpenTelemetry\n * module-patch hook that only fires via `require`/`import`-in-the-middle. In ESM hosts\n * where the OpenTelemetry loader cannot be registered up front (for example, Azure\n * Functions, which controls the Node.js start command), that hook never runs, so Azure\n * SDK dependency spans are missing. Because `@azure/core-tracing` resolves its\n * instrumenter lazily at span-creation time from shared module-local state, applying\n * the same patch directly here enables Azure SDK tracing regardless of module system.\n */\n private _wireAzureSdkInstrumenter(instrumentation: Instrumentation): void {\n try {\n const moduleDefinitions =\n (\n instrumentation as Instrumentation & {\n getModuleDefinitions?: () => InstrumentationModuleDefinition[];\n }\n ).getModuleDefinitions?.() ?? [];\n for (const moduleDefinition of moduleDefinitions) {\n if (moduleDefinition.name === \"@azure/core-tracing\" && moduleDefinition.patch) {\n moduleDefinition.patch(coreTracing);\n }\n }\n } catch (error) {\n Logger.getInstance().warn(\"Failed to enable Azure SDK tracing for ESM applications\", error);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,0FAG+C;AAE/C,kEAAmE;AAKnE,8EAA0E;AAC1E,oFAAgF;AAChF,gFAA4E;AAC5E,0EAAsE;AACtE,gFAA4E;AAI5E,kDAA+D;AAC/D,yDAA+D;AAC/D,qDAAsD;AAEtD,6CAA0D;AAC1D,gFAAgF;AAChF,oEAAuE;AACvE,6EAAuE;AAEvE;;GAEG;AACH,MAAa,YAAY;IAkBJ;IAjBX,mBAAmB,CAAqB;IACxC,mBAAmB,CAA4B;IAC/C,cAAc,CAA4B;IAC1C,iBAAiB,CAAoB;IACrC,OAAO,CAAiB;IACxB,cAAc,CAAgB;IAC9B,mBAAmB,CAAqB;IACxC,QAAQ,CAAU;IAE1B;;;;OAIG;IACH,YACE,MAAsB,EACtB,aAA4B,EACX,oBAAmD;QAAnD,yBAAoB,GAApB,oBAAoB,CAA+B;QAEpE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,iBA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B,CAAC,KAAK,EAAE,OAAO;YAClD,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,EACnD,CAAC;YACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CACzB,IAAA,6CAAwB,EACtB,IAAI,CAAC,oBAAoB,EACzB,OAAO,EACP,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,IAAI,EAAE,EAC/C,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,4CAAoB,CAAC,OAAO,CAAC,CAC/C,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAxJD,oCAwJC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RequestOptions } from \"node:http\";\nimport {\n AzureMonitorTraceExporter,\n RateLimitedSampler,\n} from \"@azure/monitor-opentelemetry-exporter\";\nimport type { Sampler } from \"@opentelemetry/sdk-trace-base\";\nimport { BatchSpanProcessor } from \"@opentelemetry/sdk-trace-base\";\nimport type {\n HttpInstrumentationConfig,\n IgnoreOutgoingRequestFunction,\n} from \"@opentelemetry/instrumentation-http\";\nimport { HttpInstrumentation } from \"@opentelemetry/instrumentation-http\";\nimport { MongoDBInstrumentation } from \"@opentelemetry/instrumentation-mongodb\";\nimport { MySQLInstrumentation } from \"@opentelemetry/instrumentation-mysql\";\nimport { PgInstrumentation } from \"@opentelemetry/instrumentation-pg\";\nimport { RedisInstrumentation } from \"@opentelemetry/instrumentation-redis\";\n\nimport type { InternalConfig } from \"../shared/config.js\";\nimport type { MetricHandler } from \"../metrics/handler.js\";\nimport { ignoreOutgoingRequestHook } from \"../utils/common.js\";\nimport { AzureMonitorSpanProcessor } from \"./spanProcessor.js\";\nimport { AzureFunctionsHook } from \"./azureFnHook.js\";\nimport type { Instrumentation } from \"@opentelemetry/instrumentation\";\nimport { ApplicationInsightsSampler } from \"./sampler.js\";\nimport { ensureAzureSdkTracingBridge } from \"../utils/azureSdkTracingBridge.js\";\nimport { configureInstrumentation } from \"../utils/instrumentation.js\";\nimport { AzureSdkInstrumentation } from \"./azureSdkInstrumentation.js\";\n\n/**\n * Azure Monitor OpenTelemetry Trace Handler\n */\nexport class TraceHandler {\n private _batchSpanProcessor: BatchSpanProcessor;\n private _azureSpanProcessor: AzureMonitorSpanProcessor;\n private _azureExporter: AzureMonitorTraceExporter;\n private _instrumentations: Instrumentation[];\n private _config: InternalConfig;\n private _metricHandler: MetricHandler;\n private _azureFunctionsHook: AzureFunctionsHook;\n private _sampler: Sampler;\n\n /**\n * Initializes a new instance of the TraceHandler class.\n * @param _config - Configuration.\n * @param _metricHandler - MetricHandler.\n */\n constructor(\n config: InternalConfig,\n metricHandler: MetricHandler,\n private readonly instrumentationCache?: Map<string, Instrumentation>,\n ) {\n this._config = config;\n this._metricHandler = metricHandler;\n this._instrumentations = [];\n // Check sampler precedence\n if (this._config.sampler) {\n this._sampler = this._config.sampler;\n } else if (this._config.tracesPerSecond && this._config.tracesPerSecond > 0) {\n // If tracesPerSecond is set to a positive number, use RateLimitedSampler\n this._sampler = new RateLimitedSampler(this._config.tracesPerSecond);\n } else {\n // Otherwise, use PercentageSampler with samplingRatio\n this._sampler = new ApplicationInsightsSampler(this._config.samplingRatio);\n }\n this._azureExporter = new AzureMonitorTraceExporter(this._config.azureMonitorExporterOptions);\n this._batchSpanProcessor = new BatchSpanProcessor(this._azureExporter);\n this._azureSpanProcessor = new AzureMonitorSpanProcessor(this._metricHandler);\n this._azureFunctionsHook = new AzureFunctionsHook();\n this._initializeInstrumentations();\n }\n\n public getSampler(): Sampler {\n return this._sampler;\n }\n\n public getBatchSpanProcessor(): BatchSpanProcessor {\n return this._batchSpanProcessor;\n }\n\n public getAzureMonitorSpanProcessor(): AzureMonitorSpanProcessor {\n return this._azureSpanProcessor;\n }\n\n public getInstrumentations(): Instrumentation[] {\n return this._instrumentations;\n }\n\n /**\n * Shutdown handler\n */\n public async shutdown(): Promise<void> {\n this._azureFunctionsHook.shutdown();\n await this._batchSpanProcessor.shutdown();\n await this._azureSpanProcessor.shutdown();\n await this._azureExporter.shutdown();\n }\n\n /**\n * Start auto collection of telemetry\n */\n private _initializeInstrumentations(): void {\n if (this._config.instrumentationOptions.http?.enabled) {\n const httpinstrumentationOptions = this._config.instrumentationOptions\n .http as HttpInstrumentationConfig;\n const providedIgnoreOutgoingRequestHook =\n httpinstrumentationOptions.ignoreOutgoingRequestHook;\n const mergedIgnoreOutgoingRequestHook: IgnoreOutgoingRequestFunction = (\n request: RequestOptions,\n ) => {\n const result = ignoreOutgoingRequestHook(request);\n if (!result) {\n // Not internal call\n if (providedIgnoreOutgoingRequestHook) {\n // Provided hook in config\n return providedIgnoreOutgoingRequestHook(request);\n }\n }\n return result;\n };\n httpinstrumentationOptions.ignoreOutgoingRequestHook = mergedIgnoreOutgoingRequestHook;\n this._instrumentations.push(\n configureInstrumentation(\n this.instrumentationCache,\n \"http\",\n httpinstrumentationOptions,\n (options) => new HttpInstrumentation(options),\n ),\n );\n }\n if (this._config.instrumentationOptions.azureSdk?.enabled) {\n const azureSdkInstrumentation = configureInstrumentation(\n this.instrumentationCache,\n \"azureSdk\",\n this._config.instrumentationOptions.azureSdk,\n (options) => new AzureSdkInstrumentation(options),\n );\n this._instrumentations.push(azureSdkInstrumentation);\n ensureAzureSdkTracingBridge(azureSdkInstrumentation);\n }\n if (this._config.instrumentationOptions.mongoDb?.enabled) {\n this._instrumentations.push(\n configureInstrumentation(\n this.instrumentationCache,\n \"mongoDb\",\n this._config.instrumentationOptions.mongoDb,\n (options) => new MongoDBInstrumentation(options),\n ),\n );\n }\n if (this._config.instrumentationOptions.mySql?.enabled) {\n this._instrumentations.push(\n configureInstrumentation(\n this.instrumentationCache,\n \"mySql\",\n this._config.instrumentationOptions.mySql,\n (options) => new MySQLInstrumentation(options),\n ),\n );\n }\n if (this._config.instrumentationOptions.postgreSql?.enabled) {\n this._instrumentations.push(\n configureInstrumentation(\n this.instrumentationCache,\n \"postgreSql\",\n this._config.instrumentationOptions.postgreSql,\n (options) => new PgInstrumentation(options),\n ),\n );\n }\n if (\n this._config.instrumentationOptions.redis?.enabled ||\n this._config.instrumentationOptions.redis4?.enabled\n ) {\n this._instrumentations.push(\n configureInstrumentation(\n this.instrumentationCache,\n \"redis\",\n this._config.instrumentationOptions.redis ?? {},\n (options) => new RedisInstrumentation(options),\n ),\n );\n }\n }\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.58.12"
8
+ "packageVersion": "7.59.3"
9
9
  }
10
10
  ]
11
11
  }
@@ -152,7 +152,7 @@ export interface BrowserSdkLoaderOptions {
152
152
  /** Browser SDK Loader Connection String */
153
153
  connectionString?: string;
154
154
  }
155
- export declare const AZURE_MONITOR_OPENTELEMETRY_VERSION = "1.20.0";
155
+ export declare const AZURE_MONITOR_OPENTELEMETRY_VERSION = "1.20.1";
156
156
  export declare const AZURE_MONITOR_STATSBEAT_FEATURES = "AZURE_MONITOR_STATSBEAT_FEATURES";
157
157
  export declare const AZURE_MONITOR_PREFIX = "AZURE_MONITOR_PREFIX";
158
158
  export declare const AZURE_MONITOR_AUTO_ATTACH = "AZURE_MONITOR_AUTO_ATTACH";
@@ -16,7 +16,7 @@ exports.StatsbeatFeaturesMap = new Map([
16
16
  ["multiIkey", 128],
17
17
  ["aksResourceDetectorPopulation", 256],
18
18
  ]);
19
- exports.AZURE_MONITOR_OPENTELEMETRY_VERSION = "1.20.0";
19
+ exports.AZURE_MONITOR_OPENTELEMETRY_VERSION = "1.20.1";
20
20
  exports.AZURE_MONITOR_STATSBEAT_FEATURES = "AZURE_MONITOR_STATSBEAT_FEATURES";
21
21
  exports.AZURE_MONITOR_PREFIX = "AZURE_MONITOR_PREFIX";
22
22
  exports.AZURE_MONITOR_AUTO_ATTACH = "AZURE_MONITOR_AUTO_ATTACH";
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],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AC7C,CAAC,KAAK,EAAE,wBAAwB,CAAC,GAAG,CAAC;IACrC,CAAC,SAAS,EAAE,wBAAwB,CAAC,OAAO,CAAC;IAC7C,CAAC,SAAS,EAAE,wBAAwB,CAAC,OAAO,CAAC;IAC7C,CAAC,aAAa,EAAE,wBAAwB,CAAC,YAAY,CAAC;IACtD,CAAC,SAAS,EAAE,wBAAwB,CAAC,OAAO,CAAC;IAC7C,CAAC,MAAM,EAAE,wBAAwB,CAAC,IAAI,CAAC;IACvC,CAAC,SAAS,EAAE,wBAAwB,CAAC,OAAO,CAAC;IAC7C,CAAC,MAAM,EAAE,wBAAwB,CAAC,IAAI,CAAC;IACvC,CAAC,KAAK,EAAE,wBAAwB,CAAC,GAAG,CAAC;IACrC,CAAC,WAAW,EAAE,wBAAwB,CAAC,SAAS,CAAC;IACjD,CAAC,QAAQ,EAAE,wBAAwB,CAAC,MAAM,CAAC;IAC3C,CAAC,YAAY,EAAE,wBAAwB,CAAC,WAAW,CAAC;IACpD,CAAC,KAAK,EAAE,wBAAwB,CAAC,GAAG,CAAC;IACrC,CAAC,MAAM,EAAE,wBAAwB,CAAC,IAAI,CAAC;IACvC,CAAC,SAAS,EAAE,wBAAwB,CAAC,OAAO,CAAC;IAC7C,CAAC,QAAQ,EAAE,wBAAwB,CAAC,MAAM,CAAC;CAC5C,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { AzureMonitorExporterOptions } from \"@azure/monitor-opentelemetry-exporter\";\nimport type { InstrumentationConfig } from \"@opentelemetry/instrumentation\";\nimport type { SeverityNumber } from \"@opentelemetry/api-logs\";\nimport type { Resource } from \"@opentelemetry/resources\";\nimport type { LogRecordProcessor } from \"@opentelemetry/sdk-logs\";\nimport type { MetricReader, ViewOptions } from \"@opentelemetry/sdk-metrics\";\nimport type { SpanProcessor } from \"@opentelemetry/sdk-trace-base\";\n\n/**\n * Azure Monitor OpenTelemetry Options\n */\nexport interface AzureMonitorOpenTelemetryOptions {\n /** Azure Monitor Exporter Configuration */\n azureMonitorExporterOptions?: AzureMonitorExporterOptions;\n /** OpenTelemetry Resource */\n resource?: Resource;\n /** The rate of telemetry items tracked that should be transmitted (Default 1.0) */\n samplingRatio?: number;\n /** The maximum number of traces to sample per second (Default 5). Set to 0 to use samplingRatio instead. */\n tracesPerSecond?: number;\n /** Enable Live Metrics feature (Default false)*/\n enableLiveMetrics?: boolean;\n /** Enable Standard Metrics feature (Default true)*/\n enableStandardMetrics?: boolean;\n /** Enable log sampling based on trace (Default true) */\n enableTraceBasedSamplingForLogs?: boolean;\n /** Enable Performance Counter feature */\n enablePerformanceCounters?: boolean;\n /** OpenTelemetry Instrumentations options included as part of Azure Monitor. See {@link InstrumentationOptions} for the full set of supported instrumentations. */\n instrumentationOptions?: InstrumentationOptions;\n /** Application Insights Web Instrumentation options (enabled, connectionString, src, config)*/\n browserSdkLoaderOptions?: BrowserSdkLoaderOptions;\n /** An array of log record processors to register to the logger provider.*/\n logRecordProcessors?: LogRecordProcessor[];\n /** An array of span processors to register to the tracer provider.*/\n spanProcessors?: SpanProcessor[];\n /** An array of metric readers to register to the meter provider.*/\n metricReaders?: MetricReader[];\n /** An array of metric views to register to the meter provider.*/\n views?: ViewOptions[];\n}\n\n/**\n * OpenTelemetry Instrumentations Configuration interface\n */\nexport interface InstrumentationOptions {\n /** Azure SDK Instrumentation Config */\n azureSdk?: InstrumentationConfig;\n /** HTTP Instrumentation Config */\n http?: InstrumentationConfig;\n /** MongoDB Instrumentation Config */\n mongoDb?: InstrumentationConfig;\n /** MySQL Instrumentation Config */\n mySql?: InstrumentationConfig;\n /** PostgreSql Instrumentation Config */\n postgreSql?: InstrumentationConfig;\n /** Redis Instrumentation Config */\n redis?: InstrumentationConfig;\n /** Redis4 Instrumentation Config */\n redis4?: InstrumentationConfig;\n /** Bunyan Instrumentation Config */\n bunyan?: InstrumentationConfig;\n /** Winston Instrumentation Config */\n winston?: InstrumentationConfig;\n /** Console Instrumentation Config */\n console?: ConsoleInstrumentationOptions;\n}\n\n/**\n * Console Instrumentation Configuration interface\n */\nexport interface ConsoleInstrumentationOptions extends InstrumentationConfig {\n /** The minimum severity of `console` calls to collect. Defaults to the value derived from the\n * `APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL` environment variable. */\n logSeverity?: SeverityNumber;\n}\n\n/**\n * Statsbeat Features Configuration interface\n * @internal\n */\nexport interface StatsbeatFeatures {\n diskRetry?: boolean;\n aadHandling?: boolean;\n browserSdkLoader?: boolean;\n distro?: boolean;\n liveMetrics?: boolean;\n shim?: boolean;\n customerSdkStats?: boolean;\n multiIkey?: boolean;\n aksResourceDetectorPopulation?: boolean;\n}\n\n/**\n * Statsbeat Features Mapping\n * @internal\n */\nexport const StatsbeatFeaturesMap = new Map<string, number>([\n [\"diskRetry\", 1],\n [\"aadHandling\", 2],\n [\"browserSdkLoader\", 4],\n [\"distro\", 8],\n [\"liveMetrics\", 16],\n [\"shim\", 32],\n [\"customerSdkStats\", 64],\n [\"multiIkey\", 128],\n [\"aksResourceDetectorPopulation\", 256],\n]);\n\n/**\n * Statsbeat Instrumentations Configuration interface\n * @internal\n */\nexport interface StatsbeatInstrumentations {\n /** Azure Monitor Supported Instrumentations */\n azureSdk?: boolean;\n mongoDb?: boolean;\n mySql?: boolean;\n postgreSql?: boolean;\n redis?: boolean;\n bunyan?: boolean;\n winston?: boolean;\n console?: boolean;\n /** OpenTelemetry Community Instrumentations */\n amqplib?: boolean;\n cucumber?: boolean;\n dataloader?: boolean;\n fs?: boolean;\n lruMemoizer?: boolean;\n mongoose?: boolean;\n runtimeNode?: boolean;\n socketIo?: boolean;\n tedious?: boolean;\n undici?: boolean;\n cassandra?: boolean;\n connect?: boolean;\n dns?: boolean;\n express?: boolean;\n fastify?: boolean;\n genericPool?: boolean;\n graphql?: boolean;\n hapi?: boolean;\n ioredis?: boolean;\n knex?: boolean;\n koa?: boolean;\n memcached?: boolean;\n mysql2?: boolean;\n nestjsCore?: boolean;\n net?: boolean;\n pino?: boolean;\n restify?: boolean;\n router?: boolean;\n}\n\n/**\n * Statsbeat Instrumentation and Feature Option interface\n * @internal\n */\nexport interface StatsbeatOption {\n option: string;\n value: boolean;\n}\n\n/**\n * Application Insights Web Instrumentation Configuration interface\n */\nexport interface BrowserSdkLoaderOptions {\n /** Browser SDK Loader Enable */\n enabled?: boolean;\n /** Browser SDK Loader Connection String */\n connectionString?: string;\n}\n\nexport const AZURE_MONITOR_OPENTELEMETRY_VERSION = \"1.20.0\";\nexport const AZURE_MONITOR_STATSBEAT_FEATURES = \"AZURE_MONITOR_STATSBEAT_FEATURES\";\nexport const AZURE_MONITOR_PREFIX = \"AZURE_MONITOR_PREFIX\";\nexport const AZURE_MONITOR_AUTO_ATTACH = \"AZURE_MONITOR_AUTO_ATTACH\";\nexport const APPLICATION_INSIGHTS_SHIM_VERSION = \"APPLICATION_INSIGHTS_SHIM_VERSION\";\nexport const APPLICATIONINSIGHTS_AUTHENTICATION_STRING =\n \"APPLICATIONINSIGHTS_AUTHENTICATION_STRING\";\n\nexport enum AttachTypePrefix {\n INTEGRATED_AUTO = \"i\",\n MANUAL = \"m\",\n}\n\n/**\n * Default Browser SDK Loader Source\n * @internal\n */\nexport const BROWSER_SDK_LOADER_DEFAULT_SOURCE = \"https://js.monitor.azure.com/scripts/b/ai\";\n\n/**\n * Default Breeze endpoint.\n * @internal\n */\nexport const DEFAULT_BREEZE_ENDPOINT = \"https://dc.services.visualstudio.com\";\n/**\n * Default Live Metrics endpoint.\n * @internal\n */\nexport const DEFAULT_LIVEMETRICS_ENDPOINT = \"https://global.livediagnostics.monitor.azure.com\";\n\n/**\n * Internal attribute name for sample rate\n * @internal\n */\nexport const AzureMonitorSampleRate = \"microsoft.sample_rate\";\n\n/**\n * Disables customer-facing SDK Stats.\n * @internal\n */\nexport const APPLICATIONINSIGHTS_SDKSTATS_DISABLED = \"APPLICATIONINSIGHTS_SDKSTATS_DISABLED\";\n\nexport enum StatsbeatFeature {\n NONE = 0,\n DISK_RETRY = 1,\n AAD_HANDLING = 2,\n BROWSER_SDK_LOADER = 4,\n DISTRO = 8,\n LIVE_METRICS = 16,\n SHIM = 32,\n CUSTOMER_SDKSTATS = 64,\n MULTI_IKEY = 128,\n AKS_RESOURCE_DETECTOR_POPULATION = 256,\n}\n\nexport enum StatsbeatInstrumentation {\n /** Azure Monitor Supported Instrumentations */\n NONE = 0,\n AZURE_CORE_TRACING = 1,\n MONGODB = 2,\n MYSQL = 4,\n REDIS = 8,\n POSTGRES = 16,\n BUNYAN = 32,\n WINSTON = 64,\n CONSOLE = 128,\n /** OpenTelemetry Supported Instrumentations */\n CUCUMBER = 256,\n DATALOADER = 512,\n FS = 1024,\n LRU_MEMOIZER = 2048,\n MONGOOSE = 4096,\n RUNTIME_NODE = 8192,\n SOCKET_IO = 16384,\n TEDIOUS = 32768,\n UNDICI = 65536,\n CASSANDRA = 131072,\n CONNECT = 262144,\n DNS = 524288,\n EXPRESS = 1048576,\n FASTIFY = 2097152,\n GENERIC_POOL = 4194304,\n GRAPHQL = 8388608,\n HAPI = 16777216,\n IOREDIS = 33554432,\n KNEX = 67108864,\n KOA = 134217728,\n MEMCACHED = 268435456,\n MYSQL2 = 536870912,\n NESTJS_CORE = 1073741824,\n NET = 2147483648,\n PINO = 4294967296,\n RESTIFY = 8589934592,\n ROUTER = 17179869184,\n AMQPLIB = 34359738368,\n}\n\n/**\n * Statsbeat Instrumentation Mapping\n * @internal\n */\nexport const StatsbeatInstrumentationMap = new Map<string, number>([\n [\"@opentelemetry/instrumentation-console\", StatsbeatInstrumentation.CONSOLE],\n [\"@opentelemetry/instrumentation-amqplib\", StatsbeatInstrumentation.AMQPLIB],\n [\"@opentelemetry/instrumentation-cucumber\", StatsbeatInstrumentation.CUCUMBER],\n [\"@opentelemetry/instrumentation-dataloader\", StatsbeatInstrumentation.DATALOADER],\n [\"@opentelemetry/instrumentation-fs\", StatsbeatInstrumentation.FS],\n [\"@opentelemetry/instrumentation-lru-memoizer\", StatsbeatInstrumentation.LRU_MEMOIZER],\n [\"@opentelemetry/instrumentation-mongoose\", StatsbeatInstrumentation.MONGOOSE],\n [\"@opentelemetry/instrumentation-runtime-node\", StatsbeatInstrumentation.RUNTIME_NODE],\n [\"@opentelemetry/instrumentation-socket.io\", StatsbeatInstrumentation.SOCKET_IO],\n [\"@opentelemetry/instrumentation-tedious\", StatsbeatInstrumentation.TEDIOUS],\n [\"@opentelemetry/instrumentation-undici\", StatsbeatInstrumentation.UNDICI],\n [\"@opentelemetry/instrumentation-cassandra-driver\", StatsbeatInstrumentation.CASSANDRA],\n [\"@opentelemetry/instrumentation-connect\", StatsbeatInstrumentation.CONNECT],\n [\"@opentelemetry/instrumentation-dns\", StatsbeatInstrumentation.DNS],\n [\"@opentelemetry/instrumentation-express\", StatsbeatInstrumentation.EXPRESS],\n [\"@opentelemetry/instrumentation-fastify\", StatsbeatInstrumentation.FASTIFY],\n [\"@opentelemetry/instrumentation-generic-pool\", StatsbeatInstrumentation.GENERIC_POOL],\n [\"@opentelemetry/instrumentation-graphql\", StatsbeatInstrumentation.GRAPHQL],\n [\"@opentelemetry/instrumentation-hapi\", StatsbeatInstrumentation.HAPI],\n [\"@opentelemetry/instrumentation-ioredis\", StatsbeatInstrumentation.IOREDIS],\n [\"@opentelemetry/instrumentation-knex\", StatsbeatInstrumentation.KNEX],\n [\"@opentelemetry/instrumentation-koa\", StatsbeatInstrumentation.KOA],\n [\"@opentelemetry/instrumentation-memcached\", StatsbeatInstrumentation.MEMCACHED],\n [\"@opentelemetry/instrumentation-mysql2\", StatsbeatInstrumentation.MYSQL2],\n [\"@opentelemetry/instrumentation-nestjs-core\", StatsbeatInstrumentation.NESTJS_CORE],\n [\"@opentelemetry/instrumentation-net\", StatsbeatInstrumentation.NET],\n [\"@opentelemetry/instrumentation-pino\", StatsbeatInstrumentation.PINO],\n [\"@opentelemetry/instrumentation-restify\", StatsbeatInstrumentation.RESTIFY],\n [\"@opentelemetry/instrumentation-router\", StatsbeatInstrumentation.ROUTER],\n]);\n\n/**\n * Maps Statsbeat instrumentation option names to their assigned bits.\n * @internal\n */\nexport const StatsbeatInstrumentationsMap = new Map<string, number>([\n [\"azureSdk\", StatsbeatInstrumentation.AZURE_CORE_TRACING],\n [\"mongoDb\", StatsbeatInstrumentation.MONGODB],\n [\"mySql\", StatsbeatInstrumentation.MYSQL],\n [\"postgreSql\", StatsbeatInstrumentation.POSTGRES],\n [\"redis\", StatsbeatInstrumentation.REDIS],\n [\"bunyan\", StatsbeatInstrumentation.BUNYAN],\n [\"winston\", StatsbeatInstrumentation.WINSTON],\n [\"console\", StatsbeatInstrumentation.CONSOLE],\n [\"amqplib\", StatsbeatInstrumentation.AMQPLIB],\n [\"cucumber\", StatsbeatInstrumentation.CUCUMBER],\n [\"dataloader\", StatsbeatInstrumentation.DATALOADER],\n [\"fs\", StatsbeatInstrumentation.FS],\n [\"lruMemoizer\", StatsbeatInstrumentation.LRU_MEMOIZER],\n [\"mongoose\", StatsbeatInstrumentation.MONGOOSE],\n [\"runtimeNode\", StatsbeatInstrumentation.RUNTIME_NODE],\n [\"socketIo\", StatsbeatInstrumentation.SOCKET_IO],\n [\"tedious\", StatsbeatInstrumentation.TEDIOUS],\n [\"undici\", StatsbeatInstrumentation.UNDICI],\n [\"cassandra\", StatsbeatInstrumentation.CASSANDRA],\n [\"connect\", StatsbeatInstrumentation.CONNECT],\n [\"dns\", StatsbeatInstrumentation.DNS],\n [\"express\", StatsbeatInstrumentation.EXPRESS],\n [\"fastify\", StatsbeatInstrumentation.FASTIFY],\n [\"genericPool\", StatsbeatInstrumentation.GENERIC_POOL],\n [\"graphql\", StatsbeatInstrumentation.GRAPHQL],\n [\"hapi\", StatsbeatInstrumentation.HAPI],\n [\"ioredis\", StatsbeatInstrumentation.IOREDIS],\n [\"knex\", StatsbeatInstrumentation.KNEX],\n [\"koa\", StatsbeatInstrumentation.KOA],\n [\"memcached\", StatsbeatInstrumentation.MEMCACHED],\n [\"mysql2\", StatsbeatInstrumentation.MYSQL2],\n [\"nestjsCore\", StatsbeatInstrumentation.NESTJS_CORE],\n [\"net\", StatsbeatInstrumentation.NET],\n [\"pino\", StatsbeatInstrumentation.PINO],\n [\"restify\", StatsbeatInstrumentation.RESTIFY],\n [\"router\", StatsbeatInstrumentation.ROUTER],\n]);\n\nexport interface StatsbeatEnvironmentConfig {\n instrumentation: StatsbeatInstrumentation;\n feature: StatsbeatFeature;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AA+FA;;;GAGG;AACU,QAAA,oBAAoB,GAAG,IAAI,GAAG,CAAiB;IAC1D,CAAC,WAAW,EAAE,CAAC,CAAC;IAChB,CAAC,aAAa,EAAE,CAAC,CAAC;IAClB,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACvB,CAAC,QAAQ,EAAE,CAAC,CAAC;IACb,CAAC,aAAa,EAAE,EAAE,CAAC;IACnB,CAAC,MAAM,EAAE,EAAE,CAAC;IACZ,CAAC,kBAAkB,EAAE,EAAE,CAAC;IACxB,CAAC,WAAW,EAAE,GAAG,CAAC;IAClB,CAAC,+BAA+B,EAAE,GAAG,CAAC;CACvC,CAAC,CAAC;AAkEU,QAAA,mCAAmC,GAAG,QAAQ,CAAC;AAC/C,QAAA,gCAAgC,GAAG,kCAAkC,CAAC;AACtE,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,yBAAyB,GAAG,2BAA2B,CAAC;AACxD,QAAA,iCAAiC,GAAG,mCAAmC,CAAC;AACxE,QAAA,yCAAyC,GACpD,2CAA2C,CAAC;AAE9C,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,yCAAqB,CAAA;IACrB,gCAAY,CAAA;AACd,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED;;;GAGG;AACU,QAAA,iCAAiC,GAAG,2CAA2C,CAAC;AAE7F;;;GAGG;AACU,QAAA,uBAAuB,GAAG,sCAA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itorExporterOptions } from \"@azure/monitor-opentelemetry-exporter\";\nimport type { InstrumentationConfig } from \"@opentelemetry/instrumentation\";\nimport type { SeverityNumber } from \"@opentelemetry/api-logs\";\nimport type { Resource } from \"@opentelemetry/resources\";\nimport type { LogRecordProcessor } from \"@opentelemetry/sdk-logs\";\nimport type { MetricReader, ViewOptions } from \"@opentelemetry/sdk-metrics\";\nimport type { SpanProcessor } from \"@opentelemetry/sdk-trace-base\";\n\n/**\n * Azure Monitor OpenTelemetry Options\n */\nexport interface AzureMonitorOpenTelemetryOptions {\n /** Azure Monitor Exporter Configuration */\n azureMonitorExporterOptions?: AzureMonitorExporterOptions;\n /** OpenTelemetry Resource */\n resource?: Resource;\n /** The rate of telemetry items tracked that should be transmitted (Default 1.0) */\n samplingRatio?: number;\n /** The maximum number of traces to sample per second (Default 5). Set to 0 to use samplingRatio instead. */\n tracesPerSecond?: number;\n /** Enable Live Metrics feature (Default false)*/\n enableLiveMetrics?: boolean;\n /** Enable Standard Metrics feature (Default true)*/\n enableStandardMetrics?: boolean;\n /** Enable log sampling based on trace (Default true) */\n enableTraceBasedSamplingForLogs?: boolean;\n /** Enable Performance Counter feature */\n enablePerformanceCounters?: boolean;\n /** OpenTelemetry Instrumentations options included as part of Azure Monitor. See {@link InstrumentationOptions} for the full set of supported instrumentations. */\n instrumentationOptions?: InstrumentationOptions;\n /** Application Insights Web Instrumentation options (enabled, connectionString, src, config)*/\n browserSdkLoaderOptions?: BrowserSdkLoaderOptions;\n /** An array of log record processors to register to the logger provider.*/\n logRecordProcessors?: LogRecordProcessor[];\n /** An array of span processors to register to the tracer provider.*/\n spanProcessors?: SpanProcessor[];\n /** An array of metric readers to register to the meter provider.*/\n metricReaders?: MetricReader[];\n /** An array of metric views to register to the meter provider.*/\n views?: ViewOptions[];\n}\n\n/**\n * OpenTelemetry Instrumentations Configuration interface\n */\nexport interface InstrumentationOptions {\n /** Azure SDK Instrumentation Config */\n azureSdk?: InstrumentationConfig;\n /** HTTP Instrumentation Config */\n http?: InstrumentationConfig;\n /** MongoDB Instrumentation Config */\n mongoDb?: InstrumentationConfig;\n /** MySQL Instrumentation Config */\n mySql?: InstrumentationConfig;\n /** PostgreSql Instrumentation Config */\n postgreSql?: InstrumentationConfig;\n /** Redis Instrumentation Config */\n redis?: InstrumentationConfig;\n /** Redis4 Instrumentation Config */\n redis4?: InstrumentationConfig;\n /** Bunyan Instrumentation Config */\n bunyan?: InstrumentationConfig;\n /** Winston Instrumentation Config */\n winston?: InstrumentationConfig;\n /** Console Instrumentation Config */\n console?: ConsoleInstrumentationOptions;\n}\n\n/**\n * Console Instrumentation Configuration interface\n */\nexport interface ConsoleInstrumentationOptions extends InstrumentationConfig {\n /** The minimum severity of `console` calls to collect. Defaults to the value derived from the\n * `APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL` environment variable. */\n logSeverity?: SeverityNumber;\n}\n\n/**\n * Statsbeat Features Configuration interface\n * @internal\n */\nexport interface StatsbeatFeatures {\n diskRetry?: boolean;\n aadHandling?: boolean;\n browserSdkLoader?: boolean;\n distro?: boolean;\n liveMetrics?: boolean;\n shim?: boolean;\n customerSdkStats?: boolean;\n multiIkey?: boolean;\n aksResourceDetectorPopulation?: boolean;\n}\n\n/**\n * Statsbeat Features Mapping\n * @internal\n */\nexport const StatsbeatFeaturesMap = new Map<string, number>([\n [\"diskRetry\", 1],\n [\"aadHandling\", 2],\n [\"browserSdkLoader\", 4],\n [\"distro\", 8],\n [\"liveMetrics\", 16],\n [\"shim\", 32],\n [\"customerSdkStats\", 64],\n [\"multiIkey\", 128],\n [\"aksResourceDetectorPopulation\", 256],\n]);\n\n/**\n * Statsbeat Instrumentations Configuration interface\n * @internal\n */\nexport interface StatsbeatInstrumentations {\n /** Azure Monitor Supported Instrumentations */\n azureSdk?: boolean;\n mongoDb?: boolean;\n mySql?: boolean;\n postgreSql?: boolean;\n redis?: boolean;\n bunyan?: boolean;\n winston?: boolean;\n console?: boolean;\n /** OpenTelemetry Community Instrumentations */\n amqplib?: boolean;\n cucumber?: boolean;\n dataloader?: boolean;\n fs?: boolean;\n lruMemoizer?: boolean;\n mongoose?: boolean;\n runtimeNode?: boolean;\n socketIo?: boolean;\n tedious?: boolean;\n undici?: boolean;\n cassandra?: boolean;\n connect?: boolean;\n dns?: boolean;\n express?: boolean;\n fastify?: boolean;\n genericPool?: boolean;\n graphql?: boolean;\n hapi?: boolean;\n ioredis?: boolean;\n knex?: boolean;\n koa?: boolean;\n memcached?: boolean;\n mysql2?: boolean;\n nestjsCore?: boolean;\n net?: boolean;\n pino?: boolean;\n restify?: boolean;\n router?: boolean;\n}\n\n/**\n * Statsbeat Instrumentation and Feature Option interface\n * @internal\n */\nexport interface StatsbeatOption {\n option: string;\n value: boolean;\n}\n\n/**\n * Application Insights Web Instrumentation Configuration interface\n */\nexport interface BrowserSdkLoaderOptions {\n /** Browser SDK Loader Enable */\n enabled?: boolean;\n /** Browser SDK Loader Connection String */\n connectionString?: string;\n}\n\nexport const AZURE_MONITOR_OPENTELEMETRY_VERSION = \"1.20.1\";\nexport const AZURE_MONITOR_STATSBEAT_FEATURES = \"AZURE_MONITOR_STATSBEAT_FEATURES\";\nexport const AZURE_MONITOR_PREFIX = \"AZURE_MONITOR_PREFIX\";\nexport const AZURE_MONITOR_AUTO_ATTACH = \"AZURE_MONITOR_AUTO_ATTACH\";\nexport const APPLICATION_INSIGHTS_SHIM_VERSION = \"APPLICATION_INSIGHTS_SHIM_VERSION\";\nexport const APPLICATIONINSIGHTS_AUTHENTICATION_STRING =\n \"APPLICATIONINSIGHTS_AUTHENTICATION_STRING\";\n\nexport enum AttachTypePrefix {\n INTEGRATED_AUTO = \"i\",\n MANUAL = \"m\",\n}\n\n/**\n * Default Browser SDK Loader Source\n * @internal\n */\nexport const BROWSER_SDK_LOADER_DEFAULT_SOURCE = \"https://js.monitor.azure.com/scripts/b/ai\";\n\n/**\n * Default Breeze endpoint.\n * @internal\n */\nexport const DEFAULT_BREEZE_ENDPOINT = \"https://dc.services.visualstudio.com\";\n/**\n * Default Live Metrics endpoint.\n * @internal\n */\nexport const DEFAULT_LIVEMETRICS_ENDPOINT = \"https://global.livediagnostics.monitor.azure.com\";\n\n/**\n * Internal attribute name for sample rate\n * @internal\n */\nexport const AzureMonitorSampleRate = \"microsoft.sample_rate\";\n\n/**\n * Disables customer-facing SDK Stats.\n * @internal\n */\nexport const APPLICATIONINSIGHTS_SDKSTATS_DISABLED = \"APPLICATIONINSIGHTS_SDKSTATS_DISABLED\";\n\nexport enum StatsbeatFeature {\n NONE = 0,\n DISK_RETRY = 1,\n AAD_HANDLING = 2,\n BROWSER_SDK_LOADER = 4,\n DISTRO = 8,\n LIVE_METRICS = 16,\n SHIM = 32,\n CUSTOMER_SDKSTATS = 64,\n MULTI_IKEY = 128,\n AKS_RESOURCE_DETECTOR_POPULATION = 256,\n}\n\nexport enum StatsbeatInstrumentation {\n /** Azure Monitor Supported Instrumentations */\n NONE = 0,\n AZURE_CORE_TRACING = 1,\n MONGODB = 2,\n MYSQL = 4,\n REDIS = 8,\n POSTGRES = 16,\n BUNYAN = 32,\n WINSTON = 64,\n CONSOLE = 128,\n /** OpenTelemetry Supported Instrumentations */\n CUCUMBER = 256,\n DATALOADER = 512,\n FS = 1024,\n LRU_MEMOIZER = 2048,\n MONGOOSE = 4096,\n RUNTIME_NODE = 8192,\n SOCKET_IO = 16384,\n TEDIOUS = 32768,\n UNDICI = 65536,\n CASSANDRA = 131072,\n CONNECT = 262144,\n DNS = 524288,\n EXPRESS = 1048576,\n FASTIFY = 2097152,\n GENERIC_POOL = 4194304,\n GRAPHQL = 8388608,\n HAPI = 16777216,\n IOREDIS = 33554432,\n KNEX = 67108864,\n KOA = 134217728,\n MEMCACHED = 268435456,\n MYSQL2 = 536870912,\n NESTJS_CORE = 1073741824,\n NET = 2147483648,\n PINO = 4294967296,\n RESTIFY = 8589934592,\n ROUTER = 17179869184,\n AMQPLIB = 34359738368,\n}\n\n/**\n * Statsbeat Instrumentation Mapping\n * @internal\n */\nexport const StatsbeatInstrumentationMap = new Map<string, number>([\n [\"@opentelemetry/instrumentation-console\", StatsbeatInstrumentation.CONSOLE],\n [\"@opentelemetry/instrumentation-amqplib\", StatsbeatInstrumentation.AMQPLIB],\n [\"@opentelemetry/instrumentation-cucumber\", StatsbeatInstrumentation.CUCUMBER],\n [\"@opentelemetry/instrumentation-dataloader\", StatsbeatInstrumentation.DATALOADER],\n [\"@opentelemetry/instrumentation-fs\", StatsbeatInstrumentation.FS],\n [\"@opentelemetry/instrumentation-lru-memoizer\", StatsbeatInstrumentation.LRU_MEMOIZER],\n [\"@opentelemetry/instrumentation-mongoose\", StatsbeatInstrumentation.MONGOOSE],\n [\"@opentelemetry/instrumentation-runtime-node\", StatsbeatInstrumentation.RUNTIME_NODE],\n [\"@opentelemetry/instrumentation-socket.io\", StatsbeatInstrumentation.SOCKET_IO],\n [\"@opentelemetry/instrumentation-tedious\", StatsbeatInstrumentation.TEDIOUS],\n [\"@opentelemetry/instrumentation-undici\", StatsbeatInstrumentation.UNDICI],\n [\"@opentelemetry/instrumentation-cassandra-driver\", StatsbeatInstrumentation.CASSANDRA],\n [\"@opentelemetry/instrumentation-connect\", StatsbeatInstrumentation.CONNECT],\n [\"@opentelemetry/instrumentation-dns\", StatsbeatInstrumentation.DNS],\n [\"@opentelemetry/instrumentation-express\", StatsbeatInstrumentation.EXPRESS],\n [\"@opentelemetry/instrumentation-fastify\", StatsbeatInstrumentation.FASTIFY],\n [\"@opentelemetry/instrumentation-generic-pool\", StatsbeatInstrumentation.GENERIC_POOL],\n [\"@opentelemetry/instrumentation-graphql\", StatsbeatInstrumentation.GRAPHQL],\n [\"@opentelemetry/instrumentation-hapi\", StatsbeatInstrumentation.HAPI],\n [\"@opentelemetry/instrumentation-ioredis\", StatsbeatInstrumentation.IOREDIS],\n [\"@opentelemetry/instrumentation-knex\", StatsbeatInstrumentation.KNEX],\n [\"@opentelemetry/instrumentation-koa\", StatsbeatInstrumentation.KOA],\n [\"@opentelemetry/instrumentation-memcached\", StatsbeatInstrumentation.MEMCACHED],\n [\"@opentelemetry/instrumentation-mysql2\", StatsbeatInstrumentation.MYSQL2],\n [\"@opentelemetry/instrumentation-nestjs-core\", StatsbeatInstrumentation.NESTJS_CORE],\n [\"@opentelemetry/instrumentation-net\", StatsbeatInstrumentation.NET],\n [\"@opentelemetry/instrumentation-pino\", StatsbeatInstrumentation.PINO],\n [\"@opentelemetry/instrumentation-restify\", StatsbeatInstrumentation.RESTIFY],\n [\"@opentelemetry/instrumentation-router\", StatsbeatInstrumentation.ROUTER],\n]);\n\n/**\n * Maps Statsbeat instrumentation option names to their assigned bits.\n * @internal\n */\nexport const StatsbeatInstrumentationsMap = new Map<string, number>([\n [\"azureSdk\", StatsbeatInstrumentation.AZURE_CORE_TRACING],\n [\"mongoDb\", StatsbeatInstrumentation.MONGODB],\n [\"mySql\", StatsbeatInstrumentation.MYSQL],\n [\"postgreSql\", StatsbeatInstrumentation.POSTGRES],\n [\"redis\", StatsbeatInstrumentation.REDIS],\n [\"bunyan\", StatsbeatInstrumentation.BUNYAN],\n [\"winston\", StatsbeatInstrumentation.WINSTON],\n [\"console\", StatsbeatInstrumentation.CONSOLE],\n [\"amqplib\", StatsbeatInstrumentation.AMQPLIB],\n [\"cucumber\", StatsbeatInstrumentation.CUCUMBER],\n [\"dataloader\", StatsbeatInstrumentation.DATALOADER],\n [\"fs\", StatsbeatInstrumentation.FS],\n [\"lruMemoizer\", StatsbeatInstrumentation.LRU_MEMOIZER],\n [\"mongoose\", StatsbeatInstrumentation.MONGOOSE],\n [\"runtimeNode\", StatsbeatInstrumentation.RUNTIME_NODE],\n [\"socketIo\", StatsbeatInstrumentation.SOCKET_IO],\n [\"tedious\", StatsbeatInstrumentation.TEDIOUS],\n [\"undici\", StatsbeatInstrumentation.UNDICI],\n [\"cassandra\", StatsbeatInstrumentation.CASSANDRA],\n [\"connect\", StatsbeatInstrumentation.CONNECT],\n [\"dns\", StatsbeatInstrumentation.DNS],\n [\"express\", StatsbeatInstrumentation.EXPRESS],\n [\"fastify\", StatsbeatInstrumentation.FASTIFY],\n [\"genericPool\", StatsbeatInstrumentation.GENERIC_POOL],\n [\"graphql\", StatsbeatInstrumentation.GRAPHQL],\n [\"hapi\", StatsbeatInstrumentation.HAPI],\n [\"ioredis\", StatsbeatInstrumentation.IOREDIS],\n [\"knex\", StatsbeatInstrumentation.KNEX],\n [\"koa\", StatsbeatInstrumentation.KOA],\n [\"memcached\", StatsbeatInstrumentation.MEMCACHED],\n [\"mysql2\", StatsbeatInstrumentation.MYSQL2],\n [\"nestjsCore\", StatsbeatInstrumentation.NESTJS_CORE],\n [\"net\", StatsbeatInstrumentation.NET],\n [\"pino\", StatsbeatInstrumentation.PINO],\n [\"restify\", StatsbeatInstrumentation.RESTIFY],\n [\"router\", StatsbeatInstrumentation.ROUTER],\n]);\n\nexport interface StatsbeatEnvironmentConfig {\n instrumentation: StatsbeatInstrumentation;\n feature: StatsbeatFeature;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { Instrumentation } from "@opentelemetry/instrumentation";
1
2
  /**
2
3
  * Eagerly installs the OpenTelemetry bridge for \@azure/core-tracing.
3
4
  *
@@ -8,11 +9,10 @@
8
9
  * imported \@azure/ai-projects or any other Azure SDK package first), the hook
9
10
  * never fires, and Azure SDK spans are silently dropped.
10
11
  *
11
- * This function works around the issue by directly calling useInstrumenter()
12
- * with an instrumenter created via createOpenTelemetryInstrumenter(), which
13
- * patches the already-loaded \@azure/core-tracing singleton state.
12
+ * Apply the registered instrumentation's patch so the eager bridge follows the
13
+ * same enable/disable lifecycle as the module hooks.
14
14
  *
15
15
  * @internal
16
16
  */
17
- export declare function ensureAzureSdkTracingBridge(): void;
17
+ export declare function ensureAzureSdkTracingBridge(instrumentation: Instrumentation): void;
18
18
  //# sourceMappingURL=azureSdkTracingBridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"azureSdkTracingBridge.d.ts","sourceRoot":"","sources":["../../../src/utils/azureSdkTracingBridge.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAalD"}
1
+ {"version":3,"file":"azureSdkTracingBridge.d.ts","sourceRoot":"","sources":["../../../src/utils/azureSdkTracingBridge.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAExC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI,CAkBlF"}
@@ -14,19 +14,21 @@ const api_1 = require("@opentelemetry/api");
14
14
  * imported \@azure/ai-projects or any other Azure SDK package first), the hook
15
15
  * never fires, and Azure SDK spans are silently dropped.
16
16
  *
17
- * This function works around the issue by directly calling useInstrumenter()
18
- * with an instrumenter created via createOpenTelemetryInstrumenter(), which
19
- * patches the already-loaded \@azure/core-tracing singleton state.
17
+ * Apply the registered instrumentation's patch so the eager bridge follows the
18
+ * same enable/disable lifecycle as the module hooks.
20
19
  *
21
20
  * @internal
22
21
  */
23
- function ensureAzureSdkTracingBridge() {
22
+ function ensureAzureSdkTracingBridge(instrumentation) {
24
23
  try {
25
24
  // eslint-disable-next-line @typescript-eslint/no-require-imports
26
- const { useInstrumenter } = require("@azure/core-tracing");
27
- // eslint-disable-next-line @typescript-eslint/no-require-imports
28
- const { createOpenTelemetryInstrumenter } = require("@azure/opentelemetry-instrumentation-azure-sdk");
29
- useInstrumenter(createOpenTelemetryInstrumenter());
25
+ const coreTracing = require("@azure/core-tracing");
26
+ const moduleDefinitions = instrumentation.getModuleDefinitions?.() ?? [];
27
+ for (const moduleDefinition of moduleDefinitions) {
28
+ if (moduleDefinition.name === "@azure/core-tracing" && moduleDefinition.patch) {
29
+ moduleDefinition.patch(coreTracing);
30
+ }
31
+ }
30
32
  }
31
33
  catch (e) {
32
34
  api_1.diag.warn("Failed to install Azure SDK tracing bridge", e);
@@ -1 +1 @@
1
- {"version":3,"file":"azureSdkTracingBridge.js","sourceRoot":"","sources":["../../../src/utils/azureSdkTracingBridge.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAoBlC,kEAaC;AA/BD,4CAA0C;AAE1C;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,2BAA2B;IACzC,IAAI,CAAC;QACH,iEAAiE;QACjE,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAC3D,iEAAiE;QACjE,MAAM,EAAE,+BAA+B,EAAE,GAAG,OAAO,CACjD,gDAAgD,CACjD,CAAC;QAEF,eAAe,CAAC,+BAA+B,EAAE,CAAC,CAAC;IACrD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,UAAI,CAAC,IAAI,CAAC,4CAA4C,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { diag } from \"@opentelemetry/api\";\n\n/**\n * Eagerly installs the OpenTelemetry bridge for \\@azure/core-tracing.\n *\n * The \\@azure/opentelemetry-instrumentation-azure-sdk package normally installs\n * the bridge via a require-in-the-middle (RITM) hook that intercepts future\n * `require(\"@azure/core-tracing\")` calls. However, if \\@azure/core-tracing is\n * already loaded before useAzureMonitor() is called (e.g. because the customer\n * imported \\@azure/ai-projects or any other Azure SDK package first), the hook\n * never fires, and Azure SDK spans are silently dropped.\n *\n * This function works around the issue by directly calling useInstrumenter()\n * with an instrumenter created via createOpenTelemetryInstrumenter(), which\n * patches the already-loaded \\@azure/core-tracing singleton state.\n *\n * @internal\n */\nexport function ensureAzureSdkTracingBridge(): void {\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { useInstrumenter } = require(\"@azure/core-tracing\");\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { createOpenTelemetryInstrumenter } = require(\n \"@azure/opentelemetry-instrumentation-azure-sdk\",\n );\n\n useInstrumenter(createOpenTelemetryInstrumenter());\n } catch (e) {\n diag.warn(\"Failed to install Azure SDK tracing bridge\", e);\n }\n}\n"]}
1
+ {"version":3,"file":"azureSdkTracingBridge.js","sourceRoot":"","sources":["../../../src/utils/azureSdkTracingBridge.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAwBlC,kEAkBC;AAxCD,4CAA0C;AAO1C;;;;;;;;;;;;;;GAcG;AACH,SAAgB,2BAA2B,CAAC,eAAgC;IAC1E,IAAI,CAAC;QACH,iEAAiE;QACjE,MAAM,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAuB,CAAC;QACzE,MAAM,iBAAiB,GAEnB,eAGD,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,CAAC;QACnC,KAAK,MAAM,gBAAgB,IAAI,iBAAiB,EAAE,CAAC;YACjD,IAAI,gBAAgB,CAAC,IAAI,KAAK,qBAAqB,IAAI,gBAAgB,CAAC,KAAK,EAAE,CAAC;gBAC9E,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,UAAI,CAAC,IAAI,CAAC,4CAA4C,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { diag } from \"@opentelemetry/api\";\nimport type * as CoreTracing from \"@azure/core-tracing\";\nimport type {\n Instrumentation,\n InstrumentationModuleDefinition,\n} from \"@opentelemetry/instrumentation\";\n\n/**\n * Eagerly installs the OpenTelemetry bridge for \\@azure/core-tracing.\n *\n * The \\@azure/opentelemetry-instrumentation-azure-sdk package normally installs\n * the bridge via a require-in-the-middle (RITM) hook that intercepts future\n * `require(\"@azure/core-tracing\")` calls. However, if \\@azure/core-tracing is\n * already loaded before useAzureMonitor() is called (e.g. because the customer\n * imported \\@azure/ai-projects or any other Azure SDK package first), the hook\n * never fires, and Azure SDK spans are silently dropped.\n *\n * Apply the registered instrumentation's patch so the eager bridge follows the\n * same enable/disable lifecycle as the module hooks.\n *\n * @internal\n */\nexport function ensureAzureSdkTracingBridge(instrumentation: Instrumentation): void {\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const coreTracing = require(\"@azure/core-tracing\") as typeof CoreTracing;\n const moduleDefinitions =\n (\n instrumentation as Instrumentation & {\n getModuleDefinitions?: () => InstrumentationModuleDefinition[];\n }\n ).getModuleDefinitions?.() ?? [];\n for (const moduleDefinition of moduleDefinitions) {\n if (moduleDefinition.name === \"@azure/core-tracing\" && moduleDefinition.patch) {\n moduleDefinition.patch(coreTracing);\n }\n }\n } catch (e) {\n diag.warn(\"Failed to install Azure SDK tracing bridge\", e);\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { Instrumentation, InstrumentationConfig } from "@opentelemetry/instrumentation";
2
+ /**
3
+ * Reuse module hooks across SDK lifetimes: new hooks cannot reliably patch
4
+ * libraries that have already been loaded. NodeSDK supplies the new providers
5
+ * before enabling the returned instrumentation.
6
+ */
7
+ export declare function configureInstrumentation<T extends InstrumentationConfig>(cache: Map<string, Instrumentation> | undefined, name: string, config: T, create: (config: T) => Instrumentation): Instrumentation;
8
+ //# sourceMappingURL=instrumentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/utils/instrumentation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE7F;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,qBAAqB,EACtE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,EAC/C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,eAAe,GACrC,eAAe,CAajB"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.configureInstrumentation = configureInstrumentation;
6
+ /**
7
+ * Reuse module hooks across SDK lifetimes: new hooks cannot reliably patch
8
+ * libraries that have already been loaded. NodeSDK supplies the new providers
9
+ * before enabling the returned instrumentation.
10
+ */
11
+ function configureInstrumentation(cache, name, config, create) {
12
+ if (!cache) {
13
+ return create(config);
14
+ }
15
+ const deferredConfig = { ...config, enabled: false };
16
+ let instrumentation = cache.get(name);
17
+ if (instrumentation) {
18
+ instrumentation.setConfig(deferredConfig);
19
+ }
20
+ else {
21
+ instrumentation = create(deferredConfig);
22
+ cache.set(name, instrumentation);
23
+ }
24
+ return instrumentation;
25
+ }
26
+ //# sourceMappingURL=instrumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../../src/utils/instrumentation.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AASlC,4DAkBC;AAvBD;;;;GAIG;AACH,SAAgB,wBAAwB,CACtC,KAA+C,EAC/C,IAAY,EACZ,MAAS,EACT,MAAsC;IAEtC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,MAAM,cAAc,GAAG,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACrD,IAAI,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,eAAe,EAAE,CAAC;QACpB,eAAe,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC5C,CAAC;SAAM,CAAC;QACN,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;QACzC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Instrumentation, InstrumentationConfig } from \"@opentelemetry/instrumentation\";\n\n/**\n * Reuse module hooks across SDK lifetimes: new hooks cannot reliably patch\n * libraries that have already been loaded. NodeSDK supplies the new providers\n * before enabling the returned instrumentation.\n */\nexport function configureInstrumentation<T extends InstrumentationConfig>(\n cache: Map<string, Instrumentation> | undefined,\n name: string,\n config: T,\n create: (config: T) => Instrumentation,\n): Instrumentation {\n if (!cache) {\n return create(config);\n }\n const deferredConfig = { ...config, enabled: false };\n let instrumentation = cache.get(name);\n if (instrumentation) {\n instrumentation.setConfig(deferredConfig);\n } else {\n instrumentation = create(deferredConfig);\n cache.set(name, instrumentation);\n }\n return instrumentation;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAMlD,OAAO,KAAK,EAGV,gCAAgC,EAChC,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAiBpB,YAAY,EACV,gCAAgC,EAChC,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,GACxB,CAAC;AA4BF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,gCAAgC,GAAG,IAAI,CAsGhF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAMpD;AAED;;;GAGG;AAEH,wBAAgB,eAAe,IAAI,OAAO,GAAG,SAAS,CAErD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAMlD,OAAO,KAAK,EAGV,gCAAgC,EAChC,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAgBpB,YAAY,EACV,gCAAgC,EAChC,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,GACxB,CAAC;AAoCF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,gCAAgC,GAAG,IAAI,CA6FhF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIpD;AAED;;;GAGG;AAEH,wBAAgB,eAAe,IAAI,OAAO,GAAG,SAAS,CAErD"}
package/dist/esm/index.js CHANGED
@@ -12,7 +12,6 @@ import { BrowserSdkLoader } from "./browserSdkLoader/browserSdkLoader.js";
12
12
  import { setSdkPrefix } from "./metrics/quickpulse/utils.js";
13
13
  import { getInstance } from "./utils/statsbeat.js";
14
14
  import { patchOpenTelemetryInstrumentationEnable } from "./utils/opentelemetryInstrumentationPatcher.js";
15
- import { ensureAzureSdkTracingBridge } from "./utils/azureSdkTracingBridge.js";
16
15
  import { isFunctionApp, parseResourceDetectorsFromEnvVar } from "./utils/common.js";
17
16
  import { isLogCollectionDisabled } from "./utils/logUtils.js";
18
17
  import { Logger } from "./shared/logging/index.js";
@@ -20,8 +19,15 @@ import { AZURE_MONITOR_AUTO_ATTACH } from "./types.js";
20
19
  process.env["AZURE_MONITOR_DISTRO_VERSION"] = AZURE_MONITOR_OPENTELEMETRY_VERSION;
21
20
  let sdk;
22
21
  let browserSdkLoader;
23
- // Track the global console patch because NodeSDK does not disable instrumentations.
24
- let consoleInstrumentation;
22
+ // NodeSDK shuts down providers, but leaves instrumentation hooks enabled.
23
+ let instrumentations = [];
24
+ const instrumentationCache = new Map();
25
+ function disableInstrumentations() {
26
+ for (const instrumentation of instrumentations) {
27
+ instrumentation.disable();
28
+ }
29
+ instrumentations = [];
30
+ }
25
31
  /**
26
32
  * Check if auto-attach (autoinstrumentation) is enabled and warn about double instrumentation.
27
33
  */
@@ -45,6 +51,7 @@ function sendAttachWarning() {
45
51
  */
46
52
  export function useAzureMonitor(options) {
47
53
  const config = new InternalConfig(options);
54
+ disableInstrumentations();
48
55
  patchOpenTelemetryInstrumentationEnable();
49
56
  // Omit disabled log instrumentations from Statsbeat.
50
57
  const logInstrumentationsEnabled = !isLogCollectionDisabled();
@@ -77,9 +84,6 @@ export function useAzureMonitor(options) {
77
84
  metrics.disable();
78
85
  trace.disable();
79
86
  logs.disable();
80
- // Restore any console patch from the previous initialization.
81
- consoleInstrumentation?.disable();
82
- consoleInstrumentation = undefined;
83
87
  // Clear the entire OpenTelemetry API global state to avoid version conflicts.
84
88
  // The disable() calls above remove individual providers but leave the `version` field
85
89
  // on the global object intact. If a different version of @opentelemetry/api was loaded
@@ -91,12 +95,9 @@ export function useAzureMonitor(options) {
91
95
  Reflect.deleteProperty(globalThis, globalOpentelemetryApiKey);
92
96
  // Create internal handlers
93
97
  const metricHandler = new MetricHandler(config);
94
- const traceHandler = new TraceHandler(config, metricHandler);
95
- const logHandler = new LogHandler(config, metricHandler);
96
- const instrumentations = traceHandler
97
- .getInstrumentations()
98
- .concat(logHandler.getInstrumentations());
99
- consoleInstrumentation = logHandler.getConsoleInstrumentation();
98
+ const traceHandler = new TraceHandler(config, metricHandler, instrumentationCache);
99
+ const logHandler = new LogHandler(config, metricHandler, instrumentationCache);
100
+ instrumentations = traceHandler.getInstrumentations().concat(logHandler.getInstrumentations());
100
101
  const resourceDetectorsList = parseResourceDetectorsFromEnvVar();
101
102
  // Add extra SpanProcessors, and logRecordProcessors from user configuration
102
103
  const spanProcessors = options?.spanProcessors || [];
@@ -132,9 +133,6 @@ export function useAzureMonitor(options) {
132
133
  setSdkPrefix();
133
134
  sendAttachWarning();
134
135
  sdk.start();
135
- // Eagerly install the Azure SDK tracing bridge in case @azure/core-tracing
136
- // was loaded before useAzureMonitor() (the RITM hook misses it otherwise).
137
- ensureAzureSdkTracingBridge();
138
136
  }
139
137
  /**
140
138
  * Shutdown Azure Monitor Open Telemetry Distro
@@ -142,9 +140,7 @@ export function useAzureMonitor(options) {
142
140
  */
143
141
  export function shutdownAzureMonitor() {
144
142
  browserSdkLoader?.dispose();
145
- // NodeSDK.shutdown() does not restore the global console.
146
- consoleInstrumentation?.disable();
147
- consoleInstrumentation = undefined;
143
+ disableInstrumentations();
148
144
  return sdk?.shutdown();
149
145
  }
150
146
  /**