@azure/monitor-opentelemetry 1.18.2 → 1.20.0
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/README.md +12 -1
- package/dist/commonjs/browserSdkLoader/browserSdkLoaderHelper.d.ts.map +1 -1
- package/dist/commonjs/browserSdkLoader/browserSdkLoaderHelper.js +1 -2
- package/dist/commonjs/browserSdkLoader/browserSdkLoaderHelper.js.map +1 -1
- package/dist/commonjs/index.d.ts +2 -2
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +19 -15
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/logs/batchLogRecordProcessor.js +1 -1
- package/dist/commonjs/logs/batchLogRecordProcessor.js.map +1 -1
- package/dist/commonjs/logs/handler.d.ts +3 -0
- package/dist/commonjs/logs/handler.d.ts.map +1 -1
- package/dist/commonjs/logs/handler.js +23 -2
- package/dist/commonjs/logs/handler.js.map +1 -1
- package/dist/commonjs/metrics/performanceCounters.d.ts +3 -0
- package/dist/commonjs/metrics/performanceCounters.d.ts.map +1 -1
- package/dist/commonjs/metrics/performanceCounters.js +26 -26
- package/dist/commonjs/metrics/performanceCounters.js.map +1 -1
- package/dist/commonjs/metrics/quickpulse/credentialUtils.d.ts +16 -0
- package/dist/commonjs/metrics/quickpulse/credentialUtils.d.ts.map +1 -0
- package/dist/commonjs/metrics/quickpulse/credentialUtils.js +48 -0
- package/dist/commonjs/metrics/quickpulse/credentialUtils.js.map +1 -0
- package/dist/commonjs/metrics/quickpulse/export/sender.d.ts.map +1 -1
- package/dist/commonjs/metrics/quickpulse/export/sender.js +8 -7
- package/dist/commonjs/metrics/quickpulse/export/sender.js.map +1 -1
- package/dist/commonjs/metrics/quickpulse/liveMetrics.d.ts.map +1 -1
- package/dist/commonjs/metrics/quickpulse/liveMetrics.js +4 -2
- package/dist/commonjs/metrics/quickpulse/liveMetrics.js.map +1 -1
- package/dist/commonjs/package.json +6 -1
- package/dist/commonjs/shared/config.d.ts +7 -0
- package/dist/commonjs/shared/config.d.ts.map +1 -1
- package/dist/commonjs/shared/config.js +28 -6
- package/dist/commonjs/shared/config.js.map +1 -1
- package/dist/commonjs/shared/logging/diagFileConsoleLogger.d.ts +1 -0
- package/dist/commonjs/shared/logging/diagFileConsoleLogger.d.ts.map +1 -1
- package/dist/commonjs/shared/logging/diagFileConsoleLogger.js +13 -12
- package/dist/commonjs/shared/logging/diagFileConsoleLogger.js.map +1 -1
- package/dist/commonjs/traces/handler.d.ts.map +1 -1
- package/dist/commonjs/traces/handler.js +1 -7
- package/dist/commonjs/traces/handler.js.map +1 -1
- package/dist/commonjs/traces/sampler.js +1 -1
- package/dist/commonjs/traces/sampler.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/types.d.ts +20 -1
- package/dist/commonjs/types.d.ts.map +1 -1
- package/dist/commonjs/types.js +47 -3
- package/dist/commonjs/types.js.map +1 -1
- package/dist/commonjs/utils/common.d.ts +34 -0
- package/dist/commonjs/utils/common.d.ts.map +1 -1
- package/dist/commonjs/utils/common.js +63 -0
- package/dist/commonjs/utils/common.js.map +1 -1
- package/dist/commonjs/utils/logUtils.d.ts +5 -0
- package/dist/commonjs/utils/logUtils.d.ts.map +1 -1
- package/dist/commonjs/utils/logUtils.js +8 -0
- package/dist/commonjs/utils/logUtils.js.map +1 -1
- package/dist/commonjs/utils/opentelemetryInstrumentationPatcher.d.ts.map +1 -1
- package/dist/commonjs/utils/opentelemetryInstrumentationPatcher.js +3 -2
- package/dist/commonjs/utils/opentelemetryInstrumentationPatcher.js.map +1 -1
- package/dist/commonjs/utils/statsbeat.d.ts.map +1 -1
- package/dist/commonjs/utils/statsbeat.js +38 -31
- package/dist/commonjs/utils/statsbeat.js.map +1 -1
- package/dist/esm/browserSdkLoader/browserSdkLoaderHelper.d.ts.map +1 -1
- package/dist/esm/browserSdkLoader/browserSdkLoaderHelper.js +1 -2
- package/dist/esm/browserSdkLoader/browserSdkLoaderHelper.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +19 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logs/batchLogRecordProcessor.js +1 -1
- package/dist/esm/logs/batchLogRecordProcessor.js.map +1 -1
- package/dist/esm/logs/handler.d.ts +3 -0
- package/dist/esm/logs/handler.d.ts.map +1 -1
- package/dist/esm/logs/handler.js +24 -3
- package/dist/esm/logs/handler.js.map +1 -1
- package/dist/esm/metrics/performanceCounters.d.ts +3 -0
- package/dist/esm/metrics/performanceCounters.d.ts.map +1 -1
- package/dist/esm/metrics/performanceCounters.js +26 -26
- package/dist/esm/metrics/performanceCounters.js.map +1 -1
- package/dist/esm/metrics/quickpulse/credentialUtils.d.ts +16 -0
- package/dist/esm/metrics/quickpulse/credentialUtils.d.ts.map +1 -0
- package/dist/esm/metrics/quickpulse/credentialUtils.js +45 -0
- package/dist/esm/metrics/quickpulse/credentialUtils.js.map +1 -0
- package/dist/esm/metrics/quickpulse/export/sender.d.ts.map +1 -1
- package/dist/esm/metrics/quickpulse/export/sender.js +8 -7
- package/dist/esm/metrics/quickpulse/export/sender.js.map +1 -1
- package/dist/esm/metrics/quickpulse/liveMetrics.d.ts.map +1 -1
- package/dist/esm/metrics/quickpulse/liveMetrics.js +4 -2
- package/dist/esm/metrics/quickpulse/liveMetrics.js.map +1 -1
- package/dist/esm/package.json +6 -1
- package/dist/esm/shared/config.d.ts +7 -0
- package/dist/esm/shared/config.d.ts.map +1 -1
- package/dist/esm/shared/config.js +29 -7
- package/dist/esm/shared/config.js.map +1 -1
- package/dist/esm/shared/logging/diagFileConsoleLogger.d.ts +1 -0
- package/dist/esm/shared/logging/diagFileConsoleLogger.d.ts.map +1 -1
- package/dist/esm/shared/logging/diagFileConsoleLogger.js +13 -12
- package/dist/esm/shared/logging/diagFileConsoleLogger.js.map +1 -1
- package/dist/esm/traces/handler.d.ts.map +1 -1
- package/dist/esm/traces/handler.js +1 -7
- package/dist/esm/traces/handler.js.map +1 -1
- package/dist/esm/traces/sampler.js +1 -1
- package/dist/esm/traces/sampler.js.map +1 -1
- package/dist/esm/types.d.ts +20 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +46 -2
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/common.d.ts +34 -0
- package/dist/esm/utils/common.d.ts.map +1 -1
- package/dist/esm/utils/common.js +59 -0
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/esm/utils/logUtils.d.ts +5 -0
- package/dist/esm/utils/logUtils.d.ts.map +1 -1
- package/dist/esm/utils/logUtils.js +7 -0
- package/dist/esm/utils/logUtils.js.map +1 -1
- package/dist/esm/utils/opentelemetryInstrumentationPatcher.d.ts.map +1 -1
- package/dist/esm/utils/opentelemetryInstrumentationPatcher.js +3 -2
- package/dist/esm/utils/opentelemetryInstrumentationPatcher.js.map +1 -1
- package/dist/esm/utils/statsbeat.d.ts.map +1 -1
- package/dist/esm/utils/statsbeat.js +39 -32
- package/dist/esm/utils/statsbeat.js.map +1 -1
- package/package.json +31 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sender.js","sourceRoot":"","sources":["../../../../../src/metrics/quickpulse/export/sender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAO1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,2BAA2B,GAAG,oCAAoC,CAAC;AAiBzE;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACnB,gBAAgB,CAAmB;IACnC,kBAAkB,CAAS;IAC3B,WAAW,CAAS;IACpB,U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B,CAAC;YACrC,IAAI,CAAC,IAAI,CAAC,mCAAmC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;QACpE,CAAC;QACD,OAAO;IACT,CAAC;IAED;;;;;;;;;OASG;IACH,uBAAuB,CAAC,QAA4B;QAClD,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,MAAe,CAAC;YACpB,IAAI,CAAC;gBACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACjC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO;YACT,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBACjB,OAAO;YACT,CAAC;YAED,IAAI,WAAW,GAAG,EAAE,CAAC;YACrB,IAAI,CAAC;gBACH,WAAW,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;YACnD,CAAC;YAAC,MAAM,CAAC;gBACP,WAAW,GAAG,EAAE,CAAC;YACnB,CAAC;YAED,IAAI,CAAC,sBAAsB,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtD,IAAI,CAAC,KAAK,CACR,0DAA0D,MAAM,CAAC,IAAI,oGAAoG,CAC1K,CAAC;gBACF,OAAO;YACT,CAAC;YAED,IAAI,CAAC,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC;YAC5C,kEAAkE;YAClE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,sBAAsB,CAAC;gBAClD,QAAQ,EAAE,IAAI,CAAC,WAAW;gBAC1B,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE;aAC/C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport url from \"url\";\nimport type { RestError } from \"@azure/core-rest-pipeline\";\nimport { redirectPolicyName } from \"@azure/core-rest-pipeline\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { diag } from \"@opentelemetry/api\";\nimport type {\n IsSubscribedOptionalParams,\n PublishOptionalParams,\n QuickpulseClientOptionalParams,\n CollectionConfigurationInfo,\n} from \"../../../generated/index.js\";\nimport { QuickpulseClient } from \"../../../generated/index.js\";\nimport { isSameRegisteredDomain } from \"../redirectUtils.js\";\n\nconst applicationInsightsResource = \"https://monitor.azure.com/.default\";\n\n/**\n * Response type that includes the body and response headers from the Live Metrics service.\n * @internal\n */\nexport interface QuickpulseResponse extends CollectionConfigurationInfo {\n /** Whether the instrumentation key is subscribed. */\n xMsQpsSubscribed?: string;\n /** Configuration ETag. */\n xMsQpsConfigurationEtag?: string;\n /** Polling interval hint (only for ping). */\n xMsQpsServicePollingIntervalHint?: string;\n /** Endpoint redirect (only for ping). */\n xMsQpsServiceEndpointRedirectV2?: string;\n}\n\n/**\n * Quickpulse sender class\n * @internal\n */\nexport class QuickpulseSender {\n private quickpulseClient: QuickpulseClient;\n private instrumentationKey: string;\n private endpointUrl: string;\n private credential: TokenCredential;\n private credentialScopes: string[];\n\n constructor(options: {\n endpointUrl: string;\n instrumentationKey: string;\n credential?: TokenCredential;\n credentialScopes?: string | string[];\n }) {\n // Build endpoint using provided configuration or default values\n this.endpointUrl = options.endpointUrl;\n const clientOptions: QuickpulseClientOptionalParams = {\n endpoint: this.endpointUrl,\n };\n\n this.instrumentationKey = options.instrumentationKey;\n this.credential = options.credential as TokenCredential;\n\n // Configure credential scopes\n if (options.credentialScopes) {\n this.credentialScopes = Array.isArray(options.credentialScopes)\n ? options.credentialScopes\n : [options.credentialScopes];\n } else {\n this.credentialScopes = [applicationInsightsResource];\n }\n if (options.credential) {\n clientOptions.credentials = { scopes: this.credentialScopes };\n }\n\n this.quickpulseClient = this.createQuickpulseClient(clientOptions);\n }\n\n private createQuickpulseClient(clientOptions: QuickpulseClientOptionalParams): QuickpulseClient {\n const client = new QuickpulseClient(this.credential, clientOptions);\n // Handle redirects in HTTP Sender\n client.pipeline.removePolicy({ name: redirectPolicyName });\n return client;\n }\n\n /**\n * isSubscribed Quickpulse service\n * @internal\n */\n async isSubscribed(\n optionalParams: IsSubscribedOptionalParams,\n ): Promise<QuickpulseResponse | undefined> {\n try {\n let responseHeaders: Record<string, string> = {};\n const body = await this.quickpulseClient.isSubscribed(this.instrumentationKey, {\n ...optionalParams,\n onResponse: (rawResponse) => {\n responseHeaders = rawResponse.headers.toJSON();\n },\n });\n return {\n ...body,\n xMsQpsSubscribed: responseHeaders[\"x-ms-qps-subscribed\"],\n xMsQpsConfigurationEtag: responseHeaders[\"x-ms-qps-configuration-etag\"],\n xMsQpsServicePollingIntervalHint: responseHeaders[\"x-ms-qps-service-polling-interval-hint\"],\n xMsQpsServiceEndpointRedirectV2: responseHeaders[\"x-ms-qps-service-endpoint-redirect-v2\"],\n };\n } catch (error: any) {\n const restError = error as RestError;\n diag.info(\"Failed to ping Quickpulse service\", restError.message);\n }\n return;\n }\n\n /**\n * publish Quickpulse service\n * @internal\n */\n async publish(optionalParams: PublishOptionalParams): Promise<QuickpulseResponse | undefined> {\n try {\n let responseHeaders: Record<string, string> = {};\n const body = await this.quickpulseClient.publish(this.instrumentationKey, {\n ...optionalParams,\n onResponse: (rawResponse) => {\n responseHeaders = rawResponse.headers.toJSON();\n },\n });\n return {\n ...body,\n xMsQpsSubscribed: responseHeaders[\"x-ms-qps-subscribed\"],\n xMsQpsConfigurationEtag: responseHeaders[\"x-ms-qps-configuration-etag\"],\n };\n } catch (error: any) {\n const restError = error as RestError;\n diag.warn(\"Failed to post Quickpulse service\", restError.message);\n }\n return;\n }\n\n /**\n * Apply a server-issued Live Metrics redirect (`x-ms-qps-service-endpoint-redirect-v2`) by\n * re-pointing the underlying client at the new host.\n *\n * Cross-origin redirects are refused (no state mutated) when the target is neither the configured\n * Live Metrics host nor under a known Azure Monitor ingestion domain suffix. Refusing them is\n * required to prevent an attacker-controlled redirect from causing the bearer auth policy to\n * attach a freshly-signed AAD token (scope `https://monitor.azure.com/.default`) — and the\n * telemetry body — to a foreign host on the next ping/publish call.\n */\n handlePermanentRedirect(location: string | undefined): void {\n if (location) {\n let locUrl: url.URL;\n try {\n locUrl = new url.URL(location);\n } catch {\n return;\n }\n if (!locUrl.host) {\n return;\n }\n\n let currentHost = \"\";\n try {\n currentHost = new url.URL(this.endpointUrl).host;\n } catch {\n currentHost = \"\";\n }\n\n if (!isSameRegisteredDomain(currentHost, locUrl.host)) {\n diag.error(\n `Refusing cross-origin Live Metrics redirect to https://${locUrl.host}: target is neither the configured endpoint host nor under a known Azure Monitor ingestion domain.`,\n );\n return;\n }\n\n this.endpointUrl = \"https://\" + locUrl.host;\n // Recreate the client so subsequent requests use the new endpoint\n this.quickpulseClient = this.createQuickpulseClient({\n endpoint: this.endpointUrl,\n credentials: { scopes: this.credentialScopes },\n });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sender.js","sourceRoot":"","sources":["../../../../../src/metrics/quickpulse/export/sender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAO1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,2BAA2B,GAAG,oCAAoC,CAAC;AAiBzE;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACnB,gBAAgB,CAAmB;IACnC,kBAAkB,CAAS;IAC3B,WAAW,CAAS;IACpB,UAAU,CAAkB;IAC5B,gBAAgB,CAAW;IAEnC,YAAY,OAKX;QACC,gEAAgE;QAChE,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,MAAM,aAAa,GAAmC;YACpD,QAAQ,E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B;QAClD,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,MAAe,CAAC;YACpB,IAAI,CAAC;gBACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACjC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO;YACT,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBACjB,OAAO;YACT,CAAC;YAED,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE;gBACxB,IAAI,CAAC;oBACH,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;gBAC5C,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC,CAAC,EAAE,CAAC;YAEL,IAAI,CAAC,sBAAsB,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtD,IAAI,CAAC,KAAK,CACR,0DAA0D,MAAM,CAAC,IAAI,oGAAoG,CAC1K,CAAC;gBACF,OAAO;YACT,CAAC;YAED,IAAI,CAAC,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC;YAC5C,kEAAkE;YAClE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,sBAAsB,CAAC;gBAClD,QAAQ,EAAE,IAAI,CAAC,WAAW;gBAC1B,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE;aAC/C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport url from \"url\";\nimport type { RestError } from \"@azure/core-rest-pipeline\";\nimport { redirectPolicyName } from \"@azure/core-rest-pipeline\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { diag } from \"@opentelemetry/api\";\nimport type {\n IsSubscribedOptionalParams,\n PublishOptionalParams,\n QuickpulseClientOptionalParams,\n CollectionConfigurationInfo,\n} from \"../../../generated/index.js\";\nimport { QuickpulseClient } from \"../../../generated/index.js\";\nimport { isSameRegisteredDomain } from \"../redirectUtils.js\";\n\nconst applicationInsightsResource = \"https://monitor.azure.com/.default\";\n\n/**\n * Response type that includes the body and response headers from the Live Metrics service.\n * @internal\n */\nexport interface QuickpulseResponse extends CollectionConfigurationInfo {\n /** Whether the instrumentation key is subscribed. */\n xMsQpsSubscribed?: string;\n /** Configuration ETag. */\n xMsQpsConfigurationEtag?: string;\n /** Polling interval hint (only for ping). */\n xMsQpsServicePollingIntervalHint?: string;\n /** Endpoint redirect (only for ping). */\n xMsQpsServiceEndpointRedirectV2?: string;\n}\n\n/**\n * Quickpulse sender class\n * @internal\n */\nexport class QuickpulseSender {\n private quickpulseClient: QuickpulseClient;\n private instrumentationKey: string;\n private endpointUrl: string;\n private credential: TokenCredential;\n private credentialScopes: string[];\n\n constructor(options: {\n endpointUrl: string;\n instrumentationKey: string;\n credential?: TokenCredential;\n credentialScopes?: string | string[];\n }) {\n // Build endpoint using provided configuration or default values\n this.endpointUrl = options.endpointUrl;\n const clientOptions: QuickpulseClientOptionalParams = {\n endpoint: this.endpointUrl,\n };\n\n this.instrumentationKey = options.instrumentationKey;\n this.credential = options.credential as TokenCredential;\n\n // Configure credential scopes\n if (options.credentialScopes) {\n this.credentialScopes = Array.isArray(options.credentialScopes)\n ? options.credentialScopes\n : [options.credentialScopes];\n } else {\n this.credentialScopes = [applicationInsightsResource];\n }\n if (options.credential) {\n clientOptions.credentials = { scopes: this.credentialScopes };\n }\n\n this.quickpulseClient = this.createQuickpulseClient(clientOptions);\n }\n\n private createQuickpulseClient(clientOptions: QuickpulseClientOptionalParams): QuickpulseClient {\n const client = new QuickpulseClient(this.credential, clientOptions);\n // Handle redirects in HTTP Sender\n client.pipeline.removePolicy({ name: redirectPolicyName });\n return client;\n }\n\n /**\n * isSubscribed Quickpulse service\n * @internal\n */\n async isSubscribed(\n optionalParams: IsSubscribedOptionalParams,\n ): Promise<QuickpulseResponse | undefined> {\n try {\n let responseHeaders: Record<string, string> = {};\n const body = await this.quickpulseClient.isSubscribed(this.instrumentationKey, {\n ...optionalParams,\n onResponse: (rawResponse) => {\n responseHeaders = rawResponse.headers.toJSON();\n },\n });\n return {\n ...body,\n xMsQpsSubscribed: responseHeaders[\"x-ms-qps-subscribed\"],\n xMsQpsConfigurationEtag: responseHeaders[\"x-ms-qps-configuration-etag\"],\n xMsQpsServicePollingIntervalHint: responseHeaders[\"x-ms-qps-service-polling-interval-hint\"],\n xMsQpsServiceEndpointRedirectV2: responseHeaders[\"x-ms-qps-service-endpoint-redirect-v2\"],\n };\n } catch (error: any) {\n const restError = error as RestError;\n diag.info(\"Failed to ping Quickpulse service\", restError.message);\n }\n return;\n }\n\n /**\n * publish Quickpulse service\n * @internal\n */\n async publish(optionalParams: PublishOptionalParams): Promise<QuickpulseResponse | undefined> {\n try {\n let responseHeaders: Record<string, string> = {};\n const body = await this.quickpulseClient.publish(this.instrumentationKey, {\n ...optionalParams,\n onResponse: (rawResponse) => {\n responseHeaders = rawResponse.headers.toJSON();\n },\n });\n return {\n ...body,\n xMsQpsSubscribed: responseHeaders[\"x-ms-qps-subscribed\"],\n xMsQpsConfigurationEtag: responseHeaders[\"x-ms-qps-configuration-etag\"],\n };\n } catch (error: any) {\n const restError = error as RestError;\n diag.warn(\"Failed to post Quickpulse service\", restError.message);\n }\n return;\n }\n\n /**\n * Apply a server-issued Live Metrics redirect (`x-ms-qps-service-endpoint-redirect-v2`) by\n * re-pointing the underlying client at the new host.\n *\n * Cross-origin redirects are refused (no state mutated) when the target is neither the configured\n * Live Metrics host nor under a known Azure Monitor ingestion domain suffix. Refusing them is\n * required to prevent an attacker-controlled redirect from causing the bearer auth policy to\n * attach a freshly-signed AAD token (scope `https://monitor.azure.com/.default`) — and the\n * telemetry body — to a foreign host on the next ping/publish call.\n */\n handlePermanentRedirect(location: string | undefined): void {\n if (location) {\n let locUrl: url.URL;\n try {\n locUrl = new url.URL(location);\n } catch {\n return;\n }\n if (!locUrl.host) {\n return;\n }\n\n const currentHost = (() => {\n try {\n return new url.URL(this.endpointUrl).host;\n } catch {\n return \"\";\n }\n })();\n\n if (!isSameRegisteredDomain(currentHost, locUrl.host)) {\n diag.error(\n `Refusing cross-origin Live Metrics redirect to https://${locUrl.host}: target is neither the configured endpoint host nor under a known Azure Monitor ingestion domain.`,\n );\n return;\n }\n\n this.endpointUrl = \"https://\" + locUrl.host;\n // Recreate the client so subsequent requests use the new endpoint\n this.quickpulseClient = this.createQuickpulseClient({\n endpoint: this.endpointUrl,\n credentials: { scopes: this.credentialScopes },\n });\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liveMetrics.d.ts","sourceRoot":"","sources":["../../../../src/metrics/quickpulse/liveMetrics.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAiC,MAAM,4BAA4B,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,+BAA+B,CAAC;AAE9E,OAAO,KAAK,EACV,eAAe,EAUhB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"liveMetrics.d.ts","sourceRoot":"","sources":["../../../../src/metrics/quickpulse/liveMetrics.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAiC,MAAM,4BAA4B,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,+BAA+B,CAAC;AAE9E,OAAO,KAAK,EACV,eAAe,EAUhB,MAAM,0BAA0B,CAAC;AA8BlC,OAAO,KAAK,EAAE,4B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OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,0BAA0B;IAWlC,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,gCAAgC;IAyDxC,OAAO,CAAC,oBAAoB;IAiC5B,OAAO,CAAC,8BAA8B;IAoDtC,OAAO,CAAC,oCAAoC;CAgC7C"}
|
|
@@ -9,6 +9,7 @@ import { QuickpulseMetricExporter } from "./export/exporter.js";
|
|
|
9
9
|
import { QuickpulseSender } from "./export/sender.js";
|
|
10
10
|
import { ConnectionStringParser } from "../../utils/connectionStringParser.js";
|
|
11
11
|
import { DEFAULT_LIVEMETRICS_ENDPOINT } from "../../types.js";
|
|
12
|
+
import { getAuthenticationCredentialFromEnv } from "./credentialUtils.js";
|
|
12
13
|
import { QuickPulseOpenTelemetryMetricNames } from "./types.js";
|
|
13
14
|
import { hrTimeToMilliseconds, suppressTracing } from "@opentelemetry/core";
|
|
14
15
|
import { getInstance } from "../../utils/statsbeat.js";
|
|
@@ -116,17 +117,18 @@ export class LiveMetrics {
|
|
|
116
117
|
};
|
|
117
118
|
const parsedConnectionString = ConnectionStringParser.parse(this.config.azureMonitorExporterOptions.connectionString ||
|
|
118
119
|
process.env["APPLICATIONINSIGHTS_CONNECTION_STRING"]);
|
|
120
|
+
const credential = this.config.azureMonitorExporterOptions.credential ?? getAuthenticationCredentialFromEnv();
|
|
119
121
|
this.pingSender = new QuickpulseSender({
|
|
120
122
|
endpointUrl: parsedConnectionString.liveendpoint || DEFAULT_LIVEMETRICS_ENDPOINT,
|
|
121
123
|
instrumentationKey: parsedConnectionString.instrumentationkey || "",
|
|
122
|
-
credential:
|
|
124
|
+
credential: credential,
|
|
123
125
|
credentialScopes: parsedConnectionString.aadaudience ||
|
|
124
126
|
this.config.azureMonitorExporterOptions.credentialScopes,
|
|
125
127
|
});
|
|
126
128
|
const exporterOptions = {
|
|
127
129
|
endpointUrl: parsedConnectionString.liveendpoint || DEFAULT_LIVEMETRICS_ENDPOINT,
|
|
128
130
|
instrumentationKey: parsedConnectionString.instrumentationkey || "",
|
|
129
|
-
credential:
|
|
131
|
+
credential: credential,
|
|
130
132
|
credentialScopes: parsedConnectionString.aadaudience ||
|
|
131
133
|
this.config.azureMonitorExporterOptions.credentialScopes,
|
|
132
134
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
@@ -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;AAS9D,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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AC,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 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 this.pingSender = new QuickpulseSender({\n endpointUrl: parsedConnectionString.liveendpoint || DEFAULT_LIVEMETRICS_ENDPOINT,\n instrumentationKey: parsedConnectionString.instrumentationkey || \"\",\n credential: this.config.azureMonitorExporterOptions.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: this.config.azureMonitorExporterOptions.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,EACd,aAAa,EACb,WAAW,EACX,UAAU,EACV,eAA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AE,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"]}
|
package/dist/esm/package.json
CHANGED
|
@@ -29,11 +29,18 @@ export declare class InternalConfig implements AzureMonitorOpenTelemetryOptions
|
|
|
29
29
|
/** Custom OpenTelemetry sampler (env-only) */
|
|
30
30
|
sampler?: Sampler;
|
|
31
31
|
private _resource;
|
|
32
|
+
private _aksResourceDetectorPopulated;
|
|
32
33
|
set resource(resource: Resource);
|
|
33
34
|
/**
|
|
34
35
|
*Get OpenTelemetry Resource
|
|
35
36
|
*/
|
|
36
37
|
get resource(): Resource;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the AKS resource detector was able to populate the AKS cluster attributes, which
|
|
40
|
+
* requires the customer to have configured access to the `aks-cluster-metadata` ConfigMap.
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
get aksResourceDetectorPopulated(): boolean;
|
|
37
44
|
browserSdkLoaderOptions: BrowserSdkLoaderOptions;
|
|
38
45
|
/**
|
|
39
46
|
* Initializes a new instance of the AzureMonitorOpenTelemetryOptions class.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/shared/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA2B,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAOlF,OAAO,KAAK,EACV,uBAAuB,EACvB,gCAAgC,EAChC,sBAAsB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts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CAAC,mBAAmB;IAgC3B;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAwB3B,6BAA6B,CAAC,OAAO,CAAC,EAAE;QAAE,kBAAkB,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;CAmBvF"}
|
|
@@ -4,7 +4,9 @@ import { defaultResource, detectResources, emptyResource, envDetector, } from "@
|
|
|
4
4
|
import { EnvConfig } from "./envConfig.js";
|
|
5
5
|
import { JsonConfig } from "./jsonConfig.js";
|
|
6
6
|
import { Logger } from "./logging/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { isAksResourceDetectorPopulated } from "../utils/common.js";
|
|
8
|
+
import { azureAksDetector, azureAppServiceDetector, azureContainerAppsDetector, azureFunctionsDetector, azureVmDetector, } from "@opentelemetry/resource-detector-azure";
|
|
9
|
+
import { SEMRESATTRS_CLOUD_PLATFORM } from "@opentelemetry/semantic-conventions";
|
|
8
10
|
/**
|
|
9
11
|
* Azure Monitor OpenTelemetry Client Configuration
|
|
10
12
|
*/
|
|
@@ -32,6 +34,7 @@ export class InternalConfig {
|
|
|
32
34
|
/** Custom OpenTelemetry sampler (env-only) */
|
|
33
35
|
sampler;
|
|
34
36
|
_resource = emptyResource();
|
|
37
|
+
_aksResourceDetectorPopulated = false;
|
|
35
38
|
set resource(resource) {
|
|
36
39
|
this._resource = this._resource.merge(resource);
|
|
37
40
|
}
|
|
@@ -41,6 +44,14 @@ export class InternalConfig {
|
|
|
41
44
|
get resource() {
|
|
42
45
|
return this._resource;
|
|
43
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether the AKS resource detector was able to populate the AKS cluster attributes, which
|
|
49
|
+
* requires the customer to have configured access to the `aks-cluster-metadata` ConfigMap.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
get aksResourceDetectorPopulated() {
|
|
53
|
+
return this._aksResourceDetectorPopulated;
|
|
54
|
+
}
|
|
44
55
|
browserSdkLoaderOptions;
|
|
45
56
|
/**
|
|
46
57
|
* Initializes a new instance of the AzureMonitorOpenTelemetryOptions class.
|
|
@@ -63,6 +74,7 @@ export class InternalConfig {
|
|
|
63
74
|
postgreSql: { enabled: true },
|
|
64
75
|
redis: { enabled: true },
|
|
65
76
|
redis4: { enabled: true },
|
|
77
|
+
console: { enabled: false },
|
|
66
78
|
};
|
|
67
79
|
this._setDefaultResource();
|
|
68
80
|
this.browserSdkLoaderOptions = {
|
|
@@ -146,14 +158,24 @@ export class InternalConfig {
|
|
|
146
158
|
};
|
|
147
159
|
const envResource = detectResources(detectResourceConfig);
|
|
148
160
|
resource = resource.merge(envResource);
|
|
149
|
-
// Load resource attributes from Azure
|
|
161
|
+
// Load resource attributes from Azure. AKS is detected on its own so that we can tell
|
|
162
|
+
// whether the AKS detector itself populated the cluster attributes - other detectors and the
|
|
163
|
+
// customer can populate the same attributes without AKS being involved.
|
|
164
|
+
const aksResource = detectResources({
|
|
165
|
+
detectors: [azureAksDetector],
|
|
166
|
+
});
|
|
167
|
+
this._aksResourceDetectorPopulated = isAksResourceDetectorPopulated(aksResource.attributes);
|
|
150
168
|
const azureResource = detectResources({
|
|
151
|
-
detectors: [
|
|
169
|
+
detectors: [azureAppServiceDetector, azureContainerAppsDetector, azureFunctionsDetector],
|
|
152
170
|
});
|
|
153
|
-
this._resource = resource.merge(azureResource);
|
|
154
|
-
//
|
|
155
|
-
//
|
|
156
|
-
|
|
171
|
+
this._resource = resource.merge(aksResource).merge(azureResource);
|
|
172
|
+
// The IMDS probe fails on App Service, Functions, and Container Apps, and on AKS
|
|
173
|
+
// it describes the node VM rather than the cluster.
|
|
174
|
+
const platformDetected = aksResource.attributes[SEMRESATTRS_CLOUD_PLATFORM] ??
|
|
175
|
+
azureResource.attributes[SEMRESATTRS_CLOUD_PLATFORM];
|
|
176
|
+
if (!platformDetected) {
|
|
177
|
+
this._initializeVmResourceAsync();
|
|
178
|
+
}
|
|
157
179
|
}
|
|
158
180
|
/**
|
|
159
181
|
* Initialize VM resource detection asynchronously to avoid warnings
|
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,EAAE;gBACT,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAClD,OAAO;YACT,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,EAAE;gBACV,oEAAoE;gBACpE,4EAA4E;YAC9E,CAAC,CAAC,CAAC;QACP,CAAC;aAAM,CAAC;YACN,6DAA6D;YAC7D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAEM,6BAA6B,CAAC,OAAwC;QAC3E,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,aAAa;QAE5C,iDAAiD;QACjD,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,CAAC;YAC5C,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YACjF,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;gBAC3C,OAAO,WAAW,CAAC;YACrB,CAAC;QACH,CAAC;QAED,+BAA+B;QAC/B,IAAI,OAAO,EAAE,kBAAkB,EAAE,CAAC;YAChC,OAAO,OAAO,CAAC,kBAAkB,CAAC;QACpC,CAAC;QAED,mBAAmB;QACnB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ResourceDetectionConfig, Resource } from \"@opentelemetry/resources\";\nimport {\n defaultResource,\n detectResources,\n emptyResource,\n envDetector,\n} from \"@opentelemetry/resources\";\nimport type {\n BrowserSdkLoaderOptions,\n AzureMonitorOpenTelemetryOptions,\n InstrumentationOptions,\n} from \"../types.js\";\nimport type { Sampler } from \"@opentelemetry/sdk-trace-base\";\nimport type { AzureMonitorExporterOptions } from \"@azure/monitor-opentelemetry-exporter\";\nimport { EnvConfig } from \"./envConfig.js\";\nimport { JsonConfig } from \"./jsonConfig.js\";\nimport { Logger } from \"./logging/index.js\";\nimport {\n azureAksDetector,\n azureAppServiceDetector,\n azureFunctionsDetector,\n azureVmDetector,\n} from \"@opentelemetry/resource-detector-azure\";\n\n/**\n * Azure Monitor OpenTelemetry Client Configuration\n */\nexport class InternalConfig implements AzureMonitorOpenTelemetryOptions {\n /** The rate of telemetry items tracked that should be transmitted (Default 1.0) */\n public samplingRatio: number;\n /** The maximum number of spans to sample per second. */\n public tracesPerSecond?: number;\n /** Azure Monitor Exporter Configuration */\n public azureMonitorExporterOptions: AzureMonitorExporterOptions;\n /**\n * OpenTelemetry Instrumentations configuration included as part of Azure Monitor (azureSdk, http, mongoDb, mySql, postgreSql, redis, redis4)\n */\n public instrumentationOptions: InstrumentationOptions;\n /** Enable Live Metrics feature */\n enableLiveMetrics?: boolean;\n /** Enable Standard Metrics feature */\n enableStandardMetrics?: boolean;\n /** Enable log sampling based on trace (Default true) */\n enableTraceBasedSamplingForLogs?: boolean;\n /** Enable Performance Counter feature */\n enablePerformanceCounters?: boolean;\n /** Metric export interval in milliseconds */\n public metricExportIntervalMillis: number;\n /** Custom OpenTelemetry sampler (env-only) */\n public sampler?: Sampler;\n\n private _resource: Resource = emptyResource();\n\n public set resource(resource: Resource) {\n this._resource = this._resource.merge(resource);\n }\n\n /**\n *Get OpenTelemetry Resource\n */\n public get resource(): Resource {\n return this._resource;\n }\n\n public browserSdkLoaderOptions: BrowserSdkLoaderOptions;\n\n /**\n * Initializes a new instance of the AzureMonitorOpenTelemetryOptions class.\n */\n constructor(options?: AzureMonitorOpenTelemetryOptions) {\n // Default values\n this.azureMonitorExporterOptions = {};\n this.samplingRatio = 1;\n this.tracesPerSecond = 5;\n this.enableLiveMetrics = true;\n this.enableStandardMetrics = true;\n this.enableTraceBasedSamplingForLogs = false;\n this.enablePerformanceCounters = true;\n this.metricExportIntervalMillis = this.calculateMetricExportInterval();\n this.instrumentationOptions = {\n http: { enabled: true },\n azureSdk: { enabled: true },\n mongoDb: { enabled: true },\n mySql: { enabled: true },\n postgreSql: { enabled: true },\n redis: { enabled: true },\n redis4: { enabled: true },\n };\n this._setDefaultResource();\n this.browserSdkLoaderOptions = {\n enabled: false,\n connectionString: \"\",\n };\n\n if (options) {\n // Merge default with provided options\n this.azureMonitorExporterOptions = Object.assign(\n this.azureMonitorExporterOptions,\n options.azureMonitorExporterOptions,\n );\n this.instrumentationOptions = Object.assign(\n this.instrumentationOptions,\n options.instrumentationOptions,\n );\n this.resource = Object.assign(this.resource, options.resource);\n this.samplingRatio =\n options.samplingRatio !== undefined ? options.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n options.tracesPerSecond !== undefined ? options.tracesPerSecond : this.tracesPerSecond;\n this.browserSdkLoaderOptions = Object.assign(\n this.browserSdkLoaderOptions,\n options.browserSdkLoaderOptions,\n );\n this.enableLiveMetrics =\n options.enableLiveMetrics !== undefined\n ? options.enableLiveMetrics\n : this.enableLiveMetrics;\n this.enableStandardMetrics =\n options.enableStandardMetrics !== undefined\n ? options.enableStandardMetrics\n : this.enableStandardMetrics;\n this.enableTraceBasedSamplingForLogs =\n options.enableTraceBasedSamplingForLogs !== undefined\n ? options.enableTraceBasedSamplingForLogs\n : this.enableTraceBasedSamplingForLogs;\n this.enablePerformanceCounters =\n options.enablePerformanceCounters !== undefined\n ? options.enablePerformanceCounters\n : this.enablePerformanceCounters;\n }\n // JSON configuration will take precedence over options provided\n this._mergeJsonConfig();\n // ENV configuration will take precedence over other configurations\n this._mergeEnvConfig();\n }\n\n private _mergeEnvConfig(): void {\n const envConfig = EnvConfig.getInstance();\n this.samplingRatio =\n envConfig.samplingRatio !== undefined ? envConfig.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n envConfig.tracesPerSecond !== undefined ? envConfig.tracesPerSecond : this.tracesPerSecond;\n this.sampler = envConfig.sampler ?? this.sampler;\n }\n\n private _mergeJsonConfig(): void {\n try {\n const jsonConfig = JsonConfig.getInstance();\n this.samplingRatio =\n jsonConfig.samplingRatio !== undefined ? jsonConfig.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n jsonConfig.tracesPerSecond !== undefined\n ? jsonConfig.tracesPerSecond\n : this.tracesPerSecond;\n this.browserSdkLoaderOptions = Object.assign(\n this.browserSdkLoaderOptions,\n jsonConfig.browserSdkLoaderOptions,\n );\n this.enableLiveMetrics =\n jsonConfig.enableLiveMetrics !== undefined\n ? jsonConfig.enableLiveMetrics\n : this.enableLiveMetrics;\n this.enableStandardMetrics =\n jsonConfig.enableStandardMetrics !== undefined\n ? jsonConfig.enableStandardMetrics\n : this.enableStandardMetrics;\n this.enableTraceBasedSamplingForLogs =\n jsonConfig.enableTraceBasedSamplingForLogs !== undefined\n ? jsonConfig.enableTraceBasedSamplingForLogs\n : this.enableTraceBasedSamplingForLogs;\n this.azureMonitorExporterOptions = Object.assign(\n this.azureMonitorExporterOptions,\n jsonConfig.azureMonitorExporterOptions,\n );\n this.instrumentationOptions = Object.assign(\n this.instrumentationOptions,\n jsonConfig.instrumentationOptions,\n );\n } catch (error) {\n Logger.getInstance().error(\"Failed to load JSON config file values.\", error);\n }\n }\n\n private _setDefaultResource(): void {\n let resource = defaultResource();\n // Load resource attributes from env\n const detectResourceConfig: ResourceDetectionConfig = {\n detectors: [envDetector],\n };\n const envResource = detectResources(detectResourceConfig);\n resource = resource.merge(envResource);\n\n // Load resource attributes from Azure\n const azureResource: Resource = detectResources({\n detectors: [azureAksDetector, azureAppServiceDetector, azureFunctionsDetector],\n });\n this._resource = resource.merge(azureResource);\n\n // Handle VM resource detection asynchronously to avoid warnings\n // about accessing resource attributes before async attributes are settled\n this._initializeVmResourceAsync();\n }\n\n /**\n * Initialize VM resource detection asynchronously to avoid warnings\n * about accessing resource attributes before async attributes settle\n */\n private _initializeVmResourceAsync(): void {\n const vmResource = detectResources({\n detectors: [azureVmDetector],\n });\n\n // Don't wait for VM resource detection to complete during initialization\n // This prevents warnings about accessing resource attributes before async attributes are settled\n if (vmResource.asyncAttributesPending) {\n void vmResource\n .waitForAsyncAttributes?.()\n .then(() => {\n this._resource = this._resource.merge(vmResource);\n return;\n })\n .catch(() => {\n // Silently ignore VM detection errors to avoid unnecessary warnings\n // VM detection is optional and failures shouldn't impact core functionality\n });\n } else {\n // If VM detection completed synchronously, merge immediately\n this._resource = this._resource.merge(vmResource);\n }\n }\n\n public calculateMetricExportInterval(options?: { collectionInterval: number }): number {\n const defaultInterval = 60000; // 60 seconds\n\n // Prioritize OTEL_METRIC_EXPORT_INTERVAL env var\n if (process.env.OTEL_METRIC_EXPORT_INTERVAL) {\n const envInterval = parseInt(process.env.OTEL_METRIC_EXPORT_INTERVAL.trim(), 10);\n if (!isNaN(envInterval) && envInterval > 0) {\n return envInterval;\n }\n }\n\n // Then use options if provided\n if (options?.collectionInterval) {\n return options.collectionInterval;\n }\n\n // Default fallback\n return defaultInterval;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/shared/config.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,0BAA0B,EAC1B,sBAAsB,EACtB,eAAe,GAChB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAEjF;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB,mFAAmF;IAC5E,aAAa,CAAS;IAC7B,wDAAw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1B,IAAI,CAAC,GAAG,EAAE;gBACT,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAClD,OAAO;YACT,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,EAAE;gBACV,oEAAoE;gBACpE,4EAA4E;YAC9E,CAAC,CAAC,CAAC;QACP,CAAC;aAAM,CAAC;YACN,6DAA6D;YAC7D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAEM,6BAA6B,CAAC,OAAwC;QAC3E,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,aAAa;QAE5C,iDAAiD;QACjD,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,CAAC;YAC5C,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YACjF,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;gBAC3C,OAAO,WAAW,CAAC;YACrB,CAAC;QACH,CAAC;QAED,+BAA+B;QAC/B,IAAI,OAAO,EAAE,kBAAkB,EAAE,CAAC;YAChC,OAAO,OAAO,CAAC,kBAAkB,CAAC;QACpC,CAAC;QAED,mBAAmB;QACnB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ResourceDetectionConfig, Resource } from \"@opentelemetry/resources\";\nimport {\n defaultResource,\n detectResources,\n emptyResource,\n envDetector,\n} from \"@opentelemetry/resources\";\nimport type {\n BrowserSdkLoaderOptions,\n AzureMonitorOpenTelemetryOptions,\n InstrumentationOptions,\n} from \"../types.js\";\nimport type { Sampler } from \"@opentelemetry/sdk-trace-base\";\nimport type { AzureMonitorExporterOptions } from \"@azure/monitor-opentelemetry-exporter\";\nimport { EnvConfig } from \"./envConfig.js\";\nimport { JsonConfig } from \"./jsonConfig.js\";\nimport { Logger } from \"./logging/index.js\";\nimport { isAksResourceDetectorPopulated } from \"../utils/common.js\";\nimport {\n azureAksDetector,\n azureAppServiceDetector,\n azureContainerAppsDetector,\n azureFunctionsDetector,\n azureVmDetector,\n} from \"@opentelemetry/resource-detector-azure\";\nimport { SEMRESATTRS_CLOUD_PLATFORM } from \"@opentelemetry/semantic-conventions\";\n\n/**\n * Azure Monitor OpenTelemetry Client Configuration\n */\nexport class InternalConfig implements AzureMonitorOpenTelemetryOptions {\n /** The rate of telemetry items tracked that should be transmitted (Default 1.0) */\n public samplingRatio: number;\n /** The maximum number of spans to sample per second. */\n public tracesPerSecond?: number;\n /** Azure Monitor Exporter Configuration */\n public azureMonitorExporterOptions: AzureMonitorExporterOptions;\n /**\n * OpenTelemetry Instrumentations configuration included as part of Azure Monitor (azureSdk, http, mongoDb, mySql, postgreSql, redis, redis4)\n */\n public instrumentationOptions: InstrumentationOptions;\n /** Enable Live Metrics feature */\n enableLiveMetrics?: boolean;\n /** Enable Standard Metrics feature */\n enableStandardMetrics?: boolean;\n /** Enable log sampling based on trace (Default true) */\n enableTraceBasedSamplingForLogs?: boolean;\n /** Enable Performance Counter feature */\n enablePerformanceCounters?: boolean;\n /** Metric export interval in milliseconds */\n public metricExportIntervalMillis: number;\n /** Custom OpenTelemetry sampler (env-only) */\n public sampler?: Sampler;\n\n private _resource: Resource = emptyResource();\n private _aksResourceDetectorPopulated: boolean = false;\n\n public set resource(resource: Resource) {\n this._resource = this._resource.merge(resource);\n }\n\n /**\n *Get OpenTelemetry Resource\n */\n public get resource(): Resource {\n return this._resource;\n }\n\n /**\n * Whether the AKS resource detector was able to populate the AKS cluster attributes, which\n * requires the customer to have configured access to the `aks-cluster-metadata` ConfigMap.\n * @internal\n */\n public get aksResourceDetectorPopulated(): boolean {\n return this._aksResourceDetectorPopulated;\n }\n\n public browserSdkLoaderOptions: BrowserSdkLoaderOptions;\n\n /**\n * Initializes a new instance of the AzureMonitorOpenTelemetryOptions class.\n */\n constructor(options?: AzureMonitorOpenTelemetryOptions) {\n // Default values\n this.azureMonitorExporterOptions = {};\n this.samplingRatio = 1;\n this.tracesPerSecond = 5;\n this.enableLiveMetrics = true;\n this.enableStandardMetrics = true;\n this.enableTraceBasedSamplingForLogs = false;\n this.enablePerformanceCounters = true;\n this.metricExportIntervalMillis = this.calculateMetricExportInterval();\n this.instrumentationOptions = {\n http: { enabled: true },\n azureSdk: { enabled: true },\n mongoDb: { enabled: true },\n mySql: { enabled: true },\n postgreSql: { enabled: true },\n redis: { enabled: true },\n redis4: { enabled: true },\n console: { enabled: false },\n };\n this._setDefaultResource();\n this.browserSdkLoaderOptions = {\n enabled: false,\n connectionString: \"\",\n };\n\n if (options) {\n // Merge default with provided options\n this.azureMonitorExporterOptions = Object.assign(\n this.azureMonitorExporterOptions,\n options.azureMonitorExporterOptions,\n );\n this.instrumentationOptions = Object.assign(\n this.instrumentationOptions,\n options.instrumentationOptions,\n );\n this.resource = Object.assign(this.resource, options.resource);\n this.samplingRatio =\n options.samplingRatio !== undefined ? options.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n options.tracesPerSecond !== undefined ? options.tracesPerSecond : this.tracesPerSecond;\n this.browserSdkLoaderOptions = Object.assign(\n this.browserSdkLoaderOptions,\n options.browserSdkLoaderOptions,\n );\n this.enableLiveMetrics =\n options.enableLiveMetrics !== undefined\n ? options.enableLiveMetrics\n : this.enableLiveMetrics;\n this.enableStandardMetrics =\n options.enableStandardMetrics !== undefined\n ? options.enableStandardMetrics\n : this.enableStandardMetrics;\n this.enableTraceBasedSamplingForLogs =\n options.enableTraceBasedSamplingForLogs !== undefined\n ? options.enableTraceBasedSamplingForLogs\n : this.enableTraceBasedSamplingForLogs;\n this.enablePerformanceCounters =\n options.enablePerformanceCounters !== undefined\n ? options.enablePerformanceCounters\n : this.enablePerformanceCounters;\n }\n // JSON configuration will take precedence over options provided\n this._mergeJsonConfig();\n // ENV configuration will take precedence over other configurations\n this._mergeEnvConfig();\n }\n\n private _mergeEnvConfig(): void {\n const envConfig = EnvConfig.getInstance();\n this.samplingRatio =\n envConfig.samplingRatio !== undefined ? envConfig.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n envConfig.tracesPerSecond !== undefined ? envConfig.tracesPerSecond : this.tracesPerSecond;\n this.sampler = envConfig.sampler ?? this.sampler;\n }\n\n private _mergeJsonConfig(): void {\n try {\n const jsonConfig = JsonConfig.getInstance();\n this.samplingRatio =\n jsonConfig.samplingRatio !== undefined ? jsonConfig.samplingRatio : this.samplingRatio;\n this.tracesPerSecond =\n jsonConfig.tracesPerSecond !== undefined\n ? jsonConfig.tracesPerSecond\n : this.tracesPerSecond;\n this.browserSdkLoaderOptions = Object.assign(\n this.browserSdkLoaderOptions,\n jsonConfig.browserSdkLoaderOptions,\n );\n this.enableLiveMetrics =\n jsonConfig.enableLiveMetrics !== undefined\n ? jsonConfig.enableLiveMetrics\n : this.enableLiveMetrics;\n this.enableStandardMetrics =\n jsonConfig.enableStandardMetrics !== undefined\n ? jsonConfig.enableStandardMetrics\n : this.enableStandardMetrics;\n this.enableTraceBasedSamplingForLogs =\n jsonConfig.enableTraceBasedSamplingForLogs !== undefined\n ? jsonConfig.enableTraceBasedSamplingForLogs\n : this.enableTraceBasedSamplingForLogs;\n this.azureMonitorExporterOptions = Object.assign(\n this.azureMonitorExporterOptions,\n jsonConfig.azureMonitorExporterOptions,\n );\n this.instrumentationOptions = Object.assign(\n this.instrumentationOptions,\n jsonConfig.instrumentationOptions,\n );\n } catch (error) {\n Logger.getInstance().error(\"Failed to load JSON config file values.\", error);\n }\n }\n\n private _setDefaultResource(): void {\n let resource = defaultResource();\n // Load resource attributes from env\n const detectResourceConfig: ResourceDetectionConfig = {\n detectors: [envDetector],\n };\n const envResource = detectResources(detectResourceConfig);\n resource = resource.merge(envResource);\n\n // Load resource attributes from Azure. AKS is detected on its own so that we can tell\n // whether the AKS detector itself populated the cluster attributes - other detectors and the\n // customer can populate the same attributes without AKS being involved.\n const aksResource: Resource = detectResources({\n detectors: [azureAksDetector],\n });\n this._aksResourceDetectorPopulated = isAksResourceDetectorPopulated(aksResource.attributes);\n\n const azureResource: Resource = detectResources({\n detectors: [azureAppServiceDetector, azureContainerAppsDetector, azureFunctionsDetector],\n });\n this._resource = resource.merge(aksResource).merge(azureResource);\n\n // The IMDS probe fails on App Service, Functions, and Container Apps, and on AKS\n // it describes the node VM rather than the cluster.\n const platformDetected =\n aksResource.attributes[SEMRESATTRS_CLOUD_PLATFORM] ??\n azureResource.attributes[SEMRESATTRS_CLOUD_PLATFORM];\n if (!platformDetected) {\n this._initializeVmResourceAsync();\n }\n }\n\n /**\n * Initialize VM resource detection asynchronously to avoid warnings\n * about accessing resource attributes before async attributes settle\n */\n private _initializeVmResourceAsync(): void {\n const vmResource = detectResources({\n detectors: [azureVmDetector],\n });\n\n // Don't wait for VM resource detection to complete during initialization\n // This prevents warnings about accessing resource attributes before async attributes are settled\n if (vmResource.asyncAttributesPending) {\n void vmResource\n .waitForAsyncAttributes?.()\n .then(() => {\n this._resource = this._resource.merge(vmResource);\n return;\n })\n .catch(() => {\n // Silently ignore VM detection errors to avoid unnecessary warnings\n // VM detection is optional and failures shouldn't impact core functionality\n });\n } else {\n // If VM detection completed synchronously, merge immediately\n this._resource = this._resource.merge(vmResource);\n }\n }\n\n public calculateMetricExportInterval(options?: { collectionInterval: number }): number {\n const defaultInterval = 60000; // 60 seconds\n\n // Prioritize OTEL_METRIC_EXPORT_INTERVAL env var\n if (process.env.OTEL_METRIC_EXPORT_INTERVAL) {\n const envInterval = parseInt(process.env.OTEL_METRIC_EXPORT_INTERVAL.trim(), 10);\n if (!isNaN(envInterval) && envInterval > 0) {\n return envInterval;\n }\n }\n\n // Then use options if provided\n if (options?.collectionInterval) {\n return options.collectionInterval;\n }\n\n // Default fallback\n return defaultInterval;\n }\n}\n"]}
|