@azure/monitor-opentelemetry 1.20.0 → 1.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +14 -18
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/logs/handler.d.ts +2 -1
- package/dist/commonjs/logs/handler.d.ts.map +1 -1
- package/dist/commonjs/logs/handler.js +10 -5
- package/dist/commonjs/logs/handler.js.map +1 -1
- package/dist/commonjs/metrics/quickpulse/export/sender.d.ts +1 -1
- package/dist/commonjs/metrics/quickpulse/export/sender.d.ts.map +1 -1
- package/dist/commonjs/metrics/quickpulse/export/sender.js +21 -16
- package/dist/commonjs/metrics/quickpulse/export/sender.js.map +1 -1
- package/dist/commonjs/metrics/quickpulse/liveMetrics.d.ts +5 -1
- package/dist/commonjs/metrics/quickpulse/liveMetrics.d.ts.map +1 -1
- package/dist/commonjs/metrics/quickpulse/liveMetrics.js +86 -75
- package/dist/commonjs/metrics/quickpulse/liveMetrics.js.map +1 -1
- package/dist/commonjs/package.json +1 -1
- package/dist/commonjs/traces/azureSdkInstrumentation.d.ts +12 -0
- package/dist/commonjs/traces/azureSdkInstrumentation.d.ts.map +1 -0
- package/dist/commonjs/traces/azureSdkInstrumentation.js +64 -0
- package/dist/commonjs/traces/azureSdkInstrumentation.js.map +1 -0
- package/dist/commonjs/traces/handler.d.ts +2 -13
- package/dist/commonjs/traces/handler.d.ts.map +1 -1
- package/dist/commonjs/traces/handler.js +13 -36
- package/dist/commonjs/traces/handler.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/types.d.ts +1 -1
- package/dist/commonjs/types.js +1 -1
- package/dist/commonjs/types.js.map +1 -1
- package/dist/commonjs/utils/azureSdkTracingBridge.d.ts +4 -4
- package/dist/commonjs/utils/azureSdkTracingBridge.d.ts.map +1 -1
- package/dist/commonjs/utils/azureSdkTracingBridge.js +10 -8
- package/dist/commonjs/utils/azureSdkTracingBridge.js.map +1 -1
- package/dist/commonjs/utils/instrumentation.d.ts +8 -0
- package/dist/commonjs/utils/instrumentation.d.ts.map +1 -0
- package/dist/commonjs/utils/instrumentation.js +26 -0
- package/dist/commonjs/utils/instrumentation.js.map +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +14 -18
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logs/handler.d.ts +2 -1
- package/dist/esm/logs/handler.d.ts.map +1 -1
- package/dist/esm/logs/handler.js +10 -5
- package/dist/esm/logs/handler.js.map +1 -1
- package/dist/esm/metrics/quickpulse/export/sender.d.ts +1 -1
- package/dist/esm/metrics/quickpulse/export/sender.d.ts.map +1 -1
- package/dist/esm/metrics/quickpulse/export/sender.js +21 -16
- package/dist/esm/metrics/quickpulse/export/sender.js.map +1 -1
- package/dist/esm/metrics/quickpulse/liveMetrics.d.ts +5 -1
- package/dist/esm/metrics/quickpulse/liveMetrics.d.ts.map +1 -1
- package/dist/esm/metrics/quickpulse/liveMetrics.js +86 -75
- package/dist/esm/metrics/quickpulse/liveMetrics.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/traces/azureSdkInstrumentation.d.ts +12 -0
- package/dist/esm/traces/azureSdkInstrumentation.d.ts.map +1 -0
- package/dist/esm/traces/azureSdkInstrumentation.js +60 -0
- package/dist/esm/traces/azureSdkInstrumentation.js.map +1 -0
- package/dist/esm/traces/handler.d.ts +2 -13
- package/dist/esm/traces/handler.d.ts.map +1 -1
- package/dist/esm/traces/handler.js +13 -35
- package/dist/esm/traces/handler.js.map +1 -1
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/types.js +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/azureSdkTracingBridge.d.ts +4 -4
- package/dist/esm/utils/azureSdkTracingBridge.d.ts.map +1 -1
- package/dist/esm/utils/azureSdkTracingBridge.js +11 -7
- package/dist/esm/utils/azureSdkTracingBridge.js.map +1 -1
- package/dist/esm/utils/instrumentation.d.ts +8 -0
- package/dist/esm/utils/instrumentation.d.ts.map +1 -0
- package/dist/esm/utils/instrumentation.js +23 -0
- package/dist/esm/utils/instrumentation.js.map +1 -0
- package/package.json +8 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liveMetrics.js","sourceRoot":"","sources":["../../../../src/metrics/quickpulse/liveMetrics.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AAKzB,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAI1F,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAclE,OAAO,EACL,cAAc,EACd,aAAa,EACb,WAAW,EACX,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,uBAAuB,EACvB,eAAe,EACf,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,kCAAkC,EAAE,MAAM,sBAAsB,CAAC;AAS1E,OAAO,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,0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,mBAAmB,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;gBAC5E,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,WAAW,GAAiC;wBAChD,gCAAgC,EAAE,SAAS;wBAC3C,OAAO,EAAE,EAAE;wBACX,aAAa,EAAE,EAAE;wBACjB,IAAI,EAAE,EAAE;qBACT,CAAC;oBACF,IAAI,KAAK,YAAY,0BAA0B,EAAE,CAAC;wBAChD,WAAW,CAAC,gCAAgC,GAAG,uBAAuB,CAAC;wBAEvE,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;4BAC3B,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;4BACpC,WAAW,CAAC,aAAa,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;wBAChD,CAAC;wBACD,MAAM,SAAS,GAA+B,EAAE,CAAC;wBACjD,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAAC,CAAC;wBACjE,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;wBAClD,WAAW,CAAC,IAAI,GAAG,SAAS,CAAC;wBAC7B,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;oBACjD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport os from \"node:os\";\nimport type {\n MeterProviderOptions,\n PeriodicExportingMetricReaderOptions,\n} from \"@opentelemetry/sdk-metrics\";\nimport { MeterProvider, PeriodicExportingMetricReader } from \"@opentelemetry/sdk-metrics\";\nimport type { SdkLogRecord } from \"@opentelemetry/sdk-logs\";\nimport type { InternalConfig } from \"../../shared/config.js\";\nimport type { Meter, ObservableGauge, ObservableResult } from \"@opentelemetry/api\";\nimport { SpanKind, SpanStatusCode, ValueType, context } from \"@opentelemetry/api\";\nimport type { ReadableSpan, TimedEvent } from \"@opentelemetry/sdk-trace-base\";\nimport { RandomIdGenerator } from \"@opentelemetry/sdk-trace-base\";\nimport type {\n DocumentIngress,\n Exception,\n MonitoringDataPoint,\n IsSubscribedOptionalParams,\n RemoteDependency,\n Request,\n Trace,\n KeyValuePairStringString,\n DerivedMetricInfo,\n FilterConjunctionGroupInfo,\n} from \"../../generated/index.js\";\nimport type { QuickpulseResponse } from \"./export/sender.js\";\nimport {\n getLogDocument,\n getSdkVersion,\n getSpanData,\n getLogData,\n getSpanDocument,\n getTransmissionTime,\n isRequestData,\n getSpanExceptionColumns,\n isExceptionData,\n isDependencyData,\n} from \"./utils.js\";\nimport { QuickpulseMetricExporter } from \"./export/exporter.js\";\nimport { QuickpulseSender } from \"./export/sender.js\";\nimport { ConnectionStringParser } from \"../../utils/connectionStringParser.js\";\nimport { DEFAULT_LIVEMETRICS_ENDPOINT } from \"../../types.js\";\nimport { getAuthenticationCredentialFromEnv } from \"./credentialUtils.js\";\nimport type {\n QuickpulseExporterOptions,\n RequestData,\n DependencyData,\n TraceData,\n ExceptionData,\n TelemetryData,\n} from \"./types.js\";\nimport { QuickPulseOpenTelemetryMetricNames } from \"./types.js\";\nimport { hrTimeToMilliseconds, suppressTracing } from \"@opentelemetry/core\";\nimport { getInstance } from \"../../utils/statsbeat.js\";\nimport type { CollectionConfigurationError } from \"../../generated/index.js\";\nimport { Filter } from \"./filtering/filter.js\";\nimport { Validator } from \"./filtering/validator.js\";\nimport { CollectionConfigurationErrorTracker } from \"./filtering/collectionConfigurationErrorTracker.js\";\nimport { Projection } from \"./filtering/projection.js\";\nimport {\n TelemetryTypeError,\n UnexpectedFilterCreateError,\n DuplicateMetricIdError,\n MetricFailureToCreateError,\n} from \"./filtering/quickpulseErrors.js\";\nimport { SEMATTRS_EXCEPTION_TYPE } from \"@opentelemetry/semantic-conventions\";\nimport { getPhysicalMemory, getProcessorTimeNormalized } from \"../utils.js\";\nimport { getCloudRole, getCloudRoleInstance } from \"../utils.js\";\nimport { Logger } from \"../../shared/logging/logger.js\";\n\nconst POST_INTERVAL = 1000;\nconst MAX_POST_WAIT_TIME = 20000;\nconst PING_INTERVAL = 5000;\nconst MAX_PING_WAIT_TIME = 60000;\nconst FALLBACK_INTERVAL = 60000;\n\n/**\n * Azure Monitor Live Metrics\n * @internal\n */\nexport class LiveMetrics {\n private config: InternalConfig;\n private meterProvider: MeterProvider | undefined;\n private metricReader: PeriodicExportingMetricReader | undefined;\n private meter: Meter | undefined;\n private requestDurationGauge: ObservableGauge | undefined;\n private dependencyDurationGauge: ObservableGauge | undefined;\n private requestRateGauge: ObservableGauge | undefined;\n private requestFailedRateGauge: ObservableGauge | undefined;\n private dependencyRateGauge: ObservableGauge | undefined;\n private dependencyFailedRateGauge: ObservableGauge | undefined;\n private processPhysicalBytesGauge: ObservableGauge | undefined;\n private percentProcessorTimeNormalizedGauge: ObservableGauge | undefined;\n private exceptionsRateGauge: ObservableGauge | undefined;\n\n private documents: DocumentIngress[] = [];\n private pingInterval: number;\n private postInterval: number;\n private quickpulseExporter: QuickpulseMetricExporter;\n private pingSender: QuickpulseSender;\n private isCollectingData: boolean;\n private isDeactivating: boolean = false;\n private deactivatingPromise: Promise<void> | undefined;\n private lastSuccessTime: number = Date.now();\n private handle: NodeJS.Timer;\n // Monitoring data point with common properties\n private baseMonitoringDataPoint: MonitoringDataPoint;\n private totalRequestCount = 0;\n private totalFailedRequestCount = 0;\n private totalDependencyCount = 0;\n private totalFailedDependencyCount = 0;\n private totalExceptionCount = 0;\n private requestDuration = 0;\n private dependencyDuration = 0;\n private lastRequestDuration: { count: number; duration: number; time: number } = {\n count: 0,\n duration: 0,\n time: 0,\n };\n private lastRequestRate: { count: number; time: number } = { count: 0, time: 0 };\n private lastFailedRequestRate: { count: number; time: number } = { count: 0, time: 0 };\n private lastDependencyDuration: { count: number; duration: number; time: number } = {\n count: 0,\n duration: 0,\n time: 0,\n };\n private lastDependencyRate: { count: number; time: number } = { count: 0, time: 0 };\n private lastFailedDependencyRate: { count: number; time: number } = { count: 0, time: 0 };\n private lastExceptionRate: { count: number; time: number } = { count: 0, time: 0 };\n private lastCpuUsage: NodeJS.CpuUsage;\n private lastHrTime: bigint;\n private statsbeatOptionsUpdated = false;\n private etag: string = \"\";\n private errorTracker: CollectionConfigurationErrorTracker =\n new CollectionConfigurationErrorTracker();\n // For tracking of duplicate metric ids in the same configuration.\n private seenMetricIds: Set<string> = new Set();\n private validDerivedMetrics: Map<string, DerivedMetricInfo[]> = new Map();\n private derivedMetricProjection: Projection = new Projection();\n private validator: Validator = new Validator();\n private filter: Filter = new Filter();\n // type: Map<telemetryType, Map<id, FilterConjunctionGroupInfo[]>>\n private validDocumentFilterConjuctionGroupInfos: Map<\n string,\n Map<string, FilterConjunctionGroupInfo[]>\n > = new Map();\n /**\n * Initializes a new instance of the StandardMetrics class.\n * @param config - Distro configuration.\n * @param options - Standard Metrics options.\n */\n constructor(config: InternalConfig) {\n this.config = config;\n const idGenerator = new RandomIdGenerator();\n const streamId = idGenerator.generateTraceId();\n const machineName = os.hostname();\n const instance = getCloudRoleInstance(this.config.resource);\n const roleName = getCloudRole(this.config.resource);\n const version = getSdkVersion();\n this.baseMonitoringDataPoint = {\n version: version,\n invariantVersion: 5, // 5 means we support live metrics filtering of metrics and documents\n instance: instance,\n roleName: roleName,\n machineName: machineName,\n streamId: streamId,\n performanceCollectionSupported: true,\n isWebApp: process.env[\"WEBSITE_SITE_NAME\"] ? true : false,\n };\n const parsedConnectionString = ConnectionStringParser.parse(\n this.config.azureMonitorExporterOptions.connectionString ||\n process.env[\"APPLICATIONINSIGHTS_CONNECTION_STRING\"],\n );\n const credential =\n this.config.azureMonitorExporterOptions.credential ?? getAuthenticationCredentialFromEnv();\n this.pingSender = new QuickpulseSender({\n endpointUrl: parsedConnectionString.liveendpoint || DEFAULT_LIVEMETRICS_ENDPOINT,\n instrumentationKey: parsedConnectionString.instrumentationkey || \"\",\n credential: credential,\n credentialScopes:\n parsedConnectionString.aadaudience ||\n this.config.azureMonitorExporterOptions.credentialScopes,\n });\n const exporterOptions: QuickpulseExporterOptions = {\n endpointUrl: parsedConnectionString.liveendpoint || DEFAULT_LIVEMETRICS_ENDPOINT,\n instrumentationKey: parsedConnectionString.instrumentationkey || \"\",\n credential: credential,\n credentialScopes:\n parsedConnectionString.aadaudience ||\n this.config.azureMonitorExporterOptions.credentialScopes,\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n postCallback: this.quickPulseDone.bind(this),\n getDocumentsFn: this.getDocuments.bind(this),\n getErrorsFn: this.getErrors.bind(this),\n getDerivedMetricValuesFn: this.getDerivedMetricValues.bind(this),\n baseMonitoringDataPoint: this.baseMonitoringDataPoint,\n };\n this.quickpulseExporter = new QuickpulseMetricExporter(exporterOptions);\n this.isCollectingData = false;\n this.pingInterval = PING_INTERVAL; // Default\n this.postInterval = POST_INTERVAL;\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.handle = setTimeout(this.goQuickpulse.bind(this), this.pingInterval);\n this.handle.unref(); // Don't block apps from terminating\n this.lastCpuUsage = process.cpuUsage();\n this.lastHrTime = process.hrtime.bigint();\n }\n\n public async shutdown(): Promise<void> {\n // Force collecting=false before tearing down so the shutdown's final\n // force-flush export, if it fails, cannot trigger the deactivate/\n // reactivate fallback in quickPulseDone(). Delegate to deactivateMetrics()\n // which manages the in-flight deactivation promise so callers (including\n // a concurrent failure-fallback in quickPulseDone) all observe the same\n // completion and shutdown waits for any in-flight deactivation to finish.\n this.isCollectingData = false;\n await this.deactivateMetrics();\n }\n\n private async goQuickpulse(): Promise<void> {\n if (!this.isCollectingData) {\n // If not collecting, Ping\n try {\n const params: IsSubscribedOptionalParams = {\n transmissionTime: getTransmissionTime(),\n monitoringDataPoint: this.baseMonitoringDataPoint,\n configurationEtag: this.etag,\n };\n await context.with(suppressTracing(context.active()), async () => {\n const response = await this.pingSender.isSubscribed(params);\n this.quickPulseDone(response);\n });\n } catch (error) {\n this.quickPulseDone(undefined);\n }\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.handle = setTimeout(this.goQuickpulse.bind(this), this.pingInterval);\n this.handle.unref();\n }\n if (this.isCollectingData) {\n this.activateMetrics({ collectionInterval: this.postInterval });\n }\n }\n\n private async quickPulseDone(response: QuickpulseResponse | undefined): Promise<void> {\n if (!response) {\n if (!this.isCollectingData) {\n if (Date.now() - this.lastSuccessTime >= MAX_PING_WAIT_TIME) {\n this.pingInterval = FALLBACK_INTERVAL;\n }\n } else {\n if (Date.now() - this.lastSuccessTime >= MAX_POST_WAIT_TIME) {\n // Re-entrancy guard: MeterProvider.shutdown() triggers a final\n // force-flush export which, on failure, re-invokes this callback\n // synchronously from inside the shutdown's export call. If a\n // deactivation is already in flight, bail out — awaiting the\n // in-flight promise here would deadlock the exporter's callback.\n if (this.isDeactivating) {\n return;\n }\n this.postInterval = FALLBACK_INTERVAL;\n try {\n await this.deactivateMetrics();\n } catch (error) {\n // The exporter invokes postCallback without awaiting it, so a\n // rejection here would surface as an unhandled rejection. Swallow\n // and log so the failure path stays contained.\n Logger.getInstance().warn(\n \"Failed to deactivate Live Metrics during failure fallback\",\n error,\n );\n }\n // Reset the success-time baseline so the FALLBACK_INTERVAL backoff\n // can take effect before we consider deactivating again.\n this.lastSuccessTime = Date.now();\n // Re-check after the await: shutdown() may have run concurrently and\n // flipped isCollectingData to false. Don't restart collection in\n // that case — doing so would re-create the meterProvider after\n // shutdown has begun.\n if (this.isCollectingData) {\n this.activateMetrics({ collectionInterval: this.postInterval });\n }\n }\n }\n } else {\n this.postInterval = POST_INTERVAL;\n // Update using response if needed\n this.lastSuccessTime = Date.now();\n this.isCollectingData =\n response.xMsQpsSubscribed && response.xMsQpsSubscribed === \"true\" ? true : false;\n if (response.xMsQpsConfigurationEtag && this.etag !== response.xMsQpsConfigurationEtag) {\n this.updateConfiguration(response);\n }\n\n // If collecting was stoped\n if (!this.isCollectingData && this.meterProvider) {\n this.etag = \"\";\n await this.deactivateMetrics();\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.handle = setTimeout(this.goQuickpulse.bind(this), this.pingInterval);\n this.handle.unref();\n }\n\n const endpointRedirect = response.xMsQpsServiceEndpointRedirectV2;\n if (endpointRedirect) {\n this.pingSender.handlePermanentRedirect(endpointRedirect);\n this.quickpulseExporter.getSender().handlePermanentRedirect(endpointRedirect);\n }\n const pollingInterval = response.xMsQpsServicePollingIntervalHint;\n if (pollingInterval) {\n this.pingInterval = Number(pollingInterval);\n } else {\n this.pingInterval = PING_INTERVAL;\n }\n }\n }\n\n // Activate live metrics collection\n public activateMetrics(options?: { collectionInterval: number }): void {\n if (this.meterProvider) {\n return;\n }\n // Turn on live metrics active collection for statsbeat\n if (!this.statsbeatOptionsUpdated) {\n getInstance().setStatsbeatFeatures({}, { liveMetrics: true });\n this.statsbeatOptionsUpdated = true;\n }\n this.totalDependencyCount = 0;\n this.totalExceptionCount = 0;\n this.totalFailedDependencyCount = 0;\n this.totalFailedRequestCount = 0;\n this.totalRequestCount = 0;\n this.requestDuration = 0;\n this.dependencyDuration = 0;\n this.lastRequestDuration = { count: 0, duration: 0, time: 0 };\n this.lastRequestRate = { count: 0, time: 0 };\n this.lastFailedRequestRate = { count: 0, time: 0 };\n this.lastDependencyDuration = { count: 0, duration: 0, time: 0 };\n this.lastDependencyRate = { count: 0, time: 0 };\n this.lastFailedDependencyRate = { count: 0, time: 0 };\n this.lastExceptionRate = { count: 0, time: 0 };\n\n const metricReaderOptions: PeriodicExportingMetricReaderOptions = {\n exporter: this.quickpulseExporter,\n exportIntervalMillis: options?.collectionInterval,\n };\n this.metricReader = new PeriodicExportingMetricReader(metricReaderOptions);\n const meterProviderConfig: MeterProviderOptions = {\n resource: this.config.resource,\n readers: [this.metricReader],\n };\n this.meterProvider = new MeterProvider(meterProviderConfig);\n this.meter = this.meterProvider.getMeter(\"AzureMonitorLiveMetricsMeter\");\n this.requestDurationGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.REQUEST_DURATION,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.requestRateGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.REQUEST_RATE,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.requestFailedRateGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.REQUEST_FAILURE_RATE,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.dependencyDurationGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.DEPENDENCY_DURATION,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.dependencyRateGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.DEPENDENCY_RATE,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.dependencyFailedRateGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.DEPENDENCY_FAILURE_RATE,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n\n this.processPhysicalBytesGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.PHYSICAL_BYTES,\n {\n valueType: ValueType.INT,\n },\n );\n\n this.percentProcessorTimeNormalizedGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.PROCESSOR_TIME_NORMALIZED,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.exceptionsRateGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.EXCEPTION_RATE,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n\n this.requestDurationGauge.addCallback(this.getRequestDuration.bind(this));\n this.requestRateGauge.addCallback(this.getRequestRate.bind(this));\n this.requestFailedRateGauge.addCallback(this.getRequestFailedRate.bind(this));\n this.dependencyDurationGauge.addCallback(this.getDependencyDuration.bind(this));\n this.dependencyRateGauge.addCallback(this.getDependencyRate.bind(this));\n this.dependencyFailedRateGauge.addCallback(this.getDependencyFailedRate.bind(this));\n this.exceptionsRateGauge.addCallback(this.getExceptionRate.bind(this));\n this.processPhysicalBytesGauge.addCallback(this.getPhysicalMemory.bind(this));\n this.percentProcessorTimeNormalizedGauge.addCallback(\n this.getProcessorTimeNormalized.bind(this),\n );\n }\n\n /**\n * Deactivate metric collection\n */\n public async deactivateMetrics(): Promise<void> {\n // Coalesce concurrent deactivations: callers (shutdown(), the\n // failure-fallback in quickPulseDone(), and the \"unsubscribed\" branch in\n // goQuickpulse()) can all race. Return the in-flight promise so every\n // caller awaits the same completion and the underlying meterProvider\n // shutdown only runs once.\n if (this.deactivatingPromise) {\n return this.deactivatingPromise;\n }\n this.isDeactivating = true;\n this.deactivatingPromise = (async () => {\n try {\n this.documents = [];\n this.validDocumentFilterConjuctionGroupInfos.clear();\n this.errorTracker.clearRunTimeErrors();\n this.errorTracker.clearValidationTimeErrors();\n this.validDerivedMetrics.clear();\n this.derivedMetricProjection.clearProjectionMaps();\n this.seenMetricIds.clear();\n // Capture and clear the reference before awaiting shutdown so any\n // re-entrant calls triggered by the shutdown's final force-flush\n // export observe meterProvider as undefined and exit early.\n const provider = this.meterProvider;\n this.meterProvider = undefined;\n await provider?.shutdown();\n } finally {\n this.isDeactivating = false;\n this.deactivatingPromise = undefined;\n }\n })();\n return this.deactivatingPromise;\n }\n\n /**\n * Force flush Meter Provider.\n */\n public async flush(): Promise<void> {\n await this.meterProvider?.forceFlush();\n }\n\n /**\n *Get OpenTelemetry MeterProvider\n */\n public getMeterProvider(): MeterProvider | undefined {\n return this.meterProvider;\n }\n\n public getDocuments(): DocumentIngress[] {\n const result: DocumentIngress[] = this.documents;\n this.documents = [];\n return result;\n }\n\n public getErrors(): CollectionConfigurationError[] {\n const result = this.errorTracker.getErrors();\n this.errorTracker.clearRunTimeErrors();\n return result;\n }\n\n public getDerivedMetricValues(): Map<string, number> {\n return this.derivedMetricProjection.getMetricValues();\n }\n\n private addDocument(document: DocumentIngress): void {\n if (document) {\n // Limit risk of memory leak by limiting doc length to something manageable\n if (this.documents.length > 20) {\n this.documents.shift(); // Remove oldest document\n }\n this.documents.push(document);\n }\n }\n\n /**\n * Record Span metrics\n * @internal\n */\n public recordSpan(span: ReadableSpan): void {\n if (this.isCollectingData) {\n const columns: RequestData | DependencyData = getSpanData(span);\n let documentConfiguration: Map<string, FilterConjunctionGroupInfo[]>;\n let derivedMetricInfos: DerivedMetricInfo[];\n if (isRequestData(columns)) {\n documentConfiguration =\n this.validDocumentFilterConjuctionGroupInfos.get(\"Request\") ||\n new Map<string, FilterConjunctionGroupInfo[]>();\n derivedMetricInfos = this.validDerivedMetrics.get(\"Request\") || [];\n } else {\n documentConfiguration =\n this.validDocumentFilterConjuctionGroupInfos.get(\"Dependency\") ||\n new Map<string, FilterConjunctionGroupInfo[]>();\n derivedMetricInfos = this.validDerivedMetrics.get(\"Dependency\") || [];\n }\n this.applyDocumentFilters(documentConfiguration, columns);\n this.checkMetricFilterAndCreateProjection(derivedMetricInfos, columns);\n\n const durationMs = hrTimeToMilliseconds(span.duration);\n const success = span.status.code !== SpanStatusCode.ERROR;\n\n if (span.kind === SpanKind.SERVER || span.kind === SpanKind.CONSUMER) {\n this.totalRequestCount++;\n this.requestDuration += durationMs;\n if (!success) {\n this.totalFailedRequestCount++;\n }\n } else {\n this.totalDependencyCount++;\n this.dependencyDuration += durationMs;\n if (!success) {\n this.totalFailedDependencyCount++;\n }\n }\n if (span.events) {\n span.events.forEach((event: TimedEvent) => {\n event.attributes = event.attributes || {};\n if (event.name === \"exception\") {\n const exceptionColumns: ExceptionData = getSpanExceptionColumns(\n event.attributes,\n span.attributes,\n );\n documentConfiguration =\n this.validDocumentFilterConjuctionGroupInfos.get(\"Exception\") ||\n new Map<string, FilterConjunctionGroupInfo[]>();\n this.applyDocumentFilters(\n documentConfiguration,\n exceptionColumns,\n event.attributes[SEMATTRS_EXCEPTION_TYPE] as string,\n );\n derivedMetricInfos = this.validDerivedMetrics.get(\"Exception\") || [];\n this.checkMetricFilterAndCreateProjection(derivedMetricInfos, exceptionColumns);\n this.totalExceptionCount++;\n }\n });\n }\n }\n }\n\n /**\n * Record LogRecord metrics, add attribute so data is not aggregated again in ingestion\n * @internal\n */\n public recordLog(logRecord: SdkLogRecord): void {\n if (this.isCollectingData) {\n const columns: TraceData | ExceptionData = getLogData(logRecord);\n let derivedMetricInfos: DerivedMetricInfo[];\n let documentConfiguration: Map<string, FilterConjunctionGroupInfo[]>;\n if (isExceptionData(columns)) {\n documentConfiguration =\n this.validDocumentFilterConjuctionGroupInfos.get(\"Exception\") ||\n new Map<string, FilterConjunctionGroupInfo[]>();\n this.applyDocumentFilters(\n documentConfiguration,\n columns,\n logRecord.attributes[SEMATTRS_EXCEPTION_TYPE] as string,\n );\n derivedMetricInfos = this.validDerivedMetrics.get(\"Exception\") || [];\n this.totalExceptionCount++;\n } else {\n // trace\n documentConfiguration =\n this.validDocumentFilterConjuctionGroupInfos.get(\"Trace\") ||\n new Map<string, FilterConjunctionGroupInfo[]>();\n this.applyDocumentFilters(documentConfiguration, columns);\n derivedMetricInfos = this.validDerivedMetrics.get(\"Trace\") || [];\n }\n this.checkMetricFilterAndCreateProjection(derivedMetricInfos, columns);\n }\n }\n\n private getRequestDuration(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const requestInterval = this.totalRequestCount - this.lastRequestDuration.count || 0;\n const durationInterval = this.requestDuration - this.lastRequestDuration.duration || 0;\n const elapsedMs = currentTime - this.lastRequestDuration.time;\n if (elapsedMs > 0) {\n const averageExecutionTime = durationInterval / requestInterval || 0; // default to 0 in case no requests in this interval\n observableResult.observe(averageExecutionTime);\n }\n this.lastRequestDuration = {\n count: this.totalRequestCount,\n duration: this.requestDuration,\n time: currentTime,\n };\n }\n\n private getRequestRate(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const intervalRequests = this.totalRequestCount - this.lastRequestRate.count || 0;\n const elapsedMs = currentTime - this.lastRequestRate.time;\n if (elapsedMs > 0) {\n const elapsedSeconds = elapsedMs / 1000;\n const dataPerSec = intervalRequests / elapsedSeconds;\n observableResult.observe(dataPerSec);\n }\n this.lastRequestRate = {\n count: this.totalRequestCount,\n time: currentTime,\n };\n }\n\n private getRequestFailedRate(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const intervalRequests = this.totalFailedRequestCount - this.lastFailedRequestRate.count || 0;\n const elapsedMs = currentTime - this.lastFailedRequestRate.time;\n if (elapsedMs > 0) {\n const elapsedSeconds = elapsedMs / 1000;\n const dataPerSec = intervalRequests / elapsedSeconds;\n observableResult.observe(dataPerSec);\n }\n this.lastFailedRequestRate = {\n count: this.totalFailedRequestCount,\n time: currentTime,\n };\n }\n\n private getDependencyDuration(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const dependencyInterval = this.totalDependencyCount - this.lastDependencyDuration.count || 0;\n const durationInterval = this.dependencyDuration - this.lastDependencyDuration.duration || 0;\n const elapsedMs = currentTime - this.lastDependencyDuration.time;\n if (elapsedMs > 0) {\n const averageExecutionTime = durationInterval / dependencyInterval || 0; // default to 0 in case no dependencies in this interval\n observableResult.observe(averageExecutionTime);\n }\n this.lastDependencyDuration = {\n count: this.totalDependencyCount,\n duration: this.dependencyDuration,\n time: currentTime,\n };\n }\n\n private getDependencyRate(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const intervalData = this.totalDependencyCount - this.lastDependencyRate.count || 0;\n const elapsedMs = currentTime - this.lastDependencyRate.time;\n if (elapsedMs > 0) {\n const elapsedSeconds = elapsedMs / 1000;\n const dataPerSec = intervalData / elapsedSeconds;\n observableResult.observe(dataPerSec);\n }\n this.lastDependencyRate = {\n count: this.totalDependencyCount,\n time: currentTime,\n };\n }\n\n private getDependencyFailedRate(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const intervalData = this.totalFailedDependencyCount - this.lastFailedDependencyRate.count || 0;\n const elapsedMs = currentTime - this.lastFailedDependencyRate.time;\n if (elapsedMs > 0) {\n const elapsedSeconds = elapsedMs / 1000;\n const dataPerSec = intervalData / elapsedSeconds;\n observableResult.observe(dataPerSec);\n }\n this.lastFailedDependencyRate = {\n count: this.totalFailedDependencyCount,\n time: currentTime,\n };\n }\n\n private getExceptionRate(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const intervalData = this.totalExceptionCount - this.lastExceptionRate.count || 0;\n const elapsedMs = currentTime - this.lastExceptionRate.time;\n if (elapsedMs > 0) {\n const elapsedSeconds = elapsedMs / 1000;\n const dataPerSec = intervalData / elapsedSeconds;\n observableResult.observe(dataPerSec);\n }\n this.lastExceptionRate = {\n count: this.totalExceptionCount,\n time: currentTime,\n };\n }\n\n private getPhysicalMemory(observableResult: ObservableResult): void {\n const rss = getPhysicalMemory();\n observableResult.observe(rss);\n }\n\n private getProcessorTimeNormalized(observableResult: ObservableResult): void {\n if (process && process.hrtime) {\n const cpuUsagePercent = getProcessorTimeNormalized(this.lastHrTime, this.lastCpuUsage);\n observableResult.observe(cpuUsagePercent);\n this.lastHrTime = process.hrtime.bigint();\n this.lastCpuUsage = process.cpuUsage();\n } else {\n Logger.getInstance().debug(\"Getting Normalized Processor Time Failed. No process available.\");\n }\n }\n\n private updateConfiguration(response: QuickpulseResponse): void {\n this.etag = response.xMsQpsConfigurationEtag || \"\";\n this.quickpulseExporter.setEtag(this.etag);\n this.errorTracker.clearValidationTimeErrors();\n this.validDocumentFilterConjuctionGroupInfos.clear();\n this.validDerivedMetrics.clear();\n this.derivedMetricProjection.clearProjectionMaps();\n this.seenMetricIds.clear();\n\n this.parseDocumentFilterConfiguration(response);\n this.parseMetricFilterConfiguration(response);\n }\n\n private parseDocumentFilterConfiguration(response: QuickpulseResponse): void {\n if (!response?.documentStreams || typeof response.documentStreams.forEach !== \"function\") {\n return;\n }\n response.documentStreams.forEach((documentStreamInfo) => {\n documentStreamInfo.documentFilterGroups.forEach((documentFilterGroupInfo) => {\n try {\n this.validator.validateTelemetryType(documentFilterGroupInfo.telemetryType);\n this.validator.validateDocumentFilters(documentFilterGroupInfo);\n this.filter.renameExceptionFieldNamesForFiltering(documentFilterGroupInfo.filters);\n\n if (\n !this.validDocumentFilterConjuctionGroupInfos.has(documentFilterGroupInfo.telemetryType)\n ) {\n this.validDocumentFilterConjuctionGroupInfos.set(\n documentFilterGroupInfo.telemetryType,\n new Map<string, FilterConjunctionGroupInfo[]>(),\n );\n }\n\n const innerMap = this.validDocumentFilterConjuctionGroupInfos.get(\n documentFilterGroupInfo.telemetryType,\n );\n if (!innerMap?.has(documentStreamInfo.id)) {\n innerMap?.set(documentStreamInfo.id, [documentFilterGroupInfo.filters]);\n } else {\n innerMap.get(documentStreamInfo.id)?.push(documentFilterGroupInfo.filters);\n }\n } catch (error) {\n const configError: CollectionConfigurationError = {\n collectionConfigurationErrorType: \"Unknown\",\n message: \"\",\n fullException: \"\",\n data: [],\n };\n if (error instanceof TelemetryTypeError) {\n configError.collectionConfigurationErrorType =\n \"CollectionConfigurationFailureToCreateUnexpected\";\n } else if (error instanceof UnexpectedFilterCreateError) {\n configError.collectionConfigurationErrorType =\n \"DocumentStreamFailureToCreateFilterUnexpected\";\n }\n\n if (error instanceof Error) {\n configError.message = error.message;\n configError.fullException = error.stack || \"\";\n }\n const data: KeyValuePairStringString[] = [];\n data.push({ key: \"DocumentStreamInfoId\", value: documentStreamInfo.id });\n data.push({ key: \"ETag\", value: this.etag });\n configError.data = data;\n this.errorTracker.addValidationError(configError);\n }\n });\n });\n }\n\n private applyDocumentFilters(\n documentConfiguration: Map<string, FilterConjunctionGroupInfo[]>,\n data: TelemetryData,\n exceptionType?: string,\n ): void {\n const streamIds: Set<string> = new Set<string>();\n documentConfiguration.forEach((filterConjunctionGroupInfoList, streamId) => {\n filterConjunctionGroupInfoList.forEach((filterConjunctionGroupInfo) => {\n // by going though each filterConjuctionGroupInfo, we are implicitly -OR-ing\n // different filterConjunctionGroupInfo within documentStreamInfo. If there are multiple\n // documentStreamInfos, this logic will -OR- the filtering results of each documentStreamInfo.\n if (this.filter.checkFilterConjunctionGroup(filterConjunctionGroupInfo, data)) {\n streamIds.add(streamId);\n }\n });\n });\n\n // Emit a document when a telemetry data matches a particular filtering configuration,\n // or when filtering configuration is empty.\n if (streamIds.size > 0 || documentConfiguration.size === 0) {\n let document: Request | RemoteDependency | Trace | Exception;\n if (isRequestData(data) || isDependencyData(data)) {\n document = getSpanDocument(data);\n } else if (isExceptionData(data) && exceptionType) {\n document = getLogDocument(data, exceptionType);\n } else {\n document = getLogDocument(data);\n }\n document.documentStreamIds = [...streamIds];\n this.addDocument(document);\n }\n }\n\n private parseMetricFilterConfiguration(response: QuickpulseResponse): void {\n if (!response?.documentStreams || typeof response.documentStreams.forEach !== \"function\") {\n return;\n }\n response.metrics.forEach((derivedMetricInfo) => {\n try {\n if (!this.seenMetricIds.has(derivedMetricInfo.id)) {\n this.seenMetricIds.add(derivedMetricInfo.id);\n this.validator.validateTelemetryType(derivedMetricInfo.telemetryType);\n this.validator.checkCustomMetricProjection(derivedMetricInfo);\n this.validator.validateMetricFilters(derivedMetricInfo);\n derivedMetricInfo.filterGroups.forEach((filterConjunctionGroupInfo) => {\n this.filter.renameExceptionFieldNamesForFiltering(filterConjunctionGroupInfo);\n });\n\n if (this.validDerivedMetrics.has(derivedMetricInfo.telemetryType)) {\n this.validDerivedMetrics.get(derivedMetricInfo.telemetryType)?.push(derivedMetricInfo);\n } else {\n this.validDerivedMetrics.set(derivedMetricInfo.telemetryType, [derivedMetricInfo]);\n }\n } else {\n throw new DuplicateMetricIdError(`Duplicate Metric Id: ${derivedMetricInfo.id}`);\n }\n this.derivedMetricProjection.initDerivedMetricProjection(derivedMetricInfo);\n } catch (error) {\n const configError: CollectionConfigurationError = {\n collectionConfigurationErrorType: \"Unknown\",\n message: \"\",\n fullException: \"\",\n data: [],\n };\n if (error instanceof TelemetryTypeError) {\n configError.collectionConfigurationErrorType = \"MetricTelemetryTypeUnsupported\";\n } else if (error instanceof UnexpectedFilterCreateError) {\n configError.collectionConfigurationErrorType = \"MetricFailureToCreateFilterUnexpected\";\n } else if (error instanceof DuplicateMetricIdError) {\n configError.collectionConfigurationErrorType = \"MetricDuplicateIds\";\n }\n\n if (error instanceof Error) {\n configError.message = error.message;\n configError.fullException = error.stack || \"\";\n }\n const data: KeyValuePairStringString[] = [];\n data.push({ key: \"MetricId\", value: derivedMetricInfo.id });\n data.push({ key: \"ETag\", value: this.etag });\n configError.data = data;\n this.errorTracker.addValidationError(configError);\n }\n });\n }\n\n private checkMetricFilterAndCreateProjection(\n derivedMetricInfoList: DerivedMetricInfo[],\n data: TelemetryData,\n ): void {\n derivedMetricInfoList.forEach((derivedMetricInfo: DerivedMetricInfo) => {\n if (this.filter.checkMetricFilters(derivedMetricInfo, data)) {\n try {\n this.derivedMetricProjection.calculateProjection(derivedMetricInfo, data);\n } catch (error) {\n const configError: CollectionConfigurationError = {\n collectionConfigurationErrorType: \"Unknown\",\n message: \"\",\n fullException: \"\",\n data: [],\n };\n if (error instanceof MetricFailureToCreateError) {\n configError.collectionConfigurationErrorType = \"MetricFailureToCreate\";\n\n if (error instanceof Error) {\n configError.message = error.message;\n configError.fullException = error.stack || \"\";\n }\n const errorData: KeyValuePairStringString[] = [];\n errorData.push({ key: \"MetricId\", value: derivedMetricInfo.id });\n errorData.push({ key: \"ETag\", value: this.etag });\n configError.data = errorData;\n this.errorTracker.addRunTimeError(configError);\n }\n }\n }\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"liveMetrics.js","sourceRoot":"","sources":["../../../../src/metrics/quickpulse/liveMetrics.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AAKzB,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAI1F,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAclE,OAAO,EACL,cAAc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,uBAAuB,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;gBAC5E,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,WAAW,GAAiC;wBAChD,gCAAgC,EAAE,SAAS;wBAC3C,OAAO,EAAE,EAAE;wBACX,aAAa,EAAE,EAAE;wBACjB,IAAI,EAAE,EAAE;qBACT,CAAC;oBACF,IAAI,KAAK,YAAY,0BAA0B,EAAE,CAAC;wBAChD,WAAW,CAAC,gCAAgC,GAAG,uBAAuB,CAAC;wBAEvE,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;4BAC3B,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;4BACpC,WAAW,CAAC,aAAa,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;wBAChD,CAAC;wBACD,MAAM,SAAS,GAA+B,EAAE,CAAC;wBACjD,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAAC,CAAC;wBACjE,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;wBAClD,WAAW,CAAC,IAAI,GAAG,SAAS,CAAC;wBAC7B,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;oBACjD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport os from \"node:os\";\nimport type {\n MeterProviderOptions,\n PeriodicExportingMetricReaderOptions,\n} from \"@opentelemetry/sdk-metrics\";\nimport { MeterProvider, PeriodicExportingMetricReader } from \"@opentelemetry/sdk-metrics\";\nimport type { SdkLogRecord } from \"@opentelemetry/sdk-logs\";\nimport type { InternalConfig } from \"../../shared/config.js\";\nimport type { Meter, ObservableGauge, ObservableResult } from \"@opentelemetry/api\";\nimport { SpanKind, SpanStatusCode, ValueType, context } from \"@opentelemetry/api\";\nimport type { ReadableSpan, TimedEvent } from \"@opentelemetry/sdk-trace-base\";\nimport { RandomIdGenerator } from \"@opentelemetry/sdk-trace-base\";\nimport type {\n DocumentIngress,\n Exception,\n MonitoringDataPoint,\n IsSubscribedOptionalParams,\n RemoteDependency,\n Request,\n Trace,\n KeyValuePairStringString,\n DerivedMetricInfo,\n FilterConjunctionGroupInfo,\n} from \"../../generated/index.js\";\nimport type { QuickpulseResponse } from \"./export/sender.js\";\nimport {\n getLogDocument,\n getSdkVersion,\n getSpanData,\n getLogData,\n getSpanDocument,\n getTransmissionTime,\n isRequestData,\n getSpanExceptionColumns,\n isExceptionData,\n isDependencyData,\n} from \"./utils.js\";\nimport { QuickpulseMetricExporter } from \"./export/exporter.js\";\nimport { QuickpulseSender } from \"./export/sender.js\";\nimport { ConnectionStringParser } from \"../../utils/connectionStringParser.js\";\nimport { DEFAULT_LIVEMETRICS_ENDPOINT } from \"../../types.js\";\nimport { getAuthenticationCredentialFromEnv } from \"./credentialUtils.js\";\nimport type {\n QuickpulseExporterOptions,\n RequestData,\n DependencyData,\n TraceData,\n ExceptionData,\n TelemetryData,\n} from \"./types.js\";\nimport { QuickPulseOpenTelemetryMetricNames } from \"./types.js\";\nimport { hrTimeToMilliseconds, suppressTracing } from \"@opentelemetry/core\";\nimport { getInstance } from \"../../utils/statsbeat.js\";\nimport type { CollectionConfigurationError } from \"../../generated/index.js\";\nimport { Filter } from \"./filtering/filter.js\";\nimport { Validator } from \"./filtering/validator.js\";\nimport { CollectionConfigurationErrorTracker } from \"./filtering/collectionConfigurationErrorTracker.js\";\nimport { Projection } from \"./filtering/projection.js\";\nimport {\n TelemetryTypeError,\n UnexpectedFilterCreateError,\n DuplicateMetricIdError,\n MetricFailureToCreateError,\n} from \"./filtering/quickpulseErrors.js\";\nimport { SEMATTRS_EXCEPTION_TYPE } from \"@opentelemetry/semantic-conventions\";\nimport { getPhysicalMemory, getProcessorTimeNormalized } from \"../utils.js\";\nimport { getCloudRole, getCloudRoleInstance } from \"../utils.js\";\nimport { Logger } from \"../../shared/logging/logger.js\";\n\nconst POST_INTERVAL = 1000;\nconst MAX_POST_WAIT_TIME = 20000;\nconst PING_INTERVAL = 5000;\nconst MAX_PING_WAIT_TIME = 60000;\nconst FALLBACK_INTERVAL = 60000;\n\n/**\n * Azure Monitor Live Metrics\n * @internal\n */\nexport class LiveMetrics {\n private config: InternalConfig;\n private meterProvider: MeterProvider | undefined;\n private metricReader: PeriodicExportingMetricReader | undefined;\n private meter: Meter | undefined;\n private requestDurationGauge: ObservableGauge | undefined;\n private dependencyDurationGauge: ObservableGauge | undefined;\n private requestRateGauge: ObservableGauge | undefined;\n private requestFailedRateGauge: ObservableGauge | undefined;\n private dependencyRateGauge: ObservableGauge | undefined;\n private dependencyFailedRateGauge: ObservableGauge | undefined;\n private processPhysicalBytesGauge: ObservableGauge | undefined;\n private percentProcessorTimeNormalizedGauge: ObservableGauge | undefined;\n private exceptionsRateGauge: ObservableGauge | undefined;\n\n private documents: DocumentIngress[] = [];\n private pingInterval: number;\n private postInterval: number;\n private quickpulseExporter: QuickpulseMetricExporter;\n private pingSender: QuickpulseSender;\n private isCollectingData: boolean;\n private isShutdown = false;\n private resetCountersOnActivation = true;\n private isDeactivating: boolean = false;\n private deactivatingPromise: Promise<void> | undefined;\n private lastSuccessTime: number = Date.now();\n private handle: NodeJS.Timeout | undefined;\n // Monitoring data point with common properties\n private baseMonitoringDataPoint: MonitoringDataPoint;\n private totalRequestCount = 0;\n private totalFailedRequestCount = 0;\n private totalDependencyCount = 0;\n private totalFailedDependencyCount = 0;\n private totalExceptionCount = 0;\n private requestDuration = 0;\n private dependencyDuration = 0;\n private lastRequestDuration: { count: number; duration: number; time: number } = {\n count: 0,\n duration: 0,\n time: 0,\n };\n private lastRequestRate: { count: number; time: number } = { count: 0, time: 0 };\n private lastFailedRequestRate: { count: number; time: number } = { count: 0, time: 0 };\n private lastDependencyDuration: { count: number; duration: number; time: number } = {\n count: 0,\n duration: 0,\n time: 0,\n };\n private lastDependencyRate: { count: number; time: number } = { count: 0, time: 0 };\n private lastFailedDependencyRate: { count: number; time: number } = { count: 0, time: 0 };\n private lastExceptionRate: { count: number; time: number } = { count: 0, time: 0 };\n private lastCpuUsage: NodeJS.CpuUsage;\n private lastHrTime: bigint;\n private statsbeatOptionsUpdated = false;\n private etag: string = \"\";\n private errorTracker: CollectionConfigurationErrorTracker =\n new CollectionConfigurationErrorTracker();\n // For tracking of duplicate metric ids in the same configuration.\n private seenMetricIds: Set<string> = new Set();\n private validDerivedMetrics: Map<string, DerivedMetricInfo[]> = new Map();\n private derivedMetricProjection: Projection = new Projection();\n private validator: Validator = new Validator();\n private filter: Filter = new Filter();\n // type: Map<telemetryType, Map<id, FilterConjunctionGroupInfo[]>>\n private validDocumentFilterConjuctionGroupInfos: Map<\n string,\n Map<string, FilterConjunctionGroupInfo[]>\n > = new Map();\n /**\n * Initializes a new instance of the StandardMetrics class.\n * @param config - Distro configuration.\n * @param options - Standard Metrics options.\n */\n constructor(config: InternalConfig) {\n this.config = config;\n const idGenerator = new RandomIdGenerator();\n const streamId = idGenerator.generateTraceId();\n const machineName = os.hostname();\n const instance = getCloudRoleInstance(this.config.resource);\n const roleName = getCloudRole(this.config.resource);\n const version = getSdkVersion();\n this.baseMonitoringDataPoint = {\n version: version,\n invariantVersion: 5, // 5 means we support live metrics filtering of metrics and documents\n instance: instance,\n roleName: roleName,\n machineName: machineName,\n streamId: streamId,\n performanceCollectionSupported: true,\n isWebApp: process.env[\"WEBSITE_SITE_NAME\"] ? true : false,\n };\n const parsedConnectionString = ConnectionStringParser.parse(\n this.config.azureMonitorExporterOptions.connectionString ||\n process.env[\"APPLICATIONINSIGHTS_CONNECTION_STRING\"],\n );\n const credential =\n this.config.azureMonitorExporterOptions.credential ?? getAuthenticationCredentialFromEnv();\n this.pingSender = new QuickpulseSender({\n endpointUrl: parsedConnectionString.liveendpoint || DEFAULT_LIVEMETRICS_ENDPOINT,\n instrumentationKey: parsedConnectionString.instrumentationkey || \"\",\n credential: credential,\n credentialScopes:\n parsedConnectionString.aadaudience ||\n this.config.azureMonitorExporterOptions.credentialScopes,\n });\n const exporterOptions: QuickpulseExporterOptions = {\n endpointUrl: parsedConnectionString.liveendpoint || DEFAULT_LIVEMETRICS_ENDPOINT,\n instrumentationKey: parsedConnectionString.instrumentationkey || \"\",\n credential: credential,\n credentialScopes:\n parsedConnectionString.aadaudience ||\n this.config.azureMonitorExporterOptions.credentialScopes,\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n postCallback: this.quickPulseDone.bind(this),\n getDocumentsFn: this.getDocuments.bind(this),\n getErrorsFn: this.getErrors.bind(this),\n getDerivedMetricValuesFn: this.getDerivedMetricValues.bind(this),\n baseMonitoringDataPoint: this.baseMonitoringDataPoint,\n };\n this.quickpulseExporter = new QuickpulseMetricExporter(exporterOptions);\n this.isCollectingData = false;\n this.pingInterval = PING_INTERVAL; // Default\n this.postInterval = POST_INTERVAL;\n this.schedulePing();\n this.lastCpuUsage = process.cpuUsage();\n this.lastHrTime = process.hrtime.bigint();\n }\n\n public async shutdown(): Promise<void> {\n this.isShutdown = true;\n clearTimeout(this.handle);\n this.isCollectingData = false;\n await this.deactivateMetrics();\n }\n\n private schedulePing(): void {\n clearTimeout(this.handle);\n if (!this.isShutdown && !this.isCollectingData) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.handle = setTimeout(this.goQuickpulse.bind(this), this.pingInterval);\n this.handle.unref();\n }\n }\n\n private async goQuickpulse(): Promise<void> {\n if (this.isShutdown) {\n return;\n }\n if (!this.isCollectingData) {\n // If not collecting, Ping\n try {\n const params: IsSubscribedOptionalParams = {\n transmissionTime: getTransmissionTime(),\n monitoringDataPoint: this.baseMonitoringDataPoint,\n configurationEtag: this.etag,\n };\n await context.with(suppressTracing(context.active()), async () => {\n const response = await this.pingSender.isSubscribed(params);\n await this.quickPulseDone(response);\n });\n } catch (error) {\n await this.quickPulseDone(undefined);\n }\n this.schedulePing();\n }\n if (this.isCollectingData) {\n this.activateMetrics({ collectionInterval: this.postInterval });\n }\n }\n\n private async quickPulseDone(response: QuickpulseResponse | undefined): Promise<void> {\n if (this.isShutdown) {\n return;\n }\n if (!response) {\n if (!this.isCollectingData) {\n if (Date.now() - this.lastSuccessTime >= MAX_PING_WAIT_TIME) {\n this.pingInterval = FALLBACK_INTERVAL;\n }\n } else {\n if (\n Date.now() - this.lastSuccessTime >= MAX_POST_WAIT_TIME &&\n this.postInterval !== FALLBACK_INTERVAL &&\n !this.isDeactivating\n ) {\n this.postInterval = FALLBACK_INTERVAL;\n await this.restartMetrics();\n }\n }\n } else {\n const wasBackingOff = this.postInterval !== POST_INTERVAL;\n this.postInterval = POST_INTERVAL;\n // Update using response if needed\n this.lastSuccessTime = Date.now();\n this.isCollectingData =\n response.xMsQpsSubscribed && response.xMsQpsSubscribed === \"true\" ? true : false;\n if (\n response.eTag !== undefined &&\n response.xMsQpsConfigurationEtag &&\n this.etag !== response.xMsQpsConfigurationEtag\n ) {\n this.updateConfiguration(response);\n }\n\n const endpointRedirect = response.xMsQpsServiceEndpointRedirectV2;\n if (endpointRedirect) {\n this.pingSender.handlePermanentRedirect(endpointRedirect);\n this.quickpulseExporter.getSender().handlePermanentRedirect(endpointRedirect);\n }\n const pollingInterval = response.xMsQpsServicePollingIntervalHint;\n if (pollingInterval) {\n this.pingInterval = Number(pollingInterval);\n } else {\n this.pingInterval = PING_INTERVAL;\n }\n\n if (!this.isCollectingData && (this.meterProvider || this.isDeactivating)) {\n this.etag = \"\";\n this.quickpulseExporter.setEtag(\"\");\n await this.restartMetrics(false);\n } else if (this.isCollectingData && wasBackingOff && !this.isDeactivating) {\n await this.restartMetrics();\n }\n }\n }\n\n private async restartMetrics(preserveConfiguration = true): Promise<void> {\n // A reader's interval is fixed at construction. Preserve collection state when\n // replacing it, and let the shutdown flush update the desired interval.\n try {\n await this.deactivateMetrics(preserveConfiguration);\n } catch (error) {\n Logger.getInstance().warn(\"Failed to restart Live Metrics collection\", error);\n }\n if (this.isCollectingData) {\n this.activateMetrics({ collectionInterval: this.postInterval });\n } else {\n this.schedulePing();\n }\n }\n\n // Activate live metrics collection\n public activateMetrics(options?: { collectionInterval: number }): void {\n if (this.meterProvider || this.isDeactivating || this.isShutdown) {\n return;\n }\n // Turn on live metrics active collection for statsbeat\n if (!this.statsbeatOptionsUpdated) {\n getInstance().setStatsbeatFeatures({}, { liveMetrics: true });\n this.statsbeatOptionsUpdated = true;\n }\n // Reader replacement must retain both totals and sampling baselines so\n // telemetry recorded during the final flush is collected exactly once.\n if (this.resetCountersOnActivation) {\n this.totalDependencyCount = 0;\n this.totalExceptionCount = 0;\n this.totalFailedDependencyCount = 0;\n this.totalFailedRequestCount = 0;\n this.totalRequestCount = 0;\n this.requestDuration = 0;\n this.dependencyDuration = 0;\n this.lastRequestDuration = { count: 0, duration: 0, time: 0 };\n this.lastRequestRate = { count: 0, time: 0 };\n this.lastFailedRequestRate = { count: 0, time: 0 };\n this.lastDependencyDuration = { count: 0, duration: 0, time: 0 };\n this.lastDependencyRate = { count: 0, time: 0 };\n this.lastFailedDependencyRate = { count: 0, time: 0 };\n this.lastExceptionRate = { count: 0, time: 0 };\n this.resetCountersOnActivation = false;\n }\n\n const metricReaderOptions: PeriodicExportingMetricReaderOptions = {\n exporter: this.quickpulseExporter,\n exportIntervalMillis: options?.collectionInterval,\n };\n this.metricReader = new PeriodicExportingMetricReader(metricReaderOptions);\n const meterProviderConfig: MeterProviderOptions = {\n resource: this.config.resource,\n readers: [this.metricReader],\n };\n this.meterProvider = new MeterProvider(meterProviderConfig);\n this.meter = this.meterProvider.getMeter(\"AzureMonitorLiveMetricsMeter\");\n this.requestDurationGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.REQUEST_DURATION,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.requestRateGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.REQUEST_RATE,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.requestFailedRateGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.REQUEST_FAILURE_RATE,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.dependencyDurationGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.DEPENDENCY_DURATION,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.dependencyRateGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.DEPENDENCY_RATE,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.dependencyFailedRateGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.DEPENDENCY_FAILURE_RATE,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n\n this.processPhysicalBytesGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.PHYSICAL_BYTES,\n {\n valueType: ValueType.INT,\n },\n );\n\n this.percentProcessorTimeNormalizedGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.PROCESSOR_TIME_NORMALIZED,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n this.exceptionsRateGauge = this.meter.createObservableGauge(\n QuickPulseOpenTelemetryMetricNames.EXCEPTION_RATE,\n {\n valueType: ValueType.DOUBLE,\n },\n );\n\n this.requestDurationGauge.addCallback(this.getRequestDuration.bind(this));\n this.requestRateGauge.addCallback(this.getRequestRate.bind(this));\n this.requestFailedRateGauge.addCallback(this.getRequestFailedRate.bind(this));\n this.dependencyDurationGauge.addCallback(this.getDependencyDuration.bind(this));\n this.dependencyRateGauge.addCallback(this.getDependencyRate.bind(this));\n this.dependencyFailedRateGauge.addCallback(this.getDependencyFailedRate.bind(this));\n this.exceptionsRateGauge.addCallback(this.getExceptionRate.bind(this));\n this.processPhysicalBytesGauge.addCallback(this.getPhysicalMemory.bind(this));\n this.percentProcessorTimeNormalizedGauge.addCallback(\n this.getProcessorTimeNormalized.bind(this),\n );\n }\n\n /**\n * Deactivate metric collection\n */\n public async deactivateMetrics(preserveConfiguration = false): Promise<void> {\n if (!preserveConfiguration) {\n this.resetCountersOnActivation = true;\n this.documents = [];\n this.validDocumentFilterConjuctionGroupInfos.clear();\n this.errorTracker.clearRunTimeErrors();\n this.errorTracker.clearValidationTimeErrors();\n this.validDerivedMetrics.clear();\n this.derivedMetricProjection.clearProjectionMaps();\n this.seenMetricIds.clear();\n }\n // Coalesce concurrent deactivations: callers (shutdown(), the\n // failure-fallback in quickPulseDone(), and the \"unsubscribed\" branch in\n // goQuickpulse()) can all race. Return the in-flight promise so every\n // caller awaits the same completion and the underlying meterProvider\n // shutdown only runs once.\n if (this.deactivatingPromise) {\n return this.deactivatingPromise;\n }\n this.isDeactivating = true;\n this.deactivatingPromise = (async () => {\n try {\n // Capture and clear the reference before awaiting shutdown so any\n // re-entrant calls triggered by the shutdown's final force-flush\n // export observe meterProvider as undefined and exit early.\n const provider = this.meterProvider;\n this.meterProvider = undefined;\n await provider?.shutdown();\n } finally {\n this.isDeactivating = false;\n this.deactivatingPromise = undefined;\n }\n })();\n return this.deactivatingPromise;\n }\n\n /**\n * Force flush Meter Provider.\n */\n public async flush(): Promise<void> {\n await this.meterProvider?.forceFlush();\n }\n\n /**\n *Get OpenTelemetry MeterProvider\n */\n public getMeterProvider(): MeterProvider | undefined {\n return this.meterProvider;\n }\n\n public getDocuments(): DocumentIngress[] {\n const result: DocumentIngress[] = this.documents;\n this.documents = [];\n return result;\n }\n\n public getErrors(): CollectionConfigurationError[] {\n const result = this.errorTracker.getErrors();\n this.errorTracker.clearRunTimeErrors();\n return result;\n }\n\n public getDerivedMetricValues(): Map<string, number> {\n return this.derivedMetricProjection.getMetricValues();\n }\n\n private addDocument(document: DocumentIngress): void {\n if (document) {\n // Limit risk of memory leak by limiting doc length to something manageable\n if (this.documents.length > 20) {\n this.documents.shift(); // Remove oldest document\n }\n this.documents.push(document);\n }\n }\n\n /**\n * Record Span metrics\n * @internal\n */\n public recordSpan(span: ReadableSpan): void {\n if (this.isCollectingData) {\n const columns: RequestData | DependencyData = getSpanData(span);\n let documentConfiguration: Map<string, FilterConjunctionGroupInfo[]>;\n let derivedMetricInfos: DerivedMetricInfo[];\n if (isRequestData(columns)) {\n documentConfiguration =\n this.validDocumentFilterConjuctionGroupInfos.get(\"Request\") ||\n new Map<string, FilterConjunctionGroupInfo[]>();\n derivedMetricInfos = this.validDerivedMetrics.get(\"Request\") || [];\n } else {\n documentConfiguration =\n this.validDocumentFilterConjuctionGroupInfos.get(\"Dependency\") ||\n new Map<string, FilterConjunctionGroupInfo[]>();\n derivedMetricInfos = this.validDerivedMetrics.get(\"Dependency\") || [];\n }\n this.applyDocumentFilters(documentConfiguration, columns);\n this.checkMetricFilterAndCreateProjection(derivedMetricInfos, columns);\n\n const durationMs = hrTimeToMilliseconds(span.duration);\n const success = span.status.code !== SpanStatusCode.ERROR;\n\n if (span.kind === SpanKind.SERVER || span.kind === SpanKind.CONSUMER) {\n this.totalRequestCount++;\n this.requestDuration += durationMs;\n if (!success) {\n this.totalFailedRequestCount++;\n }\n } else {\n this.totalDependencyCount++;\n this.dependencyDuration += durationMs;\n if (!success) {\n this.totalFailedDependencyCount++;\n }\n }\n if (span.events) {\n span.events.forEach((event: TimedEvent) => {\n event.attributes = event.attributes || {};\n if (event.name === \"exception\") {\n const exceptionColumns: ExceptionData = getSpanExceptionColumns(\n event.attributes,\n span.attributes,\n );\n documentConfiguration =\n this.validDocumentFilterConjuctionGroupInfos.get(\"Exception\") ||\n new Map<string, FilterConjunctionGroupInfo[]>();\n this.applyDocumentFilters(\n documentConfiguration,\n exceptionColumns,\n event.attributes[SEMATTRS_EXCEPTION_TYPE] as string,\n );\n derivedMetricInfos = this.validDerivedMetrics.get(\"Exception\") || [];\n this.checkMetricFilterAndCreateProjection(derivedMetricInfos, exceptionColumns);\n this.totalExceptionCount++;\n }\n });\n }\n }\n }\n\n /**\n * Record LogRecord metrics, add attribute so data is not aggregated again in ingestion\n * @internal\n */\n public recordLog(logRecord: SdkLogRecord): void {\n if (this.isCollectingData) {\n const columns: TraceData | ExceptionData = getLogData(logRecord);\n let derivedMetricInfos: DerivedMetricInfo[];\n let documentConfiguration: Map<string, FilterConjunctionGroupInfo[]>;\n if (isExceptionData(columns)) {\n documentConfiguration =\n this.validDocumentFilterConjuctionGroupInfos.get(\"Exception\") ||\n new Map<string, FilterConjunctionGroupInfo[]>();\n this.applyDocumentFilters(\n documentConfiguration,\n columns,\n logRecord.attributes[SEMATTRS_EXCEPTION_TYPE] as string,\n );\n derivedMetricInfos = this.validDerivedMetrics.get(\"Exception\") || [];\n this.totalExceptionCount++;\n } else {\n // trace\n documentConfiguration =\n this.validDocumentFilterConjuctionGroupInfos.get(\"Trace\") ||\n new Map<string, FilterConjunctionGroupInfo[]>();\n this.applyDocumentFilters(documentConfiguration, columns);\n derivedMetricInfos = this.validDerivedMetrics.get(\"Trace\") || [];\n }\n this.checkMetricFilterAndCreateProjection(derivedMetricInfos, columns);\n }\n }\n\n private getRequestDuration(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const requestInterval = this.totalRequestCount - this.lastRequestDuration.count || 0;\n const durationInterval = this.requestDuration - this.lastRequestDuration.duration || 0;\n const elapsedMs = currentTime - this.lastRequestDuration.time;\n if (elapsedMs > 0) {\n const averageExecutionTime = durationInterval / requestInterval || 0; // default to 0 in case no requests in this interval\n observableResult.observe(averageExecutionTime);\n }\n this.lastRequestDuration = {\n count: this.totalRequestCount,\n duration: this.requestDuration,\n time: currentTime,\n };\n }\n\n private getRequestRate(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const intervalRequests = this.totalRequestCount - this.lastRequestRate.count || 0;\n const elapsedMs = currentTime - this.lastRequestRate.time;\n if (elapsedMs > 0) {\n const elapsedSeconds = elapsedMs / 1000;\n const dataPerSec = intervalRequests / elapsedSeconds;\n observableResult.observe(dataPerSec);\n }\n this.lastRequestRate = {\n count: this.totalRequestCount,\n time: currentTime,\n };\n }\n\n private getRequestFailedRate(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const intervalRequests = this.totalFailedRequestCount - this.lastFailedRequestRate.count || 0;\n const elapsedMs = currentTime - this.lastFailedRequestRate.time;\n if (elapsedMs > 0) {\n const elapsedSeconds = elapsedMs / 1000;\n const dataPerSec = intervalRequests / elapsedSeconds;\n observableResult.observe(dataPerSec);\n }\n this.lastFailedRequestRate = {\n count: this.totalFailedRequestCount,\n time: currentTime,\n };\n }\n\n private getDependencyDuration(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const dependencyInterval = this.totalDependencyCount - this.lastDependencyDuration.count || 0;\n const durationInterval = this.dependencyDuration - this.lastDependencyDuration.duration || 0;\n const elapsedMs = currentTime - this.lastDependencyDuration.time;\n if (elapsedMs > 0) {\n const averageExecutionTime = durationInterval / dependencyInterval || 0; // default to 0 in case no dependencies in this interval\n observableResult.observe(averageExecutionTime);\n }\n this.lastDependencyDuration = {\n count: this.totalDependencyCount,\n duration: this.dependencyDuration,\n time: currentTime,\n };\n }\n\n private getDependencyRate(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const intervalData = this.totalDependencyCount - this.lastDependencyRate.count || 0;\n const elapsedMs = currentTime - this.lastDependencyRate.time;\n if (elapsedMs > 0) {\n const elapsedSeconds = elapsedMs / 1000;\n const dataPerSec = intervalData / elapsedSeconds;\n observableResult.observe(dataPerSec);\n }\n this.lastDependencyRate = {\n count: this.totalDependencyCount,\n time: currentTime,\n };\n }\n\n private getDependencyFailedRate(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const intervalData = this.totalFailedDependencyCount - this.lastFailedDependencyRate.count || 0;\n const elapsedMs = currentTime - this.lastFailedDependencyRate.time;\n if (elapsedMs > 0) {\n const elapsedSeconds = elapsedMs / 1000;\n const dataPerSec = intervalData / elapsedSeconds;\n observableResult.observe(dataPerSec);\n }\n this.lastFailedDependencyRate = {\n count: this.totalFailedDependencyCount,\n time: currentTime,\n };\n }\n\n private getExceptionRate(observableResult: ObservableResult): void {\n const currentTime = +new Date();\n const intervalData = this.totalExceptionCount - this.lastExceptionRate.count || 0;\n const elapsedMs = currentTime - this.lastExceptionRate.time;\n if (elapsedMs > 0) {\n const elapsedSeconds = elapsedMs / 1000;\n const dataPerSec = intervalData / elapsedSeconds;\n observableResult.observe(dataPerSec);\n }\n this.lastExceptionRate = {\n count: this.totalExceptionCount,\n time: currentTime,\n };\n }\n\n private getPhysicalMemory(observableResult: ObservableResult): void {\n const rss = getPhysicalMemory();\n observableResult.observe(rss);\n }\n\n private getProcessorTimeNormalized(observableResult: ObservableResult): void {\n if (process && process.hrtime) {\n const cpuUsagePercent = getProcessorTimeNormalized(this.lastHrTime, this.lastCpuUsage);\n observableResult.observe(cpuUsagePercent);\n this.lastHrTime = process.hrtime.bigint();\n this.lastCpuUsage = process.cpuUsage();\n } else {\n Logger.getInstance().debug(\"Getting Normalized Processor Time Failed. No process available.\");\n }\n }\n\n private updateConfiguration(response: QuickpulseResponse): void {\n this.etag = response.xMsQpsConfigurationEtag || \"\";\n this.quickpulseExporter.setEtag(this.etag);\n this.errorTracker.clearValidationTimeErrors();\n this.validDocumentFilterConjuctionGroupInfos.clear();\n this.validDerivedMetrics.clear();\n this.derivedMetricProjection.clearProjectionMaps();\n this.seenMetricIds.clear();\n\n this.parseDocumentFilterConfiguration(response);\n this.parseMetricFilterConfiguration(response);\n }\n\n private parseDocumentFilterConfiguration(response: QuickpulseResponse): void {\n if (!response?.documentStreams || typeof response.documentStreams.forEach !== \"function\") {\n return;\n }\n response.documentStreams.forEach((documentStreamInfo) => {\n documentStreamInfo.documentFilterGroups.forEach((documentFilterGroupInfo) => {\n try {\n this.validator.validateTelemetryType(documentFilterGroupInfo.telemetryType);\n this.validator.validateDocumentFilters(documentFilterGroupInfo);\n this.filter.renameExceptionFieldNamesForFiltering(documentFilterGroupInfo.filters);\n\n if (\n !this.validDocumentFilterConjuctionGroupInfos.has(documentFilterGroupInfo.telemetryType)\n ) {\n this.validDocumentFilterConjuctionGroupInfos.set(\n documentFilterGroupInfo.telemetryType,\n new Map<string, FilterConjunctionGroupInfo[]>(),\n );\n }\n\n const innerMap = this.validDocumentFilterConjuctionGroupInfos.get(\n documentFilterGroupInfo.telemetryType,\n );\n if (!innerMap?.has(documentStreamInfo.id)) {\n innerMap?.set(documentStreamInfo.id, [documentFilterGroupInfo.filters]);\n } else {\n innerMap.get(documentStreamInfo.id)?.push(documentFilterGroupInfo.filters);\n }\n } catch (error) {\n const configError: CollectionConfigurationError = {\n collectionConfigurationErrorType: \"Unknown\",\n message: \"\",\n fullException: \"\",\n data: [],\n };\n if (error instanceof TelemetryTypeError) {\n configError.collectionConfigurationErrorType =\n \"CollectionConfigurationFailureToCreateUnexpected\";\n } else if (error instanceof UnexpectedFilterCreateError) {\n configError.collectionConfigurationErrorType =\n \"DocumentStreamFailureToCreateFilterUnexpected\";\n }\n\n if (error instanceof Error) {\n configError.message = error.message;\n configError.fullException = error.stack || \"\";\n }\n const data: KeyValuePairStringString[] = [];\n data.push({ key: \"DocumentStreamInfoId\", value: documentStreamInfo.id });\n data.push({ key: \"ETag\", value: this.etag });\n configError.data = data;\n this.errorTracker.addValidationError(configError);\n }\n });\n });\n }\n\n private applyDocumentFilters(\n documentConfiguration: Map<string, FilterConjunctionGroupInfo[]>,\n data: TelemetryData,\n exceptionType?: string,\n ): void {\n const streamIds: Set<string> = new Set<string>();\n documentConfiguration.forEach((filterConjunctionGroupInfoList, streamId) => {\n filterConjunctionGroupInfoList.forEach((filterConjunctionGroupInfo) => {\n // by going though each filterConjuctionGroupInfo, we are implicitly -OR-ing\n // different filterConjunctionGroupInfo within documentStreamInfo. If there are multiple\n // documentStreamInfos, this logic will -OR- the filtering results of each documentStreamInfo.\n if (this.filter.checkFilterConjunctionGroup(filterConjunctionGroupInfo, data)) {\n streamIds.add(streamId);\n }\n });\n });\n\n // Emit a document when a telemetry data matches a particular filtering configuration,\n // or when filtering configuration is empty.\n if (streamIds.size > 0 || documentConfiguration.size === 0) {\n let document: Request | RemoteDependency | Trace | Exception;\n if (isRequestData(data) || isDependencyData(data)) {\n document = getSpanDocument(data);\n } else if (isExceptionData(data) && exceptionType) {\n document = getLogDocument(data, exceptionType);\n } else {\n document = getLogDocument(data);\n }\n document.documentStreamIds = [...streamIds];\n this.addDocument(document);\n }\n }\n\n private parseMetricFilterConfiguration(response: QuickpulseResponse): void {\n if (!response.metrics || typeof response.metrics.forEach !== \"function\") {\n return;\n }\n response.metrics.forEach((derivedMetricInfo) => {\n try {\n if (!this.seenMetricIds.has(derivedMetricInfo.id)) {\n this.seenMetricIds.add(derivedMetricInfo.id);\n this.validator.validateTelemetryType(derivedMetricInfo.telemetryType);\n this.validator.checkCustomMetricProjection(derivedMetricInfo);\n this.validator.validateMetricFilters(derivedMetricInfo);\n derivedMetricInfo.filterGroups.forEach((filterConjunctionGroupInfo) => {\n this.filter.renameExceptionFieldNamesForFiltering(filterConjunctionGroupInfo);\n });\n\n if (this.validDerivedMetrics.has(derivedMetricInfo.telemetryType)) {\n this.validDerivedMetrics.get(derivedMetricInfo.telemetryType)?.push(derivedMetricInfo);\n } else {\n this.validDerivedMetrics.set(derivedMetricInfo.telemetryType, [derivedMetricInfo]);\n }\n } else {\n throw new DuplicateMetricIdError(`Duplicate Metric Id: ${derivedMetricInfo.id}`);\n }\n this.derivedMetricProjection.initDerivedMetricProjection(derivedMetricInfo);\n } catch (error) {\n const configError: CollectionConfigurationError = {\n collectionConfigurationErrorType: \"Unknown\",\n message: \"\",\n fullException: \"\",\n data: [],\n };\n if (error instanceof TelemetryTypeError) {\n configError.collectionConfigurationErrorType = \"MetricTelemetryTypeUnsupported\";\n } else if (error instanceof UnexpectedFilterCreateError) {\n configError.collectionConfigurationErrorType = \"MetricFailureToCreateFilterUnexpected\";\n } else if (error instanceof DuplicateMetricIdError) {\n configError.collectionConfigurationErrorType = \"MetricDuplicateIds\";\n }\n\n if (error instanceof Error) {\n configError.message = error.message;\n configError.fullException = error.stack || \"\";\n }\n const data: KeyValuePairStringString[] = [];\n data.push({ key: \"MetricId\", value: derivedMetricInfo.id });\n data.push({ key: \"ETag\", value: this.etag });\n configError.data = data;\n this.errorTracker.addValidationError(configError);\n }\n });\n }\n\n private checkMetricFilterAndCreateProjection(\n derivedMetricInfoList: DerivedMetricInfo[],\n data: TelemetryData,\n ): void {\n derivedMetricInfoList.forEach((derivedMetricInfo: DerivedMetricInfo) => {\n if (this.filter.checkMetricFilters(derivedMetricInfo, data)) {\n try {\n this.derivedMetricProjection.calculateProjection(derivedMetricInfo, data);\n } catch (error) {\n const configError: CollectionConfigurationError = {\n collectionConfigurationErrorType: \"Unknown\",\n message: \"\",\n fullException: \"\",\n data: [],\n };\n if (error instanceof MetricFailureToCreateError) {\n configError.collectionConfigurationErrorType = \"MetricFailureToCreate\";\n\n if (error instanceof Error) {\n configError.message = error.message;\n configError.fullException = error.stack || \"\";\n }\n const errorData: KeyValuePairStringString[] = [];\n errorData.push({ key: \"MetricId\", value: derivedMetricInfo.id });\n errorData.push({ key: \"ETag\", value: this.etag });\n configError.data = errorData;\n this.errorTracker.addRunTimeError(configError);\n }\n }\n }\n });\n }\n}\n"]}
|
package/dist/esm/package.json
CHANGED
|
@@ -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,MAAM,o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AErB,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":"
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAWnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAMtE;;GAEG;AACH,qBAAa,YAAY;IAkBrB,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IAjBxC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,mBAAmB,CAA4B;IACvD,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;OAIG;gBAED,MAAM,EAAE,cAAc,EACtB,aAAa,EAAE,aAAa,EACX,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,YAAA;IAsB/D,UAAU,IAAI,OAAO;IAIrB,qBAAqB,IAAI,kBAAkB;IAI3C,4BAA4B,IAAI,yBAAyB;IAIzD,mBAAmB,IAAI,eAAe,EAAE;IAI/C;;OAEG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtC;;OAEG;IACH,OAAO,CAAC,2BAA2B;CAmFpC"}
|
|
@@ -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 {
|
|
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 = [];
|
|
@@ -94,49 +96,25 @@ export class TraceHandler {
|
|
|
94
96
|
return result;
|
|
95
97
|
};
|
|
96
98
|
httpinstrumentationOptions.ignoreOutgoingRequestHook = mergedIgnoreOutgoingRequestHook;
|
|
97
|
-
this._instrumentations.push(
|
|
99
|
+
this._instrumentations.push(configureInstrumentation(this.instrumentationCache, "http", httpinstrumentationOptions, (options) => new HttpInstrumentation(options)));
|
|
98
100
|
}
|
|
99
101
|
if (this._config.instrumentationOptions.azureSdk?.enabled) {
|
|
100
|
-
const azureSdkInstrumentation =
|
|
102
|
+
const azureSdkInstrumentation = configureInstrumentation(this.instrumentationCache, "azureSdk", this._config.instrumentationOptions.azureSdk, (options) => new AzureSdkInstrumentation(options));
|
|
101
103
|
this._instrumentations.push(azureSdkInstrumentation);
|
|
102
|
-
|
|
104
|
+
ensureAzureSdkTracingBridge(azureSdkInstrumentation);
|
|
103
105
|
}
|
|
104
106
|
if (this._config.instrumentationOptions.mongoDb?.enabled) {
|
|
105
|
-
this._instrumentations.push(
|
|
107
|
+
this._instrumentations.push(configureInstrumentation(this.instrumentationCache, "mongoDb", this._config.instrumentationOptions.mongoDb, (options) => new MongoDBInstrumentation(options)));
|
|
106
108
|
}
|
|
107
109
|
if (this._config.instrumentationOptions.mySql?.enabled) {
|
|
108
|
-
this._instrumentations.push(
|
|
110
|
+
this._instrumentations.push(configureInstrumentation(this.instrumentationCache, "mySql", this._config.instrumentationOptions.mySql, (options) => new MySQLInstrumentation(options)));
|
|
109
111
|
}
|
|
110
112
|
if (this._config.instrumentationOptions.postgreSql?.enabled) {
|
|
111
|
-
this._instrumentations.push(
|
|
113
|
+
this._instrumentations.push(configureInstrumentation(this.instrumentationCache, "postgreSql", this._config.instrumentationOptions.postgreSql, (options) => new PgInstrumentation(options)));
|
|
112
114
|
}
|
|
113
115
|
if (this._config.instrumentationOptions.redis?.enabled ||
|
|
114
116
|
this._config.instrumentationOptions.redis4?.enabled) {
|
|
115
|
-
this._instrumentations.push(
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Wire the Azure SDK instrumenter into `@azure/core-tracing` directly.
|
|
120
|
-
*
|
|
121
|
-
* The Azure SDK instrumentation registers its instrumenter through an OpenTelemetry
|
|
122
|
-
* module-patch hook that only fires via `require`/`import`-in-the-middle. In ESM hosts
|
|
123
|
-
* where the OpenTelemetry loader cannot be registered up front (for example, Azure
|
|
124
|
-
* Functions, which controls the Node.js start command), that hook never runs, so Azure
|
|
125
|
-
* SDK dependency spans are missing. Because `@azure/core-tracing` resolves its
|
|
126
|
-
* instrumenter lazily at span-creation time from shared module-local state, applying
|
|
127
|
-
* the same patch directly here enables Azure SDK tracing regardless of module system.
|
|
128
|
-
*/
|
|
129
|
-
_wireAzureSdkInstrumenter(instrumentation) {
|
|
130
|
-
try {
|
|
131
|
-
const moduleDefinitions = instrumentation.getModuleDefinitions?.() ?? [];
|
|
132
|
-
for (const moduleDefinition of moduleDefinitions) {
|
|
133
|
-
if (moduleDefinition.name === "@azure/core-tracing" && moduleDefinition.patch) {
|
|
134
|
-
moduleDefinition.patch(coreTracing);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
catch (error) {
|
|
139
|
-
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)));
|
|
140
118
|
}
|
|
141
119
|
}
|
|
142
120
|
}
|
|
@@ -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,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,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;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAKtD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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;IAED;;;;;;;;;;OAUG;IACK,yBAAyB,CAAC,eAAgC;QAChE,IAAI,CAAC;YACH,MAAM,iBAAiB,GAEnB,eAGD,CAAC,oBAAoB,EAAE,EAAE,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 { Sampler } from \"@opentelemetry/sdk-trace-base\";\nimport { BatchSpanProcessor } from \"@opentelemetry/sdk-trace-base\";\nimport type {\n HttpInstrumentationConfig,\n IgnoreOutgoingRequestFunction,\n} from \"@opentelemetry/instrumentation-http\";\nimport { HttpInstrumentation } from \"@opentelemetry/instrumentation-http\";\nimport { MongoDBInstrumentation } from \"@opentelemetry/instrumentation-mongodb\";\nimport { MySQLInstrumentation } from \"@opentelemetry/instrumentation-mysql\";\nimport { PgInstrumentation } from \"@opentelemetry/instrumentation-pg\";\nimport { RedisInstrumentation } from \"@opentelemetry/instrumentation-redis\";\n\nimport type { InternalConfig } from \"../shared/config.js\";\nimport type { MetricHandler } from \"../metrics/handler.js\";\nimport { ignoreOutgoingRequestHook } from \"../utils/common.js\";\nimport { AzureMonitorSpanProcessor } from \"./spanProcessor.js\";\nimport { AzureFunctionsHook } from \"./azureFnHook.js\";\nimport type {\n Instrumentation,\n InstrumentationModuleDefinition,\n} from \"@opentelemetry/instrumentation\";\nimport { ApplicationInsightsSampler } from \"./sampler.js\";\nimport { Logger } from \"../shared/logging/index.js\";\n\n/**\n * Azure Monitor OpenTelemetry Trace Handler\n */\nexport class TraceHandler {\n private _batchSpanProcessor: BatchSpanProcessor;\n private _azureSpanProcessor: AzureMonitorSpanProcessor;\n private _azureExporter: AzureMonitorTraceExporter;\n private _instrumentations: Instrumentation[];\n private _config: InternalConfig;\n private _metricHandler: MetricHandler;\n private _azureFunctionsHook: AzureFunctionsHook;\n private _sampler: Sampler;\n\n /**\n * Initializes a new instance of the TraceHandler class.\n * @param _config - Configuration.\n * @param _metricHandler - MetricHandler.\n */\n constructor(config: InternalConfig, metricHandler: MetricHandler) {\n this._config = config;\n this._metricHandler = metricHandler;\n this._instrumentations = [];\n // Check sampler precedence\n if (this._config.sampler) {\n this._sampler = this._config.sampler;\n } else if (this._config.tracesPerSecond && this._config.tracesPerSecond > 0) {\n // If tracesPerSecond is set to a positive number, use RateLimitedSampler\n this._sampler = new RateLimitedSampler(this._config.tracesPerSecond);\n } else {\n // Otherwise, use PercentageSampler with samplingRatio\n this._sampler = new ApplicationInsightsSampler(this._config.samplingRatio);\n }\n this._azureExporter = new AzureMonitorTraceExporter(this._config.azureMonitorExporterOptions);\n this._batchSpanProcessor = new BatchSpanProcessor(this._azureExporter);\n this._azureSpanProcessor = new AzureMonitorSpanProcessor(this._metricHandler);\n this._azureFunctionsHook = new AzureFunctionsHook();\n this._initializeInstrumentations();\n }\n\n public getSampler(): Sampler {\n return this._sampler;\n }\n\n public getBatchSpanProcessor(): BatchSpanProcessor {\n return this._batchSpanProcessor;\n }\n\n public getAzureMonitorSpanProcessor(): AzureMonitorSpanProcessor {\n return this._azureSpanProcessor;\n }\n\n public getInstrumentations(): Instrumentation[] {\n return this._instrumentations;\n }\n\n /**\n * Shutdown handler\n */\n public async shutdown(): Promise<void> {\n this._azureFunctionsHook.shutdown();\n await this._batchSpanProcessor.shutdown();\n await this._azureSpanProcessor.shutdown();\n await this._azureExporter.shutdown();\n }\n\n /**\n * Start auto collection of telemetry\n */\n private _initializeInstrumentations(): void {\n if (this._config.instrumentationOptions.http?.enabled) {\n const httpinstrumentationOptions = this._config.instrumentationOptions\n .http as HttpInstrumentationConfig;\n const providedIgnoreOutgoingRequestHook =\n httpinstrumentationOptions.ignoreOutgoingRequestHook;\n const mergedIgnoreOutgoingRequestHook: IgnoreOutgoingRequestFunction = (\n request: RequestOptions,\n ) => {\n const result = ignoreOutgoingRequestHook(request);\n if (!result) {\n // Not internal call\n if (providedIgnoreOutgoingRequestHook) {\n // Provided hook in config\n return providedIgnoreOutgoingRequestHook(request);\n }\n }\n return result;\n };\n httpinstrumentationOptions.ignoreOutgoingRequestHook = mergedIgnoreOutgoingRequestHook;\n this._instrumentations.push(\n new HttpInstrumentation(this._config.instrumentationOptions.http),\n );\n }\n if (this._config.instrumentationOptions.azureSdk?.enabled) {\n const azureSdkInstrumentation = createAzureSdkInstrumentation(\n this._config.instrumentationOptions.azureSdk,\n );\n this._instrumentations.push(azureSdkInstrumentation);\n this._wireAzureSdkInstrumenter(azureSdkInstrumentation);\n }\n if (this._config.instrumentationOptions.mongoDb?.enabled) {\n this._instrumentations.push(\n new MongoDBInstrumentation(this._config.instrumentationOptions.mongoDb),\n );\n }\n if (this._config.instrumentationOptions.mySql?.enabled) {\n this._instrumentations.push(\n new MySQLInstrumentation(this._config.instrumentationOptions.mySql),\n );\n }\n if (this._config.instrumentationOptions.postgreSql?.enabled) {\n this._instrumentations.push(\n new PgInstrumentation(this._config.instrumentationOptions.postgreSql),\n );\n }\n if (\n this._config.instrumentationOptions.redis?.enabled ||\n this._config.instrumentationOptions.redis4?.enabled\n ) {\n this._instrumentations.push(\n new RedisInstrumentation(this._config.instrumentationOptions.redis),\n );\n }\n }\n\n /**\n * Wire the Azure SDK instrumenter into `@azure/core-tracing` directly.\n *\n * The Azure SDK instrumentation registers its instrumenter through an OpenTelemetry\n * module-patch hook that only fires via `require`/`import`-in-the-middle. In ESM hosts\n * where the OpenTelemetry loader cannot be registered up front (for example, Azure\n * Functions, which controls the Node.js start command), that hook never runs, so Azure\n * SDK dependency spans are missing. Because `@azure/core-tracing` resolves its\n * instrumenter lazily at span-creation time from shared module-local state, applying\n * the same patch directly here enables Azure SDK tracing regardless of module system.\n */\n private _wireAzureSdkInstrumenter(instrumentation: Instrumentation): void {\n try {\n const moduleDefinitions =\n (\n instrumentation as Instrumentation & {\n getModuleDefinitions?: () => InstrumentationModuleDefinition[];\n }\n ).getModuleDefinitions?.() ?? [];\n for (const moduleDefinition of moduleDefinitions) {\n if (moduleDefinition.name === \"@azure/core-tracing\" && moduleDefinition.patch) {\n moduleDefinition.patch(coreTracing);\n }\n }\n } catch (error) {\n Logger.getInstance().warn(\"Failed to enable Azure SDK tracing for ESM applications\", error);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/traces/handler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,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;A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":["// 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"]}
|