@azure/monitor-opentelemetry 1.19.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 (117) hide show
  1. package/README.md +7 -3
  2. package/dist/commonjs/browserSdkLoader/browserSdkLoaderHelper.d.ts.map +1 -1
  3. package/dist/commonjs/browserSdkLoader/browserSdkLoaderHelper.js +1 -2
  4. package/dist/commonjs/browserSdkLoader/browserSdkLoaderHelper.js.map +1 -1
  5. package/dist/commonjs/index.d.ts +2 -2
  6. package/dist/commonjs/index.d.ts.map +1 -1
  7. package/dist/commonjs/index.js +18 -31
  8. package/dist/commonjs/index.js.map +1 -1
  9. package/dist/commonjs/logs/handler.d.ts +2 -1
  10. package/dist/commonjs/logs/handler.d.ts.map +1 -1
  11. package/dist/commonjs/logs/handler.js +14 -8
  12. package/dist/commonjs/logs/handler.js.map +1 -1
  13. package/dist/commonjs/metrics/performanceCounters.d.ts +3 -0
  14. package/dist/commonjs/metrics/performanceCounters.d.ts.map +1 -1
  15. package/dist/commonjs/metrics/performanceCounters.js +26 -26
  16. package/dist/commonjs/metrics/performanceCounters.js.map +1 -1
  17. package/dist/commonjs/metrics/quickpulse/export/sender.d.ts +1 -1
  18. package/dist/commonjs/metrics/quickpulse/export/sender.d.ts.map +1 -1
  19. package/dist/commonjs/metrics/quickpulse/export/sender.js +29 -23
  20. package/dist/commonjs/metrics/quickpulse/export/sender.js.map +1 -1
  21. package/dist/commonjs/metrics/quickpulse/liveMetrics.d.ts +5 -1
  22. package/dist/commonjs/metrics/quickpulse/liveMetrics.d.ts.map +1 -1
  23. package/dist/commonjs/metrics/quickpulse/liveMetrics.js +86 -75
  24. package/dist/commonjs/metrics/quickpulse/liveMetrics.js.map +1 -1
  25. package/dist/commonjs/package.json +6 -1
  26. package/dist/commonjs/shared/config.d.ts +7 -0
  27. package/dist/commonjs/shared/config.d.ts.map +1 -1
  28. package/dist/commonjs/shared/config.js +27 -6
  29. package/dist/commonjs/shared/config.js.map +1 -1
  30. package/dist/commonjs/traces/azureSdkInstrumentation.d.ts +12 -0
  31. package/dist/commonjs/traces/azureSdkInstrumentation.d.ts.map +1 -0
  32. package/dist/commonjs/traces/azureSdkInstrumentation.js +64 -0
  33. package/dist/commonjs/traces/azureSdkInstrumentation.js.map +1 -0
  34. package/dist/commonjs/traces/handler.d.ts +2 -13
  35. package/dist/commonjs/traces/handler.d.ts.map +1 -1
  36. package/dist/commonjs/traces/handler.js +14 -43
  37. package/dist/commonjs/traces/handler.js.map +1 -1
  38. package/dist/commonjs/traces/sampler.js +1 -1
  39. package/dist/commonjs/traces/sampler.js.map +1 -1
  40. package/dist/commonjs/tsdoc-metadata.json +1 -1
  41. package/dist/commonjs/types.d.ts +11 -2
  42. package/dist/commonjs/types.d.ts.map +1 -1
  43. package/dist/commonjs/types.js +1 -1
  44. package/dist/commonjs/types.js.map +1 -1
  45. package/dist/commonjs/utils/azureSdkTracingBridge.d.ts +4 -4
  46. package/dist/commonjs/utils/azureSdkTracingBridge.d.ts.map +1 -1
  47. package/dist/commonjs/utils/azureSdkTracingBridge.js +10 -8
  48. package/dist/commonjs/utils/azureSdkTracingBridge.js.map +1 -1
  49. package/dist/commonjs/utils/common.d.ts +24 -0
  50. package/dist/commonjs/utils/common.d.ts.map +1 -1
  51. package/dist/commonjs/utils/common.js +47 -0
  52. package/dist/commonjs/utils/common.js.map +1 -1
  53. package/dist/commonjs/utils/instrumentation.d.ts +8 -0
  54. package/dist/commonjs/utils/instrumentation.d.ts.map +1 -0
  55. package/dist/commonjs/utils/instrumentation.js +26 -0
  56. package/dist/commonjs/utils/instrumentation.js.map +1 -0
  57. package/dist/commonjs/utils/statsbeat.d.ts.map +1 -1
  58. package/dist/commonjs/utils/statsbeat.js +3 -1
  59. package/dist/commonjs/utils/statsbeat.js.map +1 -1
  60. package/dist/esm/browserSdkLoader/browserSdkLoaderHelper.d.ts.map +1 -1
  61. package/dist/esm/browserSdkLoader/browserSdkLoaderHelper.js +1 -2
  62. package/dist/esm/browserSdkLoader/browserSdkLoaderHelper.js.map +1 -1
  63. package/dist/esm/index.d.ts +2 -2
  64. package/dist/esm/index.d.ts.map +1 -1
  65. package/dist/esm/index.js +18 -31
  66. package/dist/esm/index.js.map +1 -1
  67. package/dist/esm/logs/handler.d.ts +2 -1
  68. package/dist/esm/logs/handler.d.ts.map +1 -1
  69. package/dist/esm/logs/handler.js +14 -8
  70. package/dist/esm/logs/handler.js.map +1 -1
  71. package/dist/esm/metrics/performanceCounters.d.ts +3 -0
  72. package/dist/esm/metrics/performanceCounters.d.ts.map +1 -1
  73. package/dist/esm/metrics/performanceCounters.js +26 -26
  74. package/dist/esm/metrics/performanceCounters.js.map +1 -1
  75. package/dist/esm/metrics/quickpulse/export/sender.d.ts +1 -1
  76. package/dist/esm/metrics/quickpulse/export/sender.d.ts.map +1 -1
  77. package/dist/esm/metrics/quickpulse/export/sender.js +29 -23
  78. package/dist/esm/metrics/quickpulse/export/sender.js.map +1 -1
  79. package/dist/esm/metrics/quickpulse/liveMetrics.d.ts +5 -1
  80. package/dist/esm/metrics/quickpulse/liveMetrics.d.ts.map +1 -1
  81. package/dist/esm/metrics/quickpulse/liveMetrics.js +86 -75
  82. package/dist/esm/metrics/quickpulse/liveMetrics.js.map +1 -1
  83. package/dist/esm/package.json +6 -1
  84. package/dist/esm/shared/config.d.ts +7 -0
  85. package/dist/esm/shared/config.d.ts.map +1 -1
  86. package/dist/esm/shared/config.js +28 -7
  87. package/dist/esm/shared/config.js.map +1 -1
  88. package/dist/esm/traces/azureSdkInstrumentation.d.ts +12 -0
  89. package/dist/esm/traces/azureSdkInstrumentation.d.ts.map +1 -0
  90. package/dist/esm/traces/azureSdkInstrumentation.js +60 -0
  91. package/dist/esm/traces/azureSdkInstrumentation.js.map +1 -0
  92. package/dist/esm/traces/handler.d.ts +2 -13
  93. package/dist/esm/traces/handler.d.ts.map +1 -1
  94. package/dist/esm/traces/handler.js +14 -42
  95. package/dist/esm/traces/handler.js.map +1 -1
  96. package/dist/esm/traces/sampler.js +1 -1
  97. package/dist/esm/traces/sampler.js.map +1 -1
  98. package/dist/esm/types.d.ts +11 -2
  99. package/dist/esm/types.d.ts.map +1 -1
  100. package/dist/esm/types.js +1 -1
  101. package/dist/esm/types.js.map +1 -1
  102. package/dist/esm/utils/azureSdkTracingBridge.d.ts +4 -4
  103. package/dist/esm/utils/azureSdkTracingBridge.d.ts.map +1 -1
  104. package/dist/esm/utils/azureSdkTracingBridge.js +11 -7
  105. package/dist/esm/utils/azureSdkTracingBridge.js.map +1 -1
  106. package/dist/esm/utils/common.d.ts +24 -0
  107. package/dist/esm/utils/common.d.ts.map +1 -1
  108. package/dist/esm/utils/common.js +45 -0
  109. package/dist/esm/utils/common.js.map +1 -1
  110. package/dist/esm/utils/instrumentation.d.ts +8 -0
  111. package/dist/esm/utils/instrumentation.d.ts.map +1 -0
  112. package/dist/esm/utils/instrumentation.js +23 -0
  113. package/dist/esm/utils/instrumentation.js.map +1 -0
  114. package/dist/esm/utils/statsbeat.d.ts.map +1 -1
  115. package/dist/esm/utils/statsbeat.js +4 -2
  116. package/dist/esm/utils/statsbeat.js.map +1 -1
  117. package/package.json +33 -30
@@ -4,7 +4,9 @@ import { defaultResource, detectResources, emptyResource, envDetector, } from "@
4
4
  import { EnvConfig } from "./envConfig.js";
5
5
  import { JsonConfig } from "./jsonConfig.js";
6
6
  import { Logger } from "./logging/index.js";
7
- import { azureAksDetector, azureAppServiceDetector, azureFunctionsDetector, azureVmDetector, } from "@opentelemetry/resource-detector-azure";
7
+ import { isAksResourceDetectorPopulated } from "../utils/common.js";
8
+ import { azureAksDetector, azureAppServiceDetector, azureContainerAppsDetector, azureFunctionsDetector, azureVmDetector, } from "@opentelemetry/resource-detector-azure";
9
+ import { SEMRESATTRS_CLOUD_PLATFORM } from "@opentelemetry/semantic-conventions";
8
10
  /**
9
11
  * Azure Monitor OpenTelemetry Client Configuration
10
12
  */
@@ -32,6 +34,7 @@ export class InternalConfig {
32
34
  /** Custom OpenTelemetry sampler (env-only) */
33
35
  sampler;
34
36
  _resource = emptyResource();
37
+ _aksResourceDetectorPopulated = false;
35
38
  set resource(resource) {
36
39
  this._resource = this._resource.merge(resource);
37
40
  }
@@ -41,6 +44,14 @@ export class InternalConfig {
41
44
  get resource() {
42
45
  return this._resource;
43
46
  }
47
+ /**
48
+ * Whether the AKS resource detector was able to populate the AKS cluster attributes, which
49
+ * requires the customer to have configured access to the `aks-cluster-metadata` ConfigMap.
50
+ * @internal
51
+ */
52
+ get aksResourceDetectorPopulated() {
53
+ return this._aksResourceDetectorPopulated;
54
+ }
44
55
  browserSdkLoaderOptions;
45
56
  /**
46
57
  * Initializes a new instance of the AzureMonitorOpenTelemetryOptions class.
@@ -147,14 +158,24 @@ export class InternalConfig {
147
158
  };
148
159
  const envResource = detectResources(detectResourceConfig);
149
160
  resource = resource.merge(envResource);
150
- // Load resource attributes from Azure
161
+ // Load resource attributes from Azure. AKS is detected on its own so that we can tell
162
+ // whether the AKS detector itself populated the cluster attributes - other detectors and the
163
+ // customer can populate the same attributes without AKS being involved.
164
+ const aksResource = detectResources({
165
+ detectors: [azureAksDetector],
166
+ });
167
+ this._aksResourceDetectorPopulated = isAksResourceDetectorPopulated(aksResource.attributes);
151
168
  const azureResource = detectResources({
152
- detectors: [azureAksDetector, azureAppServiceDetector, azureFunctionsDetector],
169
+ detectors: [azureAppServiceDetector, azureContainerAppsDetector, azureFunctionsDetector],
153
170
  });
154
- this._resource = resource.merge(azureResource);
155
- // Handle VM resource detection asynchronously to avoid warnings
156
- // about accessing resource attributes before async attributes are settled
157
- this._initializeVmResourceAsync();
171
+ this._resource = resource.merge(aksResource).merge(azureResource);
172
+ // The IMDS probe fails on App Service, Functions, and Container Apps, and on AKS
173
+ // it describes the node VM rather than the cluster.
174
+ const platformDetected = aksResource.attributes[SEMRESATTRS_CLOUD_PLATFORM] ??
175
+ azureResource.attributes[SEMRESATTRS_CLOUD_PLATFORM];
176
+ if (!platformDetected) {
177
+ this._initializeVmResourceAsync();
178
+ }
158
179
  }
159
180
  /**
160
181
  * Initialize VM resource detection asynchronously to avoid warnings
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/shared/config.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,GAChB,MAAM,wCAAwC,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB,mFAAmF;IAC5E,aAAa,CAAS;IAC7B,wDAAwD;IACjD,eAAe,CAAU;IAChC,2CAA2C;IACpC,2BAA2B,CAA8B;IAChE;;OAEG;IACI,sBAAsB,CAAyB;IACtD,kCAAkC;IAClC,iBAAiB,CAAW;IAC5B,sCAAsC;IACtC,qBAAqB,CAAW;IAChC,wDAAwD;IACxD,+BAA+B,CAAW;IAC1C,yCAAyC;IACzC,yBAAyB,CAAW;IACpC,6CAA6C;IACtC,0BAA0B,CAAS;IAC1C,8CAA8C;IACvC,OAAO,CAAW;IAEjB,SAAS,GAAa,aAAa,EAAE,CAAC;IAE9C,IAAW,QAAQ,CAAC,QAAkB;QACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEM,uBAAuB,CAA0B;IAExD;;OAEG;IACH,YAAY,OAA0C;QACpD,iBAAiB;QACjB,I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iG;QACjG,IAAI,UAAU,CAAC,sBAAsB,EAAE,CAAC;YACtC,KAAK,UAAU;iBACZ,sBAAsB,EAAE,EAAE;iBAC1B,IAAI,CAAC,GAAG,EAAE;gBACT,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAClD,OAAO;YACT,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,EAAE;gBACV,oEAAoE;gBACpE,4EAA4E;YAC9E,CAAC,CAAC,CAAC;QACP,CAAC;aAAM,CAAC;YACN,6DAA6D;YAC7D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAEM,6BAA6B,CAAC,OAAwC;QAC3E,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,aAAa;QAE5C,iDAAiD;QACjD,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,CAAC;YAC5C,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YACjF,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;gBAC3C,OAAO,WAAW,CAAC;YACrB,CAAC;QACH,CAAC;QAED,+BAA+B;QAC/B,IAAI,OAAO,EAAE,kBAAkB,EAAE,CAAC;YAChC,OAAO,OAAO,CAAC,kBAAkB,CAAC;QACpC,CAAC;QAED,mBAAmB;QACnB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ResourceDetectionConfig, Resource } from \"@opentelemetry/resources\";\nimport {\n defaultResource,\n detectResources,\n emptyResource,\n envDetector,\n} from \"@opentelemetry/resources\";\nimport type {\n BrowserSdkLoaderOptions,\n AzureMonitorOpenTelemetryOptions,\n InstrumentationOptions,\n} from \"../types.js\";\nimport type { Sampler } from \"@opentelemetry/sdk-trace-base\";\nimport type { AzureMonitorExporterOptions } from \"@azure/monitor-opentelemetry-exporter\";\nimport { EnvConfig } from \"./envConfig.js\";\nimport { JsonConfig } from \"./jsonConfig.js\";\nimport { Logger } from \"./logging/index.js\";\nimport {\n azureAksDetector,\n azureAppServiceDetector,\n azureFunctionsDetector,\n azureVmDetector,\n} from \"@opentelemetry/resource-detector-azure\";\n\n/**\n * Azure Monitor OpenTelemetry Client Configuration\n */\nexport class InternalConfig implements AzureMonitorOpenTelemetryOptions {\n /** The rate of telemetry items tracked that should be transmitted (Default 1.0) */\n public samplingRatio: number;\n /** The maximum number of spans to sample per second. */\n public tracesPerSecond?: number;\n /** Azure Monitor Exporter Configuration */\n public azureMonitorExporterOptions: AzureMonitorExporterOptions;\n /**\n * OpenTelemetry Instrumentations configuration included as part of Azure Monitor (azureSdk, http, mongoDb, mySql, postgreSql, redis, redis4)\n */\n public instrumentationOptions: InstrumentationOptions;\n /** Enable Live Metrics feature */\n enableLiveMetrics?: boolean;\n /** Enable Standard Metrics feature */\n enableStandardMetrics?: boolean;\n /** Enable log sampling based on trace (Default true) */\n enableTraceBasedSamplingForLogs?: boolean;\n /** Enable Performance Counter feature */\n enablePerformanceCounters?: boolean;\n /** Metric export interval in milliseconds */\n public metricExportIntervalMillis: number;\n /** Custom OpenTelemetry sampler (env-only) */\n public sampler?: Sampler;\n\n private _resource: Resource = emptyResource();\n\n public set resource(resource: Resource) {\n this._resource = this._resource.merge(resource);\n }\n\n /**\n *Get OpenTelemetry Resource\n */\n public get resource(): Resource {\n return this._resource;\n }\n\n public browserSdkLoaderOptions: BrowserSdkLoaderOptions;\n\n /**\n * Initializes a new instance of the AzureMonitorOpenTelemetryOptions class.\n */\n constructor(options?: AzureMonitorOpenTelemetryOptions) {\n // Default values\n this.azureMonitorExporterOptions = {};\n this.samplingRatio = 1;\n this.tracesPerSecond = 5;\n this.enableLiveMetrics = true;\n this.enableStandardMetrics = true;\n this.enableTraceBasedSamplingForLogs = false;\n this.enablePerformanceCounters = true;\n this.metricExportIntervalMillis = this.calculateMetricExportInterval();\n this.instrumentationOptions = {\n http: { enabled: true },\n azureSdk: { enabled: true },\n mongoDb: { enabled: true },\n mySql: { enabled: true },\n postgreSql: { enabled: true },\n redis: { enabled: true },\n redis4: { enabled: true },\n console: { enabled: false },\n };\n this._setDefaultResource();\n this.browserSdkLoaderOptions = {\n enabled: false,\n connectionString: \"\",\n };\n\n if (options) {\n // Merge default with provided options\n this.azureMonitorExporterOptions = Object.assign(\n this.azureMonitorExporterOptions,\n options.azureMonitorExporterOptions,\n );\n this.instrumentationOptions = Object.assign(\n this.instrumentationOptions,\n options.instrumentationOptions,\n );\n this.resource = Object.assign(this.resource, options.resource);\n this.samplingRatio =\n options.samplingRatio !== undefined ? options.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n options.tracesPerSecond !== undefined ? options.tracesPerSecond : this.tracesPerSecond;\n this.browserSdkLoaderOptions = Object.assign(\n this.browserSdkLoaderOptions,\n options.browserSdkLoaderOptions,\n );\n this.enableLiveMetrics =\n options.enableLiveMetrics !== undefined\n ? options.enableLiveMetrics\n : this.enableLiveMetrics;\n this.enableStandardMetrics =\n options.enableStandardMetrics !== undefined\n ? options.enableStandardMetrics\n : this.enableStandardMetrics;\n this.enableTraceBasedSamplingForLogs =\n options.enableTraceBasedSamplingForLogs !== undefined\n ? options.enableTraceBasedSamplingForLogs\n : this.enableTraceBasedSamplingForLogs;\n this.enablePerformanceCounters =\n options.enablePerformanceCounters !== undefined\n ? options.enablePerformanceCounters\n : this.enablePerformanceCounters;\n }\n // JSON configuration will take precedence over options provided\n this._mergeJsonConfig();\n // ENV configuration will take precedence over other configurations\n this._mergeEnvConfig();\n }\n\n private _mergeEnvConfig(): void {\n const envConfig = EnvConfig.getInstance();\n this.samplingRatio =\n envConfig.samplingRatio !== undefined ? envConfig.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n envConfig.tracesPerSecond !== undefined ? envConfig.tracesPerSecond : this.tracesPerSecond;\n this.sampler = envConfig.sampler ?? this.sampler;\n }\n\n private _mergeJsonConfig(): void {\n try {\n const jsonConfig = JsonConfig.getInstance();\n this.samplingRatio =\n jsonConfig.samplingRatio !== undefined ? jsonConfig.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n jsonConfig.tracesPerSecond !== undefined\n ? jsonConfig.tracesPerSecond\n : this.tracesPerSecond;\n this.browserSdkLoaderOptions = Object.assign(\n this.browserSdkLoaderOptions,\n jsonConfig.browserSdkLoaderOptions,\n );\n this.enableLiveMetrics =\n jsonConfig.enableLiveMetrics !== undefined\n ? jsonConfig.enableLiveMetrics\n : this.enableLiveMetrics;\n this.enableStandardMetrics =\n jsonConfig.enableStandardMetrics !== undefined\n ? jsonConfig.enableStandardMetrics\n : this.enableStandardMetrics;\n this.enableTraceBasedSamplingForLogs =\n jsonConfig.enableTraceBasedSamplingForLogs !== undefined\n ? jsonConfig.enableTraceBasedSamplingForLogs\n : this.enableTraceBasedSamplingForLogs;\n this.azureMonitorExporterOptions = Object.assign(\n this.azureMonitorExporterOptions,\n jsonConfig.azureMonitorExporterOptions,\n );\n this.instrumentationOptions = Object.assign(\n this.instrumentationOptions,\n jsonConfig.instrumentationOptions,\n );\n } catch (error) {\n Logger.getInstance().error(\"Failed to load JSON config file values.\", error);\n }\n }\n\n private _setDefaultResource(): void {\n let resource = defaultResource();\n // Load resource attributes from env\n const detectResourceConfig: ResourceDetectionConfig = {\n detectors: [envDetector],\n };\n const envResource = detectResources(detectResourceConfig);\n resource = resource.merge(envResource);\n\n // Load resource attributes from Azure\n const azureResource: Resource = detectResources({\n detectors: [azureAksDetector, azureAppServiceDetector, azureFunctionsDetector],\n });\n this._resource = resource.merge(azureResource);\n\n // Handle VM resource detection asynchronously to avoid warnings\n // about accessing resource attributes before async attributes are settled\n this._initializeVmResourceAsync();\n }\n\n /**\n * Initialize VM resource detection asynchronously to avoid warnings\n * about accessing resource attributes before async attributes settle\n */\n private _initializeVmResourceAsync(): void {\n const vmResource = detectResources({\n detectors: [azureVmDetector],\n });\n\n // Don't wait for VM resource detection to complete during initialization\n // This prevents warnings about accessing resource attributes before async attributes are settled\n if (vmResource.asyncAttributesPending) {\n void vmResource\n .waitForAsyncAttributes?.()\n .then(() => {\n this._resource = this._resource.merge(vmResource);\n return;\n })\n .catch(() => {\n // Silently ignore VM detection errors to avoid unnecessary warnings\n // VM detection is optional and failures shouldn't impact core functionality\n });\n } else {\n // If VM detection completed synchronously, merge immediately\n this._resource = this._resource.merge(vmResource);\n }\n }\n\n public calculateMetricExportInterval(options?: { collectionInterval: number }): number {\n const defaultInterval = 60000; // 60 seconds\n\n // Prioritize OTEL_METRIC_EXPORT_INTERVAL env var\n if (process.env.OTEL_METRIC_EXPORT_INTERVAL) {\n const envInterval = parseInt(process.env.OTEL_METRIC_EXPORT_INTERVAL.trim(), 10);\n if (!isNaN(envInterval) && envInterval > 0) {\n return envInterval;\n }\n }\n\n // Then use options if provided\n if (options?.collectionInterval) {\n return options.collectionInterval;\n }\n\n // Default fallback\n return defaultInterval;\n }\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/shared/config.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,0BAA0B,EAC1B,sBAAsB,EACtB,eAAe,GAChB,MAAM,wCAAwC,CAAC;AAChD,OAAO,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;QAEH,yEAAyE;QACzE,iGAAiG;QACjG,IAAI,UAAU,CAAC,sBAAsB,EAAE,CAAC;YACtC,KAAK,UAAU;iBACZ,sBAAsB,EAAE,EAAE;iBAC1B,IAAI,CAAC,GAAG,EAAE;gBACT,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAClD,OAAO;YACT,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,EAAE;gBACV,oEAAoE;gBACpE,4EAA4E;YAC9E,CAAC,CAAC,CAAC;QACP,CAAC;aAAM,CAAC;YACN,6DAA6D;YAC7D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAEM,6BAA6B,CAAC,OAAwC;QAC3E,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,aAAa;QAE5C,iDAAiD;QACjD,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,CAAC;YAC5C,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YACjF,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;gBAC3C,OAAO,WAAW,CAAC;YACrB,CAAC;QACH,CAAC;QAED,+BAA+B;QAC/B,IAAI,OAAO,EAAE,kBAAkB,EAAE,CAAC;YAChC,OAAO,OAAO,CAAC,kBAAkB,CAAC;QACpC,CAAC;QAED,mBAAmB;QACnB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ResourceDetectionConfig, Resource } from \"@opentelemetry/resources\";\nimport {\n defaultResource,\n detectResources,\n emptyResource,\n envDetector,\n} from \"@opentelemetry/resources\";\nimport type {\n BrowserSdkLoaderOptions,\n AzureMonitorOpenTelemetryOptions,\n InstrumentationOptions,\n} from \"../types.js\";\nimport type { Sampler } from \"@opentelemetry/sdk-trace-base\";\nimport type { AzureMonitorExporterOptions } from \"@azure/monitor-opentelemetry-exporter\";\nimport { EnvConfig } from \"./envConfig.js\";\nimport { JsonConfig } from \"./jsonConfig.js\";\nimport { Logger } from \"./logging/index.js\";\nimport { isAksResourceDetectorPopulated } from \"../utils/common.js\";\nimport {\n azureAksDetector,\n azureAppServiceDetector,\n azureContainerAppsDetector,\n azureFunctionsDetector,\n azureVmDetector,\n} from \"@opentelemetry/resource-detector-azure\";\nimport { SEMRESATTRS_CLOUD_PLATFORM } from \"@opentelemetry/semantic-conventions\";\n\n/**\n * Azure Monitor OpenTelemetry Client Configuration\n */\nexport class InternalConfig implements AzureMonitorOpenTelemetryOptions {\n /** The rate of telemetry items tracked that should be transmitted (Default 1.0) */\n public samplingRatio: number;\n /** The maximum number of spans to sample per second. */\n public tracesPerSecond?: number;\n /** Azure Monitor Exporter Configuration */\n public azureMonitorExporterOptions: AzureMonitorExporterOptions;\n /**\n * OpenTelemetry Instrumentations configuration included as part of Azure Monitor (azureSdk, http, mongoDb, mySql, postgreSql, redis, redis4)\n */\n public instrumentationOptions: InstrumentationOptions;\n /** Enable Live Metrics feature */\n enableLiveMetrics?: boolean;\n /** Enable Standard Metrics feature */\n enableStandardMetrics?: boolean;\n /** Enable log sampling based on trace (Default true) */\n enableTraceBasedSamplingForLogs?: boolean;\n /** Enable Performance Counter feature */\n enablePerformanceCounters?: boolean;\n /** Metric export interval in milliseconds */\n public metricExportIntervalMillis: number;\n /** Custom OpenTelemetry sampler (env-only) */\n public sampler?: Sampler;\n\n private _resource: Resource = emptyResource();\n private _aksResourceDetectorPopulated: boolean = false;\n\n public set resource(resource: Resource) {\n this._resource = this._resource.merge(resource);\n }\n\n /**\n *Get OpenTelemetry Resource\n */\n public get resource(): Resource {\n return this._resource;\n }\n\n /**\n * Whether the AKS resource detector was able to populate the AKS cluster attributes, which\n * requires the customer to have configured access to the `aks-cluster-metadata` ConfigMap.\n * @internal\n */\n public get aksResourceDetectorPopulated(): boolean {\n return this._aksResourceDetectorPopulated;\n }\n\n public browserSdkLoaderOptions: BrowserSdkLoaderOptions;\n\n /**\n * Initializes a new instance of the AzureMonitorOpenTelemetryOptions class.\n */\n constructor(options?: AzureMonitorOpenTelemetryOptions) {\n // Default values\n this.azureMonitorExporterOptions = {};\n this.samplingRatio = 1;\n this.tracesPerSecond = 5;\n this.enableLiveMetrics = true;\n this.enableStandardMetrics = true;\n this.enableTraceBasedSamplingForLogs = false;\n this.enablePerformanceCounters = true;\n this.metricExportIntervalMillis = this.calculateMetricExportInterval();\n this.instrumentationOptions = {\n http: { enabled: true },\n azureSdk: { enabled: true },\n mongoDb: { enabled: true },\n mySql: { enabled: true },\n postgreSql: { enabled: true },\n redis: { enabled: true },\n redis4: { enabled: true },\n console: { enabled: false },\n };\n this._setDefaultResource();\n this.browserSdkLoaderOptions = {\n enabled: false,\n connectionString: \"\",\n };\n\n if (options) {\n // Merge default with provided options\n this.azureMonitorExporterOptions = Object.assign(\n this.azureMonitorExporterOptions,\n options.azureMonitorExporterOptions,\n );\n this.instrumentationOptions = Object.assign(\n this.instrumentationOptions,\n options.instrumentationOptions,\n );\n this.resource = Object.assign(this.resource, options.resource);\n this.samplingRatio =\n options.samplingRatio !== undefined ? options.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n options.tracesPerSecond !== undefined ? options.tracesPerSecond : this.tracesPerSecond;\n this.browserSdkLoaderOptions = Object.assign(\n this.browserSdkLoaderOptions,\n options.browserSdkLoaderOptions,\n );\n this.enableLiveMetrics =\n options.enableLiveMetrics !== undefined\n ? options.enableLiveMetrics\n : this.enableLiveMetrics;\n this.enableStandardMetrics =\n options.enableStandardMetrics !== undefined\n ? options.enableStandardMetrics\n : this.enableStandardMetrics;\n this.enableTraceBasedSamplingForLogs =\n options.enableTraceBasedSamplingForLogs !== undefined\n ? options.enableTraceBasedSamplingForLogs\n : this.enableTraceBasedSamplingForLogs;\n this.enablePerformanceCounters =\n options.enablePerformanceCounters !== undefined\n ? options.enablePerformanceCounters\n : this.enablePerformanceCounters;\n }\n // JSON configuration will take precedence over options provided\n this._mergeJsonConfig();\n // ENV configuration will take precedence over other configurations\n this._mergeEnvConfig();\n }\n\n private _mergeEnvConfig(): void {\n const envConfig = EnvConfig.getInstance();\n this.samplingRatio =\n envConfig.samplingRatio !== undefined ? envConfig.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n envConfig.tracesPerSecond !== undefined ? envConfig.tracesPerSecond : this.tracesPerSecond;\n this.sampler = envConfig.sampler ?? this.sampler;\n }\n\n private _mergeJsonConfig(): void {\n try {\n const jsonConfig = JsonConfig.getInstance();\n this.samplingRatio =\n jsonConfig.samplingRatio !== undefined ? jsonConfig.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n jsonConfig.tracesPerSecond !== undefined\n ? jsonConfig.tracesPerSecond\n : this.tracesPerSecond;\n this.browserSdkLoaderOptions = Object.assign(\n this.browserSdkLoaderOptions,\n jsonConfig.browserSdkLoaderOptions,\n );\n this.enableLiveMetrics =\n jsonConfig.enableLiveMetrics !== undefined\n ? jsonConfig.enableLiveMetrics\n : this.enableLiveMetrics;\n this.enableStandardMetrics =\n jsonConfig.enableStandardMetrics !== undefined\n ? jsonConfig.enableStandardMetrics\n : this.enableStandardMetrics;\n this.enableTraceBasedSamplingForLogs =\n jsonConfig.enableTraceBasedSamplingForLogs !== undefined\n ? jsonConfig.enableTraceBasedSamplingForLogs\n : this.enableTraceBasedSamplingForLogs;\n this.azureMonitorExporterOptions = Object.assign(\n this.azureMonitorExporterOptions,\n jsonConfig.azureMonitorExporterOptions,\n );\n this.instrumentationOptions = Object.assign(\n this.instrumentationOptions,\n jsonConfig.instrumentationOptions,\n );\n } catch (error) {\n Logger.getInstance().error(\"Failed to load JSON config file values.\", error);\n }\n }\n\n private _setDefaultResource(): void {\n let resource = defaultResource();\n // Load resource attributes from env\n const detectResourceConfig: ResourceDetectionConfig = {\n detectors: [envDetector],\n };\n const envResource = detectResources(detectResourceConfig);\n resource = resource.merge(envResource);\n\n // Load resource attributes from Azure. AKS is detected on its own so that we can tell\n // whether the AKS detector itself populated the cluster attributes - other detectors and the\n // customer can populate the same attributes without AKS being involved.\n const aksResource: Resource = detectResources({\n detectors: [azureAksDetector],\n });\n this._aksResourceDetectorPopulated = isAksResourceDetectorPopulated(aksResource.attributes);\n\n const azureResource: Resource = detectResources({\n detectors: [azureAppServiceDetector, azureContainerAppsDetector, azureFunctionsDetector],\n });\n this._resource = resource.merge(aksResource).merge(azureResource);\n\n // The IMDS probe fails on App Service, Functions, and Container Apps, and on AKS\n // it describes the node VM rather than the cluster.\n const platformDetected =\n aksResource.attributes[SEMRESATTRS_CLOUD_PLATFORM] ??\n azureResource.attributes[SEMRESATTRS_CLOUD_PLATFORM];\n if (!platformDetected) {\n this._initializeVmResourceAsync();\n }\n }\n\n /**\n * Initialize VM resource detection asynchronously to avoid warnings\n * about accessing resource attributes before async attributes settle\n */\n private _initializeVmResourceAsync(): void {\n const vmResource = detectResources({\n detectors: [azureVmDetector],\n });\n\n // Don't wait for VM resource detection to complete during initialization\n // This prevents warnings about accessing resource attributes before async attributes are settled\n if (vmResource.asyncAttributesPending) {\n void vmResource\n .waitForAsyncAttributes?.()\n .then(() => {\n this._resource = this._resource.merge(vmResource);\n return;\n })\n .catch(() => {\n // Silently ignore VM detection errors to avoid unnecessary warnings\n // VM detection is optional and failures shouldn't impact core functionality\n });\n } else {\n // If VM detection completed synchronously, merge immediately\n this._resource = this._resource.merge(vmResource);\n }\n }\n\n public calculateMetricExportInterval(options?: { collectionInterval: number }): number {\n const defaultInterval = 60000; // 60 seconds\n\n // Prioritize OTEL_METRIC_EXPORT_INTERVAL env var\n if (process.env.OTEL_METRIC_EXPORT_INTERVAL) {\n const envInterval = parseInt(process.env.OTEL_METRIC_EXPORT_INTERVAL.trim(), 10);\n if (!isNaN(envInterval) && envInterval > 0) {\n return envInterval;\n }\n }\n\n // Then use options if provided\n if (options?.collectionInterval) {\n return options.collectionInterval;\n }\n\n // Default fallback\n return defaultInterval;\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { AzureSdkInstrumentation as BaseAzureSdkInstrumentation } from "@azure/opentelemetry-instrumentation-azure-sdk";
2
+ import type { InstrumentationModuleDefinition } from "@opentelemetry/instrumentation";
3
+ /**
4
+ * Keep both eager and module-hook bridges tied to the distro's instrumentation
5
+ * lifecycle without changing the shared Azure SDK instrumentation package.
6
+ * Context activation remains available when instrumentation is disabled.
7
+ * @internal
8
+ */
9
+ export declare class AzureSdkInstrumentation extends BaseAzureSdkInstrumentation {
10
+ protected init(): InstrumentationModuleDefinition | InstrumentationModuleDefinition[] | void;
11
+ }
12
+ //# sourceMappingURL=azureSdkInstrumentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azureSdkInstrumentation.d.ts","sourceRoot":"","sources":["../../../src/traces/azureSdkInstrumentation.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,uBAAuB,IAAI,2BAA2B,EAEvD,MAAM,gDAAgD,CAAC;AAExD,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAmCtF;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,2BAA2B;cACnD,IAAI,IACrB,+BAA+B,GAAG,+BAA+B,EAAE,GAAG,IAAI;CAgB7E"}
@@ -0,0 +1,60 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { AzureSdkInstrumentation as BaseAzureSdkInstrumentation, createOpenTelemetryInstrumenter, } from "@azure/opentelemetry-instrumentation-azure-sdk";
4
+ import { context } from "@opentelemetry/api";
5
+ const nonRecordingSpan = {
6
+ end: () => { },
7
+ isRecording: () => false,
8
+ recordException: () => { },
9
+ setAttribute: () => { },
10
+ setStatus: () => { },
11
+ addEvent: () => { },
12
+ };
13
+ function createLifecycleInstrumenter(isEnabled) {
14
+ const instrumenter = createOpenTelemetryInstrumenter();
15
+ return {
16
+ startSpan(name, options) {
17
+ if (!isEnabled()) {
18
+ return {
19
+ span: nonRecordingSpan,
20
+ tracingContext: options.tracingContext ?? context.active(),
21
+ };
22
+ }
23
+ return instrumenter.startSpan(name, options);
24
+ },
25
+ withContext(tracingContext, callback, ...args) {
26
+ return instrumenter.withContext(tracingContext, callback, ...args);
27
+ },
28
+ parseTraceparentHeader(header) {
29
+ return isEnabled() ? instrumenter.parseTraceparentHeader(header) : undefined;
30
+ },
31
+ createRequestHeaders(tracingContext) {
32
+ return isEnabled() ? instrumenter.createRequestHeaders(tracingContext) : {};
33
+ },
34
+ };
35
+ }
36
+ /**
37
+ * Keep both eager and module-hook bridges tied to the distro's instrumentation
38
+ * lifecycle without changing the shared Azure SDK instrumentation package.
39
+ * Context activation remains available when instrumentation is disabled.
40
+ * @internal
41
+ */
42
+ export class AzureSdkInstrumentation extends BaseAzureSdkInstrumentation {
43
+ init() {
44
+ const definitions = super.init();
45
+ const modules = Array.isArray(definitions) ? definitions : definitions ? [definitions] : [];
46
+ for (const module of modules) {
47
+ if (module.name === "@azure/core-tracing") {
48
+ module.patch = (moduleExports) => {
49
+ if (typeof moduleExports.useInstrumenter === "function") {
50
+ // Disable only this bridge; leave customer-installed instrumenters untouched.
51
+ moduleExports.useInstrumenter(createLifecycleInstrumenter(() => this.isEnabled()));
52
+ }
53
+ return moduleExports;
54
+ };
55
+ }
56
+ }
57
+ return definitions;
58
+ }
59
+ }
60
+ //# 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,OAAO,EACL,uBAAuB,IAAI,2BAA2B,EACtD,+BAA+B,GAChC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MA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AI;QAErB,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5F,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;gBAC1C,MAAM,CAAC,KAAK,GAAG,CAAC,aAAiC,EAAE,EAAE;oBACnD,IAAI,OAAO,aAAa,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;wBACxD,8EAA8E;wBAC9E,aAAa,CAAC,eAAe,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","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,EAAgB,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC3E,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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,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"}
@@ -1,7 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { createAzureSdkInstrumentation } from "@azure/opentelemetry-instrumentation-azure-sdk";
4
- import * as coreTracing from "@azure/core-tracing";
5
3
  import { AzureMonitorTraceExporter, RateLimitedSampler, } from "@azure/monitor-opentelemetry-exporter";
6
4
  import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
7
5
  import { HttpInstrumentation } from "@opentelemetry/instrumentation-http";
@@ -13,11 +11,14 @@ import { ignoreOutgoingRequestHook } from "../utils/common.js";
13
11
  import { AzureMonitorSpanProcessor } from "./spanProcessor.js";
14
12
  import { AzureFunctionsHook } from "./azureFnHook.js";
15
13
  import { ApplicationInsightsSampler } from "./sampler.js";
16
- import { Logger } from "../shared/logging/index.js";
14
+ import { ensureAzureSdkTracingBridge } from "../utils/azureSdkTracingBridge.js";
15
+ import { configureInstrumentation } from "../utils/instrumentation.js";
16
+ import { AzureSdkInstrumentation } from "./azureSdkInstrumentation.js";
17
17
  /**
18
18
  * Azure Monitor OpenTelemetry Trace Handler
19
19
  */
20
20
  export class TraceHandler {
21
+ instrumentationCache;
21
22
  _batchSpanProcessor;
22
23
  _azureSpanProcessor;
23
24
  _azureExporter;
@@ -31,7 +32,8 @@ export class TraceHandler {
31
32
  * @param _config - Configuration.
32
33
  * @param _metricHandler - MetricHandler.
33
34
  */
34
- constructor(config, metricHandler) {
35
+ constructor(config, metricHandler, instrumentationCache) {
36
+ this.instrumentationCache = instrumentationCache;
35
37
  this._config = config;
36
38
  this._metricHandler = metricHandler;
37
39
  this._instrumentations = [];
@@ -48,13 +50,7 @@ export class TraceHandler {
48
50
  this._sampler = new ApplicationInsightsSampler(this._config.samplingRatio);
49
51
  }
50
52
  this._azureExporter = new AzureMonitorTraceExporter(this._config.azureMonitorExporterOptions);
51
- const bufferConfig = {
52
- maxExportBatchSize: 512,
53
- scheduledDelayMillis: 5000,
54
- exportTimeoutMillis: 30000,
55
- maxQueueSize: 2048,
56
- };
57
- this._batchSpanProcessor = new BatchSpanProcessor(this._azureExporter, bufferConfig);
53
+ this._batchSpanProcessor = new BatchSpanProcessor(this._azureExporter);
58
54
  this._azureSpanProcessor = new AzureMonitorSpanProcessor(this._metricHandler);
59
55
  this._azureFunctionsHook = new AzureFunctionsHook();
60
56
  this._initializeInstrumentations();
@@ -100,49 +96,25 @@ export class TraceHandler {
100
96
  return result;
101
97
  };
102
98
  httpinstrumentationOptions.ignoreOutgoingRequestHook = mergedIgnoreOutgoingRequestHook;
103
- this._instrumentations.push(new HttpInstrumentation(this._config.instrumentationOptions.http));
99
+ this._instrumentations.push(configureInstrumentation(this.instrumentationCache, "http", httpinstrumentationOptions, (options) => new HttpInstrumentation(options)));
104
100
  }
105
101
  if (this._config.instrumentationOptions.azureSdk?.enabled) {
106
- const azureSdkInstrumentation = createAzureSdkInstrumentation(this._config.instrumentationOptions.azureSdk);
102
+ const azureSdkInstrumentation = configureInstrumentation(this.instrumentationCache, "azureSdk", this._config.instrumentationOptions.azureSdk, (options) => new AzureSdkInstrumentation(options));
107
103
  this._instrumentations.push(azureSdkInstrumentation);
108
- this._wireAzureSdkInstrumenter(azureSdkInstrumentation);
104
+ ensureAzureSdkTracingBridge(azureSdkInstrumentation);
109
105
  }
110
106
  if (this._config.instrumentationOptions.mongoDb?.enabled) {
111
- this._instrumentations.push(new MongoDBInstrumentation(this._config.instrumentationOptions.mongoDb));
107
+ this._instrumentations.push(configureInstrumentation(this.instrumentationCache, "mongoDb", this._config.instrumentationOptions.mongoDb, (options) => new MongoDBInstrumentation(options)));
112
108
  }
113
109
  if (this._config.instrumentationOptions.mySql?.enabled) {
114
- this._instrumentations.push(new MySQLInstrumentation(this._config.instrumentationOptions.mySql));
110
+ this._instrumentations.push(configureInstrumentation(this.instrumentationCache, "mySql", this._config.instrumentationOptions.mySql, (options) => new MySQLInstrumentation(options)));
115
111
  }
116
112
  if (this._config.instrumentationOptions.postgreSql?.enabled) {
117
- this._instrumentations.push(new PgInstrumentation(this._config.instrumentationOptions.postgreSql));
113
+ this._instrumentations.push(configureInstrumentation(this.instrumentationCache, "postgreSql", this._config.instrumentationOptions.postgreSql, (options) => new PgInstrumentation(options)));
118
114
  }
119
115
  if (this._config.instrumentationOptions.redis?.enabled ||
120
116
  this._config.instrumentationOptions.redis4?.enabled) {
121
- this._instrumentations.push(new RedisInstrumentation(this._config.instrumentationOptions.redis));
122
- }
123
- }
124
- /**
125
- * Wire the Azure SDK instrumenter into `@azure/core-tracing` directly.
126
- *
127
- * The Azure SDK instrumentation registers its instrumenter through an OpenTelemetry
128
- * module-patch hook that only fires via `require`/`import`-in-the-middle. In ESM hosts
129
- * where the OpenTelemetry loader cannot be registered up front (for example, Azure
130
- * Functions, which controls the Node.js start command), that hook never runs, so Azure
131
- * SDK dependency spans are missing. Because `@azure/core-tracing` resolves its
132
- * instrumenter lazily at span-creation time from shared module-local state, applying
133
- * the same patch directly here enables Azure SDK tracing regardless of module system.
134
- */
135
- _wireAzureSdkInstrumenter(instrumentation) {
136
- try {
137
- const moduleDefinitions = instrumentation.getModuleDefinitions?.() ?? [];
138
- for (const moduleDefinition of moduleDefinitions) {
139
- if (moduleDefinition.name === "@azure/core-tracing" && moduleDefinition.patch) {
140
- moduleDefinition.patch(coreTracing);
141
- }
142
- }
143
- }
144
- catch (error) {
145
- Logger.getInstance().warn("Failed to enable Azure SDK tracing for ESM applications", error);
117
+ this._instrumentations.push(configureInstrumentation(this.instrumentationCache, "redis", this._config.instrumentationOptions.redis ?? {}, (options) => new RedisInstrumentation(options)));
146
118
  }
147
119
  }
148
120
  }
@@ -1 +1 @@
1
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AAE,IAAI,EAAE,CAAC;YACnC,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,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,yDAAyD,EAAE,KAAK,CAAC,CAAC;QAC9F,CAAC;IACH,CAAC;CACF","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 { BufferConfig, 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 const bufferConfig: BufferConfig = {\n maxExportBatchSize: 512,\n scheduledDelayMillis: 5000,\n exportTimeoutMillis: 30000,\n maxQueueSize: 2048,\n };\n this._batchSpanProcessor = new BatchSpanProcessor(this._azureExporter, bufferConfig);\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,OAAO,EACL,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAKnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAI5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;A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sB,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;YACvD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CACzB,wBAAwB,CACtB,IAAI,CAAC,oBAAoB,EACzB,OAAO,EACP,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,EACzC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAC/C,CACF,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC;YAC5D,IAAI,CAAC,iBAAiB,CAAC,IAAI,CACzB,wBAAwB,CACtB,IAAI,CAAC,oBAAoB,EACzB,YAAY,EACZ,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,UAAU,EAC9C,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAC5C,CACF,CAAC;QACJ,CAAC;QACD,IACE,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,EAAE,OAAO;YAClD,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,EACnD,CAAC;YACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CACzB,wBAAwB,CACtB,IAAI,CAAC,oBAAoB,EACzB,OAAO,EACP,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,IAAI,EAAE,EAC/C,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAC/C,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF","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"]}
@@ -46,7 +46,7 @@ export class ApplicationInsightsSampler {
46
46
  spanKind, attributes,
47
47
  // @ts-expect-error unused var
48
48
  links) {
49
- let isSampledIn = false;
49
+ let isSampledIn;
50
50
  if (this._sampleRate === 100) {
51
51
  isSampledIn = true;
52
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sampler.js","sourceRoot":"","sources":["../../../src/traces/sampler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,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ChB,CAAC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE;YAC3E,CAAC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;IACpE,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,OAAO,8BAA8B,IAAI,CAAC,cAAc,GAAG,CAAC;IAC9D,CAAC;IAEO,oBAAoB,CAAC,KAAa;QACxC,MAAM,SAAS,GAAG,CAAC,UAAU,CAAC;QAC9B,MAAM,SAAS,GAAG,UAAU,CAAC;QAC7B,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;QACxB,CAAC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,uGAAuG;YACvG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,GAAG,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC;IAClC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n/**\n * TODO: Remove this sampler in favor of the implementation in the AzMon Exporter once we support M2M approach for standard metrics.\n * This sampler specifically marks spans as sampled out and records them instead of dropping the span altogether.\n */\nimport type { Link, Attributes, SpanKind, Context } from \"@opentelemetry/api\";\nimport { diag } from \"@opentelemetry/api\";\nimport type { Sampler, SamplingResult } from \"@opentelemetry/sdk-trace-base\";\nimport { SamplingDecision } from \"@opentelemetry/sdk-trace-base\";\nimport { AzureMonitorSampleRate } from \"../types.js\";\n\n/**\n * ApplicationInsightsSampler is responsible for the following:\n * Implements same trace id hashing algorithm so that traces are sampled the same across multiple nodes\n * Adds item count to span attribute if span is sampled (needed for ingestion service)\n * @param samplingRatio - 0 to 1 value.\n */\nexport class ApplicationInsightsSampler implements Sampler {\n private readonly _sampleRate: number;\n private readonly _samplingRatio: number;\n\n /**\n * Initializes a new instance of the ApplicationInsightsSampler class.\n * @param samplingRatio - Value in the range [0,1], 1 meaning all data will sampled and 0 all Tracing data will be sampled out.\n */\n constructor(samplingRatio: number = 1) {\n this._samplingRatio = samplingRatio;\n if (\n this._samplingRatio > 1 ||\n this._samplingRatio < 0 ||\n !Number.isFinite(this._samplingRatio)\n ) {\n diag.warn(\"Invalid sampling rate, sampling rate must be a value in the range [0,1].\");\n }\n this._sampleRate = Math.round(this._samplingRatio * 100);\n }\n\n /**\n * Checks whether span needs to be created and tracked.\n *\n * @param context - Parent Context which may contain a span.\n * @param traceId - of the span to be created. It can be different from the\n * traceId in the {@link SpanContext}. Typically in situations when the\n * span to be created starts a new trace.\n * @param spanName - of the span to be created.\n * @param spanKind - of the span to be created.\n * @param attributes - Initial set of SpanAttributes for the Span being constructed.\n * @param links - Collection of links that will be associated with the Span to\n * be created. Typically useful for batch operations.\n * @returns a {@link SamplingResult}.\n */\n public shouldSample(\n // @ts-expect-error unused var\n context: Context,\n traceId: string,\n // @ts-expect-error unused var\n spanName: string,\n // @ts-expect-error unused var\n spanKind: SpanKind,\n attributes: Attributes,\n // @ts-expect-error unused var\n links: Link[],\n ): SamplingResult {\n let isSampledIn = false;\n if (this._sampleRate === 100) {\n isSampledIn = true;\n } else if (this._sampleRate === 0) {\n isSampledIn = false;\n } else {\n isSampledIn = this._getSamplingHashCode(traceId) < this._sampleRate;\n }\n // Add sample rate as span attribute if it is not 100\n attributes = attributes || {};\n if (this._sampleRate !== 100) {\n attributes[AzureMonitorSampleRate] = this._sampleRate;\n }\n return isSampledIn\n ? { decision: SamplingDecision.RECORD_AND_SAMPLED, attributes: attributes }\n : { decision: SamplingDecision.RECORD, attributes: attributes };\n }\n\n /**\n * Return Sampler description\n */\n public toString(): string {\n return `ApplicationInsightsSampler{${this._samplingRatio}}`;\n }\n\n private _getSamplingHashCode(input: string): number {\n const csharpMin = -2147483648;\n const csharpMax = 2147483647;\n let hash = 5381;\n\n if (!input) {\n return 0;\n }\n\n while (input.length < 8) {\n input = input + input;\n }\n\n for (let i = 0; i < input.length; i++) {\n // JS doesn't respond to integer overflow by wrapping around. Simulate it with bitwise operators ( | 0)\n hash = ((((hash << 5) + hash) | 0) + input.charCodeAt(i)) | 0;\n }\n\n hash = hash <= csharpMin ? csharpMax : Math.abs(hash);\n return (hash / csharpMax) * 100;\n }\n}\n"]}
1
+ {"version":3,"file":"sampler.js","sourceRoot":"","sources":["../../../src/traces/sampler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;GAKG;AACH,MAAM,OAAO,0BAA0B;IACpB,WAAW,CAAS;IACpB,cAAc,CAAS;IAExC;;;OAGG;IACH,YAAY,gBAAwB,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IACE,IAAI,CAAC,cAAc,GAAG,CAAC;YACvB,IAAI,CAAC,cAAc,GAAG,CAAC;YACvB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,EACrC,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,0EAA0E,CA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,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;QACxB,CAAC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,uGAAuG;YACvG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,GAAG,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC;IAClC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n/**\n * TODO: Remove this sampler in favor of the implementation in the AzMon Exporter once we support M2M approach for standard metrics.\n * This sampler specifically marks spans as sampled out and records them instead of dropping the span altogether.\n */\nimport type { Link, Attributes, SpanKind, Context } from \"@opentelemetry/api\";\nimport { diag } from \"@opentelemetry/api\";\nimport type { Sampler, SamplingResult } from \"@opentelemetry/sdk-trace-base\";\nimport { SamplingDecision } from \"@opentelemetry/sdk-trace-base\";\nimport { AzureMonitorSampleRate } from \"../types.js\";\n\n/**\n * ApplicationInsightsSampler is responsible for the following:\n * Implements same trace id hashing algorithm so that traces are sampled the same across multiple nodes\n * Adds item count to span attribute if span is sampled (needed for ingestion service)\n * @param samplingRatio - 0 to 1 value.\n */\nexport class ApplicationInsightsSampler implements Sampler {\n private readonly _sampleRate: number;\n private readonly _samplingRatio: number;\n\n /**\n * Initializes a new instance of the ApplicationInsightsSampler class.\n * @param samplingRatio - Value in the range [0,1], 1 meaning all data will sampled and 0 all Tracing data will be sampled out.\n */\n constructor(samplingRatio: number = 1) {\n this._samplingRatio = samplingRatio;\n if (\n this._samplingRatio > 1 ||\n this._samplingRatio < 0 ||\n !Number.isFinite(this._samplingRatio)\n ) {\n diag.warn(\"Invalid sampling rate, sampling rate must be a value in the range [0,1].\");\n }\n this._sampleRate = Math.round(this._samplingRatio * 100);\n }\n\n /**\n * Checks whether span needs to be created and tracked.\n *\n * @param context - Parent Context which may contain a span.\n * @param traceId - of the span to be created. It can be different from the\n * traceId in the {@link SpanContext}. Typically in situations when the\n * span to be created starts a new trace.\n * @param spanName - of the span to be created.\n * @param spanKind - of the span to be created.\n * @param attributes - Initial set of SpanAttributes for the Span being constructed.\n * @param links - Collection of links that will be associated with the Span to\n * be created. Typically useful for batch operations.\n * @returns a {@link SamplingResult}.\n */\n public shouldSample(\n // @ts-expect-error unused var\n context: Context,\n traceId: string,\n // @ts-expect-error unused var\n spanName: string,\n // @ts-expect-error unused var\n spanKind: SpanKind,\n attributes: Attributes,\n // @ts-expect-error unused var\n links: Link[],\n ): SamplingResult {\n let isSampledIn: boolean;\n if (this._sampleRate === 100) {\n isSampledIn = true;\n } else if (this._sampleRate === 0) {\n isSampledIn = false;\n } else {\n isSampledIn = this._getSamplingHashCode(traceId) < this._sampleRate;\n }\n // Add sample rate as span attribute if it is not 100\n attributes = attributes || {};\n if (this._sampleRate !== 100) {\n attributes[AzureMonitorSampleRate] = this._sampleRate;\n }\n return isSampledIn\n ? { decision: SamplingDecision.RECORD_AND_SAMPLED, attributes: attributes }\n : { decision: SamplingDecision.RECORD, attributes: attributes };\n }\n\n /**\n * Return Sampler description\n */\n public toString(): string {\n return `ApplicationInsightsSampler{${this._samplingRatio}}`;\n }\n\n private _getSamplingHashCode(input: string): number {\n const csharpMin = -2147483648;\n const csharpMax = 2147483647;\n let hash = 5381;\n\n if (!input) {\n return 0;\n }\n\n while (input.length < 8) {\n input = input + input;\n }\n\n for (let i = 0; i < input.length; i++) {\n // JS doesn't respond to integer overflow by wrapping around. Simulate it with bitwise operators ( | 0)\n hash = ((((hash << 5) + hash) | 0) + input.charCodeAt(i)) | 0;\n }\n\n hash = hash <= csharpMin ? csharpMax : Math.abs(hash);\n return (hash / csharpMax) * 100;\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { AzureMonitorExporterOptions } from "@azure/monitor-opentelemetry-exporter";
2
2
  import type { InstrumentationConfig } from "@opentelemetry/instrumentation";
3
+ import type { SeverityNumber } from "@opentelemetry/api-logs";
3
4
  import type { Resource } from "@opentelemetry/resources";
4
5
  import type { LogRecordProcessor } from "@opentelemetry/sdk-logs";
5
6
  import type { MetricReader, ViewOptions } from "@opentelemetry/sdk-metrics";
@@ -60,7 +61,15 @@ export interface InstrumentationOptions {
60
61
  /** Winston Instrumentation Config */
61
62
  winston?: InstrumentationConfig;
62
63
  /** Console Instrumentation Config */
63
- console?: InstrumentationConfig;
64
+ console?: ConsoleInstrumentationOptions;
65
+ }
66
+ /**
67
+ * Console Instrumentation Configuration interface
68
+ */
69
+ export interface ConsoleInstrumentationOptions extends InstrumentationConfig {
70
+ /** The minimum severity of `console` calls to collect. Defaults to the value derived from the
71
+ * `APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL` environment variable. */
72
+ logSeverity?: SeverityNumber;
64
73
  }
65
74
  /**
66
75
  * Statsbeat Features Configuration interface
@@ -143,7 +152,7 @@ export interface BrowserSdkLoaderOptions {
143
152
  /** Browser SDK Loader Connection String */
144
153
  connectionString?: string;
145
154
  }
146
- export declare const AZURE_MONITOR_OPENTELEMETRY_VERSION = "1.19.0";
155
+ export declare const AZURE_MONITOR_OPENTELEMETRY_VERSION = "1.20.1";
147
156
  export declare const AZURE_MONITOR_STATSBEAT_FEATURES = "AZURE_MONITOR_STATSBEAT_FEATURES";
148
157
  export declare const AZURE_MONITOR_PREFIX = "AZURE_MONITOR_PREFIX";
149
158
  export declare const AZURE_MONITOR_AUTO_ATTACH = "AZURE_MONITOR_AUTO_ATTACH";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C,2CAA2C;IAC3C,2BAA2B,CAAC,EAAE,2BAA2B,CAAC;IAC1D,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4GAA4G;IAC5G,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,oDAAoD;IACpD,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,wDAAwD;IACxD,+BAA+B,CAAC,EAAE,OAAO,CAAC;IAC1C,yCAAyC;IACzC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,mKAAmK;IACnK,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD,+FAA+F;IAC/F,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAClD,2EAA2E;IAC3E,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC3C,qEAAqE;IACrE,cAAc,CAAC,EAAE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,WAAW;IACf,OAAO,WAAW;IAClB,IAAI,WAAW;IACf,GAAG,YAAY;IACf,SAAS,YAAY;IACrB,MAAM,YAAY;IAClB,WAAW,aAAa;IACxB,GAAG,aAAa;IAChB,IAAI,aAAa;IACjB,OAAO,aAAa;IACpB,MAAM,cAAc;IACpB,OAAO,cAAc;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,qBA8BtC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,4BAA4B,qBAqCvC,CAAC;AAEH,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,wBAAwB,CAAC;IAC1C,OAAO,EAAE,gBAAgB,CAAC;CAC3B"}
package/dist/esm/types.js CHANGED
@@ -13,7 +13,7 @@ export const StatsbeatFeaturesMap = new Map([
13
13
  ["multiIkey", 128],
14
14
  ["aksResourceDetectorPopulation", 256],
15
15
  ]);
16
- export const AZURE_MONITOR_OPENTELEMETRY_VERSION = "1.19.0";
16
+ export const AZURE_MONITOR_OPENTELEMETRY_VERSION = "1.20.1";
17
17
  export const AZURE_MONITOR_STATSBEAT_FEATURES = "AZURE_MONITOR_STATSBEAT_FEATURES";
18
18
  export const AZURE_MONITOR_PREFIX = "AZURE_MONITOR_PREFIX";
19
19
  export const AZURE_MONITOR_AUTO_ATTACH = "AZURE_MONITOR_AUTO_ATTACH";