@azure/monitor-opentelemetry-exporter 1.0.0-beta.19 → 1.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.js +58 -48
- package/dist-esm/src/export/base.js.map +1 -1
- package/dist-esm/src/export/log.js.map +1 -1
- package/dist-esm/src/export/metric.js.map +1 -1
- package/dist-esm/src/export/statsbeat/longIntervalStatsbeatMetrics.js +3 -3
- package/dist-esm/src/export/statsbeat/longIntervalStatsbeatMetrics.js.map +1 -1
- package/dist-esm/src/export/statsbeat/networkStatsbeatMetrics.js +2 -2
- package/dist-esm/src/export/statsbeat/networkStatsbeatMetrics.js.map +1 -1
- package/dist-esm/src/export/statsbeat/statsbeatExporter.js +1 -0
- package/dist-esm/src/export/statsbeat/statsbeatExporter.js.map +1 -1
- package/dist-esm/src/export/statsbeat/statsbeatMetrics.js +1 -1
- package/dist-esm/src/export/statsbeat/statsbeatMetrics.js.map +1 -1
- package/dist-esm/src/export/trace.js.map +1 -1
- package/dist-esm/src/generated/applicationInsightsClient.js +1 -1
- package/dist-esm/src/generated/applicationInsightsClient.js.map +1 -1
- package/dist-esm/src/generated/models/index.js.map +1 -1
- package/dist-esm/src/platform/nodejs/baseSender.js +7 -2
- package/dist-esm/src/platform/nodejs/baseSender.js.map +1 -1
- package/dist-esm/src/platform/nodejs/context/context.js +2 -4
- package/dist-esm/src/platform/nodejs/context/context.js.map +1 -1
- package/dist-esm/src/platform/nodejs/httpSender.js.map +1 -1
- package/dist-esm/src/platform/nodejs/persist/fileAccessControl.js +2 -2
- package/dist-esm/src/platform/nodejs/persist/fileAccessControl.js.map +1 -1
- package/dist-esm/src/platform/nodejs/persist/fileSystemHelpers.js +15 -8
- package/dist-esm/src/platform/nodejs/persist/fileSystemHelpers.js.map +1 -1
- package/dist-esm/src/platform/nodejs/persist/fileSystemPersist.js.map +1 -1
- package/dist-esm/src/sampling.js.map +1 -1
- package/dist-esm/src/utils/breezeUtils.js +12 -16
- package/dist-esm/src/utils/breezeUtils.js.map +1 -1
- package/dist-esm/src/utils/common.js +5 -1
- package/dist-esm/src/utils/common.js.map +1 -1
- package/dist-esm/src/utils/connectionStringParser.js.map +1 -1
- package/dist-esm/src/utils/constants/applicationinsights.js +2 -2
- package/dist-esm/src/utils/constants/applicationinsights.js.map +1 -1
- package/dist-esm/src/utils/eventhub.js.map +1 -1
- package/dist-esm/src/utils/logUtils.js +2 -3
- package/dist-esm/src/utils/logUtils.js.map +1 -1
- package/dist-esm/src/utils/metricUtils.js +1 -1
- package/dist-esm/src/utils/metricUtils.js.map +1 -1
- package/dist-esm/src/utils/spanUtils.js +7 -6
- package/dist-esm/src/utils/spanUtils.js.map +1 -1
- package/package.json +21 -22
- package/types/monitor-opentelemetry-exporter.d.ts +3 -0
|
@@ -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;;;OAGG;IACH,YAAY,gBAAwB,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,IAAI,CAAC,aAAa,GAAG,CAAC,EAAE;
|
|
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,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,IAAI,CAAC,a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AI,IAAI,GAAG,IAAI,CAAC;QAEhB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;QACxB,CAAC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,uGAAuG;YACvG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChE,CAAC;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 - traceif 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 - Name of the span to be created.\n * @param spanKind - Kind 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 const csharpMin = -2147483648;\n const csharpMax = 2147483647;\n let hash = 5381;\n\n if (!input) {\n return 0;\n }\n\n while (input.length < 8) {\n input = input + input;\n }\n\n for (let 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"]}
|
|
@@ -17,23 +17,19 @@ export function isRetriable(statusCode) {
|
|
|
17
17
|
statusCode === 504 // Gateway Timeout
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
export function msToTimeSpan(ms) {
|
|
25
|
-
let totalms = ms;
|
|
26
|
-
if (Number.isNaN(totalms) || totalms < 0 || !Number.isFinite(ms)) {
|
|
20
|
+
// Convert ms to c# time span format DD.HH:MM:SS.MMMMMM
|
|
21
|
+
export function msToTimeSpan(totalms) {
|
|
22
|
+
if (isNaN(totalms) || totalms < 0) {
|
|
27
23
|
totalms = 0;
|
|
28
24
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
sec = sec.indexOf(".") < 2 ?
|
|
34
|
-
min = min.length < 2 ?
|
|
35
|
-
hour = hour.length < 2 ?
|
|
36
|
-
|
|
37
|
-
return
|
|
25
|
+
var sec = ((totalms / 1000) % 60).toFixed(7).replace(/0{0,4}$/, "");
|
|
26
|
+
var min = "" + (Math.floor(totalms / (1000 * 60)) % 60);
|
|
27
|
+
var hour = "" + (Math.floor(totalms / (1000 * 60 * 60)) % 24);
|
|
28
|
+
var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
|
|
29
|
+
sec = sec.indexOf(".") < 2 ? "0" + sec : sec;
|
|
30
|
+
min = min.length < 2 ? "0" + min : min;
|
|
31
|
+
hour = hour.length < 2 ? "0" + hour : hour;
|
|
32
|
+
var daysText = days > 0 ? days + "." : "";
|
|
33
|
+
return daysText + hour + ":" + min + ":" + sec;
|
|
38
34
|
}
|
|
39
35
|
//# sourceMappingURL=breezeUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breezeUtils.js","sourceRoot":"","sources":["../../../src/utils/breezeUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAsBlC;;;GAGG;AACH,MAAM,UAAU,W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AAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACpE,IAAI,GAAG,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACxD,IAAI,IAAI,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9D,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IAEvD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC7C,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACvC,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,IAAI,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1C,OAAO,QAAQ,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACjD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Breeze errors.\n * @internal\n */\nexport interface BreezeError {\n index: number;\n statusCode: number;\n message: string;\n}\n\n/**\n * Breeze response definition.\n * @internal\n */\nexport interface BreezeResponse {\n itemsReceived: number;\n itemsAccepted: number;\n errors: BreezeError[];\n}\n\n/**\n * Breeze retriable status codes.\n * @internal\n */\nexport function isRetriable(statusCode: number): boolean {\n return (\n statusCode === 206 || // Partial Accept\n statusCode === 401 || // Unauthorized\n statusCode === 403 || // Forbidden\n statusCode === 408 || // Timeout\n statusCode === 429 || // Too many requests\n statusCode === 439 || // Daily quota exceeded (legacy)\n statusCode === 500 || // Server Error\n statusCode === 502 || // Bad Gateway\n statusCode === 503 || // Server Unavailable\n statusCode === 504 // Gateway Timeout\n );\n}\n\n// Convert ms to c# time span format DD.HH:MM:SS.MMMMMM\nexport function msToTimeSpan(totalms: number): string {\n if (isNaN(totalms) || totalms < 0) {\n totalms = 0;\n }\n var sec = ((totalms / 1000) % 60).toFixed(7).replace(/0{0,4}$/, \"\");\n var min = \"\" + (Math.floor(totalms / (1000 * 60)) % 60);\n var hour = \"\" + (Math.floor(totalms / (1000 * 60 * 60)) % 24);\n var days = Math.floor(totalms / (1000 * 60 * 60 * 24));\n\n sec = sec.indexOf(\".\") < 2 ? \"0\" + sec : sec;\n min = min.length < 2 ? \"0\" + min : min;\n hour = hour.length < 2 ? \"0\" + hour : hour;\n var daysText = days > 0 ? days + \".\" : \"\";\n return daysText + hour + \":\" + min + \":\" + sec;\n}\n"]}
|
|
@@ -4,6 +4,10 @@ import os from "os";
|
|
|
4
4
|
import { SemanticResourceAttributes, SemanticAttributes, DbSystemValues, } from "@opentelemetry/semantic-conventions";
|
|
5
5
|
import { getInstance } from "../platform";
|
|
6
6
|
import { KnownContextTagKeys } from "../generated";
|
|
7
|
+
import { hrTimeToNanoseconds } from "@opentelemetry/core";
|
|
8
|
+
export function hrTimeToDate(hrTime) {
|
|
9
|
+
return new Date(hrTimeToNanoseconds(hrTime) / 1000000);
|
|
10
|
+
}
|
|
7
11
|
export function createTagsFromResource(resource) {
|
|
8
12
|
const context = getInstance();
|
|
9
13
|
const tags = Object.assign({}, context.tags);
|
|
@@ -181,7 +185,7 @@ export function createResourceMetricEnvelope(resource, instrumentationKey) {
|
|
|
181
185
|
const envelope = {
|
|
182
186
|
name: "Microsoft.ApplicationInsights.Metric",
|
|
183
187
|
time: new Date(),
|
|
184
|
-
sampleRate: 100,
|
|
188
|
+
sampleRate: 100, // Metrics are never sampled
|
|
185
189
|
instrumentationKey: instrumentationKey,
|
|
186
190
|
version: 1,
|
|
187
191
|
data: {
|
|
@@ -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,QA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;YACpD,IACE,CAAC,CACC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;gBACtB,GAAG,KAAK,0BAA0B,CAAC,qBAAqB;gBACxD,GAAG,KAAK,0BAA0B,CAAC,sBAAsB;gBACzD,GAAG,KAAK,0BAA0B,CAAC,kBAAkB,CACtD,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,MAAM,QAAQ,GAAgB;gBAC5B,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;gBAC/C,UAAU,EAAE,kBAAkB;aAC/B,CAAC;YACF,MAAM,QAAQ,GAAa;gBACzB,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 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"]}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],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) 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, HrTime } from \"@opentelemetry/api\";\nimport { hrTimeToNanoseconds } from \"@opentelemetry/core\";\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 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 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionStringParser.js","sourceRoot":"","sources":["../../../src/utils/connectionStringParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAK1B,MAAM,CAAC,KAAK,CAAC,gBAAyB;QAC3C,IAAI,CAAC,gBAAgB,EAAE;
|
|
1
|
+
{"version":3,"file":"connectionStringParser.js","sourceRoot":"","sources":["../../../src/utils/connectionStringParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAK1B,MAAM,CAAC,KAAK,CAAC,gBAAyB;QAC3C,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;QAChF,IAAI,OAAO,GAAG,IAAI,CAAC;QAEnB,MAAM,MAAM,GAAqB,OAA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B,CAAC,MAAM,CAAC;YACtF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;YAC/C,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,UAAU,GAAG,gEAAgE,CAAC;QACpF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;QACtC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;;AArFuB,uCAAgB,GAAG,GAAG,CAAC;AAEvB,gDAAyB,GAAG,GAAG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { diag } from \"@opentelemetry/api\";\nimport { ConnectionString, ConnectionStringKey } from \"../Declarations/Contracts\";\n\nimport * as Constants from \"../Declarations/Constants\";\n\n/**\n * ConnectionString parser.\n * @internal\n */\nexport class ConnectionStringParser {\n private static readonly FIELDS_SEPARATOR = \";\";\n\n private static readonly FIELD_KEY_VALUE_SEPARATOR = \"=\";\n\n public static parse(connectionString?: string): ConnectionString {\n if (!connectionString) {\n return {};\n }\n\n const kvPairs = connectionString.split(ConnectionStringParser.FIELDS_SEPARATOR);\n let isValid = true;\n\n const result: ConnectionString = kvPairs.reduce((fields: ConnectionString, kv: string) => {\n const kvParts = kv.split(ConnectionStringParser.FIELD_KEY_VALUE_SEPARATOR);\n\n if (kvParts.length === 2) {\n // only save fields with valid formats\n const key = kvParts[0].toLowerCase() as ConnectionStringKey;\n const value = kvParts[1];\n return { ...fields, [key]: value };\n }\n diag.error(\n `Connection string key-value pair is invalid: ${kv}`,\n `Entire connection string will be discarded`,\n connectionString,\n );\n isValid = false;\n return fields;\n }, {});\n\n if (isValid && Object.keys(result).length > 0) {\n // this is a valid connection string, so parse the results\n\n if (result.endpointsuffix) {\n // use endpoint suffix where overrides are not provided\n const locationPrefix = result.location ? `${result.location}.` : \"\";\n result.ingestionendpoint =\n result.ingestionendpoint || `https://${locationPrefix}dc.${result.endpointsuffix}`;\n result.liveendpoint =\n result.liveendpoint || `https://${locationPrefix}live.${result.endpointsuffix}`;\n }\n\n result.ingestionendpoint = result.ingestionendpoint\n ? ConnectionStringParser.sanitizeUrl(result.ingestionendpoint)\n : Constants.DEFAULT_BREEZE_ENDPOINT;\n result.liveendpoint = result.liveendpoint\n ? ConnectionStringParser.sanitizeUrl(result.liveendpoint)\n : Constants.DEFAULT_LIVEMETRICS_ENDPOINT;\n if (result.authorization && result.authorization.toLowerCase() !== \"ikey\") {\n diag.warn(\n `Connection String contains an unsupported 'Authorization' value: ${result.authorization!}. Defaulting to 'Authorization=ikey'. Instrumentation Key ${result.instrumentationkey!}`,\n );\n }\n } else {\n diag.error(\n \"An invalid connection string was passed in. There may be telemetry loss\",\n connectionString,\n );\n }\n\n return result;\n }\n\n public static sanitizeUrl(url: string) {\n let newUrl = url.trim();\n if (newUrl.indexOf(\"https://\") < 0) {\n // Try to update http to https\n newUrl = newUrl.replace(\"http://\", \"https://\");\n }\n // Remove final slash if present\n if (newUrl[newUrl.length - 1] === \"/\") {\n newUrl = newUrl.slice(0, -1);\n }\n return newUrl;\n }\n\n public static validateInstrumentationKey(iKey: string): boolean {\n if (iKey.startsWith(\"InstrumentationKey=\")) {\n const startIndex = iKey.indexOf(\"InstrumentationKey=\") + \"InstrumentationKey=\".length;\n const endIndex = iKey.indexOf(\";\", startIndex);\n iKey = iKey.substring(startIndex, endIndex);\n }\n const UUID_Regex = \"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$\";\n const regexp = new RegExp(UUID_Regex);\n return regexp.test(iKey);\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license
|
|
2
|
+
// Licensed under the MIT license
|
|
3
3
|
/**
|
|
4
4
|
* AI MS Links.
|
|
5
5
|
* @internal
|
|
@@ -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.21";
|
|
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,
|
|
1
|
+
{"version":3,"file":"applicationinsights.js","sourceRoot":"","sources":["../../../../src/utils/constants/applicationinsights.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,iCAAiC;AAEjC;;;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,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.21\";\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 = \"_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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventhub.js","sourceRoot":"","sources":["../../../src/utils/eventhub.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAGzE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EACL,WAAW,EACX,qBAAqB,GAEtB,MAAM,+BAA+B,CAAC;AAEvC;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,IAAkB,EAAE,EAAE;IAClD,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAC1B,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,MAAM,WAAW,GAAG,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEzD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;QACpC,MAAM,YAAY,GAAG,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,aAAa,CAAoB,CAAC;QACpE,IAAI,YAAY,EAAE;
|
|
1
|
+
{"version":3,"file":"eventhub.js","sourceRoot":"","sources":["../../../src/utils/eventhub.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,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AqB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,IAAI,SAAS,CAAW,CAAC;IAE9F,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,QAAQ,CAAC,MAAM;YAClB,QAAQ,CAAC,IAAI,GAAG,SAAS,CAAC;YAC1B,QAAQ,CAAC,MAAM,GAAG,GAAG,WAAW,IAAI,qBAAqB,EAAE,CAAC;YAC5D,MAAM;QACR,KAAK,QAAQ,CAAC,QAAQ;YACpB,QAAQ,CAAC,IAAI,GAAG,mBAAmB,SAAS,EAAE,CAAC;YAC/C,QAAQ,CAAC,MAAM,GAAG,GAAG,WAAW,IAAI,qBAAqB,EAAE,CAAC;YAC5D,MAAM;QACR,KAAK,QAAQ,CAAC,QAAQ;YACpB,QAAQ,CAAC,IAAI,GAAG,mBAAmB,SAAS,EAAE,CAAC;YAC9C,QAAgB,CAAC,MAAM,GAAG,GAAG,WAAW,IAAI,qBAAqB,EAAE,CAAC;YACrE,QAAQ,CAAC,YAAY,mCAChB,QAAQ,CAAC,YAAY,KACxB,CAAC,mBAAmB,CAAC,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAClD,CAAC;YACF,MAAM;QACR,QAAQ,CAAC,QAAQ;IACnB,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SpanKind } from \"@opentelemetry/api\";\nimport { hrTimeToMilliseconds } from \"@opentelemetry/core\";\nimport { SemanticAttributes } from \"@opentelemetry/semantic-conventions\";\nimport { ReadableSpan } from \"@opentelemetry/sdk-trace-base\";\nimport { RemoteDependencyData, RequestData } from \"../generated\";\nimport { TIME_SINCE_ENQUEUED, ENQUEUED_TIME } from \"./constants/applicationinsights\";\nimport {\n AzNamespace,\n MessageBusDestination,\n MicrosoftEventHub,\n} from \"./constants/span/azAttributes\";\n\n/**\n * Average span.links[].attributes.enqueuedTime\n */\nconst getTimeSinceEnqueued = (span: ReadableSpan) => {\n let countEnqueueDiffs = 0;\n let sumEnqueueDiffs = 0;\n const startTimeMs = hrTimeToMilliseconds(span.startTime);\n\n span.links.forEach(({ attributes }) => {\n const enqueuedTime = attributes?.[ENQUEUED_TIME] as string | number;\n if (enqueuedTime) {\n countEnqueueDiffs += 1;\n sumEnqueueDiffs += startTimeMs - (parseFloat(enqueuedTime.toString()) || 0);\n }\n });\n\n return Math.max(sumEnqueueDiffs / (countEnqueueDiffs || 1), 0);\n};\n\n/**\n * Implementation of Mapping to Azure Monitor\n *\n * https://gist.github.com/lmolkova/e4215c0f44a49ef824983382762e6b92#mapping-to-azure-monitor-application-insights-telemetry\n * @internal\n */\nexport const parseEventHubSpan = (\n span: ReadableSpan,\n baseData: RequestData | RemoteDependencyData,\n): void => {\n const namespace = span.attributes[AzNamespace] as typeof MicrosoftEventHub;\n const peerAddress = (\n (span.attributes[SemanticAttributes.NET_PEER_NAME] ||\n span.attributes[\"peer.address\"] ||\n \"unknown\") as string\n ).replace(/\\/$/g, \"\"); // remove trailing \"/\"\n const messageBusDestination = (span.attributes[MessageBusDestination] || \"unknown\") as string;\n\n switch (span.kind) {\n case SpanKind.CLIENT:\n baseData.type = namespace;\n baseData.target = `${peerAddress}/${messageBusDestination}`;\n break;\n case SpanKind.PRODUCER:\n baseData.type = `Queue Message | ${namespace}`;\n baseData.target = `${peerAddress}/${messageBusDestination}`;\n break;\n case SpanKind.CONSUMER:\n baseData.type = `Queue Message | ${namespace}`;\n (baseData as any).source = `${peerAddress}/${messageBusDestination}`;\n baseData.measurements = {\n ...baseData.measurements,\n [TIME_SINCE_ENQUEUED]: getTimeSinceEnqueued(span),\n };\n break;\n default: // no op\n }\n};\n"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
import { KnownContextTagKeys, KnownSeverityLevel, } from "../generated";
|
|
4
|
-
import { createTagsFromResource } from "./common";
|
|
4
|
+
import { createTagsFromResource, hrTimeToDate } from "./common";
|
|
5
5
|
import { SemanticAttributes } from "@opentelemetry/semantic-conventions";
|
|
6
|
-
import { hrTimeToMilliseconds } from "@opentelemetry/core";
|
|
7
6
|
import { diag } from "@opentelemetry/api";
|
|
8
7
|
import { ApplicationInsightsAvailabilityBaseType, ApplicationInsightsAvailabilityName, ApplicationInsightsBaseType, ApplicationInsightsEventBaseType, ApplicationInsightsEventName, ApplicationInsightsExceptionBaseType, ApplicationInsightsExceptionName, ApplicationInsightsMessageBaseType, ApplicationInsightsMessageName, ApplicationInsightsPageViewBaseType, ApplicationInsightsPageViewName, } from "./constants/applicationinsights";
|
|
9
8
|
/**
|
|
@@ -11,7 +10,7 @@ import { ApplicationInsightsAvailabilityBaseType, ApplicationInsightsAvailabilit
|
|
|
11
10
|
* @internal
|
|
12
11
|
*/
|
|
13
12
|
export function logToEnvelope(log, ikey) {
|
|
14
|
-
const time =
|
|
13
|
+
const time = hrTimeToDate(log.hrTime);
|
|
15
14
|
const sampleRate = 100;
|
|
16
15
|
const instrumentationKey = ikey;
|
|
17
16
|
const tags = createTagsFromLog(log);
|
|
@@ -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,kCA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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 const 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 const exceptionType = log.attributes[SemanticAttributes.EXCEPTION_TYPE];\n if (exceptionType) {\n const exceptionMessage = log.attributes[SemanticAttributes.EXCEPTION_MESSAGE];\n const exceptionStacktrace = log.attributes[SemanticAttributes.EXCEPTION_STACKTRACE];\n name = ApplicationInsightsExceptionName;\n baseType = ApplicationInsightsExceptionBaseType;\n const 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"]}
|
|
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,YAAY,EAAE,MAAM,UAAU,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,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,YAAY,CAAC,GAAG,CAAC,MAAM,CA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AC,IAAI,CAAiB,CAAC;oBAChD,MAAM;gBACR,KAAK,gCAAgC;oBACnC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAuB,CAAC;oBACtD,MAAM;YACV,CAAC;YACD,IAAI,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAA,KAAK,QAAQ,EAAE,CAAC;gBAC1C,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,CAAC,wEAAwE,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;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, hrTimeToDate } from \"./common\";\nimport { ReadableLogRecord } from \"@opentelemetry/sdk-logs\";\nimport { SemanticAttributes } from \"@opentelemetry/semantic-conventions\";\nimport { Measurements, Properties, Tags } from \"../types\";\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 = hrTimeToDate(log.hrTime);\n const 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 const exceptionType = log.attributes[SemanticAttributes.EXCEPTION_TYPE];\n if (exceptionType) {\n const exceptionMessage = log.attributes[SemanticAttributes.EXCEPTION_MESSAGE];\n const exceptionStacktrace = log.attributes[SemanticAttributes.EXCEPTION_STACKTRACE];\n name = ApplicationInsightsExceptionName;\n baseType = ApplicationInsightsExceptionBaseType;\n const 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"]}
|
|
@@ -56,7 +56,7 @@ export function resourceMetricsToEnvelope(metrics, ikey, isStatsbeat) {
|
|
|
56
56
|
const envelope = {
|
|
57
57
|
name: envelopeName,
|
|
58
58
|
time: time,
|
|
59
|
-
sampleRate: 100,
|
|
59
|
+
sampleRate: 100, // Metrics are never sampled
|
|
60
60
|
instrumentationKey: instrumentationKey,
|
|
61
61
|
tags: tags,
|
|
62
62
|
version: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metricUtils.js","sourceRoot":"","sources":["../../../src/utils/metricUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,aAAa,EAA8B,MAAM,4BAA4B,CAAC;AAEvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,SAAS,oCAAoC,CAAC,UAAuB;IAGnE,MAAM,UAAU,GAAuC,EAAE,CAAC;IAC1D,IAAI,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"metricUtils.js","sourceRoot":"","sources":["../../../src/utils/metricUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,aAAa,EAA8B,MAAM,4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port { DataPointType, Histogram, ResourceMetrics } from \"@opentelemetry/sdk-metrics\";\nimport { TelemetryItem as Envelope, MetricsData, MetricDataPoint } from \"../generated\";\nimport { createTagsFromResource } from \"./common\";\n\nfunction createPropertiesFromMetricAttributes(attributes?: Attributes): {\n [propertyName: string]: string;\n} {\n const properties: { [propertyName: string]: string } = {};\n if (attributes) {\n for (const key of Object.keys(attributes)) {\n properties[key] = attributes[key] as string;\n }\n }\n return properties;\n}\n\n/**\n * Metric to Azure envelope parsing.\n * @internal\n */\nexport function resourceMetricsToEnvelope(\n metrics: ResourceMetrics,\n ikey: string,\n isStatsbeat?: boolean,\n): Envelope[] {\n const envelopes: Envelope[] = [];\n const time = new Date();\n const instrumentationKey = ikey;\n const tags = createTagsFromResource(metrics.resource);\n let envelopeName: string;\n\n if (isStatsbeat) {\n envelopeName = \"Microsoft.ApplicationInsights.Statsbeat\";\n } else {\n envelopeName = \"Microsoft.ApplicationInsights.Metric\";\n }\n\n metrics.scopeMetrics.forEach((scopeMetric) => {\n scopeMetric.metrics.forEach((metric) => {\n metric.dataPoints.forEach((dataPoint) => {\n const baseData: MetricsData = {\n metrics: [],\n version: 2,\n properties: {},\n };\n baseData.properties = createPropertiesFromMetricAttributes(dataPoint.attributes);\n const metricDataPoint: MetricDataPoint = {\n name: metric.descriptor.name,\n value: 0,\n dataPointType: \"Aggregation\",\n };\n if (\n metric.dataPointType === DataPointType.SUM ||\n metric.dataPointType === DataPointType.GAUGE\n ) {\n metricDataPoint.value = dataPoint.value as number;\n metricDataPoint.count = 1;\n } else {\n metricDataPoint.value = (dataPoint.value as Histogram).sum || 0;\n metricDataPoint.count = (dataPoint.value as Histogram).count;\n metricDataPoint.max = (dataPoint.value as Histogram).max;\n metricDataPoint.min = (dataPoint.value as Histogram).min;\n }\n baseData.metrics.push(metricDataPoint);\n const envelope: Envelope = {\n name: envelopeName,\n time: time,\n sampleRate: 100, // Metrics are never sampled\n instrumentationKey: instrumentationKey,\n tags: tags,\n version: 1,\n data: {\n baseType: \"MetricData\",\n baseData: {\n ...baseData,\n },\n },\n };\n envelopes.push(envelope);\n });\n });\n });\n\n return envelopes;\n}\n"]}
|
|
@@ -4,12 +4,12 @@ import { URL } from "url";
|
|
|
4
4
|
import { hrTimeToMilliseconds } from "@opentelemetry/core";
|
|
5
5
|
import { diag, SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
6
6
|
import { SemanticAttributes, DbSystemValues } from "@opentelemetry/semantic-conventions";
|
|
7
|
-
import { createTagsFromResource, getDependencyTarget, getUrl, isSqlDB } from "./common";
|
|
8
|
-
import { msToTimeSpan } from "./breezeUtils";
|
|
7
|
+
import { createTagsFromResource, getDependencyTarget, getUrl, hrTimeToDate, isSqlDB, } from "./common";
|
|
9
8
|
import { parseEventHubSpan } from "./eventhub";
|
|
10
9
|
import { AzureMonitorSampleRate, DependencyTypes, MS_LINKS } from "./constants/applicationinsights";
|
|
11
10
|
import { AzNamespace, MicrosoftEventHub } from "./constants/span/azAttributes";
|
|
12
11
|
import { KnownContextTagKeys, } from "../generated";
|
|
12
|
+
import { msToTimeSpan } from "./breezeUtils";
|
|
13
13
|
function createTagsFromSpan(span) {
|
|
14
14
|
const tags = createTagsFromResource(span.resource);
|
|
15
15
|
tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;
|
|
@@ -96,10 +96,11 @@ function createPropertiesFromSpan(span) {
|
|
|
96
96
|
return [properties, measurements];
|
|
97
97
|
}
|
|
98
98
|
function createDependencyData(span) {
|
|
99
|
+
var _a;
|
|
99
100
|
const remoteDependencyData = {
|
|
100
|
-
name: span.name,
|
|
101
|
+
name: span.name, // Default
|
|
101
102
|
id: `${span.spanContext().spanId}`,
|
|
102
|
-
success: span.status.code !== SpanStatusCode.ERROR,
|
|
103
|
+
success: ((_a = span.status) === null || _a === void 0 ? void 0 : _a.code) !== SpanStatusCode.ERROR,
|
|
103
104
|
resultCode: "0",
|
|
104
105
|
type: "Dependency",
|
|
105
106
|
duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),
|
|
@@ -241,7 +242,7 @@ export function readableSpanToEnvelope(span, ikey) {
|
|
|
241
242
|
let name;
|
|
242
243
|
let baseType;
|
|
243
244
|
let baseData;
|
|
244
|
-
const time =
|
|
245
|
+
const time = hrTimeToDate(span.startTime);
|
|
245
246
|
const instrumentationKey = ikey;
|
|
246
247
|
const tags = createTagsFromSpan(span);
|
|
247
248
|
const [properties, measurements] = createPropertiesFromSpan(span);
|
|
@@ -302,7 +303,7 @@ export function spanEventsToEnvelopes(span, ikey) {
|
|
|
302
303
|
span.events.forEach((event) => {
|
|
303
304
|
var _a;
|
|
304
305
|
let baseType;
|
|
305
|
-
const time =
|
|
306
|
+
const time = hrTimeToDate(event.time);
|
|
306
307
|
let name = "";
|
|
307
308
|
let baseData;
|
|
308
309
|
const properties = createPropertiesFromSpanAttributes(event.attributes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spanUtils.js","sourceRoot":"","sources":["../../../src/utils/spanUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAoB,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAEzF,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,M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AAU;gBACtB,IAAI,EAAE;oBACJ,QAAQ,EAAE,QAAQ;oBAClB,QAAQ,EAAE,QAAQ;iBACnB;gBACD,IAAI,EAAE,IAAI;aACX,CAAC;YACF,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;KACJ;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { URL } from \"url\";\nimport { ReadableSpan, TimedEvent } from \"@opentelemetry/sdk-trace-base\";\nimport { hrTimeToMilliseconds } from \"@opentelemetry/core\";\nimport { diag, SpanKind, SpanStatusCode, Link, Attributes } from \"@opentelemetry/api\";\nimport { SemanticAttributes, DbSystemValues } from \"@opentelemetry/semantic-conventions\";\n\nimport { createTagsFromResource, getDependencyTarget, getUrl, isSqlDB } from \"./common\";\nimport { Tags, Properties, MSLink, Measurements } from \"../types\";\nimport { msToTimeSpan } from \"./breezeUtils\";\nimport { parseEventHubSpan } from \"./eventhub\";\nimport { AzureMonitorSampleRate, DependencyTypes, MS_LINKS } from \"./constants/applicationinsights\";\nimport { AzNamespace, MicrosoftEventHub } from \"./constants/span/azAttributes\";\nimport {\n TelemetryExceptionData,\n MessageData,\n RemoteDependencyData,\n RequestData,\n TelemetryItem as Envelope,\n KnownContextTagKeys,\n TelemetryExceptionDetails,\n} from \"../generated\";\n\nfunction createTagsFromSpan(span: ReadableSpan): Tags {\n const tags: Tags = createTagsFromResource(span.resource);\n tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;\n if (span.parentSpanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = span.parentSpanId;\n }\n const httpUserAgent = span.attributes[SemanticAttributes.HTTP_USER_AGENT];\n if (httpUserAgent) {\n // TODO: Not exposed in Swagger, need to update def\n tags[\"ai.user.userAgent\"] = String(httpUserAgent);\n }\n if (span.kind === SpanKind.SERVER) {\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const httpClientIp = span.attributes[SemanticAttributes.HTTP_CLIENT_IP];\n const netPeerIp = span.attributes[SemanticAttributes.NET_PEER_IP];\n if (httpMethod) {\n const httpRoute = span.attributes[SemanticAttributes.HTTP_ROUTE];\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n tags[KnownContextTagKeys.AiOperationName] = span.name; // Default\n if (httpRoute) {\n tags[KnownContextTagKeys.AiOperationName] = `${httpMethod as string} ${\n httpRoute as string\n }`;\n } else if (httpUrl) {\n try {\n const url = new URL(String(httpUrl));\n tags[KnownContextTagKeys.AiOperationName] = `${httpMethod} ${url.pathname}`;\n } catch (ex: any) {}\n }\n if (httpClientIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(httpClientIp);\n } else if (netPeerIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);\n }\n } else {\n tags[KnownContextTagKeys.AiOperationName] = span.name;\n if (netPeerIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);\n }\n }\n }\n // TODO: Operation Name and Location IP TBD for non server spans\n\n return tags;\n}\n\nfunction createPropertiesFromSpanAttributes(attributes?: Attributes): {\n [propertyName: string]: string;\n} {\n const properties: { [propertyName: string]: string } = {};\n if (attributes) {\n for (const key of Object.keys(attributes)) {\n // Avoid duplication ignoring fields already mapped.\n if (\n !(\n key.startsWith(\"_MS.\") ||\n key === SemanticAttributes.NET_PEER_IP ||\n key === SemanticAttributes.NET_PEER_NAME ||\n key === SemanticAttributes.PEER_SERVICE ||\n key === SemanticAttributes.HTTP_METHOD ||\n key === SemanticAttributes.HTTP_URL ||\n key === SemanticAttributes.HTTP_STATUS_CODE ||\n key === SemanticAttributes.HTTP_ROUTE ||\n key === SemanticAttributes.HTTP_HOST ||\n key === SemanticAttributes.HTTP_URL ||\n key === SemanticAttributes.DB_SYSTEM ||\n key === SemanticAttributes.DB_STATEMENT ||\n key === SemanticAttributes.DB_OPERATION ||\n key === SemanticAttributes.DB_NAME ||\n key === SemanticAttributes.RPC_SYSTEM ||\n key === SemanticAttributes.RPC_GRPC_STATUS_CODE\n )\n ) {\n properties[key] = attributes[key] as string;\n }\n }\n }\n return properties;\n}\n\nfunction createPropertiesFromSpan(span: ReadableSpan): [Properties, Measurements] {\n const properties: Properties = createPropertiesFromSpanAttributes(span.attributes);\n const measurements: Measurements = {};\n\n const links: MSLink[] = span.links.map((link: Link) => ({\n operation_Id: link.context.traceId,\n id: link.context.spanId,\n }));\n if (links.length > 0) {\n properties[MS_LINKS] = JSON.stringify(links);\n }\n return [properties, measurements];\n}\n\nfunction createDependencyData(span: ReadableSpan): RemoteDependencyData {\n const remoteDependencyData: RemoteDependencyData = {\n name: span.name, // Default\n id: `${span.spanContext().spanId}`,\n success: span.status.code !== SpanStatusCode.ERROR,\n resultCode: \"0\",\n type: \"Dependency\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2,\n };\n if (span.kind === SpanKind.PRODUCER) {\n remoteDependencyData.type = DependencyTypes.QueueMessage;\n }\n if (span.kind === SpanKind.INTERNAL && span.parentSpanId) {\n remoteDependencyData.type = DependencyTypes.InProc;\n }\n\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const dbSystem = span.attributes[SemanticAttributes.DB_SYSTEM];\n const rpcSystem = span.attributes[SemanticAttributes.RPC_SYSTEM];\n // HTTP Dependency\n if (httpMethod) {\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n if (httpUrl) {\n try {\n const dependencyUrl = new URL(String(httpUrl));\n remoteDependencyData.name = `${httpMethod} ${dependencyUrl.pathname}`;\n } catch (ex: any) {}\n }\n remoteDependencyData.type = DependencyTypes.Http;\n remoteDependencyData.data = getUrl(span.attributes);\n const httpStatusCode = span.attributes[SemanticAttributes.HTTP_STATUS_CODE];\n if (httpStatusCode) {\n remoteDependencyData.resultCode = String(httpStatusCode);\n }\n let target = getDependencyTarget(span.attributes);\n if (target) {\n try {\n // Remove default port\n const portRegex = new RegExp(/(https?)(:\\/\\/.*)(:\\d+)(\\S*)/);\n const res = portRegex.exec(target);\n if (res !== null) {\n const protocol = res[1];\n const port = res[3];\n if (\n (protocol === \"https\" && port === \":443\") ||\n (protocol === \"http\" && port === \":80\")\n ) {\n // Drop port\n target = res[1] + res[2] + res[4];\n }\n }\n } catch (ex: any) {}\n remoteDependencyData.target = `${target}`;\n }\n }\n // DB Dependency\n else if (dbSystem) {\n // TODO: Remove special logic when Azure UX supports OpenTelemetry dbSystem\n if (String(dbSystem) === DbSystemValues.MYSQL) {\n remoteDependencyData.type = \"mysql\";\n } else if (String(dbSystem) === DbSystemValues.POSTGRESQL) {\n remoteDependencyData.type = \"postgresql\";\n } else if (String(dbSystem) === DbSystemValues.MONGODB) {\n remoteDependencyData.type = \"mongodb\";\n } else if (String(dbSystem) === DbSystemValues.REDIS) {\n remoteDependencyData.type = \"redis\";\n } else if (isSqlDB(String(dbSystem))) {\n remoteDependencyData.type = \"SQL\";\n } else {\n remoteDependencyData.type = String(dbSystem);\n }\n const dbStatement = span.attributes[SemanticAttributes.DB_STATEMENT];\n const dbOperation = span.attributes[SemanticAttributes.DB_OPERATION];\n if (dbStatement) {\n remoteDependencyData.data = String(dbStatement);\n } else if (dbOperation) {\n remoteDependencyData.data = String(dbOperation);\n }\n const target = getDependencyTarget(span.attributes);\n const dbName = span.attributes[SemanticAttributes.DB_NAME];\n if (target) {\n remoteDependencyData.target = dbName ? `${target}|${dbName}` : `${target}`;\n } else {\n remoteDependencyData.target = dbName ? `${dbName}` : `${dbSystem}`;\n }\n }\n // grpc Dependency\n else if (rpcSystem) {\n if (rpcSystem == DependencyTypes.Wcf) {\n remoteDependencyData.type = DependencyTypes.Wcf;\n } else {\n remoteDependencyData.type = DependencyTypes.Grpc;\n }\n const grpcStatusCode = span.attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];\n if (grpcStatusCode) {\n remoteDependencyData.resultCode = String(grpcStatusCode);\n }\n const target = getDependencyTarget(span.attributes);\n if (target) {\n remoteDependencyData.target = `${target}`;\n } else if (rpcSystem) {\n remoteDependencyData.target = String(rpcSystem);\n }\n }\n return remoteDependencyData;\n}\n\nfunction createRequestData(span: ReadableSpan): RequestData {\n const requestData: RequestData = {\n id: `${span.spanContext().spanId}`,\n success: span.status.code !== SpanStatusCode.ERROR,\n responseCode: \"0\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2,\n source: undefined,\n };\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const grpcStatusCode = span.attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];\n if (httpMethod) {\n requestData.url = getUrl(span.attributes);\n const httpStatusCode = span.attributes[SemanticAttributes.HTTP_STATUS_CODE];\n if (httpStatusCode) {\n requestData.responseCode = String(httpStatusCode);\n }\n } else if (grpcStatusCode) {\n requestData.responseCode = String(grpcStatusCode);\n }\n return requestData;\n}\n\n/**\n * Span to Azure envelope parsing.\n * @internal\n */\nexport function readableSpanToEnvelope(span: ReadableSpan, ikey: string): Envelope {\n let name: string;\n let baseType: \"RemoteDependencyData\" | \"RequestData\";\n let baseData: RemoteDependencyData | RequestData;\n\n const time = new Date(hrTimeToMilliseconds(span.startTime));\n const instrumentationKey = ikey;\n const tags = createTagsFromSpan(span);\n const [properties, measurements] = createPropertiesFromSpan(span);\n switch (span.kind) {\n case SpanKind.CLIENT:\n case SpanKind.PRODUCER:\n case SpanKind.INTERNAL:\n name = \"Microsoft.ApplicationInsights.RemoteDependency\";\n baseType = \"RemoteDependencyData\";\n baseData = createDependencyData(span);\n break;\n case SpanKind.SERVER:\n case SpanKind.CONSUMER:\n name = \"Microsoft.ApplicationInsights.Request\";\n baseType = \"RequestData\";\n baseData = createRequestData(span);\n baseData.name = tags[KnownContextTagKeys.AiOperationName];\n break;\n default:\n // never\n diag.error(`Unsupported span kind ${span.kind}`);\n throw new Error(`Unsupported span kind ${span.kind}`);\n }\n\n let sampleRate = 100;\n if (span.attributes[AzureMonitorSampleRate]) {\n sampleRate = Number(span.attributes[AzureMonitorSampleRate]);\n }\n\n // Azure SDK\n if (span.attributes[AzNamespace]) {\n if (span.kind === SpanKind.INTERNAL) {\n baseData.type = `${DependencyTypes.InProc} | ${span.attributes[AzNamespace]}`;\n }\n if (span.attributes[AzNamespace] === MicrosoftEventHub) {\n parseEventHubSpan(span, baseData);\n }\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\n/**\n * Span Events to Azure envelopes parsing.\n * @internal\n */\nexport function spanEventsToEnvelopes(span: ReadableSpan, ikey: string): Envelope[] {\n const envelopes: Envelope[] = [];\n if (span.events) {\n span.events.forEach((event: TimedEvent) => {\n let baseType: \"ExceptionData\" | \"MessageData\";\n const time = new Date(hrTimeToMilliseconds(event.time));\n let name = \"\";\n let baseData: TelemetryExceptionData | MessageData;\n const properties = createPropertiesFromSpanAttributes(event.attributes);\n\n const tags: Tags = createTagsFromResource(span.resource);\n tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;\n const spanId = span.spanContext()?.spanId;\n if (spanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = spanId;\n }\n\n // Only generate exception telemetry for incoming requests\n if (event.name === \"exception\" && span.kind === SpanKind.SERVER) {\n name = \"Microsoft.ApplicationInsights.Exception\";\n baseType = \"ExceptionData\";\n let typeName = \"\";\n let message = \"Exception\";\n let stack = \"\";\n let hasFullStack = false;\n if (event.attributes) {\n typeName = String(event.attributes[SemanticAttributes.EXCEPTION_TYPE]);\n stack = String(event.attributes[SemanticAttributes.EXCEPTION_STACKTRACE]);\n if (stack) {\n hasFullStack = true;\n }\n const exceptionMsg = event.attributes[SemanticAttributes.EXCEPTION_MESSAGE];\n if (exceptionMsg) {\n message = String(exceptionMsg);\n }\n const escaped = event.attributes[SemanticAttributes.EXCEPTION_ESCAPED];\n if (escaped !== undefined) {\n properties[SemanticAttributes.EXCEPTION_ESCAPED] = String(escaped);\n }\n }\n const exceptionDetails: TelemetryExceptionDetails = {\n typeName: typeName,\n message: message,\n stack: stack,\n hasFullStack: hasFullStack,\n };\n const exceptionData: TelemetryExceptionData = {\n exceptions: [exceptionDetails],\n version: 2,\n properties: properties,\n };\n baseData = exceptionData;\n } else {\n name = \"Microsoft.ApplicationInsights.Message\";\n baseType = \"MessageData\";\n const messageData: MessageData = {\n message: event.name,\n version: 2,\n properties: properties,\n };\n baseData = messageData;\n }\n let sampleRate = 100;\n if (span.attributes[AzureMonitorSampleRate]) {\n sampleRate = Number(span.attributes[AzureMonitorSampleRate]);\n }\n const env: Envelope = {\n name: name,\n time: time,\n instrumentationKey: ikey,\n version: 1,\n sampleRate: sampleRate,\n data: {\n baseType: baseType,\n baseData: baseData,\n },\n tags: tags,\n };\n envelopes.push(env);\n });\n }\n return envelopes;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"spanUtils.js","sourceRoot":"","sources":["../../../src/utils/spanUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAoB,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAEzF,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,MAAM,EACN,YAAY,EACZ,OAAO,GACR,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAML,mBAAmB,GAEpB,MAAM,cAAc,C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,CAAC;oBAC9B,OAAO,EAAE,CAAC;oBACV,UAAU,EAAE,UAAU;iBACvB,CAAC;gBACF,QAAQ,GAAG,aAAa,CAAC;YAC3B,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,uCAAuC,CAAC;gBAC/C,QAAQ,GAAG,aAAa,CAAC;gBACzB,MAAM,WAAW,GAAgB;oBAC/B,OAAO,EAAE,KAAK,CAAC,IAAI;oBACnB,OAAO,EAAE,CAAC;oBACV,UAAU,EAAE,UAAU;iBACvB,CAAC;gBACF,QAAQ,GAAG,WAAW,CAAC;YACzB,CAAC;YACD,IAAI,UAAU,GAAG,GAAG,CAAC;YACrB,IAAI,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,CAAC;gBAC5C,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC,CAAC;YAC/D,CAAC;YACD,MAAM,GAAG,GAAa;gBACpB,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,IAAI;gBACV,kBAAkB,EAAE,IAAI;gBACxB,OAAO,EAAE,CAAC;gBACV,UAAU,EAAE,UAAU;gBACtB,IAAI,EAAE;oBACJ,QAAQ,EAAE,QAAQ;oBAClB,QAAQ,EAAE,QAAQ;iBACnB;gBACD,IAAI,EAAE,IAAI;aACX,CAAC;YACF,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { URL } from \"url\";\nimport { ReadableSpan, TimedEvent } from \"@opentelemetry/sdk-trace-base\";\nimport { hrTimeToMilliseconds } from \"@opentelemetry/core\";\nimport { diag, SpanKind, SpanStatusCode, Link, Attributes } from \"@opentelemetry/api\";\nimport { SemanticAttributes, DbSystemValues } from \"@opentelemetry/semantic-conventions\";\n\nimport {\n createTagsFromResource,\n getDependencyTarget,\n getUrl,\n hrTimeToDate,\n isSqlDB,\n} from \"./common\";\nimport { Tags, Properties, MSLink, Measurements } from \"../types\";\nimport { parseEventHubSpan } from \"./eventhub\";\nimport { AzureMonitorSampleRate, DependencyTypes, MS_LINKS } from \"./constants/applicationinsights\";\nimport { AzNamespace, MicrosoftEventHub } from \"./constants/span/azAttributes\";\nimport {\n TelemetryExceptionData,\n MessageData,\n RemoteDependencyData,\n RequestData,\n TelemetryItem as Envelope,\n KnownContextTagKeys,\n TelemetryExceptionDetails,\n} from \"../generated\";\nimport { msToTimeSpan } from \"./breezeUtils\";\n\nfunction createTagsFromSpan(span: ReadableSpan): Tags {\n const tags: Tags = createTagsFromResource(span.resource);\n tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;\n if (span.parentSpanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = span.parentSpanId;\n }\n const httpUserAgent = span.attributes[SemanticAttributes.HTTP_USER_AGENT];\n if (httpUserAgent) {\n // TODO: Not exposed in Swagger, need to update def\n tags[\"ai.user.userAgent\"] = String(httpUserAgent);\n }\n if (span.kind === SpanKind.SERVER) {\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const httpClientIp = span.attributes[SemanticAttributes.HTTP_CLIENT_IP];\n const netPeerIp = span.attributes[SemanticAttributes.NET_PEER_IP];\n if (httpMethod) {\n const httpRoute = span.attributes[SemanticAttributes.HTTP_ROUTE];\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n tags[KnownContextTagKeys.AiOperationName] = span.name; // Default\n if (httpRoute) {\n tags[KnownContextTagKeys.AiOperationName] = `${httpMethod as string} ${\n httpRoute as string\n }`;\n } else if (httpUrl) {\n try {\n const url = new URL(String(httpUrl));\n tags[KnownContextTagKeys.AiOperationName] = `${httpMethod} ${url.pathname}`;\n } catch (ex: any) {}\n }\n if (httpClientIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(httpClientIp);\n } else if (netPeerIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);\n }\n } else {\n tags[KnownContextTagKeys.AiOperationName] = span.name;\n if (netPeerIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);\n }\n }\n }\n // TODO: Operation Name and Location IP TBD for non server spans\n\n return tags;\n}\n\nfunction createPropertiesFromSpanAttributes(attributes?: Attributes): {\n [propertyName: string]: string;\n} {\n const properties: { [propertyName: string]: string } = {};\n if (attributes) {\n for (const key of Object.keys(attributes)) {\n // Avoid duplication ignoring fields already mapped.\n if (\n !(\n key.startsWith(\"_MS.\") ||\n key === SemanticAttributes.NET_PEER_IP ||\n key === SemanticAttributes.NET_PEER_NAME ||\n key === SemanticAttributes.PEER_SERVICE ||\n key === SemanticAttributes.HTTP_METHOD ||\n key === SemanticAttributes.HTTP_URL ||\n key === SemanticAttributes.HTTP_STATUS_CODE ||\n key === SemanticAttributes.HTTP_ROUTE ||\n key === SemanticAttributes.HTTP_HOST ||\n key === SemanticAttributes.HTTP_URL ||\n key === SemanticAttributes.DB_SYSTEM ||\n key === SemanticAttributes.DB_STATEMENT ||\n key === SemanticAttributes.DB_OPERATION ||\n key === SemanticAttributes.DB_NAME ||\n key === SemanticAttributes.RPC_SYSTEM ||\n key === SemanticAttributes.RPC_GRPC_STATUS_CODE\n )\n ) {\n properties[key] = attributes[key] as string;\n }\n }\n }\n return properties;\n}\n\nfunction createPropertiesFromSpan(span: ReadableSpan): [Properties, Measurements] {\n const properties: Properties = createPropertiesFromSpanAttributes(span.attributes);\n const measurements: Measurements = {};\n\n const links: MSLink[] = span.links.map((link: Link) => ({\n operation_Id: link.context.traceId,\n id: link.context.spanId,\n }));\n if (links.length > 0) {\n properties[MS_LINKS] = JSON.stringify(links);\n }\n return [properties, measurements];\n}\n\nfunction createDependencyData(span: ReadableSpan): RemoteDependencyData {\n const remoteDependencyData: RemoteDependencyData = {\n name: span.name, // Default\n id: `${span.spanContext().spanId}`,\n success: span.status?.code !== SpanStatusCode.ERROR,\n resultCode: \"0\",\n type: \"Dependency\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2,\n };\n if (span.kind === SpanKind.PRODUCER) {\n remoteDependencyData.type = DependencyTypes.QueueMessage;\n }\n if (span.kind === SpanKind.INTERNAL && span.parentSpanId) {\n remoteDependencyData.type = DependencyTypes.InProc;\n }\n\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const dbSystem = span.attributes[SemanticAttributes.DB_SYSTEM];\n const rpcSystem = span.attributes[SemanticAttributes.RPC_SYSTEM];\n // HTTP Dependency\n if (httpMethod) {\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n if (httpUrl) {\n try {\n const dependencyUrl = new URL(String(httpUrl));\n remoteDependencyData.name = `${httpMethod} ${dependencyUrl.pathname}`;\n } catch (ex: any) {}\n }\n remoteDependencyData.type = DependencyTypes.Http;\n remoteDependencyData.data = getUrl(span.attributes);\n const httpStatusCode = span.attributes[SemanticAttributes.HTTP_STATUS_CODE];\n if (httpStatusCode) {\n remoteDependencyData.resultCode = String(httpStatusCode);\n }\n let target = getDependencyTarget(span.attributes);\n if (target) {\n try {\n // Remove default port\n const portRegex = new RegExp(/(https?)(:\\/\\/.*)(:\\d+)(\\S*)/);\n const res = portRegex.exec(target);\n if (res !== null) {\n const protocol = res[1];\n const port = res[3];\n if (\n (protocol === \"https\" && port === \":443\") ||\n (protocol === \"http\" && port === \":80\")\n ) {\n // Drop port\n target = res[1] + res[2] + res[4];\n }\n }\n } catch (ex: any) {}\n remoteDependencyData.target = `${target}`;\n }\n }\n // DB Dependency\n else if (dbSystem) {\n // TODO: Remove special logic when Azure UX supports OpenTelemetry dbSystem\n if (String(dbSystem) === DbSystemValues.MYSQL) {\n remoteDependencyData.type = \"mysql\";\n } else if (String(dbSystem) === DbSystemValues.POSTGRESQL) {\n remoteDependencyData.type = \"postgresql\";\n } else if (String(dbSystem) === DbSystemValues.MONGODB) {\n remoteDependencyData.type = \"mongodb\";\n } else if (String(dbSystem) === DbSystemValues.REDIS) {\n remoteDependencyData.type = \"redis\";\n } else if (isSqlDB(String(dbSystem))) {\n remoteDependencyData.type = \"SQL\";\n } else {\n remoteDependencyData.type = String(dbSystem);\n }\n const dbStatement = span.attributes[SemanticAttributes.DB_STATEMENT];\n const dbOperation = span.attributes[SemanticAttributes.DB_OPERATION];\n if (dbStatement) {\n remoteDependencyData.data = String(dbStatement);\n } else if (dbOperation) {\n remoteDependencyData.data = String(dbOperation);\n }\n const target = getDependencyTarget(span.attributes);\n const dbName = span.attributes[SemanticAttributes.DB_NAME];\n if (target) {\n remoteDependencyData.target = dbName ? `${target}|${dbName}` : `${target}`;\n } else {\n remoteDependencyData.target = dbName ? `${dbName}` : `${dbSystem}`;\n }\n }\n // grpc Dependency\n else if (rpcSystem) {\n if (rpcSystem == DependencyTypes.Wcf) {\n remoteDependencyData.type = DependencyTypes.Wcf;\n } else {\n remoteDependencyData.type = DependencyTypes.Grpc;\n }\n const grpcStatusCode = span.attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];\n if (grpcStatusCode) {\n remoteDependencyData.resultCode = String(grpcStatusCode);\n }\n const target = getDependencyTarget(span.attributes);\n if (target) {\n remoteDependencyData.target = `${target}`;\n } else if (rpcSystem) {\n remoteDependencyData.target = String(rpcSystem);\n }\n }\n return remoteDependencyData;\n}\n\nfunction createRequestData(span: ReadableSpan): RequestData {\n const requestData: RequestData = {\n id: `${span.spanContext().spanId}`,\n success: span.status.code !== SpanStatusCode.ERROR,\n responseCode: \"0\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2,\n source: undefined,\n };\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const grpcStatusCode = span.attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];\n if (httpMethod) {\n requestData.url = getUrl(span.attributes);\n const httpStatusCode = span.attributes[SemanticAttributes.HTTP_STATUS_CODE];\n if (httpStatusCode) {\n requestData.responseCode = String(httpStatusCode);\n }\n } else if (grpcStatusCode) {\n requestData.responseCode = String(grpcStatusCode);\n }\n return requestData;\n}\n\n/**\n * Span to Azure envelope parsing.\n * @internal\n */\nexport function readableSpanToEnvelope(span: ReadableSpan, ikey: string): Envelope {\n let name: string;\n let baseType: \"RemoteDependencyData\" | \"RequestData\";\n let baseData: RemoteDependencyData | RequestData;\n\n const time = hrTimeToDate(span.startTime);\n const instrumentationKey = ikey;\n const tags = createTagsFromSpan(span);\n const [properties, measurements] = createPropertiesFromSpan(span);\n switch (span.kind) {\n case SpanKind.CLIENT:\n case SpanKind.PRODUCER:\n case SpanKind.INTERNAL:\n name = \"Microsoft.ApplicationInsights.RemoteDependency\";\n baseType = \"RemoteDependencyData\";\n baseData = createDependencyData(span);\n break;\n case SpanKind.SERVER:\n case SpanKind.CONSUMER:\n name = \"Microsoft.ApplicationInsights.Request\";\n baseType = \"RequestData\";\n baseData = createRequestData(span);\n baseData.name = tags[KnownContextTagKeys.AiOperationName];\n break;\n default:\n // never\n diag.error(`Unsupported span kind ${span.kind}`);\n throw new Error(`Unsupported span kind ${span.kind}`);\n }\n\n let sampleRate = 100;\n if (span.attributes[AzureMonitorSampleRate]) {\n sampleRate = Number(span.attributes[AzureMonitorSampleRate]);\n }\n\n // Azure SDK\n if (span.attributes[AzNamespace]) {\n if (span.kind === SpanKind.INTERNAL) {\n baseData.type = `${DependencyTypes.InProc} | ${span.attributes[AzNamespace]}`;\n }\n if (span.attributes[AzNamespace] === MicrosoftEventHub) {\n parseEventHubSpan(span, baseData);\n }\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\n/**\n * Span Events to Azure envelopes parsing.\n * @internal\n */\nexport function spanEventsToEnvelopes(span: ReadableSpan, ikey: string): Envelope[] {\n const envelopes: Envelope[] = [];\n if (span.events) {\n span.events.forEach((event: TimedEvent) => {\n let baseType: \"ExceptionData\" | \"MessageData\";\n const time = hrTimeToDate(event.time);\n let name = \"\";\n let baseData: TelemetryExceptionData | MessageData;\n const properties = createPropertiesFromSpanAttributes(event.attributes);\n\n const tags: Tags = createTagsFromResource(span.resource);\n tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;\n const spanId = span.spanContext()?.spanId;\n if (spanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = spanId;\n }\n\n // Only generate exception telemetry for incoming requests\n if (event.name === \"exception\" && span.kind === SpanKind.SERVER) {\n name = \"Microsoft.ApplicationInsights.Exception\";\n baseType = \"ExceptionData\";\n let typeName = \"\";\n let message = \"Exception\";\n let stack = \"\";\n let hasFullStack = false;\n if (event.attributes) {\n typeName = String(event.attributes[SemanticAttributes.EXCEPTION_TYPE]);\n stack = String(event.attributes[SemanticAttributes.EXCEPTION_STACKTRACE]);\n if (stack) {\n hasFullStack = true;\n }\n const exceptionMsg = event.attributes[SemanticAttributes.EXCEPTION_MESSAGE];\n if (exceptionMsg) {\n message = String(exceptionMsg);\n }\n const escaped = event.attributes[SemanticAttributes.EXCEPTION_ESCAPED];\n if (escaped !== undefined) {\n properties[SemanticAttributes.EXCEPTION_ESCAPED] = String(escaped);\n }\n }\n const exceptionDetails: TelemetryExceptionDetails = {\n typeName: typeName,\n message: message,\n stack: stack,\n hasFullStack: hasFullStack,\n };\n const exceptionData: TelemetryExceptionData = {\n exceptions: [exceptionDetails],\n version: 2,\n properties: properties,\n };\n baseData = exceptionData;\n } else {\n name = \"Microsoft.ApplicationInsights.Message\";\n baseType = \"MessageData\";\n const messageData: MessageData = {\n message: event.name,\n version: 2,\n properties: properties,\n };\n baseData = messageData;\n }\n let sampleRate = 100;\n if (span.attributes[AzureMonitorSampleRate]) {\n sampleRate = Number(span.attributes[AzureMonitorSampleRate]);\n }\n const env: Envelope = {\n name: name,\n time: time,\n instrumentationKey: ikey,\n version: 1,\n sampleRate: sampleRate,\n data: {\n baseType: baseType,\n baseData: baseData,\n },\n tags: tags,\n };\n envelopes.push(env);\n });\n }\n return envelopes;\n}\n"]}
|