@azure/monitor-opentelemetry-exporter 1.0.0-beta.35 → 1.0.0-beta.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/Declarations/Constants.d.ts +10 -0
- package/dist/commonjs/Declarations/Constants.d.ts.map +1 -1
- package/dist/commonjs/Declarations/Constants.js +11 -1
- package/dist/commonjs/Declarations/Constants.js.map +1 -1
- package/dist/commonjs/Declarations/Contracts/Constants.d.ts +1 -1
- package/dist/commonjs/Declarations/Contracts/Constants.d.ts.map +1 -1
- package/dist/commonjs/Declarations/Contracts/Constants.js.map +1 -1
- package/dist/commonjs/export/metric.d.ts.map +1 -1
- package/dist/commonjs/export/metric.js +1 -1
- package/dist/commonjs/export/metric.js.map +1 -1
- package/dist/commonjs/export/statsbeat/customerSDKStats.d.ts +2 -2
- package/dist/commonjs/export/statsbeat/customerSDKStats.d.ts.map +1 -1
- package/dist/commonjs/export/statsbeat/customerSDKStats.js +11 -9
- package/dist/commonjs/export/statsbeat/customerSDKStats.js.map +1 -1
- package/dist/commonjs/export/statsbeat/statsbeatExporter.d.ts +5 -0
- package/dist/commonjs/export/statsbeat/statsbeatExporter.d.ts.map +1 -1
- package/dist/commonjs/export/statsbeat/statsbeatExporter.js +19 -5
- package/dist/commonjs/export/statsbeat/statsbeatExporter.js.map +1 -1
- package/dist/commonjs/export/statsbeat/statsbeatMetrics.d.ts.map +1 -1
- package/dist/commonjs/export/statsbeat/statsbeatMetrics.js +3 -2
- package/dist/commonjs/export/statsbeat/statsbeatMetrics.js.map +1 -1
- package/dist/commonjs/export/trace.d.ts +1 -0
- package/dist/commonjs/export/trace.d.ts.map +1 -1
- package/dist/commonjs/export/trace.js +9 -1
- package/dist/commonjs/export/trace.js.map +1 -1
- package/dist/commonjs/generated/applicationInsightsClient.js +1 -1
- package/dist/commonjs/generated/applicationInsightsClient.js.map +1 -1
- package/dist/commonjs/generated/models/index.d.ts.map +1 -1
- package/dist/commonjs/generated/models/index.js.map +1 -1
- package/dist/commonjs/generated/models/mappers.js +11 -11
- package/dist/commonjs/generated/models/mappers.js.map +1 -1
- package/dist/commonjs/platform/nodejs/baseSender.d.ts +1 -0
- package/dist/commonjs/platform/nodejs/baseSender.d.ts.map +1 -1
- package/dist/commonjs/platform/nodejs/baseSender.js +35 -16
- package/dist/commonjs/platform/nodejs/baseSender.js.map +1 -1
- package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.d.ts +15 -0
- package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.d.ts.map +1 -1
- package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.js +65 -2
- package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/utils/common.d.ts +2 -2
- package/dist/commonjs/utils/common.d.ts.map +1 -1
- package/dist/commonjs/utils/common.js +16 -11
- package/dist/commonjs/utils/common.js.map +1 -1
- package/dist/commonjs/utils/constants/applicationinsights.d.ts +1 -1
- package/dist/commonjs/utils/constants/applicationinsights.js +1 -1
- package/dist/commonjs/utils/constants/applicationinsights.js.map +1 -1
- package/dist/commonjs/utils/logUtils.js +2 -2
- package/dist/commonjs/utils/logUtils.js.map +1 -1
- package/dist/esm/Declarations/Constants.d.ts +10 -0
- package/dist/esm/Declarations/Constants.d.ts.map +1 -1
- package/dist/esm/Declarations/Constants.js +10 -0
- package/dist/esm/Declarations/Constants.js.map +1 -1
- package/dist/esm/Declarations/Contracts/Constants.d.ts +1 -1
- package/dist/esm/Declarations/Contracts/Constants.d.ts.map +1 -1
- package/dist/esm/Declarations/Contracts/Constants.js.map +1 -1
- package/dist/esm/export/metric.d.ts.map +1 -1
- package/dist/esm/export/metric.js +1 -1
- package/dist/esm/export/metric.js.map +1 -1
- package/dist/esm/export/statsbeat/customerSDKStats.d.ts +2 -2
- package/dist/esm/export/statsbeat/customerSDKStats.d.ts.map +1 -1
- package/dist/esm/export/statsbeat/customerSDKStats.js +11 -9
- package/dist/esm/export/statsbeat/customerSDKStats.js.map +1 -1
- package/dist/esm/export/statsbeat/statsbeatExporter.d.ts +5 -0
- package/dist/esm/export/statsbeat/statsbeatExporter.d.ts.map +1 -1
- package/dist/esm/export/statsbeat/statsbeatExporter.js +19 -5
- package/dist/esm/export/statsbeat/statsbeatExporter.js.map +1 -1
- package/dist/esm/export/statsbeat/statsbeatMetrics.d.ts.map +1 -1
- package/dist/esm/export/statsbeat/statsbeatMetrics.js +3 -2
- package/dist/esm/export/statsbeat/statsbeatMetrics.js.map +1 -1
- package/dist/esm/export/trace.d.ts +1 -0
- package/dist/esm/export/trace.d.ts.map +1 -1
- package/dist/esm/export/trace.js +9 -1
- package/dist/esm/export/trace.js.map +1 -1
- package/dist/esm/generated/applicationInsightsClient.js +1 -1
- package/dist/esm/generated/applicationInsightsClient.js.map +1 -1
- package/dist/esm/generated/models/index.d.ts.map +1 -1
- package/dist/esm/generated/models/index.js.map +1 -1
- package/dist/esm/generated/models/mappers.js +11 -11
- package/dist/esm/generated/models/mappers.js.map +1 -1
- package/dist/esm/platform/nodejs/baseSender.d.ts +1 -0
- package/dist/esm/platform/nodejs/baseSender.d.ts.map +1 -1
- package/dist/esm/platform/nodejs/baseSender.js +36 -17
- package/dist/esm/platform/nodejs/baseSender.js.map +1 -1
- package/dist/esm/platform/nodejs/persist/fileSystemPersist.d.ts +15 -0
- package/dist/esm/platform/nodejs/persist/fileSystemPersist.d.ts.map +1 -1
- package/dist/esm/platform/nodejs/persist/fileSystemPersist.js +66 -4
- package/dist/esm/platform/nodejs/persist/fileSystemPersist.js.map +1 -1
- package/dist/esm/utils/common.d.ts +2 -2
- package/dist/esm/utils/common.d.ts.map +1 -1
- package/dist/esm/utils/common.js +17 -12
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/esm/utils/constants/applicationinsights.d.ts +1 -1
- package/dist/esm/utils/constants/applicationinsights.js +1 -1
- package/dist/esm/utils/constants/applicationinsights.js.map +1 -1
- package/dist/esm/utils/logUtils.js +2 -2
- package/dist/esm/utils/logUtils.js.map +1 -1
- package/package.json +18 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseSender.js","sourceRoot":"","sources":["../../../../src/platform/nodejs/baseSender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAC;AAEtG,OAAO,EACL,QAAQ,EACR,SAAS,EACT,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EACL,gDAAgD,EAChD,gDAAgD,EAChD,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAErF,MAAM,oCAAoC,GAAG,MAAM,CAAC;AAEpD;;;GAGG;AACH,MAAM,OAAgB,UAAU;IACb,SAAS,CAAoB;IACtC,uBAAuB,CAAS;IAChC,UAAU,CAAwB;IAClC,uBAAuB,CAAsC;IAC7D,uBAAuB,CAAsC;IAC7D,4BAA4B,CAAC;IAC7B,qBAAqB,GAAW,CAAC,CAAC;IAClC,wBAAwB,GAAW,oCAAoC,CAAC;IACxE,iBAAiB,CAAU;IAC3B,qBAAqB,CAAU;IAEvC,YAAY,OAOX;QACC,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,eA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,EAAE,gBAAgB,EAAE,CAAC;YACnD,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAEO,oBAAoB,CAAC,KAAgB;QAC3C,MAAM,cAAc,GAAa,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;QACxE,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { diag } from \"@opentelemetry/api\";\nimport type { PersistentStorage, SenderResult } from \"../../types.js\";\nimport { ExceptionType } from \"../../export/statsbeat/types.js\";\nimport type { AzureMonitorExporterOptions } from \"../../config.js\";\nimport { FileSystemPersist } from \"./persist/index.js\";\nimport type { ExportResult } from \"@opentelemetry/core\";\nimport { ExportResultCode } from \"@opentelemetry/core\";\nimport { NetworkStatsbeatMetrics } from \"../../export/statsbeat/networkStatsbeatMetrics.js\";\nimport { LongIntervalStatsbeatMetrics } from \"../../export/statsbeat/longIntervalStatsbeatMetrics.js\";\nimport type { RestError } from \"@azure/core-rest-pipeline\";\nimport {\n DropCode,\n RetryCode,\n MAX_STATSBEAT_FAILURES,\n isStatsbeatShutdownStatus,\n} from \"../../export/statsbeat/types.js\";\nimport type { BreezeResponse } from \"../../utils/breezeUtils.js\";\nimport { isRetriable } from \"../../utils/breezeUtils.js\";\nimport type { TelemetryItem as Envelope } from \"../../generated/index.js\";\nimport {\n ENV_APPLICATIONINSIGHTS_SDKSTATS_ENABLED_PREVIEW,\n ENV_APPLICATIONINSIGHTS_SDKSTATS_EXPORT_INTERVAL,\n RetriableRestErrorTypes,\n} from \"../../Declarations/Constants.js\";\nimport { CustomerSDKStatsMetrics } from \"../../export/statsbeat/customerSDKStats.js\";\n\nconst DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60_000;\n\n/**\n * Base sender class\n * @internal\n */\nexport abstract class BaseSender {\n private readonly persister: PersistentStorage;\n private numConsecutiveRedirects: number;\n private retryTimer: NodeJS.Timeout | null;\n private networkStatsbeatMetrics: NetworkStatsbeatMetrics | undefined;\n private customerSDKStatsMetrics: CustomerSDKStatsMetrics | undefined;\n private longIntervalStatsbeatMetrics;\n private statsbeatFailureCount: number = 0;\n private batchSendRetryIntervalMs: number = DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS;\n private isStatsbeatSender: boolean;\n private disableOfflineStorage: boolean;\n\n constructor(options: {\n endpointUrl: string;\n instrumentationKey: string;\n trackStatsbeat: boolean;\n exporterOptions: AzureMonitorExporterOptions;\n aadAudience?: string;\n isStatsbeatSender?: boolean;\n }) {\n this.numConsecutiveRedirects = 0;\n this.disableOfflineStorage = options.exporterOptions.disableOfflineStorage || false;\n if (options.trackStatsbeat) {\n this.networkStatsbeatMetrics = NetworkStatsbeatMetrics.getInstance({\n instrumentationKey: options.instrumentationKey,\n endpointUrl: options.endpointUrl,\n disableOfflineStorage: this.disableOfflineStorage,\n });\n this.longIntervalStatsbeatMetrics = LongIntervalStatsbeatMetrics.getInstance({\n instrumentationKey: options.instrumentationKey,\n endpointUrl: options.endpointUrl,\n disableOfflineStorage: this.disableOfflineStorage,\n });\n if (process.env[ENV_APPLICATIONINSIGHTS_SDKSTATS_ENABLED_PREVIEW]) {\n let exportInterval: number | undefined;\n if (process.env[ENV_APPLICATIONINSIGHTS_SDKSTATS_EXPORT_INTERVAL]) {\n const envValue = process.env[ENV_APPLICATIONINSIGHTS_SDKSTATS_EXPORT_INTERVAL];\n const exportIntervalSeconds = parseInt(envValue, 10);\n if (!isNaN(exportIntervalSeconds) && exportIntervalSeconds > 0) {\n exportInterval = exportIntervalSeconds * 1000; // Convert seconds to milliseconds\n } else {\n diag.warn(\n `Invalid value for APPLICATIONINSIGHTS_SDKSTATS_EXPORT_INTERVAL environment variable: '${envValue}'. Expected a positive number (seconds). Using default export interval.`,\n );\n }\n }\n this.customerSDKStatsMetrics = CustomerSDKStatsMetrics.getInstance({\n instrumentationKey: options.instrumentationKey,\n endpointUrl: options.endpointUrl,\n disableOfflineStorage: this.disableOfflineStorage,\n networkCollectionInterval: exportInterval,\n });\n }\n }\n this.persister = new FileSystemPersist(\n options.instrumentationKey,\n options.exporterOptions,\n this.customerSDKStatsMetrics,\n );\n this.retryTimer = null;\n this.isStatsbeatSender = options.isStatsbeatSender || false;\n }\n\n abstract send(payload: unknown[]): Promise<SenderResult>;\n abstract shutdown(): Promise<void>;\n abstract handlePermanentRedirect(location: string | undefined): void;\n\n /**\n * Export envelopes\n */\n public async exportEnvelopes(envelopes: Envelope[]): Promise<ExportResult> {\n diag.info(`Exporting ${envelopes.length} envelope(s)`);\n\n if (envelopes.length < 1) {\n return { code: ExportResultCode.SUCCESS };\n }\n\n try {\n const startTime = new Date().getTime();\n const { result, statusCode } = await this.send(envelopes);\n const endTime = new Date().getTime();\n const duration = endTime - startTime;\n this.numConsecutiveRedirects = 0;\n\n if (statusCode === 200) {\n // Success -- @todo: start retry timer\n if (!this.retryTimer) {\n this.retryTimer = setTimeout(() => {\n this.retryTimer = null;\n this.sendFirstPersistedFile();\n }, this.batchSendRetryIntervalMs);\n this.retryTimer.unref();\n }\n // If we are not exporting statsbeat and statsbeat is not disabled -- count success\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countSuccess(duration);\n this.customerSDKStatsMetrics?.countSuccessfulItems(envelopes);\n }\n return { code: ExportResultCode.SUCCESS };\n } else if (statusCode && isRetriable(statusCode)) {\n // Failed -- persist failed data\n if (statusCode === 429 || statusCode === 439) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countThrottle(statusCode);\n this.customerSDKStatsMetrics?.countRetryItems(envelopes, statusCode);\n }\n return {\n code: ExportResultCode.SUCCESS,\n };\n }\n if (result) {\n diag.info(result);\n const breezeResponse = JSON.parse(result) as BreezeResponse;\n const filteredEnvelopes: Envelope[] = [];\n // Create a list of successful envelopes by filtering out the failed ones for customer SDK Stats\n const successfulEnvelopes: Envelope[] = [...envelopes];\n\n // If we have a partial success, count the succeeded envelopes\n if (breezeResponse.itemsAccepted > 0 && statusCode === 206 && !this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countSuccess(duration);\n }\n // Figure out if we need to either retry or count failures\n if (breezeResponse.errors) {\n breezeResponse.errors.forEach((error) => {\n // Mark as undefined so we don't process them in countSuccessfulEnvelopes\n successfulEnvelopes[error.index] = undefined as unknown as Envelope;\n\n // Add to retry list if status code is retriable\n if (error.statusCode && isRetriable(error.statusCode)) {\n filteredEnvelopes.push(envelopes[error.index]);\n }\n });\n }\n\n // If we have a partial success, count the succeeded envelopes\n if (breezeResponse.itemsAccepted > 0) {\n // Count only the successful envelopes (non-undefined)\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countSuccess(duration);\n this.customerSDKStatsMetrics?.countSuccessfulItems(envelopes);\n }\n }\n if (filteredEnvelopes.length > 0) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countRetry(statusCode);\n this.customerSDKStatsMetrics?.countRetryItems(envelopes, statusCode);\n }\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this.persist(filteredEnvelopes);\n }\n // Failed -- not retriable\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countFailure(duration, statusCode);\n // Count dropped items for customer SDK Stats for non-retriable status codes\n const filteredSuccessfulEnvelopes = successfulEnvelopes.filter(Boolean);\n this.customerSDKStatsMetrics?.countDroppedItems(\n filteredSuccessfulEnvelopes,\n statusCode,\n );\n }\n return {\n code: ExportResultCode.FAILED,\n };\n } else {\n // calls resultCallback(ExportResult) based on result of persister.push\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countRetry(statusCode);\n this.customerSDKStatsMetrics?.countRetryItems(envelopes, statusCode);\n }\n return await this.persist(envelopes);\n }\n } else {\n // Failed -- not retriable\n if (this.networkStatsbeatMetrics && !this.isStatsbeatSender) {\n if (statusCode) {\n this.networkStatsbeatMetrics.countFailure(duration, statusCode);\n this.customerSDKStatsMetrics?.countDroppedItems(envelopes, statusCode);\n }\n } else {\n // Handles all other status codes or client exceptions for Statsbeat\n this.incrementStatsbeatFailure();\n this.customerSDKStatsMetrics?.countDroppedItems(envelopes, DropCode.CLIENT_EXCEPTION);\n }\n return {\n code: ExportResultCode.FAILED,\n };\n }\n } catch (error: any) {\n const restError = error as RestError;\n if (\n restError.statusCode &&\n (restError.statusCode === 307 || // Temporary redirect\n restError.statusCode === 308)\n ) {\n // Permanent redirect\n this.numConsecutiveRedirects++;\n // To prevent circular redirects\n if (this.numConsecutiveRedirects < 10) {\n if (restError.response && restError.response.headers) {\n const location = restError.response.headers.get(\"location\");\n if (location) {\n // Update sender URL\n this.handlePermanentRedirect(location);\n // Send to redirect endpoint as HTTPs library doesn't handle redirect automatically\n return this.exportEnvelopes(envelopes);\n }\n }\n } else {\n const redirectError = new Error(\"Circular redirect\");\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countException(redirectError);\n this.customerSDKStatsMetrics?.countDroppedItems(\n envelopes,\n DropCode.CLIENT_EXCEPTION,\n redirectError.message,\n ExceptionType.CLIENT_EXCEPTION,\n );\n }\n return { code: ExportResultCode.FAILED, error: redirectError };\n }\n } else if (\n restError.statusCode &&\n isRetriable(restError.statusCode) &&\n !this.isStatsbeatSender\n ) {\n this.networkStatsbeatMetrics?.countRetry(restError.statusCode);\n this.customerSDKStatsMetrics?.countRetryItems(envelopes, restError.statusCode);\n return this.persist(envelopes);\n } else if (\n restError.statusCode === 400 &&\n restError.message.includes(\"Invalid instrumentation key\")\n ) {\n // Invalid instrumentation key, shutdown statsbeat, fail silently\n this.shutdownStatsbeat();\n return { code: ExportResultCode.SUCCESS };\n } else if (\n restError.statusCode &&\n this.isStatsbeatSender &&\n isStatsbeatShutdownStatus(restError.statusCode)\n ) {\n // If the status code is a shutdown status code for statsbeat, shutdown statsbeat and fail silently\n this.incrementStatsbeatFailure();\n return { code: ExportResultCode.SUCCESS };\n }\n\n // For retriable REST errors\n if (this.isRetriableRestError(restError) && !this.isStatsbeatSender) {\n if (this.customerSDKStatsMetrics?.isTimeoutError(restError) && !this.isStatsbeatSender) {\n this.customerSDKStatsMetrics?.countRetryItems(\n envelopes,\n RetryCode.CLIENT_TIMEOUT,\n \"timeout_exception\",\n ExceptionType.TIMEOUT_EXCEPTION,\n );\n diag.error(\"Request timed out. Error message:\", restError.message);\n } else if (restError.statusCode) {\n this.networkStatsbeatMetrics?.countRetry(restError.statusCode);\n this.customerSDKStatsMetrics?.countRetryItems(envelopes, restError.statusCode);\n }\n diag.error(\n \"Retrying due to transient client side error. Error message:\",\n restError.message,\n );\n return this.persist(envelopes);\n }\n // For non-retriable REST errors or client exceptions\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countException(restError);\n this.customerSDKStatsMetrics?.countDroppedItems(\n envelopes,\n DropCode.CLIENT_EXCEPTION,\n restError.message,\n );\n diag.error(\n \"Envelopes could not be exported and are not retriable. Error message:\",\n restError.message,\n );\n }\n return { code: ExportResultCode.FAILED, error: restError };\n }\n }\n\n /**\n * Persist envelopes to disk\n */\n private async persist(envelopes: unknown[]): Promise<ExportResult> {\n try {\n const success = await this.persister.push(envelopes);\n return success\n ? { code: ExportResultCode.SUCCESS }\n : {\n code: ExportResultCode.FAILED,\n error: new Error(\"Failed to persist envelope in disk.\"),\n };\n } catch (ex: any) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countWriteFailure();\n if (this.disableOfflineStorage && envelopes) {\n this.customerSDKStatsMetrics?.countDroppedItems(\n envelopes as Envelope[],\n DropCode.CLIENT_STORAGE_DISABLED,\n );\n }\n }\n return { code: ExportResultCode.FAILED, error: ex };\n }\n }\n\n /**\n * Disable collection of statsbeat metrics after max failures\n */\n private incrementStatsbeatFailure(): void {\n this.statsbeatFailureCount++;\n if (this.statsbeatFailureCount > MAX_STATSBEAT_FAILURES) {\n this.shutdownStatsbeat();\n }\n }\n\n /**\n * Shutdown statsbeat metrics\n */\n private shutdownStatsbeat(): void {\n if (this.networkStatsbeatMetrics) {\n this.networkStatsbeatMetrics.shutdown();\n }\n if (this.longIntervalStatsbeatMetrics) {\n this.longIntervalStatsbeatMetrics?.shutdown();\n }\n if (this.customerSDKStatsMetrics) {\n this.customerSDKStatsMetrics.shutdown();\n }\n this.statsbeatFailureCount = 0;\n }\n\n private async sendFirstPersistedFile(): Promise<void> {\n const envelopes = (await this.persister.shift()) as Envelope[] | null;\n try {\n if (envelopes) {\n await this.send(envelopes);\n }\n } catch (err: any) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countReadFailure();\n }\n diag.warn(`Failed to fetch persisted file`, err);\n }\n }\n\n private isRetriableRestError(error: RestError): boolean {\n const restErrorTypes: string[] = Object.values(RetriableRestErrorTypes);\n if (error && error.code && restErrorTypes.includes(error.code)) {\n return true;\n }\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"baseSender.js","sourceRoot":"","sources":["../../../../src/platform/nodejs/baseSender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAC;AAEtG,OAAO,EACL,QAAQ,EACR,SAAS,EACT,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAA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,EAAE,GAAG,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAEO,oBAAoB,CAAC,KAAgB;QAC3C,MAAM,cAAc,GAAa,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;QACxE,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,iGAAiG;IACzF,iBAAiB,CAAC,MAAoB;QAC5C,MAAM,8BAA8B,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QAChG,IAAI,IAAI,CAAC,iBAAiB,IAAI,MAAM,CAAC,IAAI,KAAK,gBAAgB,CAAC,MAAM,EAAE,CAAC;YACtE,OAAO,8BAA8B,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,CAAC;QACtF,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { diag } from \"@opentelemetry/api\";\nimport type { PersistentStorage, SenderResult } from \"../../types.js\";\nimport { ExceptionType } from \"../../export/statsbeat/types.js\";\nimport type { AzureMonitorExporterOptions } from \"../../config.js\";\nimport { FileSystemPersist } from \"./persist/index.js\";\nimport type { ExportResult } from \"@opentelemetry/core\";\nimport { ExportResultCode } from \"@opentelemetry/core\";\nimport { NetworkStatsbeatMetrics } from \"../../export/statsbeat/networkStatsbeatMetrics.js\";\nimport { LongIntervalStatsbeatMetrics } from \"../../export/statsbeat/longIntervalStatsbeatMetrics.js\";\nimport type { RestError } from \"@azure/core-rest-pipeline\";\nimport {\n DropCode,\n RetryCode,\n MAX_STATSBEAT_FAILURES,\n isStatsbeatShutdownStatus,\n} from \"../../export/statsbeat/types.js\";\nimport type { BreezeResponse } from \"../../utils/breezeUtils.js\";\nimport { isRetriable } from \"../../utils/breezeUtils.js\";\nimport type { TelemetryItem as Envelope } from \"../../generated/index.js\";\nimport {\n ENV_APPLICATIONINSIGHTS_SDKSTATS_ENABLED_PREVIEW,\n ENV_APPLICATIONINSIGHTS_SDKSTATS_EXPORT_INTERVAL,\n ENV_APPLICATIONINSIGHTS_SDK_STATS_LOGGING,\n RetriableRestErrorTypes,\n} from \"../../Declarations/Constants.js\";\nimport { CustomerSDKStatsMetrics } from \"../../export/statsbeat/customerSDKStats.js\";\n\nconst DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60_000;\n\n/**\n * Base sender class\n * @internal\n */\nexport abstract class BaseSender {\n private readonly persister: PersistentStorage;\n private numConsecutiveRedirects: number;\n private retryTimer: NodeJS.Timeout | null;\n private networkStatsbeatMetrics: NetworkStatsbeatMetrics | undefined;\n private customerSDKStatsMetrics: CustomerSDKStatsMetrics | undefined;\n private longIntervalStatsbeatMetrics;\n private statsbeatFailureCount: number = 0;\n private batchSendRetryIntervalMs: number = DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS;\n private isStatsbeatSender: boolean;\n private disableOfflineStorage: boolean;\n\n constructor(options: {\n endpointUrl: string;\n instrumentationKey: string;\n trackStatsbeat: boolean;\n exporterOptions: AzureMonitorExporterOptions;\n aadAudience?: string;\n isStatsbeatSender?: boolean;\n }) {\n this.numConsecutiveRedirects = 0;\n this.disableOfflineStorage = options.exporterOptions.disableOfflineStorage || false;\n if (options.trackStatsbeat) {\n this.networkStatsbeatMetrics = NetworkStatsbeatMetrics.getInstance({\n instrumentationKey: options.instrumentationKey,\n endpointUrl: options.endpointUrl,\n disableOfflineStorage: this.disableOfflineStorage,\n });\n this.longIntervalStatsbeatMetrics = LongIntervalStatsbeatMetrics.getInstance({\n instrumentationKey: options.instrumentationKey,\n endpointUrl: options.endpointUrl,\n disableOfflineStorage: this.disableOfflineStorage,\n });\n if (process.env[ENV_APPLICATIONINSIGHTS_SDKSTATS_ENABLED_PREVIEW]) {\n let exportInterval: number | undefined;\n if (process.env[ENV_APPLICATIONINSIGHTS_SDKSTATS_EXPORT_INTERVAL]) {\n const envValue = process.env[ENV_APPLICATIONINSIGHTS_SDKSTATS_EXPORT_INTERVAL];\n const exportIntervalSeconds = parseInt(envValue, 10);\n if (!isNaN(exportIntervalSeconds) && exportIntervalSeconds > 0) {\n exportInterval = exportIntervalSeconds * 1000; // Convert seconds to milliseconds\n } else {\n diag.warn(\n `Invalid value for APPLICATIONINSIGHTS_SDKSTATS_EXPORT_INTERVAL environment variable: '${envValue}'. Expected a positive number (seconds). Using default export interval.`,\n );\n }\n }\n // Initialize customer SDK stats metrics asynchronously to avoid circular dependency\n // Only initialize if not already set (e.g., by tests)\n if (!this.customerSDKStatsMetrics) {\n import(\"../../export/statsbeat/customerSDKStats.js\")\n .then((module) =>\n module.CustomerSDKStatsMetrics.getInstance({\n instrumentationKey: options.instrumentationKey,\n endpointUrl: options.endpointUrl,\n disableOfflineStorage: this.disableOfflineStorage,\n networkCollectionInterval: exportInterval,\n }),\n )\n .then((metrics) => {\n this.customerSDKStatsMetrics = metrics;\n return;\n })\n .catch((error) => {\n diag.warn(\"Failed to initialize customer SDK stats metrics:\", error);\n });\n }\n }\n }\n this.persister = new FileSystemPersist(\n options.instrumentationKey,\n options.exporterOptions,\n this.customerSDKStatsMetrics,\n );\n this.retryTimer = null;\n this.isStatsbeatSender = options.isStatsbeatSender || false;\n }\n\n abstract send(payload: unknown[]): Promise<SenderResult>;\n abstract shutdown(): Promise<void>;\n abstract handlePermanentRedirect(location: string | undefined): void;\n\n /**\n * Export envelopes\n */\n public async exportEnvelopes(envelopes: Envelope[]): Promise<ExportResult> {\n diag.info(`Exporting ${envelopes.length} envelope(s)`);\n\n if (envelopes.length < 1) {\n return { code: ExportResultCode.SUCCESS };\n }\n\n try {\n const startTime = new Date().getTime();\n const { result, statusCode } = await this.send(envelopes);\n const endTime = new Date().getTime();\n const duration = endTime - startTime;\n this.numConsecutiveRedirects = 0;\n\n if (statusCode === 200) {\n // Success -- @todo: start retry timer\n if (!this.retryTimer) {\n this.retryTimer = setTimeout(() => {\n this.retryTimer = null;\n this.sendFirstPersistedFile();\n }, this.batchSendRetryIntervalMs);\n this.retryTimer.unref();\n }\n // If we are not exporting statsbeat and statsbeat is not disabled -- count success\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countSuccess(duration);\n this.customerSDKStatsMetrics?.countSuccessfulItems(envelopes);\n }\n return { code: ExportResultCode.SUCCESS };\n } else if (statusCode && isRetriable(statusCode)) {\n // Failed -- persist failed data\n if (statusCode === 429 || statusCode === 439) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countThrottle(statusCode);\n this.customerSDKStatsMetrics?.countRetryItems(envelopes, statusCode);\n }\n return {\n code: ExportResultCode.SUCCESS,\n };\n }\n if (result) {\n diag.info(result);\n const breezeResponse = JSON.parse(result) as BreezeResponse;\n const filteredEnvelopes: Envelope[] = [];\n // Create a list of successful envelopes by filtering out the failed ones for customer SDK Stats\n const successfulEnvelopes: Envelope[] = [...envelopes];\n\n // If we have a partial success, count the succeeded envelopes\n if (breezeResponse.itemsAccepted > 0 && statusCode === 206 && !this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countSuccess(duration);\n }\n // Figure out if we need to either retry or count failures\n if (breezeResponse.errors) {\n breezeResponse.errors.forEach((error) => {\n // Mark as undefined so we don't process them in countSuccessfulEnvelopes\n successfulEnvelopes[error.index] = undefined as unknown as Envelope;\n\n // Add to retry list if status code is retriable\n if (error.statusCode && isRetriable(error.statusCode)) {\n filteredEnvelopes.push(envelopes[error.index]);\n }\n });\n }\n\n // If we have a partial success, count the succeeded envelopes\n if (breezeResponse.itemsAccepted > 0) {\n // Count only the successful envelopes (non-undefined)\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countSuccess(duration);\n this.customerSDKStatsMetrics?.countSuccessfulItems(envelopes);\n }\n }\n if (filteredEnvelopes.length > 0) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countRetry(statusCode);\n this.customerSDKStatsMetrics?.countRetryItems(envelopes, statusCode);\n }\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this.persist(filteredEnvelopes);\n }\n // Failed -- not retriable\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countFailure(duration, statusCode);\n // Count dropped items for customer SDK Stats for non-retriable status codes\n const filteredSuccessfulEnvelopes = successfulEnvelopes.filter(Boolean);\n this.customerSDKStatsMetrics?.countDroppedItems(\n filteredSuccessfulEnvelopes,\n statusCode,\n );\n }\n return this.buildExportResult({\n code: ExportResultCode.FAILED,\n });\n } else {\n // calls resultCallback(ExportResult) based on result of persister.push\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countRetry(statusCode);\n this.customerSDKStatsMetrics?.countRetryItems(envelopes, statusCode);\n }\n return await this.persist(envelopes);\n }\n } else {\n // Failed -- not retriable\n if (this.networkStatsbeatMetrics && !this.isStatsbeatSender) {\n if (statusCode) {\n this.networkStatsbeatMetrics.countFailure(duration, statusCode);\n this.customerSDKStatsMetrics?.countDroppedItems(envelopes, statusCode);\n }\n } else {\n // Handles all other status codes or client exceptions for Statsbeat\n this.incrementStatsbeatFailure();\n this.customerSDKStatsMetrics?.countDroppedItems(envelopes, DropCode.CLIENT_EXCEPTION);\n }\n return this.buildExportResult({\n code: ExportResultCode.FAILED,\n });\n }\n } catch (error: any) {\n const restError = error as RestError;\n if (\n restError.statusCode &&\n (restError.statusCode === 307 || // Temporary redirect\n restError.statusCode === 308)\n ) {\n // Permanent redirect\n this.numConsecutiveRedirects++;\n // To prevent circular redirects\n if (this.numConsecutiveRedirects < 10) {\n if (restError.response && restError.response.headers) {\n const location = restError.response.headers.get(\"location\");\n if (location) {\n // Update sender URL\n this.handlePermanentRedirect(location);\n // Send to redirect endpoint as HTTPs library doesn't handle redirect automatically\n return this.exportEnvelopes(envelopes);\n }\n }\n } else {\n const redirectError = new Error(\"Circular redirect\");\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countException(redirectError);\n this.customerSDKStatsMetrics?.countDroppedItems(\n envelopes,\n DropCode.CLIENT_EXCEPTION,\n redirectError.message,\n ExceptionType.CLIENT_EXCEPTION,\n );\n }\n return this.buildExportResult({ code: ExportResultCode.FAILED, error: redirectError });\n }\n } else if (\n restError.statusCode &&\n isRetriable(restError.statusCode) &&\n !this.isStatsbeatSender\n ) {\n this.networkStatsbeatMetrics?.countRetry(restError.statusCode);\n this.customerSDKStatsMetrics?.countRetryItems(envelopes, restError.statusCode);\n return this.persist(envelopes);\n } else if (\n restError.statusCode === 400 &&\n restError.message.includes(\"Invalid instrumentation key\")\n ) {\n // Invalid instrumentation key, shutdown statsbeat, fail silently\n this.shutdownStatsbeat();\n return { code: ExportResultCode.SUCCESS };\n } else if (\n restError.statusCode &&\n this.isStatsbeatSender &&\n isStatsbeatShutdownStatus(restError.statusCode)\n ) {\n // If the status code is a shutdown status code for statsbeat, shutdown statsbeat and fail silently\n this.incrementStatsbeatFailure();\n return { code: ExportResultCode.SUCCESS };\n }\n\n // For retriable REST errors\n if (this.isRetriableRestError(restError) && !this.isStatsbeatSender) {\n if (this.customerSDKStatsMetrics?.isTimeoutError(restError) && !this.isStatsbeatSender) {\n this.customerSDKStatsMetrics?.countRetryItems(\n envelopes,\n RetryCode.CLIENT_TIMEOUT,\n \"timeout_exception\",\n ExceptionType.TIMEOUT_EXCEPTION,\n );\n diag.error(\"Request timed out. Error message:\", restError.message);\n } else if (restError.statusCode) {\n this.networkStatsbeatMetrics?.countRetry(restError.statusCode);\n this.customerSDKStatsMetrics?.countRetryItems(envelopes, restError.statusCode);\n }\n diag.error(\n \"Retrying due to transient client side error. Error message:\",\n restError.message,\n );\n return this.persist(envelopes);\n }\n // For non-retriable REST errors or client exceptions\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countException(restError);\n this.customerSDKStatsMetrics?.countDroppedItems(\n envelopes,\n DropCode.CLIENT_EXCEPTION,\n restError.message,\n );\n diag.error(\n \"Envelopes could not be exported and are not retriable. Error message:\",\n restError.message,\n );\n }\n return this.buildExportResult({ code: ExportResultCode.FAILED, error: restError });\n }\n }\n\n /**\n * Persist envelopes to disk\n */\n private async persist(envelopes: unknown[]): Promise<ExportResult> {\n try {\n const success = await this.persister.push(envelopes);\n return success\n ? { code: ExportResultCode.SUCCESS }\n : this.buildExportResult({\n code: ExportResultCode.FAILED,\n error: new Error(\"Failed to persist envelope in disk.\"),\n });\n } catch (ex: any) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countWriteFailure();\n if (this.disableOfflineStorage && envelopes) {\n this.customerSDKStatsMetrics?.countDroppedItems(\n envelopes as Envelope[],\n DropCode.CLIENT_STORAGE_DISABLED,\n );\n }\n }\n return this.buildExportResult({ code: ExportResultCode.FAILED, error: ex });\n }\n }\n\n /**\n * Disable collection of statsbeat metrics after max failures\n */\n private incrementStatsbeatFailure(): void {\n this.statsbeatFailureCount++;\n if (this.statsbeatFailureCount > MAX_STATSBEAT_FAILURES) {\n this.shutdownStatsbeat();\n }\n }\n\n /**\n * Shutdown statsbeat metrics\n */\n private shutdownStatsbeat(): void {\n if (this.networkStatsbeatMetrics) {\n this.networkStatsbeatMetrics.shutdown();\n }\n if (this.longIntervalStatsbeatMetrics) {\n this.longIntervalStatsbeatMetrics?.shutdown();\n }\n if (this.customerSDKStatsMetrics) {\n this.customerSDKStatsMetrics.shutdown();\n }\n this.statsbeatFailureCount = 0;\n }\n\n private async sendFirstPersistedFile(): Promise<void> {\n const envelopes = (await this.persister.shift()) as Envelope[] | null;\n try {\n if (envelopes) {\n await this.send(envelopes);\n }\n } catch (err: any) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countReadFailure();\n }\n diag.warn(`Failed to fetch persisted file`, err);\n }\n }\n\n private isRetriableRestError(error: RestError): boolean {\n const restErrorTypes: string[] = Object.values(RetriableRestErrorTypes);\n if (error && error.code && restErrorTypes.includes(error.code)) {\n return true;\n }\n return false;\n }\n\n // Silence noisy failures from statsbeat OTel metric readers unless logging is explicitly enabled\n private buildExportResult(result: ExportResult): ExportResult {\n const shouldSurfaceStatsbeatFailures = !!process.env[ENV_APPLICATIONINSIGHTS_SDK_STATS_LOGGING];\n if (this.isStatsbeatSender && result.code === ExportResultCode.FAILED) {\n return shouldSurfaceStatsbeatFailures ? result : { code: ExportResultCode.SUCCESS };\n }\n return result;\n }\n}\n"]}
|
|
@@ -34,4 +34,19 @@ export declare class FileSystemPersist implements PersistentStorage {
|
|
|
34
34
|
private _storeToDisk;
|
|
35
35
|
private _fileCleanupTask;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Return the deterministic local storage path for a given instrumentation key.
|
|
39
|
+
*
|
|
40
|
+
* On shared Linux hosts the first user to create `/tmp/Microsoft/AzureMonitor` can
|
|
41
|
+
* block others because the directory inherits that user's `umask`. This is avoided by
|
|
42
|
+
* inserting a hash of the instrumentation key, user name, process name, and
|
|
43
|
+
* application directory, giving each user their own subdirectory, e.g.
|
|
44
|
+
* `/tmp/Microsoft-AzureMonitor-1234...../opentelemetry-nodejs-<ikey>`.
|
|
45
|
+
*
|
|
46
|
+
* @param instrumentationKey - Application Insights instrumentation key.
|
|
47
|
+
* @param storageDirectory - Optional custom storage directory path. If not provided, system temp directory is used.
|
|
48
|
+
* @returns Absolute path to the storage directory.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export declare function getStorageDirectory(instrumentationKey: string, storageDirectory: string | undefined): string;
|
|
37
52
|
//# sourceMappingURL=fileSystemPersist.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileSystemPersist.d.ts","sourceRoot":"","sources":["../../../../../src/platform/nodejs/persist/fileSystemPersist.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fileSystemPersist.d.ts","sourceRoot":"","sources":["../../../../../src/platform/nodejs/persist/fileSystemPersist.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AAI7F;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,iBAAiB;IAevD,OAAO,CAAC,QAAQ,CAAC;IACjB,OAAO,CAAC,wBAAwB,CAAC;IAfnC,MAAM,CAAC,cAAc,SAA2B;IAChD,MAAM,CAAC,eAAe,SAAc;IAEpC,oBAAoB,SAA2B;IAC/C,cAAc,SAAkB;IAChC,cAAc,EAAE,MAAM,CAAc;IAEpC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,iBAAiB,CAA+B;IACxD,OAAO,CAAC,mBAAmB,CAAS;gBAGlC,kBAAkB,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,2BAA2B,YAAA,EACtC,wBAAwB,CAAC,EAAE,uBAAuB,YAAA;IAuC5D,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBlC,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAkB/B;;;OAGG;YACW,mBAAmB;IA8BjC;;;;;OAKG;YACW,YAAY;YAwDZ,gBAAgB;CA+B/B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,kBAAkB,EAAE,MAAM,EAC1B,gBAAgB,EAAE,MAAM,GAAG,SAAS,GACnC,MAAM,CA+CR"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { basename, join } from "node:path";
|
|
3
|
+
import { tmpdir, userInfo } from "node:os";
|
|
4
|
+
import { basename, join, dirname } from "node:path";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
5
6
|
import { diag } from "@opentelemetry/api";
|
|
6
7
|
import { FileAccessControl } from "./fileAccessControl.js";
|
|
7
8
|
import { confirmDirExists, getShallowDirectorySize } from "./fileSystemHelpers.js";
|
|
@@ -14,7 +15,7 @@ import { DropCode, ExceptionType } from "../../../export/statsbeat/types.js";
|
|
|
14
15
|
export class FileSystemPersist {
|
|
15
16
|
_options;
|
|
16
17
|
_customerSDKStatsMetrics;
|
|
17
|
-
static TEMPDIR_PREFIX = "
|
|
18
|
+
static TEMPDIR_PREFIX = "opentelemetry-nodejs-";
|
|
18
19
|
static FILENAME_SUFFIX = ".ai.json";
|
|
19
20
|
fileRetemptionPeriod = 2 * 24 * 60 * 60 * 1000; // 2 days
|
|
20
21
|
cleanupTimeOut = 60 * 60 * 1000; // 1 hour
|
|
@@ -42,7 +43,7 @@ export class FileSystemPersist {
|
|
|
42
43
|
diag.error(`No instrumentation key was provided to FileSystemPersister. Files will not be persisted`);
|
|
43
44
|
}
|
|
44
45
|
if (this._enabled) {
|
|
45
|
-
this._tempDirectory =
|
|
46
|
+
this._tempDirectory = getStorageDirectory(this._instrumentationKey, this._options?.storageDirectory);
|
|
46
47
|
// Starts file cleanup task
|
|
47
48
|
if (!this._fileCleanupTimer) {
|
|
48
49
|
this._fileCleanupTimer = setTimeout(() => {
|
|
@@ -198,4 +199,65 @@ export class FileSystemPersist {
|
|
|
198
199
|
}
|
|
199
200
|
}
|
|
200
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Return the deterministic local storage path for a given instrumentation key.
|
|
204
|
+
*
|
|
205
|
+
* On shared Linux hosts the first user to create `/tmp/Microsoft/AzureMonitor` can
|
|
206
|
+
* block others because the directory inherits that user's `umask`. This is avoided by
|
|
207
|
+
* inserting a hash of the instrumentation key, user name, process name, and
|
|
208
|
+
* application directory, giving each user their own subdirectory, e.g.
|
|
209
|
+
* `/tmp/Microsoft-AzureMonitor-1234...../opentelemetry-nodejs-<ikey>`.
|
|
210
|
+
*
|
|
211
|
+
* @param instrumentationKey - Application Insights instrumentation key.
|
|
212
|
+
* @param storageDirectory - Optional custom storage directory path. If not provided, system temp directory is used.
|
|
213
|
+
* @returns Absolute path to the storage directory.
|
|
214
|
+
* @internal
|
|
215
|
+
*/
|
|
216
|
+
export function getStorageDirectory(instrumentationKey, storageDirectory) {
|
|
217
|
+
let userSegment;
|
|
218
|
+
let processName;
|
|
219
|
+
let applicationDirectory;
|
|
220
|
+
try {
|
|
221
|
+
const user = userInfo();
|
|
222
|
+
userSegment = user.username;
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
userSegment = "";
|
|
226
|
+
}
|
|
227
|
+
if (process.title.length > 0) {
|
|
228
|
+
processName = process.title;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
processName = "";
|
|
232
|
+
}
|
|
233
|
+
const applicationDir = dirname(process.cwd() || process.argv[1]);
|
|
234
|
+
if (applicationDir) {
|
|
235
|
+
applicationDirectory = applicationDir;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
applicationDirectory = "";
|
|
239
|
+
}
|
|
240
|
+
const hash_input = `${instrumentationKey}|${userSegment}|${processName}|${applicationDirectory}`;
|
|
241
|
+
let subDirectory;
|
|
242
|
+
try {
|
|
243
|
+
subDirectory = createHash("sha256").update(hash_input).digest("hex");
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
let hash = 5381;
|
|
247
|
+
for (let i = 0; i < hash_input.length; i++) {
|
|
248
|
+
const char = hash_input.charCodeAt(i);
|
|
249
|
+
hash = (hash << 5) + hash + char;
|
|
250
|
+
hash = hash & hash;
|
|
251
|
+
}
|
|
252
|
+
subDirectory = Math.abs(hash).toString(16);
|
|
253
|
+
}
|
|
254
|
+
let sharedRoot;
|
|
255
|
+
if (storageDirectory) {
|
|
256
|
+
sharedRoot = storageDirectory;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
sharedRoot = tmpdir();
|
|
260
|
+
}
|
|
261
|
+
return join(sharedRoot, "Microsoft-AzureMonitor-" + subDirectory, FileSystemPersist.TEMPDIR_PREFIX + instrumentationKey);
|
|
262
|
+
}
|
|
201
263
|
//# sourceMappingURL=fileSystemPersist.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileSystemPersist.js","sourceRoot":"","sources":["../../../../../src/platform/nodejs/persist/fileSystemPersist.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAG7E;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAelB;IACA;IAfV,MAAM,CAAC,cAAc,GAAG,oBAAoB,CAAC;IAC7C,MAAM,CAAC,eAAe,GAAG,UAAU,CAAC;IAEpC,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;IACzD,cAAc,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;IAC1C,cAAc,GAAW,UAAU,CAAC,CAAC,QAAQ;IAErC,QAAQ,CAAU;IAClB,cAAc,GAAW,EAAE,CAAC;IAC5B,iBAAiB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AI,EAAE,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,gBAAgB,CAAC;wBACrF,IAAI,OAAO,EAAE,CAAC;4BACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;4BACjD,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;wBACzB,CAAC;oBACH,CAAC,CAAC,CAAC;oBACH,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,CAAC,yDAAyD,EAAE,KAAK,CAAC,CAAC;YAC5E,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { tmpdir } from \"node:os\";\nimport { basename, join } from \"node:path\";\nimport { diag } from \"@opentelemetry/api\";\nimport type { PersistentStorage } from \"../../../types.js\";\nimport { FileAccessControl } from \"./fileAccessControl.js\";\nimport { confirmDirExists, getShallowDirectorySize } from \"./fileSystemHelpers.js\";\nimport type { AzureMonitorExporterOptions } from \"../../../config.js\";\nimport { readdir, readFile, stat, unlink, writeFile } from \"node:fs/promises\";\nimport type { CustomerSDKStatsMetrics } from \"../../../export/statsbeat/customerSDKStats.js\";\nimport { DropCode, ExceptionType } from \"../../../export/statsbeat/types.js\";\nimport type { TelemetryItem as Envelope } from \"../../../generated/index.js\";\n\n/**\n * File system persist class.\n * @internal\n */\nexport class FileSystemPersist implements PersistentStorage {\n static TEMPDIR_PREFIX = \"ot-azure-exporter-\";\n static FILENAME_SUFFIX = \".ai.json\";\n\n fileRetemptionPeriod = 2 * 24 * 60 * 60 * 1000; // 2 days\n cleanupTimeOut = 60 * 60 * 1000; // 1 hour\n maxBytesOnDisk: number = 50_000_000; // ~50MB\n\n private _enabled: boolean;\n private _tempDirectory: string = \"\";\n private _fileCleanupTimer: NodeJS.Timeout | null = null;\n private _instrumentationKey: string;\n\n constructor(\n instrumentationKey: string,\n private _options?: AzureMonitorExporterOptions,\n private _customerSDKStatsMetrics?: CustomerSDKStatsMetrics,\n ) {\n this._instrumentationKey = instrumentationKey;\n if (this._options?.disableOfflineStorage) {\n this._enabled = false;\n return;\n }\n this._enabled = true;\n FileAccessControl.checkFileProtection();\n\n if (!FileAccessControl.OS_PROVIDES_FILE_PROTECTION) {\n this._enabled = false;\n diag.error(\n \"Sufficient file protection capabilities were not detected. Files will not be persisted\",\n );\n }\n\n if (!this._instrumentationKey) {\n this._enabled = false;\n diag.error(\n `No instrumentation key was provided to FileSystemPersister. Files will not be persisted`,\n );\n }\n if (this._enabled) {\n this._tempDirectory = join(\n this._options?.storageDirectory || tmpdir(),\n \"Microsoft\",\n \"AzureMonitor\",\n FileSystemPersist.TEMPDIR_PREFIX + this._instrumentationKey,\n );\n\n // Starts file cleanup task\n if (!this._fileCleanupTimer) {\n this._fileCleanupTimer = setTimeout(() => {\n this._fileCleanupTask();\n }, this.cleanupTimeOut);\n this._fileCleanupTimer.unref();\n }\n }\n }\n\n push(value: unknown[]): Promise<boolean> {\n if (this._enabled) {\n diag.debug(\"Pushing value to persistent storage\", value.toString());\n return this._storeToDisk(JSON.stringify(value), value as Envelope[]);\n }\n // Only return a false promise if the SDK isn't set to disable offline storage\n if (!this._options?.disableOfflineStorage) {\n return new Promise((resolve) => {\n resolve(false);\n });\n }\n return new Promise((resolve) => {\n resolve(true);\n });\n }\n\n async shift(): Promise<unknown> {\n if (this._enabled) {\n diag.debug(\"Searching for filesystem persisted files\");\n try {\n const buffer = await this._getFirstFileOnDisk();\n if (buffer) {\n return JSON.parse(buffer.toString(\"utf8\"));\n }\n } catch (e: any) {\n diag.debug(\"Failed to read persisted file\", e);\n }\n return null;\n }\n return new Promise((resolve) => {\n resolve(null);\n });\n }\n\n /**\n * Check for temp telemetry files\n * reads the first file if exist, deletes it and tries to send its load\n */\n private async _getFirstFileOnDisk(): Promise<Buffer | null> {\n try {\n const stats = await stat(this._tempDirectory);\n if (stats.isDirectory()) {\n const origFiles = await readdir(this._tempDirectory);\n const files = origFiles.filter((f) =>\n basename(f).includes(FileSystemPersist.FILENAME_SUFFIX),\n );\n if (files.length === 0) {\n return null;\n } else {\n const firstFile = files[0];\n const filePath = join(this._tempDirectory, firstFile);\n const payload = await readFile(filePath);\n // delete the file first to prevent double sending\n await unlink(filePath);\n return payload;\n }\n }\n return null;\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n // File does not exist -- return null instead of throwing\n return null;\n } else {\n throw e;\n }\n }\n }\n\n /**\n * Stores telemetry data to disk.\n * @param payload - The telemetry data to store.\n * @param envelopeLength -The length of the telemetry envelope.\n * @returns A promise that resolves to true if the data was stored successfully, false otherwise.\n */\n private async _storeToDisk(payload: string, envelopes: Envelope[]): Promise<boolean> {\n try {\n await confirmDirExists(this._tempDirectory);\n } catch (error: any) {\n // Check if error is due to permission/readonly issues\n if (error?.code === \"EACCES\" || error?.code === \"EPERM\") {\n this._customerSDKStatsMetrics?.countDroppedItems(envelopes, DropCode.CLIENT_READONLY);\n diag.warn(\n `Permission denied while checking/creating directory: ${this._tempDirectory}`,\n error?.message,\n );\n } else {\n diag.warn(`Error while checking/creating directory: `, error && error.message);\n }\n return false;\n }\n\n try {\n const size = await getShallowDirectorySize(this._tempDirectory);\n if (size > this.maxBytesOnDisk) {\n // If the directory size exceeds the max limit, we send customer SDK Stats and warn the user\n this._customerSDKStatsMetrics?.countDroppedItems(\n envelopes,\n DropCode.CLIENT_PERSISTENCE_CAPACITY,\n );\n diag.warn(\n `Not saving data due to max size limit being met. Directory size in bytes is: ${size}`,\n );\n return false;\n }\n } catch (error: any) {\n diag.warn(`Error while checking size of persistence directory: `, error && error.message);\n return false;\n }\n\n const fileName = `${new Date().getTime()}${FileSystemPersist.FILENAME_SUFFIX}`;\n const fileFullPath = join(this._tempDirectory, fileName);\n\n // Mode 600 is w/r for creator and no read access for others\n diag.info(`saving data to disk at: ${fileFullPath}`);\n try {\n await writeFile(fileFullPath, payload, { mode: 0o600 });\n } catch (writeError: any) {\n // If the envelopes cannot be written to disk, we send customer SDK Stats and warn the user\n this._customerSDKStatsMetrics?.countDroppedItems(\n envelopes,\n DropCode.CLIENT_EXCEPTION,\n writeError?.message,\n ExceptionType.STORAGE_EXCEPTION,\n );\n diag.warn(`Error writing file to persistent file storage`, writeError);\n return false;\n }\n return true;\n }\n\n private async _fileCleanupTask(): Promise<boolean> {\n try {\n const stats = await stat(this._tempDirectory);\n if (stats.isDirectory()) {\n const origFiles = await readdir(this._tempDirectory);\n const files = origFiles.filter((f) =>\n basename(f).includes(FileSystemPersist.FILENAME_SUFFIX),\n );\n if (files.length === 0) {\n return false;\n } else {\n files.forEach(async (file) => {\n // Check expiration\n const fileCreationDate: Date = new Date(\n parseInt(file.split(FileSystemPersist.FILENAME_SUFFIX)[0]),\n );\n const expired = new Date(+new Date() - this.fileRetemptionPeriod) > fileCreationDate;\n if (expired) {\n const filePath = join(this._tempDirectory, file);\n await unlink(filePath);\n }\n });\n return true;\n }\n }\n return false;\n } catch (error: any) {\n diag.info(`Failed cleanup of persistent file storage expired files`, error);\n return false;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fileSystemPersist.js","sourceRoot":"","sources":["../../../../../src/platform/nodejs/persist/fileSystemPersist.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,wBAAw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AAC;IAC7C,CAAC;IAED,IAAI,UAAkB,CAAC;IACvB,IAAI,gBAAgB,EAAE,CAAC;QACrB,UAAU,GAAG,gBAAgB,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,UAAU,GAAG,MAAM,EAAE,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,CACT,UAAU,EACV,yBAAyB,GAAG,YAAY,EACxC,iBAAiB,CAAC,cAAc,GAAG,kBAAkB,CACtD,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { tmpdir, userInfo } from \"node:os\";\nimport { basename, join, dirname } from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport { diag } from \"@opentelemetry/api\";\nimport type { PersistentStorage } from \"../../../types.js\";\nimport { FileAccessControl } from \"./fileAccessControl.js\";\nimport { confirmDirExists, getShallowDirectorySize } from \"./fileSystemHelpers.js\";\nimport type { AzureMonitorExporterOptions } from \"../../../config.js\";\nimport { readdir, readFile, stat, unlink, writeFile } from \"node:fs/promises\";\nimport type { CustomerSDKStatsMetrics } from \"../../../export/statsbeat/customerSDKStats.js\";\nimport { DropCode, ExceptionType } from \"../../../export/statsbeat/types.js\";\nimport type { TelemetryItem as Envelope } from \"../../../generated/index.js\";\n\n/**\n * File system persist class.\n * @internal\n */\nexport class FileSystemPersist implements PersistentStorage {\n static TEMPDIR_PREFIX = \"opentelemetry-nodejs-\";\n static FILENAME_SUFFIX = \".ai.json\";\n\n fileRetemptionPeriod = 2 * 24 * 60 * 60 * 1000; // 2 days\n cleanupTimeOut = 60 * 60 * 1000; // 1 hour\n maxBytesOnDisk: number = 50_000_000; // ~50MB\n\n private _enabled: boolean;\n private _tempDirectory: string = \"\";\n private _fileCleanupTimer: NodeJS.Timeout | null = null;\n private _instrumentationKey: string;\n\n constructor(\n instrumentationKey: string,\n private _options?: AzureMonitorExporterOptions,\n private _customerSDKStatsMetrics?: CustomerSDKStatsMetrics,\n ) {\n this._instrumentationKey = instrumentationKey;\n if (this._options?.disableOfflineStorage) {\n this._enabled = false;\n return;\n }\n this._enabled = true;\n FileAccessControl.checkFileProtection();\n\n if (!FileAccessControl.OS_PROVIDES_FILE_PROTECTION) {\n this._enabled = false;\n diag.error(\n \"Sufficient file protection capabilities were not detected. Files will not be persisted\",\n );\n }\n\n if (!this._instrumentationKey) {\n this._enabled = false;\n diag.error(\n `No instrumentation key was provided to FileSystemPersister. Files will not be persisted`,\n );\n }\n if (this._enabled) {\n this._tempDirectory = getStorageDirectory(\n this._instrumentationKey,\n this._options?.storageDirectory,\n );\n\n // Starts file cleanup task\n if (!this._fileCleanupTimer) {\n this._fileCleanupTimer = setTimeout(() => {\n this._fileCleanupTask();\n }, this.cleanupTimeOut);\n this._fileCleanupTimer.unref();\n }\n }\n }\n\n push(value: unknown[]): Promise<boolean> {\n if (this._enabled) {\n diag.debug(\"Pushing value to persistent storage\", value.toString());\n return this._storeToDisk(JSON.stringify(value), value as Envelope[]);\n }\n // Only return a false promise if the SDK isn't set to disable offline storage\n if (!this._options?.disableOfflineStorage) {\n return new Promise((resolve) => {\n resolve(false);\n });\n }\n return new Promise((resolve) => {\n resolve(true);\n });\n }\n\n async shift(): Promise<unknown> {\n if (this._enabled) {\n diag.debug(\"Searching for filesystem persisted files\");\n try {\n const buffer = await this._getFirstFileOnDisk();\n if (buffer) {\n return JSON.parse(buffer.toString(\"utf8\"));\n }\n } catch (e: any) {\n diag.debug(\"Failed to read persisted file\", e);\n }\n return null;\n }\n return new Promise((resolve) => {\n resolve(null);\n });\n }\n\n /**\n * Check for temp telemetry files\n * reads the first file if exist, deletes it and tries to send its load\n */\n private async _getFirstFileOnDisk(): Promise<Buffer | null> {\n try {\n const stats = await stat(this._tempDirectory);\n if (stats.isDirectory()) {\n const origFiles = await readdir(this._tempDirectory);\n const files = origFiles.filter((f) =>\n basename(f).includes(FileSystemPersist.FILENAME_SUFFIX),\n );\n if (files.length === 0) {\n return null;\n } else {\n const firstFile = files[0];\n const filePath = join(this._tempDirectory, firstFile);\n const payload = await readFile(filePath);\n // delete the file first to prevent double sending\n await unlink(filePath);\n return payload;\n }\n }\n return null;\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n // File does not exist -- return null instead of throwing\n return null;\n } else {\n throw e;\n }\n }\n }\n\n /**\n * Stores telemetry data to disk.\n * @param payload - The telemetry data to store.\n * @param envelopeLength -The length of the telemetry envelope.\n * @returns A promise that resolves to true if the data was stored successfully, false otherwise.\n */\n private async _storeToDisk(payload: string, envelopes: Envelope[]): Promise<boolean> {\n try {\n await confirmDirExists(this._tempDirectory);\n } catch (error: any) {\n // Check if error is due to permission/readonly issues\n if (error?.code === \"EACCES\" || error?.code === \"EPERM\") {\n this._customerSDKStatsMetrics?.countDroppedItems(envelopes, DropCode.CLIENT_READONLY);\n diag.warn(\n `Permission denied while checking/creating directory: ${this._tempDirectory}`,\n error?.message,\n );\n } else {\n diag.warn(`Error while checking/creating directory: `, error && error.message);\n }\n return false;\n }\n\n try {\n const size = await getShallowDirectorySize(this._tempDirectory);\n if (size > this.maxBytesOnDisk) {\n // If the directory size exceeds the max limit, we send customer SDK Stats and warn the user\n this._customerSDKStatsMetrics?.countDroppedItems(\n envelopes,\n DropCode.CLIENT_PERSISTENCE_CAPACITY,\n );\n diag.warn(\n `Not saving data due to max size limit being met. Directory size in bytes is: ${size}`,\n );\n return false;\n }\n } catch (error: any) {\n diag.warn(`Error while checking size of persistence directory: `, error && error.message);\n return false;\n }\n\n const fileName = `${new Date().getTime()}${FileSystemPersist.FILENAME_SUFFIX}`;\n const fileFullPath = join(this._tempDirectory, fileName);\n\n // Mode 600 is w/r for creator and no read access for others\n diag.info(`saving data to disk at: ${fileFullPath}`);\n try {\n await writeFile(fileFullPath, payload, { mode: 0o600 });\n } catch (writeError: any) {\n // If the envelopes cannot be written to disk, we send customer SDK Stats and warn the user\n this._customerSDKStatsMetrics?.countDroppedItems(\n envelopes,\n DropCode.CLIENT_EXCEPTION,\n writeError?.message,\n ExceptionType.STORAGE_EXCEPTION,\n );\n diag.warn(`Error writing file to persistent file storage`, writeError);\n return false;\n }\n return true;\n }\n\n private async _fileCleanupTask(): Promise<boolean> {\n try {\n const stats = await stat(this._tempDirectory);\n if (stats.isDirectory()) {\n const origFiles = await readdir(this._tempDirectory);\n const files = origFiles.filter((f) =>\n basename(f).includes(FileSystemPersist.FILENAME_SUFFIX),\n );\n if (files.length === 0) {\n return false;\n } else {\n files.forEach(async (file) => {\n // Check expiration\n const fileCreationDate: Date = new Date(\n parseInt(file.split(FileSystemPersist.FILENAME_SUFFIX)[0]),\n );\n const expired = new Date(+new Date() - this.fileRetemptionPeriod) > fileCreationDate;\n if (expired) {\n const filePath = join(this._tempDirectory, file);\n await unlink(filePath);\n }\n });\n return true;\n }\n }\n return false;\n } catch (error: any) {\n diag.info(`Failed cleanup of persistent file storage expired files`, error);\n return false;\n }\n }\n}\n\n/**\n * Return the deterministic local storage path for a given instrumentation key.\n *\n * On shared Linux hosts the first user to create `/tmp/Microsoft/AzureMonitor` can\n * block others because the directory inherits that user's `umask`. This is avoided by\n * inserting a hash of the instrumentation key, user name, process name, and\n * application directory, giving each user their own subdirectory, e.g.\n * `/tmp/Microsoft-AzureMonitor-1234...../opentelemetry-nodejs-<ikey>`.\n *\n * @param instrumentationKey - Application Insights instrumentation key.\n * @param storageDirectory - Optional custom storage directory path. If not provided, system temp directory is used.\n * @returns Absolute path to the storage directory.\n * @internal\n */\nexport function getStorageDirectory(\n instrumentationKey: string,\n storageDirectory: string | undefined,\n): string {\n let userSegment: string;\n let processName: string;\n let applicationDirectory: string;\n try {\n const user = userInfo();\n userSegment = user.username;\n } catch (error) {\n userSegment = \"\";\n }\n if (process.title.length > 0) {\n processName = process.title;\n } else {\n processName = \"\";\n }\n const applicationDir = dirname(process.cwd() || process.argv[1]);\n if (applicationDir) {\n applicationDirectory = applicationDir;\n } else {\n applicationDirectory = \"\";\n }\n const hash_input = `${instrumentationKey}|${userSegment}|${processName}|${applicationDirectory}`;\n\n let subDirectory: string;\n try {\n subDirectory = createHash(\"sha256\").update(hash_input).digest(\"hex\");\n } catch (error) {\n let hash = 5381;\n for (let i = 0; i < hash_input.length; i++) {\n const char = hash_input.charCodeAt(i);\n hash = (hash << 5) + hash + char;\n hash = hash & hash;\n }\n subDirectory = Math.abs(hash).toString(16);\n }\n\n let sharedRoot: string;\n if (storageDirectory) {\n sharedRoot = storageDirectory;\n } else {\n sharedRoot = tmpdir();\n }\n return join(\n sharedRoot,\n \"Microsoft-AzureMonitor-\" + subDirectory,\n FileSystemPersist.TEMPDIR_PREFIX + instrumentationKey,\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Tags } from "../types.js";
|
|
2
2
|
import type { TelemetryItem as Envelope } from "../generated/index.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type Resource } from "@opentelemetry/resources";
|
|
4
4
|
import type { Attributes, HrTime } from "@opentelemetry/api";
|
|
5
5
|
import type { AnyValue } from "@opentelemetry/api-logs";
|
|
6
6
|
export declare function hrTimeToDate(hrTime: HrTime): Date;
|
|
@@ -8,7 +8,7 @@ export declare function createTagsFromResource(resource: Resource): Tags;
|
|
|
8
8
|
export declare function isSqlDB(dbSystem: string): boolean;
|
|
9
9
|
export declare function getUrl(attributes: Attributes): string;
|
|
10
10
|
export declare function getDependencyTarget(attributes: Attributes): string;
|
|
11
|
-
export declare function createResourceMetricEnvelope(resource: Resource, instrumentationKey: string): Envelope | undefined;
|
|
11
|
+
export declare function createResourceMetricEnvelope(resource: Resource, instrumentationKey: string, applicationId?: string): Envelope | undefined;
|
|
12
12
|
export declare function serializeAttribute(value: AnyValue): string;
|
|
13
13
|
export declare function shouldCreateResourceMetric(): boolean;
|
|
14
14
|
export declare function isSyntheticSource(attributes: Attributes): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAmC,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAe,MAAM,uBAAuB,CAAC;AAEpF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAmC,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAe,MAAM,uBAAuB,CAAC;AAEpF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAgBxD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAkB/D;AAmED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAYjD;AAED,wBAAgB,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAkCrD;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAqBlE;AAED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,QAAQ,EAClB,kBAAkB,EAAE,MAAM,EAC1B,aAAa,CAAC,EAAE,MAAM,GACrB,QAAQ,GAAG,SAAS,CA8CtB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAsB1D;AAED,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAEjE"}
|
package/dist/esm/utils/common.js
CHANGED
|
@@ -6,7 +6,7 @@ import { experimentalOpenTelemetryValues } from "../types.js";
|
|
|
6
6
|
import { getInstance } from "../platform/index.js";
|
|
7
7
|
import { KnownContextTagKeys } from "../generated/index.js";
|
|
8
8
|
import { hrTimeToNanoseconds } from "@opentelemetry/core";
|
|
9
|
-
import { ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED } from "../Declarations/Constants.js";
|
|
9
|
+
import { APPLICATION_ID_RESOURCE_KEY, ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED, } from "../Declarations/Constants.js";
|
|
10
10
|
import { getHttpHost, getHttpMethod, getHttpScheme, getHttpTarget, getHttpUrl, getNetPeerName, getNetPeerPort, getPeerIp, } from "./spanUtils.js";
|
|
11
11
|
export function hrTimeToDate(hrTime) {
|
|
12
12
|
return new Date(hrTimeToNanoseconds(hrTime) / 1000000);
|
|
@@ -14,17 +14,18 @@ export function hrTimeToDate(hrTime) {
|
|
|
14
14
|
export function createTagsFromResource(resource) {
|
|
15
15
|
const context = getInstance();
|
|
16
16
|
const tags = { ...context.tags };
|
|
17
|
-
|
|
17
|
+
const attributes = resource?.attributes;
|
|
18
|
+
if (attributes) {
|
|
18
19
|
tags[KnownContextTagKeys.AiCloudRole] = getCloudRole(resource);
|
|
19
20
|
tags[KnownContextTagKeys.AiCloudRoleInstance] = getCloudRoleInstance(resource);
|
|
20
|
-
if (
|
|
21
|
-
tags[KnownContextTagKeys.AiDeviceId] = String(
|
|
21
|
+
if (attributes[SEMRESATTRS_DEVICE_ID]) {
|
|
22
|
+
tags[KnownContextTagKeys.AiDeviceId] = String(attributes[SEMRESATTRS_DEVICE_ID]);
|
|
22
23
|
}
|
|
23
|
-
if (
|
|
24
|
-
tags[KnownContextTagKeys.AiDeviceModel] = String(
|
|
24
|
+
if (attributes[SEMRESATTRS_DEVICE_MODEL_NAME]) {
|
|
25
|
+
tags[KnownContextTagKeys.AiDeviceModel] = String(attributes[SEMRESATTRS_DEVICE_MODEL_NAME]);
|
|
25
26
|
}
|
|
26
|
-
if (
|
|
27
|
-
tags[KnownContextTagKeys.AiApplicationVer] = String(
|
|
27
|
+
if (attributes[SEMRESATTRS_SERVICE_VERSION]) {
|
|
28
|
+
tags[KnownContextTagKeys.AiApplicationVer] = String(attributes[SEMRESATTRS_SERVICE_VERSION]);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
return tags;
|
|
@@ -170,17 +171,21 @@ export function getDependencyTarget(attributes) {
|
|
|
170
171
|
}
|
|
171
172
|
return "";
|
|
172
173
|
}
|
|
173
|
-
export function createResourceMetricEnvelope(resource, instrumentationKey) {
|
|
174
|
-
|
|
174
|
+
export function createResourceMetricEnvelope(resource, instrumentationKey, applicationId) {
|
|
175
|
+
const attributes = resource.attributes;
|
|
176
|
+
if (attributes) {
|
|
175
177
|
const tags = createTagsFromResource(resource);
|
|
176
178
|
const resourceAttributes = {};
|
|
177
|
-
|
|
179
|
+
if (applicationId && !attributes[APPLICATION_ID_RESOURCE_KEY]) {
|
|
180
|
+
resourceAttributes[APPLICATION_ID_RESOURCE_KEY] = applicationId;
|
|
181
|
+
}
|
|
182
|
+
for (const key of Object.keys(attributes)) {
|
|
178
183
|
// Avoid duplication ignoring fields already mapped.
|
|
179
184
|
if (!(key.startsWith("_MS.") ||
|
|
180
185
|
key === ATTR_TELEMETRY_SDK_VERSION ||
|
|
181
186
|
key === ATTR_TELEMETRY_SDK_LANGUAGE ||
|
|
182
187
|
key === ATTR_TELEMETRY_SDK_NAME)) {
|
|
183
|
-
resourceAttributes[key] =
|
|
188
|
+
resourceAttributes[key] = attributes[key];
|
|
184
189
|
}
|
|
185
190
|
}
|
|
186
191
|
// Only send event when resource attributes are available
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,2BAA2B,EAC3B,wBAAwB,EACxB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AED,MAAM,UAAU,iBAAiB,CAAC,UAAsB;IACtD,OAAO,CAAC,CAAC,UAAU,CAAC,+BAA+B,CAAC,cAAc,CAAC,CAAC;AACtE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport os from \"node:os\";\nimport {\n SEMRESATTRS_DEVICE_ID,\n SEMRESATTRS_DEVICE_MODEL_NAME,\n SEMRESATTRS_SERVICE_VERSION,\n SEMRESATTRS_K8S_POD_NAME,\n SEMRESATTRS_SERVICE_INSTANCE_ID,\n DBSYSTEMVALUES_DB2,\n DBSYSTEMVALUES_DERBY,\n DBSYSTEMVALUES_MARIADB,\n DBSYSTEMVALUES_MSSQL,\n DBSYSTEMVALUES_ORACLE,\n DBSYSTEMVALUES_SQLITE,\n DBSYSTEMVALUES_OTHER_SQL,\n DBSYSTEMVALUES_HSQLDB,\n SEMATTRS_PEER_SERVICE,\n SEMRESATTRS_SERVICE_NAME,\n SEMRESATTRS_SERVICE_NAMESPACE,\n SEMRESATTRS_K8S_DEPLOYMENT_NAME,\n SEMRESATTRS_K8S_REPLICASET_NAME,\n SEMRESATTRS_K8S_STATEFULSET_NAME,\n SEMRESATTRS_K8S_JOB_NAME,\n SEMRESATTRS_K8S_CRONJOB_NAME,\n SEMRESATTRS_K8S_DAEMONSET_NAME,\n ATTR_TELEMETRY_SDK_VERSION,\n ATTR_TELEMETRY_SDK_LANGUAGE,\n ATTR_TELEMETRY_SDK_NAME,\n DBSYSTEMVALUES_H2,\n} from \"@opentelemetry/semantic-conventions\";\nimport { experimentalOpenTelemetryValues, type Tags } from \"../types.js\";\nimport { getInstance } from \"../platform/index.js\";\nimport type { TelemetryItem as Envelope, MetricsData } from \"../generated/index.js\";\nimport { KnownContextTagKeys } from \"../generated/index.js\";\nimport type { Resource } from \"@opentelemetry/resources\";\nimport type { Attributes, HrTime } from \"@opentelemetry/api\";\nimport { hrTimeToNanoseconds } from \"@opentelemetry/core\";\nimport type { AnyValue } from \"@opentelemetry/api-logs\";\nimport { ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED } from \"../Declarations/Constants.js\";\nimport {\n getHttpHost,\n getHttpMethod,\n getHttpScheme,\n getHttpTarget,\n getHttpUrl,\n getNetPeerName,\n getNetPeerPort,\n getPeerIp,\n} from \"./spanUtils.js\";\n\nexport function hrTimeToDate(hrTime: HrTime): Date {\n return new Date(hrTimeToNanoseconds(hrTime) / 1000000);\n}\n\nexport function createTagsFromResource(resource: Resource): Tags {\n const context = getInstance();\n const tags: Tags = { ...context.tags };\n if (resource && resource.attributes) {\n tags[KnownContextTagKeys.AiCloudRole] = getCloudRole(resource);\n tags[KnownContextTagKeys.AiCloudRoleInstance] = getCloudRoleInstance(resource);\n if (resource.attributes[SEMRESATTRS_DEVICE_ID]) {\n tags[KnownContextTagKeys.AiDeviceId] = String(resource.attributes[SEMRESATTRS_DEVICE_ID]);\n }\n if (resource.attributes[SEMRESATTRS_DEVICE_MODEL_NAME]) {\n tags[KnownContextTagKeys.AiDeviceModel] = String(\n resource.attributes[SEMRESATTRS_DEVICE_MODEL_NAME],\n );\n }\n if (resource.attributes[SEMRESATTRS_SERVICE_VERSION]) {\n tags[KnownContextTagKeys.AiApplicationVer] = String(\n resource.attributes[SEMRESATTRS_SERVICE_VERSION],\n );\n }\n }\n return tags;\n}\n\nfunction getCloudRole(resource: Resource): string {\n let cloudRole = \"\";\n // Service attributes\n const serviceName = resource.attributes[SEMRESATTRS_SERVICE_NAME];\n const serviceNamespace = resource.attributes[SEMRESATTRS_SERVICE_NAMESPACE];\n if (serviceName) {\n // Custom Service name provided by customer is highest precedence\n if (!String(serviceName).startsWith(\"unknown_service\")) {\n if (serviceNamespace) {\n return `${serviceNamespace}.${serviceName}`;\n } else {\n return String(serviceName);\n }\n } else {\n // Service attributes will be only used if K8S attributes are not present\n if (serviceNamespace) {\n cloudRole = `${serviceNamespace}.${serviceName}`;\n } else {\n cloudRole = String(serviceName);\n }\n }\n }\n // Kubernetes attributes should take precedence\n const kubernetesDeploymentName = resource.attributes[SEMRESATTRS_K8S_DEPLOYMENT_NAME];\n if (kubernetesDeploymentName) {\n return String(kubernetesDeploymentName);\n }\n const kuberneteReplicasetName = resource.attributes[SEMRESATTRS_K8S_REPLICASET_NAME];\n if (kuberneteReplicasetName) {\n return String(kuberneteReplicasetName);\n }\n const kubernetesStatefulSetName = resource.attributes[SEMRESATTRS_K8S_STATEFULSET_NAME];\n if (kubernetesStatefulSetName) {\n return String(kubernetesStatefulSetName);\n }\n const kubernetesJobName = resource.attributes[SEMRESATTRS_K8S_JOB_NAME];\n if (kubernetesJobName) {\n return String(kubernetesJobName);\n }\n const kubernetesCronjobName = resource.attributes[SEMRESATTRS_K8S_CRONJOB_NAME];\n if (kubernetesCronjobName) {\n return String(kubernetesCronjobName);\n }\n const kubernetesDaemonsetName = resource.attributes[SEMRESATTRS_K8S_DAEMONSET_NAME];\n if (kubernetesDaemonsetName) {\n return String(kubernetesDaemonsetName);\n }\n return cloudRole;\n}\n\nfunction getCloudRoleInstance(resource: Resource): string {\n // Kubernetes attributes should take precedence\n const kubernetesPodName = resource.attributes[SEMRESATTRS_K8S_POD_NAME];\n if (kubernetesPodName) {\n return String(kubernetesPodName);\n }\n // Service attributes\n const serviceInstanceId = resource.attributes[SEMRESATTRS_SERVICE_INSTANCE_ID];\n if (serviceInstanceId) {\n return String(serviceInstanceId);\n }\n // Default\n return os && os.hostname();\n}\n\nexport function isSqlDB(dbSystem: string): boolean {\n return (\n dbSystem === DBSYSTEMVALUES_DB2 ||\n dbSystem === DBSYSTEMVALUES_DERBY ||\n dbSystem === DBSYSTEMVALUES_MARIADB ||\n dbSystem === DBSYSTEMVALUES_MSSQL ||\n dbSystem === DBSYSTEMVALUES_ORACLE ||\n dbSystem === DBSYSTEMVALUES_SQLITE ||\n dbSystem === DBSYSTEMVALUES_OTHER_SQL ||\n dbSystem === DBSYSTEMVALUES_HSQLDB ||\n dbSystem === DBSYSTEMVALUES_H2\n );\n}\n\nexport function getUrl(attributes: Attributes): string {\n if (!attributes) {\n return \"\";\n }\n const httpMethod = getHttpMethod(attributes);\n if (httpMethod) {\n const httpUrl = getHttpUrl(attributes);\n if (httpUrl) {\n return String(httpUrl);\n } else {\n const httpScheme = getHttpScheme(attributes);\n const httpTarget = getHttpTarget(attributes);\n if (httpScheme && httpTarget) {\n const httpHost = getHttpHost(attributes);\n if (httpHost) {\n return `${httpScheme}://${httpHost}${httpTarget}`;\n } else {\n const netPeerPort = getNetPeerPort(attributes);\n if (netPeerPort) {\n const netPeerName = getNetPeerName(attributes);\n if (netPeerName) {\n return `${httpScheme}://${netPeerName}:${netPeerPort}${httpTarget}`;\n } else {\n const netPeerIp = getPeerIp(attributes);\n if (netPeerIp) {\n return `${httpScheme}://${netPeerIp}:${netPeerPort}${httpTarget}`;\n }\n }\n }\n }\n }\n }\n }\n return \"\";\n}\n\nexport function getDependencyTarget(attributes: Attributes): string {\n if (!attributes) {\n return \"\";\n }\n const peerService = attributes[SEMATTRS_PEER_SERVICE];\n const httpHost = getHttpHost(attributes);\n const httpUrl = getHttpUrl(attributes);\n const netPeerName = getNetPeerName(attributes);\n const netPeerIp = getPeerIp(attributes);\n if (peerService) {\n return String(peerService);\n } else if (httpHost) {\n return String(httpHost);\n } else if (httpUrl) {\n return String(httpUrl);\n } else if (netPeerName) {\n return String(netPeerName);\n } else if (netPeerIp) {\n return String(netPeerIp);\n }\n return \"\";\n}\n\nexport function createResourceMetricEnvelope(\n resource: Resource,\n instrumentationKey: string,\n): Envelope | undefined {\n if (resource && resource.attributes) {\n const tags = createTagsFromResource(resource);\n const resourceAttributes: { [propertyName: string]: string } = {};\n for (const key of Object.keys(resource.attributes)) {\n // Avoid duplication ignoring fields already mapped.\n if (\n !(\n key.startsWith(\"_MS.\") ||\n key === ATTR_TELEMETRY_SDK_VERSION ||\n key === ATTR_TELEMETRY_SDK_LANGUAGE ||\n key === ATTR_TELEMETRY_SDK_NAME\n )\n ) {\n resourceAttributes[key] = resource.attributes[key] as string;\n }\n }\n // Only send event when resource attributes are available\n if (Object.keys(resourceAttributes).length > 0) {\n const baseData: MetricsData = {\n version: 2,\n metrics: [{ name: \"_OTELRESOURCE_\", value: 1 }],\n properties: resourceAttributes,\n };\n const envelope: Envelope = {\n name: \"Microsoft.ApplicationInsights.Metric\",\n time: new Date(),\n sampleRate: 100, // Metrics are never sampled\n instrumentationKey: instrumentationKey,\n version: 1,\n data: {\n baseType: \"MetricData\",\n baseData: baseData,\n },\n tags: tags,\n };\n return envelope;\n }\n }\n return;\n}\n\nexport function serializeAttribute(value: AnyValue): string {\n if (typeof value === \"object\") {\n if (value instanceof Error) {\n try {\n return JSON.stringify(value, Object.getOwnPropertyNames(value));\n } catch (err: unknown) {\n // Failed to serialize, return string cast\n return String(value);\n }\n } else if (value instanceof Uint8Array) {\n return String(value);\n } else {\n try {\n return JSON.stringify(value);\n } catch (err: unknown) {\n // Failed to serialize, return string cast\n return String(value);\n }\n }\n }\n // Return scalar and undefined values\n return String(value);\n}\n\nexport function shouldCreateResourceMetric(): boolean {\n return !(process.env[ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED]?.toLowerCase() === \"true\");\n}\n\nexport function isSyntheticSource(attributes: Attributes): boolean {\n return !!attributes[experimentalOpenTelemetryValues.SYNTHETIC_TYPE];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,2BAA2B,EAC3B,wBAAwB,EACxB,+BAA+B,EAC/B,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/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;AACtE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport os from \"node:os\";\nimport {\n SEMRESATTRS_DEVICE_ID,\n SEMRESATTRS_DEVICE_MODEL_NAME,\n SEMRESATTRS_SERVICE_VERSION,\n SEMRESATTRS_K8S_POD_NAME,\n SEMRESATTRS_SERVICE_INSTANCE_ID,\n DBSYSTEMVALUES_DB2,\n DBSYSTEMVALUES_DERBY,\n DBSYSTEMVALUES_MARIADB,\n DBSYSTEMVALUES_MSSQL,\n DBSYSTEMVALUES_ORACLE,\n DBSYSTEMVALUES_SQLITE,\n DBSYSTEMVALUES_OTHER_SQL,\n DBSYSTEMVALUES_HSQLDB,\n SEMATTRS_PEER_SERVICE,\n SEMRESATTRS_SERVICE_NAME,\n SEMRESATTRS_SERVICE_NAMESPACE,\n SEMRESATTRS_K8S_DEPLOYMENT_NAME,\n SEMRESATTRS_K8S_REPLICASET_NAME,\n SEMRESATTRS_K8S_STATEFULSET_NAME,\n SEMRESATTRS_K8S_JOB_NAME,\n SEMRESATTRS_K8S_CRONJOB_NAME,\n SEMRESATTRS_K8S_DAEMONSET_NAME,\n ATTR_TELEMETRY_SDK_VERSION,\n ATTR_TELEMETRY_SDK_LANGUAGE,\n ATTR_TELEMETRY_SDK_NAME,\n DBSYSTEMVALUES_H2,\n} from \"@opentelemetry/semantic-conventions\";\nimport { experimentalOpenTelemetryValues, type Tags } from \"../types.js\";\nimport { getInstance } from \"../platform/index.js\";\nimport type { TelemetryItem as Envelope, MetricsData } from \"../generated/index.js\";\nimport { KnownContextTagKeys } from \"../generated/index.js\";\nimport { type Resource } from \"@opentelemetry/resources\";\nimport type { Attributes, HrTime } from \"@opentelemetry/api\";\nimport { hrTimeToNanoseconds } from \"@opentelemetry/core\";\nimport type { AnyValue } from \"@opentelemetry/api-logs\";\nimport {\n APPLICATION_ID_RESOURCE_KEY,\n ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED,\n} from \"../Declarations/Constants.js\";\nimport {\n getHttpHost,\n getHttpMethod,\n getHttpScheme,\n getHttpTarget,\n getHttpUrl,\n getNetPeerName,\n getNetPeerPort,\n getPeerIp,\n} from \"./spanUtils.js\";\n\nexport function hrTimeToDate(hrTime: HrTime): Date {\n return new Date(hrTimeToNanoseconds(hrTime) / 1000000);\n}\n\nexport function createTagsFromResource(resource: Resource): Tags {\n const context = getInstance();\n const tags: Tags = { ...context.tags };\n const attributes = resource?.attributes;\n if (attributes) {\n tags[KnownContextTagKeys.AiCloudRole] = getCloudRole(resource);\n tags[KnownContextTagKeys.AiCloudRoleInstance] = getCloudRoleInstance(resource);\n if (attributes[SEMRESATTRS_DEVICE_ID]) {\n tags[KnownContextTagKeys.AiDeviceId] = String(attributes[SEMRESATTRS_DEVICE_ID]);\n }\n if (attributes[SEMRESATTRS_DEVICE_MODEL_NAME]) {\n tags[KnownContextTagKeys.AiDeviceModel] = String(attributes[SEMRESATTRS_DEVICE_MODEL_NAME]);\n }\n if (attributes[SEMRESATTRS_SERVICE_VERSION]) {\n tags[KnownContextTagKeys.AiApplicationVer] = String(attributes[SEMRESATTRS_SERVICE_VERSION]);\n }\n }\n return tags;\n}\n\nfunction getCloudRole(resource: Resource): string {\n let cloudRole = \"\";\n // Service attributes\n const serviceName = resource.attributes[SEMRESATTRS_SERVICE_NAME];\n const serviceNamespace = resource.attributes[SEMRESATTRS_SERVICE_NAMESPACE];\n if (serviceName) {\n // Custom Service name provided by customer is highest precedence\n if (!String(serviceName).startsWith(\"unknown_service\")) {\n if (serviceNamespace) {\n return `${serviceNamespace}.${serviceName}`;\n } else {\n return String(serviceName);\n }\n } else {\n // Service attributes will be only used if K8S attributes are not present\n if (serviceNamespace) {\n cloudRole = `${serviceNamespace}.${serviceName}`;\n } else {\n cloudRole = String(serviceName);\n }\n }\n }\n // Kubernetes attributes should take precedence\n const kubernetesDeploymentName = resource.attributes[SEMRESATTRS_K8S_DEPLOYMENT_NAME];\n if (kubernetesDeploymentName) {\n return String(kubernetesDeploymentName);\n }\n const kuberneteReplicasetName = resource.attributes[SEMRESATTRS_K8S_REPLICASET_NAME];\n if (kuberneteReplicasetName) {\n return String(kuberneteReplicasetName);\n }\n const kubernetesStatefulSetName = resource.attributes[SEMRESATTRS_K8S_STATEFULSET_NAME];\n if (kubernetesStatefulSetName) {\n return String(kubernetesStatefulSetName);\n }\n const kubernetesJobName = resource.attributes[SEMRESATTRS_K8S_JOB_NAME];\n if (kubernetesJobName) {\n return String(kubernetesJobName);\n }\n const kubernetesCronjobName = resource.attributes[SEMRESATTRS_K8S_CRONJOB_NAME];\n if (kubernetesCronjobName) {\n return String(kubernetesCronjobName);\n }\n const kubernetesDaemonsetName = resource.attributes[SEMRESATTRS_K8S_DAEMONSET_NAME];\n if (kubernetesDaemonsetName) {\n return String(kubernetesDaemonsetName);\n }\n return cloudRole;\n}\n\nfunction getCloudRoleInstance(resource: Resource): string {\n // Kubernetes attributes should take precedence\n const kubernetesPodName = resource.attributes[SEMRESATTRS_K8S_POD_NAME];\n if (kubernetesPodName) {\n return String(kubernetesPodName);\n }\n // Service attributes\n const serviceInstanceId = resource.attributes[SEMRESATTRS_SERVICE_INSTANCE_ID];\n if (serviceInstanceId) {\n return String(serviceInstanceId);\n }\n // Default\n return os && os.hostname();\n}\n\nexport function isSqlDB(dbSystem: string): boolean {\n return (\n dbSystem === DBSYSTEMVALUES_DB2 ||\n dbSystem === DBSYSTEMVALUES_DERBY ||\n dbSystem === DBSYSTEMVALUES_MARIADB ||\n dbSystem === DBSYSTEMVALUES_MSSQL ||\n dbSystem === DBSYSTEMVALUES_ORACLE ||\n dbSystem === DBSYSTEMVALUES_SQLITE ||\n dbSystem === DBSYSTEMVALUES_OTHER_SQL ||\n dbSystem === DBSYSTEMVALUES_HSQLDB ||\n dbSystem === DBSYSTEMVALUES_H2\n );\n}\n\nexport function getUrl(attributes: Attributes): string {\n if (!attributes) {\n return \"\";\n }\n const httpMethod = getHttpMethod(attributes);\n if (httpMethod) {\n const httpUrl = getHttpUrl(attributes);\n if (httpUrl) {\n return String(httpUrl);\n } else {\n const httpScheme = getHttpScheme(attributes);\n const httpTarget = getHttpTarget(attributes);\n if (httpScheme && httpTarget) {\n const httpHost = getHttpHost(attributes);\n if (httpHost) {\n return `${httpScheme}://${httpHost}${httpTarget}`;\n } else {\n const netPeerPort = getNetPeerPort(attributes);\n if (netPeerPort) {\n const netPeerName = getNetPeerName(attributes);\n if (netPeerName) {\n return `${httpScheme}://${netPeerName}:${netPeerPort}${httpTarget}`;\n } else {\n const netPeerIp = getPeerIp(attributes);\n if (netPeerIp) {\n return `${httpScheme}://${netPeerIp}:${netPeerPort}${httpTarget}`;\n }\n }\n }\n }\n }\n }\n }\n return \"\";\n}\n\nexport function getDependencyTarget(attributes: Attributes): string {\n if (!attributes) {\n return \"\";\n }\n const peerService = attributes[SEMATTRS_PEER_SERVICE];\n const httpHost = getHttpHost(attributes);\n const httpUrl = getHttpUrl(attributes);\n const netPeerName = getNetPeerName(attributes);\n const netPeerIp = getPeerIp(attributes);\n if (peerService) {\n return String(peerService);\n } else if (httpHost) {\n return String(httpHost);\n } else if (httpUrl) {\n return String(httpUrl);\n } else if (netPeerName) {\n return String(netPeerName);\n } else if (netPeerIp) {\n return String(netPeerIp);\n }\n return \"\";\n}\n\nexport function createResourceMetricEnvelope(\n resource: Resource,\n instrumentationKey: string,\n applicationId?: string,\n): Envelope | undefined {\n const attributes = resource.attributes;\n if (attributes) {\n const tags = createTagsFromResource(resource);\n const resourceAttributes: { [propertyName: string]: string } = {};\n\n if (applicationId && !attributes[APPLICATION_ID_RESOURCE_KEY]) {\n resourceAttributes[APPLICATION_ID_RESOURCE_KEY] = applicationId;\n }\n\n for (const key of Object.keys(attributes)) {\n // Avoid duplication ignoring fields already mapped.\n if (\n !(\n key.startsWith(\"_MS.\") ||\n key === ATTR_TELEMETRY_SDK_VERSION ||\n key === ATTR_TELEMETRY_SDK_LANGUAGE ||\n key === ATTR_TELEMETRY_SDK_NAME\n )\n ) {\n resourceAttributes[key] = attributes[key] as string;\n }\n }\n // Only send event when resource attributes are available\n if (Object.keys(resourceAttributes).length > 0) {\n const baseData: MetricsData = {\n version: 2,\n metrics: [{ name: \"_OTELRESOURCE_\", value: 1 }],\n properties: resourceAttributes,\n };\n const envelope: Envelope = {\n name: \"Microsoft.ApplicationInsights.Metric\",\n time: new Date(),\n sampleRate: 100, // Metrics are never sampled\n instrumentationKey: instrumentationKey,\n version: 1,\n data: {\n baseType: \"MetricData\",\n baseData: baseData,\n },\n tags: tags,\n };\n return envelope;\n }\n }\n return;\n}\n\nexport function serializeAttribute(value: AnyValue): string {\n if (typeof value === \"object\") {\n if (value instanceof Error) {\n try {\n return JSON.stringify(value, Object.getOwnPropertyNames(value));\n } catch (err: unknown) {\n // Failed to serialize, return string cast\n return String(value);\n }\n } else if (value instanceof Uint8Array) {\n return String(value);\n } else {\n try {\n return JSON.stringify(value);\n } catch (err: unknown) {\n // Failed to serialize, return string cast\n return String(value);\n }\n }\n }\n // Return scalar and undefined values\n return String(value);\n}\n\nexport function shouldCreateResourceMetric(): boolean {\n return !(process.env[ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED]?.toLowerCase() === \"true\");\n}\n\nexport function isSyntheticSource(attributes: Attributes): boolean {\n return !!attributes[experimentalOpenTelemetryValues.SYNTHETIC_TYPE];\n}\n"]}
|
|
@@ -17,7 +17,7 @@ export declare const TIME_SINCE_ENQUEUED = "timeSinceEnqueued";
|
|
|
17
17
|
* AzureMonitorTraceExporter version.
|
|
18
18
|
* @internal
|
|
19
19
|
*/
|
|
20
|
-
export declare const packageVersion = "1.0.0-beta.
|
|
20
|
+
export declare const packageVersion = "1.0.0-beta.37";
|
|
21
21
|
export declare enum DependencyTypes {
|
|
22
22
|
InProc = "InProc",
|
|
23
23
|
QueueMessage = "Queue Message",
|
|
@@ -19,7 +19,7 @@ export const TIME_SINCE_ENQUEUED = "timeSinceEnqueued";
|
|
|
19
19
|
* AzureMonitorTraceExporter version.
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
export const packageVersion = "1.0.0-beta.
|
|
22
|
+
export const packageVersion = "1.0.0-beta.37";
|
|
23
23
|
export var DependencyTypes;
|
|
24
24
|
(function (DependencyTypes) {
|
|
25
25
|
DependencyTypes["InProc"] = "InProc";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applicationinsights.js","sourceRoot":"","sources":["../../../../src/utils/constants/applicationinsights.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC;AACpC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAC5C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAE9C,MAAM,CAAN,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,iDAA8B,CAAA;IAC9B,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,KAAf,eAAe,QAO1B;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAC9D,MAAM,CAAC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAC1D,MAAM,CAAC,MAAM,kCAAkC,GAAG,6BAA6B,CAAC;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAEvD,MAAM,CAAC,MAAM,8BAA8B,GAAG,uCAAuC,CAAC;AACtF,MAAM,CAAC,MAAM,gCAAgC,GAAG,yCAAyC,CAAC;AAC1F,MAAM,CAAC,MAAM,+BAA+B,GAAG,wCAAwC,CAAC;AACxF,MAAM,CAAC,MAAM,mCAAmC,GAAG,4CAA4C,CAAC;AAChG,MAAM,CAAC,MAAM,4BAA4B,GAAG,qCAAqC,CAAC;AAElF,MAAM,CAAC,MAAM,kCAAkC,GAAG,aAAa,CAAC;AAChE,MAAM,CAAC,MAAM,oCAAoC,GAAG,eAAe,CAAC;AACpE,MAAM,CAAC,MAAM,mCAAmC,GAAG,cAAc,CAAC;AAClE,MAAM,CAAC,MAAM,uCAAuC,GAAG,kBAAkB,CAAC;AAC1E,MAAM,CAAC,MAAM,gCAAgC,GAAG,WAAW,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * AI MS Links.\n * @internal\n */\nexport const MS_LINKS = \"_MS.links\";\n/**\n * AI enqueued time attribute.\n * @internal\n */\nexport const ENQUEUED_TIME = \"enqueuedTime\";\n/**\n * AI time since enqueued attribute.\n * @internal\n */\nexport const TIME_SINCE_ENQUEUED = \"timeSinceEnqueued\";\n/**\n * AzureMonitorTraceExporter version.\n * @internal\n */\nexport const packageVersion = \"1.0.0-beta.
|
|
1
|
+
{"version":3,"file":"applicationinsights.js","sourceRoot":"","sources":["../../../../src/utils/constants/applicationinsights.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC;AACpC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAC5C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAE9C,MAAM,CAAN,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,iDAA8B,CAAA;IAC9B,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,KAAf,eAAe,QAO1B;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAC9D,MAAM,CAAC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAC1D,MAAM,CAAC,MAAM,kCAAkC,GAAG,6BAA6B,CAAC;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAEvD,MAAM,CAAC,MAAM,8BAA8B,GAAG,uCAAuC,CAAC;AACtF,MAAM,CAAC,MAAM,gCAAgC,GAAG,yCAAyC,CAAC;AAC1F,MAAM,CAAC,MAAM,+BAA+B,GAAG,wCAAwC,CAAC;AACxF,MAAM,CAAC,MAAM,mCAAmC,GAAG,4CAA4C,CAAC;AAChG,MAAM,CAAC,MAAM,4BAA4B,GAAG,qCAAqC,CAAC;AAElF,MAAM,CAAC,MAAM,kCAAkC,GAAG,aAAa,CAAC;AAChE,MAAM,CAAC,MAAM,oCAAoC,GAAG,eAAe,CAAC;AACpE,MAAM,CAAC,MAAM,mCAAmC,GAAG,cAAc,CAAC;AAClE,MAAM,CAAC,MAAM,uCAAuC,GAAG,kBAAkB,CAAC;AAC1E,MAAM,CAAC,MAAM,gCAAgC,GAAG,WAAW,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * AI MS Links.\n * @internal\n */\nexport const MS_LINKS = \"_MS.links\";\n/**\n * AI enqueued time attribute.\n * @internal\n */\nexport const ENQUEUED_TIME = \"enqueuedTime\";\n/**\n * AI time since enqueued attribute.\n * @internal\n */\nexport const TIME_SINCE_ENQUEUED = \"timeSinceEnqueued\";\n/**\n * AzureMonitorTraceExporter version.\n * @internal\n */\nexport const packageVersion = \"1.0.0-beta.37\";\n\nexport enum DependencyTypes {\n InProc = \"InProc\",\n QueueMessage = \"Queue Message\",\n Sql = \"SQL\",\n Http = \"Http\",\n Grpc = \"GRPC\",\n Wcf = \"WCF Service\",\n}\n\nexport const AzureMonitorSampleRate = \"microsoft.sample_rate\";\nexport const ApplicationInsightsBaseType = \"_MS.baseType\";\nexport const ApplicationInsightsCustomEventName = \"microsoft.custom_event.name\";\nexport const MicrosoftClientIp = \"microsoft.client.ip\";\n\nexport const ApplicationInsightsMessageName = \"Microsoft.ApplicationInsights.Message\";\nexport const ApplicationInsightsExceptionName = \"Microsoft.ApplicationInsights.Exception\";\nexport const ApplicationInsightsPageViewName = \"Microsoft.ApplicationInsights.PageView\";\nexport const ApplicationInsightsAvailabilityName = \"Microsoft.ApplicationInsights.Availability\";\nexport const ApplicationInsightsEventName = \"Microsoft.ApplicationInsights.Event\";\n\nexport const ApplicationInsightsMessageBaseType = \"MessageData\";\nexport const ApplicationInsightsExceptionBaseType = \"ExceptionData\";\nexport const ApplicationInsightsPageViewBaseType = \"PageViewData\";\nexport const ApplicationInsightsAvailabilityBaseType = \"AvailabilityData\";\nexport const ApplicationInsightsEventBaseType = \"EventData\";\n"]}
|
|
@@ -58,7 +58,7 @@ export function logToEnvelope(log, ikey) {
|
|
|
58
58
|
name = ApplicationInsightsMessageName;
|
|
59
59
|
baseType = ApplicationInsightsMessageBaseType;
|
|
60
60
|
const messageData = {
|
|
61
|
-
message:
|
|
61
|
+
message: serializeAttribute(log.body),
|
|
62
62
|
severityLevel: String(getSeverity(log.severityNumber)),
|
|
63
63
|
version: 2,
|
|
64
64
|
};
|
|
@@ -226,7 +226,7 @@ function getLegacyApplicationInsightsBaseData(log) {
|
|
|
226
226
|
break;
|
|
227
227
|
}
|
|
228
228
|
if (typeof baseData?.message === "object") {
|
|
229
|
-
baseData.message =
|
|
229
|
+
baseData.message = serializeAttribute(baseData.message);
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
catch (err) {
|