@azure/monitor-opentelemetry 1.15.1-alpha.20260127.1 → 1.15.1-alpha.20260129.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.
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":"AASA,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,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE;;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;IA2BzD,UAAU,IAAI,OAAO;IAIrB,qBAAqB,IAAI,kBAAkB;IAI3C,4BAA4B,IAAI,yBAAyB;IAIzD,mBAAmB,IAAI,eAAe,EAAE;IAI/C;;OAEG;IAEU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC;;OAEG;IACH,OAAO,CAAC,2BAA2B;CAqDpC"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":"AASA,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,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE;;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;IA2BzD,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;CAqDpC"}
@@ -75,9 +75,11 @@ class TraceHandler {
75
75
  /**
76
76
  * Shutdown handler
77
77
  */
78
- // eslint-disable-next-line @typescript-eslint/require-await
79
78
  async shutdown() {
80
79
  this._azureFunctionsHook.shutdown();
80
+ await this._batchSpanProcessor.shutdown();
81
+ await this._azureSpanProcessor.shutdown();
82
+ await this._azureExporter.shutdown();
81
83
  }
82
84
  /**
83
85
  * Start auto collection of telemetry
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../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C,sBAAsB,CAAC,KAAK,EAAE,OAAO;YAClD,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,EACnD,CAAC;YACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CACzB,IAAI,4CAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,CACpE,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA1HD,oCA0HC","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 {\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 { Instrumentation } from \"@opentelemetry/instrumentation\";\nimport { ApplicationInsightsSampler } from \"./sampler.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 // eslint-disable-next-line @typescript-eslint/require-await\n public async shutdown(): Promise<void> {\n this._azureFunctionsHook.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 this._instrumentations.push(\n createAzureSdkInstrumentation(this._config.instrumentationOptions.azureSdk),\n );\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"]}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,4GAA+F;AAC/F,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;AAE1D;;GAEG;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nD,CAAC;YACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CACzB,IAAI,4CAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,CACpE,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA5HD,oCA4HC","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 {\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 { Instrumentation } from \"@opentelemetry/instrumentation\";\nimport { ApplicationInsightsSampler } from \"./sampler.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 this._instrumentations.push(\n createAzureSdkInstrumentation(this._config.instrumentationOptions.azureSdk),\n );\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":"AASA,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,CA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AAO,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;IA2BzD,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;CAqDpC"}
@@ -72,9 +72,11 @@ export class TraceHandler {
72
72
  /**
73
73
  * Shutdown handler
74
74
  */
75
- // eslint-disable-next-line @typescript-eslint/require-await
76
75
  async shutdown() {
77
76
  this._azureFunctionsHook.shutdown();
77
+ await this._batchSpanProcessor.shutdown();
78
+ await this._azureSpanProcessor.shutdown();
79
+ await this._azureExporter.shutdown();
78
80
  }
79
81
  /**
80
82
  * Start auto collection of telemetry
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAC;AAC/F,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;AAI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,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,EACnD,CAAC;YACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CACzB,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,CACpE,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 { createAzureSdkInstrumentation } from \"@azure/opentelemetry-instrumentation-azure-sdk\";\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 { Instrumentation } from \"@opentelemetry/instrumentation\";\nimport { ApplicationInsightsSampler } from \"./sampler.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 // eslint-disable-next-line @typescript-eslint/require-await\n public async shutdown(): Promise<void> {\n this._azureFunctionsHook.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 this._instrumentations.push(\n createAzureSdkInstrumentation(this._config.instrumentationOptions.azureSdk),\n );\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"]}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAC;AAC/F,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,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,CAAC,sBAAsB,CAAC,KAAK,CAAC,CACpE,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC;YAC5D,IAAI,CAAC,iBAAiB,CAAC,IAAI,CACzB,IAAI,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,UAAU,CAAC,CACtE,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,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,CACpE,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 { createAzureSdkInstrumentation } from \"@azure/opentelemetry-instrumentation-azure-sdk\";\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 { Instrumentation } from \"@opentelemetry/instrumentation\";\nimport { ApplicationInsightsSampler } from \"./sampler.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 this._instrumentations.push(\n createAzureSdkInstrumentation(this._config.instrumentationOptions.azureSdk),\n );\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"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@azure/monitor-opentelemetry",
3
3
  "author": "Microsoft Corporation",
4
4
  "sdk-type": "client",
5
- "version": "1.15.1-alpha.20260127.1",
5
+ "version": "1.15.1-alpha.20260129.1",
6
6
  "description": "Azure Monitor OpenTelemetry (Node.js)",
7
7
  "main": "./dist/commonjs/index.js",
8
8
  "module": "./dist/esm/index.js",
@@ -47,8 +47,8 @@
47
47
  "typescript": "~5.9.3",
48
48
  "vitest": "^4.0.8",
49
49
  "@azure-tools/test-utils-vitest": "^2.0.1",
50
- "@azure/eslint-plugin-azure-sdk": "^3.0.0",
51
- "@azure/dev-tool": "^1.0.0"
50
+ "@azure/dev-tool": "^1.0.0",
51
+ "@azure/eslint-plugin-azure-sdk": "^3.0.0"
52
52
  },
53
53
  "dependencies": {
54
54
  "@azure/core-auth": ">=1.10.2-alpha <1.10.2-alphb",