@azure/monitor-opentelemetry-exporter 1.0.0-beta.14 → 1.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +0 -1
  2. package/dist/index.js +433 -412
  3. package/dist-esm/src/config.js.map +1 -1
  4. package/dist-esm/src/export/base.js +16 -201
  5. package/dist-esm/src/export/base.js.map +1 -1
  6. package/dist-esm/src/export/log.js +10 -5
  7. package/dist-esm/src/export/log.js.map +1 -1
  8. package/dist-esm/src/export/metric.js +8 -6
  9. package/dist-esm/src/export/metric.js.map +1 -1
  10. package/dist-esm/src/export/statsbeat/longIntervalStatsbeatMetrics.js +1 -1
  11. package/dist-esm/src/export/statsbeat/longIntervalStatsbeatMetrics.js.map +1 -1
  12. package/dist-esm/src/export/statsbeat/networkStatsbeatMetrics.js +1 -1
  13. package/dist-esm/src/export/statsbeat/networkStatsbeatMetrics.js.map +1 -1
  14. package/dist-esm/src/export/statsbeat/statsbeatExporter.js +5 -3
  15. package/dist-esm/src/export/statsbeat/statsbeatExporter.js.map +1 -1
  16. package/dist-esm/src/export/trace.js +7 -5
  17. package/dist-esm/src/export/trace.js.map +1 -1
  18. package/dist-esm/src/generated/applicationInsightsClient.js +1 -1
  19. package/dist-esm/src/generated/applicationInsightsClient.js.map +1 -1
  20. package/dist-esm/src/index.js +0 -1
  21. package/dist-esm/src/index.js.map +1 -1
  22. package/dist-esm/src/platform/nodejs/baseSender.js +197 -0
  23. package/dist-esm/src/platform/nodejs/baseSender.js.map +1 -0
  24. package/dist-esm/src/platform/nodejs/httpSender.js +9 -10
  25. package/dist-esm/src/platform/nodejs/httpSender.js.map +1 -1
  26. package/dist-esm/src/sampling.js +4 -0
  27. package/dist-esm/src/sampling.js.map +1 -1
  28. package/dist-esm/src/types.js.map +1 -1
  29. package/dist-esm/src/utils/common.js +1 -1
  30. package/dist-esm/src/utils/common.js.map +1 -1
  31. package/dist-esm/src/utils/constants/applicationinsights.js +1 -1
  32. package/dist-esm/src/utils/constants/applicationinsights.js.map +1 -1
  33. package/dist-esm/src/utils/logUtils.js +3 -0
  34. package/dist-esm/src/utils/logUtils.js.map +1 -1
  35. package/package.json +12 -12
  36. package/types/monitor-opentelemetry-exporter.d.ts +19 -93
@@ -7,6 +7,10 @@ import { AzureMonitorSampleRate } from "./utils/constants/applicationinsights";
7
7
  * @param samplingRatio - 0 to 1 value.
8
8
  */
9
9
  export class ApplicationInsightsSampler {
10
+ /**
11
+ * Initializes a new instance of the ApplicationInsightsSampler class.
12
+ * @param samplingRatio Value in the range [0,1], 1 meaning all data will sampled and 0 all Tracing data will be sampled out.
13
+ */
10
14
  constructor(samplingRatio = 1) {
11
15
  this._samplingRatio = samplingRatio;
12
16
  if (this._samplingRatio > 1) {
@@ -1 +1 @@
1
- {"version":3,"file":"sampling.js","sourceRoot":"","sources":["../../src/sampling.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,gBAAgB,EAAkB,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,OAAO,0BAA0B;IAIrC,YAAY,gBAAwB,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,IAAI,CAAC,cAAc,GAAG,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;SACtE;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;;;;;;OAaG;IACI,YAAY;IACjB,aAAa;IACb,OAAgB,EAChB,OAAe;IACf,aAAa;IACb,QAAgB;IAChB,aAAa;IACb,QAAkB,EAClB,UAAsB;IACtB,aAAa;IACb,KAAa;QAEb,IAAI,WAAW,GAAG,KAAK,CAAC;QACxB,IAAI,IAAI,CAAC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C,CAAC;SAC/D;QAED,IAAI,GAAG,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC;IAClC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Link, Attributes, SpanKind, Context } from \"@opentelemetry/api\";\nimport { Sampler, SamplingDecision, SamplingResult } from \"@opentelemetry/sdk-trace-base\";\nimport { AzureMonitorSampleRate } from \"./utils/constants/applicationinsights\";\n\n/**\n * ApplicationInsightsSampler is responsible for the following:\n * Implements same trace id hashing algorithm so that traces are sampled the same across multiple nodes\n * Adds item count to span attribute if span is sampled (needed for ingestion service)\n * @param samplingRatio - 0 to 1 value.\n */\nexport class ApplicationInsightsSampler implements Sampler {\n private readonly _sampleRate: number;\n private readonly _samplingRatio: number;\n\n constructor(samplingRatio: number = 1) {\n this._samplingRatio = samplingRatio;\n if (this._samplingRatio > 1) {\n throw new Error(\"Wrong sampling rate, data will not be sampled out\");\n }\n this._sampleRate = Math.round(this._samplingRatio * 100);\n }\n\n /**\n * Checks whether span needs to be created and tracked.\n *\n * @param context Parent Context which may contain a span.\n * @param traceId of the span to be created. It can be different from the\n * traceId in the {@link SpanContext}. Typically in situations when the\n * span to be created starts a new trace.\n * @param spanName of the span to be created.\n * @param spanKind of the span to be created.\n * @param attributes Initial set of SpanAttributes for the Span being constructed.\n * @param links Collection of links that will be associated with the Span to\n * be created. Typically useful for batch operations.\n * @returns a {@link SamplingResult}.\n */\n public shouldSample(\n // @ts-ignore\n context: Context,\n traceId: string,\n // @ts-ignore\n spanName: string,\n // @ts-ignore\n spanKind: SpanKind,\n attributes: Attributes,\n // @ts-ignore\n links: Link[]\n ): SamplingResult {\n let isSampledIn = false;\n if (this._sampleRate == 100) {\n isSampledIn = true;\n } else if (this._sampleRate == 0) {\n isSampledIn = false;\n } else {\n isSampledIn = this._getSamplingHashCode(traceId) < this._sampleRate;\n }\n // Add sample rate as span attribute\n attributes = attributes || {};\n attributes[AzureMonitorSampleRate] = this._sampleRate;\n return isSampledIn\n ? { decision: SamplingDecision.RECORD_AND_SAMPLED, attributes: attributes }\n : { decision: SamplingDecision.NOT_RECORD, attributes: attributes };\n }\n\n /**\n * Return Sampler description\n */\n public toString(): string {\n return `ApplicationInsightsSampler{${this._samplingRatio}}`;\n }\n\n private _getSamplingHashCode(input: string): number {\n var csharpMin = -2147483648;\n var csharpMax = 2147483647;\n var hash = 5381;\n\n if (!input) {\n return 0;\n }\n\n while (input.length < 8) {\n input = input + input;\n }\n\n for (var i = 0; i < input.length; i++) {\n // JS doesn't respond to integer overflow by wrapping around. Simulate it with bitwise operators ( | 0)\n hash = ((((hash << 5) + hash) | 0) + input.charCodeAt(i)) | 0;\n }\n\n hash = hash <= csharpMin ? csharpMax : Math.abs(hash);\n return (hash / csharpMax) * 100;\n }\n}\n"]}
1
+ {"version":3,"file":"sampling.js","sourceRoot":"","sources":["../../src/sampling.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,gBAAgB,EAAkB,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,OAAO,0BAA0B;IAIrC;;;OAGG;IACH,YAAY,gBAAwB,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,IAAI,CAAC,cAAc,GAAG,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;SACtE;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;;;;;;OAaG;IACI,YAAY;IACjB,aAAa;IACb,OAAgB,EAChB,OAAe;IACf,aAAa;IACb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AC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;SAC/D;QAED,IAAI,GAAG,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC;IAClC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Link, Attributes, SpanKind, Context } from \"@opentelemetry/api\";\nimport { Sampler, SamplingDecision, SamplingResult } from \"@opentelemetry/sdk-trace-base\";\nimport { AzureMonitorSampleRate } from \"./utils/constants/applicationinsights\";\n\n/**\n * ApplicationInsightsSampler is responsible for the following:\n * Implements same trace id hashing algorithm so that traces are sampled the same across multiple nodes\n * Adds item count to span attribute if span is sampled (needed for ingestion service)\n * @param samplingRatio - 0 to 1 value.\n */\nexport class ApplicationInsightsSampler implements Sampler {\n private readonly _sampleRate: number;\n private readonly _samplingRatio: number;\n\n /**\n * Initializes a new instance of the ApplicationInsightsSampler class.\n * @param samplingRatio Value in the range [0,1], 1 meaning all data will sampled and 0 all Tracing data will be sampled out.\n */\n constructor(samplingRatio: number = 1) {\n this._samplingRatio = samplingRatio;\n if (this._samplingRatio > 1) {\n throw new Error(\"Wrong sampling rate, data will not be sampled out\");\n }\n this._sampleRate = Math.round(this._samplingRatio * 100);\n }\n\n /**\n * Checks whether span needs to be created and tracked.\n *\n * @param context Parent Context which may contain a span.\n * @param traceId of the span to be created. It can be different from the\n * traceId in the {@link SpanContext}. Typically in situations when the\n * span to be created starts a new trace.\n * @param spanName of the span to be created.\n * @param spanKind of the span to be created.\n * @param attributes Initial set of SpanAttributes for the Span being constructed.\n * @param links Collection of links that will be associated with the Span to\n * be created. Typically useful for batch operations.\n * @returns a {@link SamplingResult}.\n */\n public shouldSample(\n // @ts-ignore\n context: Context,\n traceId: string,\n // @ts-ignore\n spanName: string,\n // @ts-ignore\n spanKind: SpanKind,\n attributes: Attributes,\n // @ts-ignore\n links: Link[]\n ): SamplingResult {\n let isSampledIn = false;\n if (this._sampleRate == 100) {\n isSampledIn = true;\n } else if (this._sampleRate == 0) {\n isSampledIn = false;\n } else {\n isSampledIn = this._getSamplingHashCode(traceId) < this._sampleRate;\n }\n // Add sample rate as span attribute\n attributes = attributes || {};\n attributes[AzureMonitorSampleRate] = this._sampleRate;\n return isSampledIn\n ? { decision: SamplingDecision.RECORD_AND_SAMPLED, attributes: attributes }\n : { decision: SamplingDecision.NOT_RECORD, attributes: attributes };\n }\n\n /**\n * Return Sampler description\n */\n public toString(): string {\n return `ApplicationInsightsSampler{${this._samplingRatio}}`;\n }\n\n private _getSamplingHashCode(input: string): number {\n var csharpMin = -2147483648;\n var csharpMax = 2147483647;\n var hash = 5381;\n\n if (!input) {\n return 0;\n }\n\n while (input.length < 8) {\n input = input + input;\n }\n\n for (var i = 0; i < input.length; i++) {\n // JS doesn't respond to integer overflow by wrapping around. Simulate it with bitwise operators ( | 0)\n hash = ((((hash << 5) + hash) | 0) + input.charCodeAt(i)) | 0;\n }\n\n hash = hash <= csharpMin ? csharpMax : Math.abs(hash);\n return (hash / csharpMax) * 100;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ContextTagKeys } from \"./generated\";\n\n/**\n * Azure Monitor envelope tags.\n * @internal\n */\nexport type Tags = { [key in ContextTagKeys]: string };\n/**\n * Azure Monitor envelope property type.\n * @internal\n */\nexport type PropertyType = string | number | boolean | object | Array<PropertyType>;\n/**\n * Azure Monitor envelope properties.\n * @internal\n */\nexport type Properties = { [key: string]: Properties | PropertyType };\n/**\n * Azure Monitor envelope links.\n * @internal\n */\nexport interface MSLink {\n operation_Id: string;\n id: string;\n}\n/**\n * Azure Monitor envelope measurements.\n * @internal\n */\nexport type Measurements = { [key: string]: number };\n/**\n * Exporter sender result.\n * @internal\n */\nexport type SenderResult = { statusCode: number | undefined; result: string };\n\n/**\n * Exporter sender.\n * @internal\n */\nexport interface Sender {\n send(payload: unknown[]): Promise<SenderResult>;\n shutdown(): Promise<void>;\n handlePermanentRedirect(location: string | undefined): void;\n}\n\n/**\n * Exporter persistent storage.\n * @internal\n */\nexport interface PersistentStorage {\n shift(): Promise<unknown>;\n push(value: unknown[]): Promise<boolean>;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ContextTagKeys } from \"./generated\";\n\n/**\n * Azure Monitor envelope tags.\n * @internal\n */\nexport type Tags = { [key in ContextTagKeys]: string };\n/**\n * Azure Monitor envelope property type.\n * @internal\n */\nexport type PropertyType = string | number | boolean | object | Array<PropertyType>;\n/**\n * Azure Monitor envelope properties.\n * @internal\n */\nexport type Properties = { [key: string]: Properties | PropertyType };\n/**\n * Azure Monitor envelope links.\n * @internal\n */\nexport interface MSLink {\n operation_Id: string;\n id: string;\n}\n/**\n * Azure Monitor envelope measurements.\n * @internal\n */\nexport type Measurements = { [key: string]: number };\n/**\n * Exporter sender result.\n * @internal\n */\nexport type SenderResult = { statusCode: number | undefined; result: string };\n\n/**\n * Exporter persistent storage.\n * @internal\n */\nexport interface PersistentStorage {\n shift(): Promise<unknown>;\n push(value: unknown[]): Promise<boolean>;\n}\n"]}
@@ -175,7 +175,7 @@ export function createResourceMetricEnvelope(resource, instrumentationKey) {
175
175
  if (Object.keys(resourceAttributes).length > 0) {
176
176
  let baseData = {
177
177
  version: 2,
178
- metrics: [{ name: "_APPRESOURCEPREVIEW_", value: 1 }],
178
+ metrics: [{ name: "_OTELRESOURCE_", value: 1 }],
179
179
  properties: resourceAttributes,
180
180
  };
181
181
  let envelope = {
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,GACf,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAA0C,MAAM,cAAc,CAAC;AAI3F,MAAM,UAAU,sBAAsB,CAAC,QAAkB;IACvD,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,MAAM,IAAI,qBAAc,OAAO,CAAC,IAAI,CAAE,CAAC;IACvC,IAAI,QAAQ,IAAI,QAAQ,CAAC,UAAU,EAAE;QACnC,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC/D,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAC/E,MAAM,SAAS,GAAG,QAAQ,CAAC,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACrE,IAAI,SAAS,EAAE;YACb,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;SACxD;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CAAC,QAAkB;IACtC,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,qBAAqB;IACrB,MAAM,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC,YAAY,CAAC,CAAC;IACjF,MAAM,gBAAgB,GAAG,QAAQ,CAAC,UA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AAkB,CACrD,EACD;gBACA,kBAAkB,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAW,CAAC;aAC9D;SACF;QACD,yDAAyD;QACzD,IAAI,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9C,IAAI,QAAQ,GAAgB;gBAC1B,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;gBACrD,UAAU,EAAE,kBAAkB;aAC/B,CAAC;YACF,IAAI,QAAQ,GAAa;gBACvB,IAAI,EAAE,sCAAsC;gBAC5C,IAAI,EAAE,IAAI,IAAI,EAAE;gBAChB,UAAU,EAAE,GAAG;gBACf,kBAAkB,EAAE,kBAAkB;gBACtC,OAAO,EAAE,CAAC;gBACV,IAAI,EAAE;oBACJ,QAAQ,EAAE,YAAY;oBACtB,QAAQ,EAAE,QAAQ;iBACnB;gBACD,IAAI,EAAE,IAAI;aACX,CAAC;YACF,OAAO,QAAQ,CAAC;SACjB;KACF;IACD,OAAO;AACT,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport os from \"os\";\nimport {\n SemanticResourceAttributes,\n SemanticAttributes,\n DbSystemValues,\n} from \"@opentelemetry/semantic-conventions\";\nimport { Tags } from \"../types\";\nimport { getInstance } from \"../platform\";\nimport { KnownContextTagKeys, TelemetryItem as Envelope, MetricsData } from \"../generated\";\nimport { Resource } from \"@opentelemetry/resources\";\nimport { Attributes } from \"@opentelemetry/api\";\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 const endUserId = resource.attributes[SemanticAttributes.ENDUSER_ID];\n if (endUserId) {\n tags[KnownContextTagKeys.AiUserId] = String(endUserId);\n }\n }\n return tags;\n}\n\nfunction getCloudRole(resource: Resource): string {\n let cloudRole = \"\";\n // Service attributes\n const serviceName = resource.attributes[SemanticResourceAttributes.SERVICE_NAME];\n const serviceNamespace = resource.attributes[SemanticResourceAttributes.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 =\n resource.attributes[SemanticResourceAttributes.K8S_DEPLOYMENT_NAME];\n if (kubernetesDeploymentName) {\n return String(kubernetesDeploymentName);\n }\n const kuberneteReplicasetName =\n resource.attributes[SemanticResourceAttributes.K8S_REPLICASET_NAME];\n if (kuberneteReplicasetName) {\n return String(kuberneteReplicasetName);\n }\n const kubernetesStatefulSetName =\n resource.attributes[SemanticResourceAttributes.K8S_STATEFULSET_NAME];\n if (kubernetesStatefulSetName) {\n return String(kubernetesStatefulSetName);\n }\n const kubernetesJobName = resource.attributes[SemanticResourceAttributes.K8S_JOB_NAME];\n if (kubernetesJobName) {\n return String(kubernetesJobName);\n }\n const kubernetesCronjobName = resource.attributes[SemanticResourceAttributes.K8S_CRONJOB_NAME];\n if (kubernetesCronjobName) {\n return String(kubernetesCronjobName);\n }\n const kubernetesDaemonsetName =\n resource.attributes[SemanticResourceAttributes.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[SemanticResourceAttributes.K8S_POD_NAME];\n if (kubernetesPodName) {\n return String(kubernetesPodName);\n }\n // Service attributes\n const serviceInstanceId = resource.attributes[SemanticResourceAttributes.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) {\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 = attributes[SemanticAttributes.HTTP_METHOD];\n if (httpMethod) {\n const httpUrl = attributes[SemanticAttributes.HTTP_URL];\n if (httpUrl) {\n return String(httpUrl);\n } else {\n const httpScheme = attributes[SemanticAttributes.HTTP_SCHEME];\n const httpTarget = attributes[SemanticAttributes.HTTP_TARGET];\n if (httpScheme && httpTarget) {\n const httpHost = attributes[SemanticAttributes.HTTP_HOST];\n if (httpHost) {\n return `${httpScheme}://${httpHost}${httpTarget}`;\n } else {\n const netPeerPort = attributes[SemanticAttributes.NET_PEER_PORT];\n if (netPeerPort) {\n const netPeerName = attributes[SemanticAttributes.NET_PEER_NAME];\n if (netPeerName) {\n return `${httpScheme}://${netPeerName}:${netPeerPort}${httpTarget}`;\n } else {\n const netPeerIp = attributes[SemanticAttributes.NET_PEER_IP];\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[SemanticAttributes.PEER_SERVICE];\n const httpHost = attributes[SemanticAttributes.HTTP_HOST];\n const httpUrl = attributes[SemanticAttributes.HTTP_URL];\n const netPeerName = attributes[SemanticAttributes.NET_PEER_NAME];\n const netPeerIp = attributes[SemanticAttributes.NET_PEER_IP];\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 == SemanticResourceAttributes.TELEMETRY_SDK_VERSION ||\n key == SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE ||\n key == SemanticResourceAttributes.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 let baseData: MetricsData = {\n version: 2,\n metrics: [{ name: \"_APPRESOURCEPREVIEW_\", value: 1 }],\n properties: resourceAttributes,\n };\n let 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"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,GACf,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,M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kBAAkB;aAC/B,CAAC;YACF,IAAI,QAAQ,GAAa;gBACvB,IAAI,EAAE,sCAAsC;gBAC5C,IAAI,EAAE,IAAI,IAAI,EAAE;gBAChB,UAAU,EAAE,GAAG;gBACf,kBAAkB,EAAE,kBAAkB;gBACtC,OAAO,EAAE,CAAC;gBACV,IAAI,EAAE;oBACJ,QAAQ,EAAE,YAAY;oBACtB,QAAQ,EAAE,QAAQ;iBACnB;gBACD,IAAI,EAAE,IAAI;aACX,CAAC;YACF,OAAO,QAAQ,CAAC;SACjB;KACF;IACD,OAAO;AACT,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport os from \"os\";\nimport {\n SemanticResourceAttributes,\n SemanticAttributes,\n DbSystemValues,\n} from \"@opentelemetry/semantic-conventions\";\nimport { Tags } from \"../types\";\nimport { getInstance } from \"../platform\";\nimport { KnownContextTagKeys, TelemetryItem as Envelope, MetricsData } from \"../generated\";\nimport { Resource } from \"@opentelemetry/resources\";\nimport { Attributes } from \"@opentelemetry/api\";\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 const endUserId = resource.attributes[SemanticAttributes.ENDUSER_ID];\n if (endUserId) {\n tags[KnownContextTagKeys.AiUserId] = String(endUserId);\n }\n }\n return tags;\n}\n\nfunction getCloudRole(resource: Resource): string {\n let cloudRole = \"\";\n // Service attributes\n const serviceName = resource.attributes[SemanticResourceAttributes.SERVICE_NAME];\n const serviceNamespace = resource.attributes[SemanticResourceAttributes.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 =\n resource.attributes[SemanticResourceAttributes.K8S_DEPLOYMENT_NAME];\n if (kubernetesDeploymentName) {\n return String(kubernetesDeploymentName);\n }\n const kuberneteReplicasetName =\n resource.attributes[SemanticResourceAttributes.K8S_REPLICASET_NAME];\n if (kuberneteReplicasetName) {\n return String(kuberneteReplicasetName);\n }\n const kubernetesStatefulSetName =\n resource.attributes[SemanticResourceAttributes.K8S_STATEFULSET_NAME];\n if (kubernetesStatefulSetName) {\n return String(kubernetesStatefulSetName);\n }\n const kubernetesJobName = resource.attributes[SemanticResourceAttributes.K8S_JOB_NAME];\n if (kubernetesJobName) {\n return String(kubernetesJobName);\n }\n const kubernetesCronjobName = resource.attributes[SemanticResourceAttributes.K8S_CRONJOB_NAME];\n if (kubernetesCronjobName) {\n return String(kubernetesCronjobName);\n }\n const kubernetesDaemonsetName =\n resource.attributes[SemanticResourceAttributes.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[SemanticResourceAttributes.K8S_POD_NAME];\n if (kubernetesPodName) {\n return String(kubernetesPodName);\n }\n // Service attributes\n const serviceInstanceId = resource.attributes[SemanticResourceAttributes.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) {\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 = attributes[SemanticAttributes.HTTP_METHOD];\n if (httpMethod) {\n const httpUrl = attributes[SemanticAttributes.HTTP_URL];\n if (httpUrl) {\n return String(httpUrl);\n } else {\n const httpScheme = attributes[SemanticAttributes.HTTP_SCHEME];\n const httpTarget = attributes[SemanticAttributes.HTTP_TARGET];\n if (httpScheme && httpTarget) {\n const httpHost = attributes[SemanticAttributes.HTTP_HOST];\n if (httpHost) {\n return `${httpScheme}://${httpHost}${httpTarget}`;\n } else {\n const netPeerPort = attributes[SemanticAttributes.NET_PEER_PORT];\n if (netPeerPort) {\n const netPeerName = attributes[SemanticAttributes.NET_PEER_NAME];\n if (netPeerName) {\n return `${httpScheme}://${netPeerName}:${netPeerPort}${httpTarget}`;\n } else {\n const netPeerIp = attributes[SemanticAttributes.NET_PEER_IP];\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[SemanticAttributes.PEER_SERVICE];\n const httpHost = attributes[SemanticAttributes.HTTP_HOST];\n const httpUrl = attributes[SemanticAttributes.HTTP_URL];\n const netPeerName = attributes[SemanticAttributes.NET_PEER_NAME];\n const netPeerIp = attributes[SemanticAttributes.NET_PEER_IP];\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 == SemanticResourceAttributes.TELEMETRY_SDK_VERSION ||\n key == SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE ||\n key == SemanticResourceAttributes.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 let baseData: MetricsData = {\n version: 2,\n metrics: [{ name: \"_OTELRESOURCE_\", value: 1 }],\n properties: resourceAttributes,\n };\n let 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"]}
@@ -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.14";
22
+ export const packageVersion = "1.0.0-beta.16";
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,eAMX;AAND,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,iDAA8B,CAAA;IAC9B,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,gCAAa,CAAA;AACf,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AACvD,MAAM,CAAC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAE1D,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.14\";\n\nexport enum DependencyTypes {\n InProc = \"InProc\",\n QueueMessage = \"Queue Message\",\n Sql = \"SQL\",\n Http = \"Http\",\n Grpc = \"GRPC\",\n}\n\nexport const AzureMonitorSampleRate = \"_MS.sampleRate\";\nexport const ApplicationInsightsBaseType = \"_MS.baseType\";\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"]}
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,eAMX;AAND,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,iDAA8B,CAAA;IAC9B,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,gCAAa,CAAA;AACf,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AACvD,MAAM,CAAC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAE1D,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.16\";\n\nexport enum DependencyTypes {\n InProc = \"InProc\",\n QueueMessage = \"Queue Message\",\n Sql = \"SQL\",\n Http = \"Http\",\n Grpc = \"GRPC\",\n}\n\nexport const AzureMonitorSampleRate = \"_MS.sampleRate\";\nexport const ApplicationInsightsBaseType = \"_MS.baseType\";\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"]}
@@ -167,6 +167,9 @@ function getLegacyApplicationInsightsBaseData(log) {
167
167
  baseData = JSON.parse(log.body);
168
168
  break;
169
169
  }
170
+ if (typeof (baseData === null || baseData === void 0 ? void 0 : baseData.message) === "object") {
171
+ baseData.message = JSON.stringify(baseData.message);
172
+ }
170
173
  }
171
174
  catch (err) {
172
175
  diag.error("AzureMonitorLogExporter failed to parse Application Insights Telemetry");
@@ -1 +1 @@
1
- {"version":3,"file":"logUtils.js","sourceRoot":"","sources":["../../../src/utils/logUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,mBAAmB,EACnB,kBAAkB,GAOnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,uCAAuC,EACvC,mCAAmC,EACnC,2BAA2B,EAC3B,gCAAgC,EAChC,4BAA4B,EAC5B,oCAAoC,EACpC,gCAAgC,EAChC,kCAAkC,EAClC,8BAA8B,EAC9B,mCAAmC,EACnC,+BAA+B,GAChC,MAAM,iCAAiC,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAsB,EAAE,IAAY;IAChE,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CA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,KAAK,CAAC,wEAAwE,CAAC,CAAC;SACtF;KACF;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AvailabilityData,\n TelemetryItem as Envelope,\n KnownContextTagKeys,\n KnownSeverityLevel,\n MessageData,\n MonitorDomain,\n PageViewData,\n TelemetryEventData,\n TelemetryExceptionData,\n TelemetryExceptionDetails,\n} from \"../generated\";\nimport { createTagsFromResource } from \"./common\";\nimport { ReadableLogRecord } from \"@opentelemetry/sdk-logs\";\nimport { SemanticAttributes } from \"@opentelemetry/semantic-conventions\";\nimport { Measurements, Properties, Tags } from \"../types\";\nimport { hrTimeToMilliseconds } from \"@opentelemetry/core\";\nimport { diag } from \"@opentelemetry/api\";\nimport {\n ApplicationInsightsAvailabilityBaseType,\n ApplicationInsightsAvailabilityName,\n ApplicationInsightsBaseType,\n ApplicationInsightsEventBaseType,\n ApplicationInsightsEventName,\n ApplicationInsightsExceptionBaseType,\n ApplicationInsightsExceptionName,\n ApplicationInsightsMessageBaseType,\n ApplicationInsightsMessageName,\n ApplicationInsightsPageViewBaseType,\n ApplicationInsightsPageViewName,\n} from \"./constants/applicationinsights\";\n\n/**\n * Log to Azure envelope parsing.\n * @internal\n */\nexport function logToEnvelope(log: ReadableLogRecord, ikey: string): Envelope | undefined {\n const time = log.hrTime ? new Date(hrTimeToMilliseconds(log.hrTime)) : new Date();\n let sampleRate = 100;\n const instrumentationKey = ikey;\n const tags = createTagsFromLog(log);\n const [properties, measurements] = createPropertiesFromLog(log);\n let name: string;\n let baseType: string;\n let baseData: MonitorDomain;\n\n if (!log.attributes[ApplicationInsightsBaseType]) {\n // Get Exception attributes if available\n let exceptionType = log.attributes[SemanticAttributes.EXCEPTION_TYPE];\n if (exceptionType) {\n let exceptionMessage = log.attributes[SemanticAttributes.EXCEPTION_MESSAGE];\n let exceptionStacktrace = log.attributes[SemanticAttributes.EXCEPTION_STACKTRACE];\n name = ApplicationInsightsExceptionName;\n baseType = ApplicationInsightsExceptionBaseType;\n let exceptionDetails: TelemetryExceptionDetails = {\n typeName: String(exceptionType),\n message: String(exceptionMessage),\n hasFullStack: exceptionStacktrace ? true : false,\n stack: String(exceptionStacktrace),\n };\n const exceptionData: TelemetryExceptionData = {\n exceptions: [exceptionDetails],\n severityLevel: String(getSeverity(log.severityNumber)),\n version: 2,\n };\n baseData = exceptionData;\n } else {\n name = ApplicationInsightsMessageName;\n baseType = ApplicationInsightsMessageBaseType;\n const messageData: MessageData = {\n message: String(log.body),\n severityLevel: String(getSeverity(log.severityNumber)),\n version: 2,\n };\n baseData = messageData;\n }\n } else {\n // If Legacy Application Insights Log\n baseType = String(log.attributes[ApplicationInsightsBaseType]);\n name = getLegacyApplicationInsightsName(log);\n baseData = getLegacyApplicationInsightsBaseData(log);\n if (!baseData) {\n // Failed to parse log\n return;\n }\n }\n return {\n name,\n sampleRate,\n time,\n instrumentationKey,\n tags,\n version: 1,\n data: {\n baseType,\n baseData: {\n ...baseData,\n properties,\n measurements,\n },\n },\n };\n}\n\nfunction createTagsFromLog(log: ReadableLogRecord): Tags {\n const tags: Tags = createTagsFromResource(log.resource);\n if (log.spanContext?.traceId) {\n tags[KnownContextTagKeys.AiOperationId] = log.spanContext.traceId;\n }\n if (log.spanContext?.spanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = log.spanContext.spanId;\n }\n return tags;\n}\n\nfunction createPropertiesFromLog(log: ReadableLogRecord): [Properties, Measurements] {\n const measurements: Measurements = {};\n const properties: { [propertyName: string]: string } = {};\n if (log.attributes) {\n for (const key of Object.keys(log.attributes)) {\n // Avoid duplication ignoring fields already mapped.\n if (\n !(\n key.startsWith(\"_MS.\") ||\n key == SemanticAttributes.EXCEPTION_TYPE ||\n key == SemanticAttributes.EXCEPTION_MESSAGE ||\n key == SemanticAttributes.EXCEPTION_STACKTRACE\n )\n ) {\n properties[key] = log.attributes[key] as string;\n }\n }\n }\n return [properties, measurements];\n}\n\n// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber\nfunction getSeverity(severityNumber: number | undefined): KnownSeverityLevel | undefined {\n if (severityNumber) {\n if (severityNumber > 0 && severityNumber < 9) {\n return KnownSeverityLevel.Verbose;\n } else if (severityNumber >= 9 && severityNumber < 13) {\n return KnownSeverityLevel.Information;\n } else if (severityNumber >= 13 && severityNumber < 17) {\n return KnownSeverityLevel.Warning;\n } else if (severityNumber >= 17 && severityNumber < 21) {\n return KnownSeverityLevel.Error;\n } else if (severityNumber >= 21 && severityNumber < 25) {\n return KnownSeverityLevel.Critical;\n }\n }\n return;\n}\n\nfunction getLegacyApplicationInsightsName(log: ReadableLogRecord): string {\n let name = \"\";\n switch (log.attributes[ApplicationInsightsBaseType]) {\n case ApplicationInsightsAvailabilityBaseType:\n name = ApplicationInsightsAvailabilityName;\n break;\n case ApplicationInsightsExceptionBaseType:\n name = ApplicationInsightsExceptionName;\n break;\n case ApplicationInsightsMessageBaseType:\n name = ApplicationInsightsMessageName;\n break;\n case ApplicationInsightsPageViewBaseType:\n name = ApplicationInsightsPageViewName;\n break;\n case ApplicationInsightsEventBaseType:\n name = ApplicationInsightsEventName;\n break;\n }\n return name;\n}\n\nfunction getLegacyApplicationInsightsBaseData(log: ReadableLogRecord): MonitorDomain {\n let baseData: MonitorDomain = {\n version: 2,\n };\n if (log.body) {\n try {\n switch (log.attributes[ApplicationInsightsBaseType]) {\n case ApplicationInsightsAvailabilityBaseType:\n baseData = JSON.parse(log.body) as AvailabilityData;\n break;\n case ApplicationInsightsExceptionBaseType:\n baseData = JSON.parse(log.body) as TelemetryExceptionData;\n break;\n case ApplicationInsightsMessageBaseType:\n baseData = JSON.parse(log.body) as MessageData;\n break;\n case ApplicationInsightsPageViewBaseType:\n baseData = JSON.parse(log.body) as PageViewData;\n break;\n case ApplicationInsightsEventBaseType:\n baseData = JSON.parse(log.body) as TelemetryEventData;\n break;\n }\n } catch (err) {\n diag.error(\"AzureMonitorLogExporter failed to parse Application Insights Telemetry\");\n }\n }\n return baseData;\n}\n"]}
1
+ {"version":3,"file":"logUtils.js","sourceRoot":"","sources":["../../../src/utils/logUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,mBAAmB,EACnB,kBAAkB,GAOnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,uCAAuC,EACvC,mCAAmC,EACnC,2BAA2B,EAC3B,gCAAgC,EAChC,4BAA4B,EAC5B,oCAAoC,EACpC,gCAAgC,EAChC,kCAAkC,EAClC,8BAA8B,EAC9B,mCAAmC,EACnC,+BAA+B,GAChC,MAAM,iCAAiC,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAsB,EAAE,IAAY;IAChE,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IAClF,IAAI,UAAU,GAAG,GAAG,CAAC;IACrB,MAAM,kBAAkB,GAAG,IAAI,CAAC;IAChC,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAChE,IAAI,IAAY,CAAC;IACjB,IAAI,QAAgB,CAAC;IACrB,IAAI,QAAuB,CAAC;IAE5B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,2BAA2B,CAAC,EAAE;QAChD,wCAAwC;QACxC,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AO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,oCAAoC,CAAC,GAAsB;IAClE,IAAI,QAAQ,GAAkB;QAC5B,OAAO,EAAE,CAAC;KACX,CAAC;IACF,IAAI,GAAG,CAAC,IAAI,EAAE;QACZ,IAAI;YACF,QAAQ,GAAG,CAAC,UAAU,CAAC,2BAA2B,CAAC,EAAE;gBACnD,KAAK,uCAAuC;oBAC1C,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAqB,CAAC;oBACpD,MAAM;gBACR,KAAK,oCAAoC;oBACvC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAA2B,CAAC;oBAC1D,MAAM;gBACR,KAAK,kCAAkC;oBACrC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAgB,CAAC;oBAC/C,MAAM;gBACR,KAAK,mCAAmC;oBACtC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAiB,CAAC;oBAChD,MAAM;gBACR,KAAK,gCAAgC;oBACnC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAuB,CAAC;oBACtD,MAAM;aACT;YACD,IAAI,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAA,KAAK,QAAQ,EAAE;gBACzC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;aACrD;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,CAAC,KAAK,CAAC,wEAAwE,CAAC,CAAC;SACtF;KACF;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AvailabilityData,\n TelemetryItem as Envelope,\n KnownContextTagKeys,\n KnownSeverityLevel,\n MessageData,\n MonitorDomain,\n PageViewData,\n TelemetryEventData,\n TelemetryExceptionData,\n TelemetryExceptionDetails,\n} from \"../generated\";\nimport { createTagsFromResource } from \"./common\";\nimport { ReadableLogRecord } from \"@opentelemetry/sdk-logs\";\nimport { SemanticAttributes } from \"@opentelemetry/semantic-conventions\";\nimport { Measurements, Properties, Tags } from \"../types\";\nimport { hrTimeToMilliseconds } from \"@opentelemetry/core\";\nimport { diag } from \"@opentelemetry/api\";\nimport {\n ApplicationInsightsAvailabilityBaseType,\n ApplicationInsightsAvailabilityName,\n ApplicationInsightsBaseType,\n ApplicationInsightsEventBaseType,\n ApplicationInsightsEventName,\n ApplicationInsightsExceptionBaseType,\n ApplicationInsightsExceptionName,\n ApplicationInsightsMessageBaseType,\n ApplicationInsightsMessageName,\n ApplicationInsightsPageViewBaseType,\n ApplicationInsightsPageViewName,\n} from \"./constants/applicationinsights\";\n\n/**\n * Log to Azure envelope parsing.\n * @internal\n */\nexport function logToEnvelope(log: ReadableLogRecord, ikey: string): Envelope | undefined {\n const time = log.hrTime ? new Date(hrTimeToMilliseconds(log.hrTime)) : new Date();\n let sampleRate = 100;\n const instrumentationKey = ikey;\n const tags = createTagsFromLog(log);\n const [properties, measurements] = createPropertiesFromLog(log);\n let name: string;\n let baseType: string;\n let baseData: MonitorDomain;\n\n if (!log.attributes[ApplicationInsightsBaseType]) {\n // Get Exception attributes if available\n let exceptionType = log.attributes[SemanticAttributes.EXCEPTION_TYPE];\n if (exceptionType) {\n let exceptionMessage = log.attributes[SemanticAttributes.EXCEPTION_MESSAGE];\n let exceptionStacktrace = log.attributes[SemanticAttributes.EXCEPTION_STACKTRACE];\n name = ApplicationInsightsExceptionName;\n baseType = ApplicationInsightsExceptionBaseType;\n let exceptionDetails: TelemetryExceptionDetails = {\n typeName: String(exceptionType),\n message: String(exceptionMessage),\n hasFullStack: exceptionStacktrace ? true : false,\n stack: String(exceptionStacktrace),\n };\n const exceptionData: TelemetryExceptionData = {\n exceptions: [exceptionDetails],\n severityLevel: String(getSeverity(log.severityNumber)),\n version: 2,\n };\n baseData = exceptionData;\n } else {\n name = ApplicationInsightsMessageName;\n baseType = ApplicationInsightsMessageBaseType;\n const messageData: MessageData = {\n message: String(log.body),\n severityLevel: String(getSeverity(log.severityNumber)),\n version: 2,\n };\n baseData = messageData;\n }\n } else {\n // If Legacy Application Insights Log\n baseType = String(log.attributes[ApplicationInsightsBaseType]);\n name = getLegacyApplicationInsightsName(log);\n baseData = getLegacyApplicationInsightsBaseData(log);\n if (!baseData) {\n // Failed to parse log\n return;\n }\n }\n return {\n name,\n sampleRate,\n time,\n instrumentationKey,\n tags,\n version: 1,\n data: {\n baseType,\n baseData: {\n ...baseData,\n properties,\n measurements,\n },\n },\n };\n}\n\nfunction createTagsFromLog(log: ReadableLogRecord): Tags {\n const tags: Tags = createTagsFromResource(log.resource);\n if (log.spanContext?.traceId) {\n tags[KnownContextTagKeys.AiOperationId] = log.spanContext.traceId;\n }\n if (log.spanContext?.spanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = log.spanContext.spanId;\n }\n return tags;\n}\n\nfunction createPropertiesFromLog(log: ReadableLogRecord): [Properties, Measurements] {\n const measurements: Measurements = {};\n const properties: { [propertyName: string]: string } = {};\n if (log.attributes) {\n for (const key of Object.keys(log.attributes)) {\n // Avoid duplication ignoring fields already mapped.\n if (\n !(\n key.startsWith(\"_MS.\") ||\n key == SemanticAttributes.EXCEPTION_TYPE ||\n key == SemanticAttributes.EXCEPTION_MESSAGE ||\n key == SemanticAttributes.EXCEPTION_STACKTRACE\n )\n ) {\n properties[key] = log.attributes[key] as string;\n }\n }\n }\n return [properties, measurements];\n}\n\n// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber\nfunction getSeverity(severityNumber: number | undefined): KnownSeverityLevel | undefined {\n if (severityNumber) {\n if (severityNumber > 0 && severityNumber < 9) {\n return KnownSeverityLevel.Verbose;\n } else if (severityNumber >= 9 && severityNumber < 13) {\n return KnownSeverityLevel.Information;\n } else if (severityNumber >= 13 && severityNumber < 17) {\n return KnownSeverityLevel.Warning;\n } else if (severityNumber >= 17 && severityNumber < 21) {\n return KnownSeverityLevel.Error;\n } else if (severityNumber >= 21 && severityNumber < 25) {\n return KnownSeverityLevel.Critical;\n }\n }\n return;\n}\n\nfunction getLegacyApplicationInsightsName(log: ReadableLogRecord): string {\n let name = \"\";\n switch (log.attributes[ApplicationInsightsBaseType]) {\n case ApplicationInsightsAvailabilityBaseType:\n name = ApplicationInsightsAvailabilityName;\n break;\n case ApplicationInsightsExceptionBaseType:\n name = ApplicationInsightsExceptionName;\n break;\n case ApplicationInsightsMessageBaseType:\n name = ApplicationInsightsMessageName;\n break;\n case ApplicationInsightsPageViewBaseType:\n name = ApplicationInsightsPageViewName;\n break;\n case ApplicationInsightsEventBaseType:\n name = ApplicationInsightsEventName;\n break;\n }\n return name;\n}\n\nfunction getLegacyApplicationInsightsBaseData(log: ReadableLogRecord): MonitorDomain {\n let baseData: MonitorDomain = {\n version: 2,\n };\n if (log.body) {\n try {\n switch (log.attributes[ApplicationInsightsBaseType]) {\n case ApplicationInsightsAvailabilityBaseType:\n baseData = JSON.parse(log.body) as AvailabilityData;\n break;\n case ApplicationInsightsExceptionBaseType:\n baseData = JSON.parse(log.body) as TelemetryExceptionData;\n break;\n case ApplicationInsightsMessageBaseType:\n baseData = JSON.parse(log.body) as MessageData;\n break;\n case ApplicationInsightsPageViewBaseType:\n baseData = JSON.parse(log.body) as PageViewData;\n break;\n case ApplicationInsightsEventBaseType:\n baseData = JSON.parse(log.body) as TelemetryEventData;\n break;\n }\n if (typeof baseData?.message === \"object\") {\n baseData.message = JSON.stringify(baseData.message);\n }\n } catch (err) {\n diag.error(\"AzureMonitorLogExporter failed to parse Application Insights Telemetry\");\n }\n }\n return baseData;\n}\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@azure/monitor-opentelemetry-exporter",
3
3
  "author": "Microsoft Corporation",
4
4
  "sdk-type": "client",
5
- "version": "1.0.0-beta.14",
5
+ "version": "1.0.0-beta.16",
6
6
  "description": "Application Insights exporter for the OpenTelemetry JavaScript (Node.js) SDK",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist-esm/src/index.js",
@@ -86,9 +86,9 @@
86
86
  "@azure/dev-tool": "^1.0.0",
87
87
  "@azure/eslint-plugin-azure-sdk": "^3.0.0",
88
88
  "@microsoft/api-extractor": "^7.31.1",
89
- "@opentelemetry/instrumentation": "^0.39.0",
90
- "@opentelemetry/instrumentation-http": "^0.39.0",
91
- "@opentelemetry/sdk-trace-node": "^1.13.0",
89
+ "@opentelemetry/instrumentation": "^0.41.2",
90
+ "@opentelemetry/instrumentation-http": "^0.41.2",
91
+ "@opentelemetry/sdk-trace-node": "^1.15.2",
92
92
  "@types/mocha": "^7.0.2",
93
93
  "@types/node": "^14.0.0",
94
94
  "dotenv": "^16.0.0",
@@ -99,7 +99,7 @@
99
99
  "nyc": "^15.0.0",
100
100
  "prettier": "^2.5.1",
101
101
  "rimraf": "^3.0.0",
102
- "sinon": "^9.0.2",
102
+ "sinon": "^15.0.0",
103
103
  "ts-node": "^10.0.0",
104
104
  "typescript": "~5.0.0"
105
105
  },
@@ -108,13 +108,13 @@
108
108
  "@azure/core-auth": "^1.3.0",
109
109
  "@azure/core-rest-pipeline": "^1.1.0",
110
110
  "@opentelemetry/api": "^1.4.1",
111
- "@opentelemetry/api-logs": "^0.40.0",
112
- "@opentelemetry/core": "^1.14.0",
113
- "@opentelemetry/resources": "^1.14.0",
114
- "@opentelemetry/sdk-metrics": "^1.14.0",
115
- "@opentelemetry/sdk-trace-base": "^1.14.0",
116
- "@opentelemetry/semantic-conventions": "^1.14.0",
117
- "@opentelemetry/sdk-logs": "^0.40.0",
111
+ "@opentelemetry/api-logs": "^0.41.2",
112
+ "@opentelemetry/core": "^1.15.2",
113
+ "@opentelemetry/resources": "^1.15.2",
114
+ "@opentelemetry/sdk-metrics": "^1.15.2",
115
+ "@opentelemetry/sdk-trace-base": "^1.15.2",
116
+ "@opentelemetry/semantic-conventions": "^1.15.2",
117
+ "@opentelemetry/sdk-logs": "^0.41.2",
118
118
  "tslib": "^2.2.0"
119
119
  },
120
120
  "sideEffects": false,
@@ -33,6 +33,10 @@ export declare interface ApplicationInsightsClientOptionalParams extends coreCli
33
33
  export declare class ApplicationInsightsSampler implements Sampler {
34
34
  private readonly _sampleRate;
35
35
  private readonly _samplingRatio;
36
+ /**
37
+ * Initializes a new instance of the ApplicationInsightsSampler class.
38
+ * @param samplingRatio Value in the range [0,1], 1 meaning all data will sampled and 0 all Tracing data will be sampled out.
39
+ */
36
40
  constructor(samplingRatio?: number);
37
41
  /**
38
42
  * Checks whether span needs to be created and tracked.
@@ -63,17 +67,16 @@ export declare abstract class AzureMonitorBaseExporter {
63
67
  /**
64
68
  * Instrumentation key to be used for exported envelopes
65
69
  */
66
- protected _instrumentationKey: string;
67
- private _endpointUrl;
68
- private readonly _persister;
69
- private readonly _sender;
70
- private _numConsecutiveRedirects;
71
- private _retryTimer;
72
- private _networkStatsbeatMetrics;
73
- private _longIntervalStatsbeatMetrics;
70
+ protected instrumentationKey: string;
71
+ /**
72
+ * Ingestion Endpoint URL
73
+ */
74
+ protected endpointUrl: string;
75
+ /**
76
+ *Flag to determine if exporter will generate Statsbeat data
77
+ */
78
+ protected trackStatsbeat: boolean;
74
79
  private _isStatsbeatExporter;
75
- private _statsbeatFailureCount;
76
- private _batchSendRetryIntervalMs;
77
80
  /**
78
81
  * Exporter internal configuration
79
82
  */
@@ -83,21 +86,6 @@ export declare abstract class AzureMonitorBaseExporter {
83
86
  * @param AzureMonitorExporterOptions - Exporter configuration.
84
87
  */
85
88
  constructor(options?: AzureMonitorExporterOptions, isStatsbeatExporter?: boolean);
86
- /**
87
- * Persist envelopes to disk
88
- */
89
- private _persist;
90
- /**
91
- * Shutdown exporter
92
- */
93
- protected _shutdown(): Promise<void>;
94
- /**
95
- * Export envelopes
96
- */
97
- protected _exportEnvelopes(envelopes: TelemetryItem[]): Promise<ExportResult>;
98
- private _incrementStatsbeatFailure;
99
- private _sendFirstPersistedFile;
100
- private _isNetworkError;
101
89
  }
102
90
 
103
91
  /**
@@ -114,9 +102,9 @@ export declare interface AzureMonitorExporterOptions extends ApplicationInsights
114
102
  */
115
103
  apiVersion?: ServiceApiVersion;
116
104
  /**
117
- * Azure Active Directory Credential
105
+ * Token Credential
118
106
  */
119
- aadTokenCredential?: TokenCredential;
107
+ credential?: TokenCredential;
120
108
  /**
121
109
  * Directory to store retriable telemetry when it fails to export.
122
110
  */
@@ -135,6 +123,7 @@ export declare class AzureMonitorLogExporter extends AzureMonitorBaseExporter im
135
123
  * Flag to determine if Exporter is shutdown.
136
124
  */
137
125
  private _isShutdown;
126
+ private readonly _sender;
138
127
  /**
139
128
  * Initializes a new instance of the AzureMonitorLogExporter class.
140
129
  * @param AzureExporterConfig - Exporter configuration.
@@ -160,6 +149,7 @@ export declare class AzureMonitorMetricExporter extends AzureMonitorBaseExporter
160
149
  * Flag to determine if Exporter is shutdown.
161
150
  */
162
151
  private _isShutdown;
152
+ private _sender;
163
153
  /**
164
154
  * Initializes a new instance of the AzureMonitorMetricExporter class.
165
155
  * @param AzureExporterConfig - Exporter configuration.
@@ -178,40 +168,13 @@ export declare class AzureMonitorMetricExporter extends AzureMonitorBaseExporter
178
168
  /**
179
169
  * Select aggregation temporality
180
170
  */
181
- selectAggregationTemporality(_instrumentType: InstrumentType): AggregationTemporality;
171
+ selectAggregationTemporality(instrumentType: InstrumentType): AggregationTemporality;
182
172
  /**
183
173
  * Force flush
184
174
  */
185
175
  forceFlush(): Promise<void>;
186
176
  }
187
177
 
188
- /**
189
- * Azure Monitor Statsbeat Exporter
190
- */
191
- export declare class AzureMonitorStatsbeatExporter extends AzureMonitorBaseExporter implements PushMetricExporter {
192
- /**
193
- * Flag to determine if the Exporter is shutdown.
194
- */
195
- private _isShutdown;
196
- /**
197
- * Initializes a new instance of the AzureMonitorStatsbeatExporter class.
198
- * @param options - Exporter configuration
199
- */
200
- constructor(options: AzureMonitorExporterOptions);
201
- /**
202
- * Export Statsbeat metrics.
203
- */
204
- export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): Promise<void>;
205
- /**
206
- * Shutdown AzureMonitorStatsbeatExporter.
207
- */
208
- shutdown(): Promise<void>;
209
- /**
210
- * Force flush.
211
- */
212
- forceFlush(): Promise<void>;
213
- }
214
-
215
178
  /**
216
179
  * Azure Monitor OpenTelemetry Trace Exporter.
217
180
  */
@@ -220,6 +183,7 @@ export declare class AzureMonitorTraceExporter extends AzureMonitorBaseExporter
220
183
  * Flag to determine if Exporter is shutdown.
221
184
  */
222
185
  private _isShutdown;
186
+ private readonly _sender;
223
187
  /**
224
188
  * Initializes a new instance of the AzureMonitorTraceExporter class.
225
189
  * @param AzureExporterConfig - Exporter configuration.
@@ -237,22 +201,6 @@ export declare class AzureMonitorTraceExporter extends AzureMonitorBaseExporter
237
201
  shutdown(): Promise<void>;
238
202
  }
239
203
 
240
- /** Data struct to contain only C section with custom fields. */
241
- export declare interface MonitorBase {
242
- /** Name of item (B section) if any. If telemetry data is derived straight from this, this should be null. */
243
- baseType?: string;
244
- /** The data payload for the telemetry request */
245
- baseData?: MonitorDomain;
246
- }
247
-
248
- /** The abstract common base of all domains. */
249
- export declare interface MonitorDomain {
250
- /** Describes unknown properties. The value of an unknown property can be of "any" type. */
251
- [property: string]: any;
252
- /** Schema version */
253
- version: number;
254
- }
255
-
256
204
  /**
257
205
  * Azure service API version.
258
206
  */
@@ -263,26 +211,4 @@ export declare enum ServiceApiVersion {
263
211
  V2 = "2020-09-15_Preview"
264
212
  }
265
213
 
266
- /** System variables for a telemetry item. */
267
- export declare interface TelemetryItem {
268
- /** Envelope version. For internal use only. By assigning this the default, it will not be serialized within the payload unless changed to a value other than #1. */
269
- version?: number;
270
- /** Type name of telemetry data item. */
271
- name: string;
272
- /** Event date time when telemetry item was created. This is the wall clock time on the client when the event was generated. There is no guarantee that the client's time is accurate. This field must be formatted in UTC ISO 8601 format, with a trailing 'Z' character, as described publicly on https://en.wikipedia.org/wiki/ISO_8601#UTC. Note: the number of decimal seconds digits provided are variable (and unspecified). Consumers should handle this, i.e. managed code consumers should not use format 'O' for parsing as it specifies a fixed length. Example: 2009-06-15T13:45:30.0000000Z. */
273
- time: Date;
274
- /** Sampling rate used in application. This telemetry item represents 100 / sampleRate actual telemetry items. */
275
- sampleRate?: number;
276
- /** Sequence field used to track absolute order of uploaded events. */
277
- sequence?: string;
278
- /** The instrumentation key of the Application Insights resource. */
279
- instrumentationKey?: string;
280
- /** Key/value collection of context properties. See ContextTagKeys for information on available properties. */
281
- tags?: {
282
- [propertyName: string]: string;
283
- };
284
- /** Telemetry data item. */
285
- data?: MonitorBase;
286
- }
287
-
288
214
  export { }