@azure/monitor-opentelemetry-exporter 1.0.0-beta.5 → 1.0.0-beta.8
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 +11 -13
- package/dist/index.js +706 -245
- package/dist-esm/src/Declarations/Constants.js +1 -1
- package/dist-esm/src/Declarations/Constants.js.map +1 -1
- package/dist-esm/src/config.js +2 -4
- package/dist-esm/src/config.js.map +1 -1
- package/dist-esm/src/export/base.js +172 -0
- package/dist-esm/src/export/base.js.map +1 -0
- package/dist-esm/src/export/metric.js +50 -0
- package/dist-esm/src/export/metric.js.map +1 -0
- package/dist-esm/src/export/trace.js +14 -145
- package/dist-esm/src/export/trace.js.map +1 -1
- package/dist-esm/src/generated/applicationInsightsClient.js.map +1 -1
- package/dist-esm/src/generated/applicationInsightsClientContext.js +2 -2
- package/dist-esm/src/generated/applicationInsightsClientContext.js.map +1 -1
- package/dist-esm/src/generated/models/index.js.map +1 -1
- package/dist-esm/src/index.js +2 -0
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/platform/nodejs/constants.js +1 -1
- package/dist-esm/src/platform/nodejs/constants.js.map +1 -1
- package/dist-esm/src/platform/nodejs/httpSender.js +12 -3
- package/dist-esm/src/platform/nodejs/httpSender.js.map +1 -1
- package/dist-esm/src/platform/nodejs/persist/fileAccessControl.js +171 -0
- package/dist-esm/src/platform/nodejs/persist/fileAccessControl.js.map +1 -0
- package/dist-esm/src/platform/nodejs/persist/fileSystemHelpers.js.map +1 -1
- package/dist-esm/src/platform/nodejs/persist/fileSystemPersist.js +40 -19
- package/dist-esm/src/platform/nodejs/persist/fileSystemPersist.js.map +1 -1
- package/dist-esm/src/utils/breezeUtils.js +5 -4
- package/dist-esm/src/utils/breezeUtils.js.map +1 -1
- package/dist-esm/src/utils/constants/applicationinsights.js +1 -1
- package/dist-esm/src/utils/constants/applicationinsights.js.map +1 -1
- package/dist-esm/src/utils/eventhub.js +1 -1
- package/dist-esm/src/utils/eventhub.js.map +1 -1
- package/dist-esm/src/utils/metricUtils.js +53 -0
- package/dist-esm/src/utils/metricUtils.js.map +1 -0
- package/dist-esm/src/utils/resourceUtils.js +35 -0
- package/dist-esm/src/utils/resourceUtils.js.map +1 -0
- package/dist-esm/src/utils/spanUtils.js +118 -49
- package/dist-esm/src/utils/spanUtils.js.map +1 -1
- package/package.json +25 -26
- package/types/monitor-opentelemetry-exporter.d.ts +110 -7
- package/CHANGELOG.md +0 -38
|
@@ -91,6 +91,6 @@ export const PerformanceToQuickPulseCounter = {
|
|
|
91
91
|
[QuickPulseCounter.DEPENDENCY_RATE]: QuickPulseCounter.DEPENDENCY_RATE,
|
|
92
92
|
[QuickPulseCounter.DEPENDENCY_FAILURE_RATE]: QuickPulseCounter.DEPENDENCY_FAILURE_RATE,
|
|
93
93
|
[QuickPulseCounter.DEPENDENCY_DURATION]: QuickPulseCounter.DEPENDENCY_DURATION,
|
|
94
|
-
[QuickPulseCounter.EXCEPTION_RATE]: QuickPulseCounter.EXCEPTION_RATE
|
|
94
|
+
[QuickPulseCounter.EXCEPTION_RATE]: QuickPulseCounter.EXCEPTION_RATE,
|
|
95
95
|
};
|
|
96
96
|
//# sourceMappingURL=Constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../../src/Declarations/Constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B;;OAEG;IACH,8CAAyB,CAAA;AAC3B,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,sCAAsC,CAAC;AAC9E;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,iBAAiB,CAAC,EAAE,CAAC;AAC/D;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B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C,EAAE,iBAAiB,CAAC,oBAAoB;IAChF,CAAC,iBAAiB,CAAC,eAAe,CAAC,EAAE,iBAAiB,CAAC,eAAe;IACtE,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,EAAE,iBAAiB,CAAC,uBAAuB;IACtF,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,EAAE,iBAAiB,CAAC,mBAAmB;IAC9E,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,iBAAiB,CAAC,cAAc;CACrE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Azure service API version.\n */\nexport enum ServiceApiVersion {\n /**\n * V2 Version\n */\n V2 = \"2020-09-15_Preview\"
|
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../../src/Declarations/Constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B;;OAEG;IACH,8CAAyB,CAAA;AAC3B,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,sCAAsC,CAAC;AAC9E;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,iBAAiB,CAAC,EAAE,CAAC;AAC/D;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,sCAAsC,CAAC;AACnF;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,8BAA8B,CAAC;AACvE;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,uCAAuC,CAAC;AAC7E;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,gCAAgC,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAN,IAAY,iBAmBX;AAnBD,WAAY,iBAAiB;IAC3B,SAAS;IACT,kEAA6C,CAAA;IAE7C,MAAM;IACN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ft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Azure service API version.\n */\nexport enum ServiceApiVersion {\n /**\n * V2 Version\n */\n V2 = \"2020-09-15_Preview\",\n}\n\n/**\n * Default Breeze endpoint.\n * @internal\n */\nexport const DEFAULT_BREEZE_ENDPOINT = \"https://dc.services.visualstudio.com\";\n/**\n * Default Breeze API version.\n * @internal\n */\nexport const DEFAULT_BREEZE_API_VERSION = ServiceApiVersion.V2;\n/**\n * Default Live Metrics endpoint.\n * @internal\n */\nexport const DEFAULT_LIVEMETRICS_ENDPOINT = \"https://rt.services.visualstudio.com\";\n/**\n * Default Live Metrics host.\n * @internal\n */\nexport const DEFAULT_LIVEMETRICS_HOST = \"rt.services.visualstudio.com\";\n/**\n * Connection string environment variable name.\n * @internal\n */\nexport const ENV_CONNECTION_STRING = \"APPLICATIONINSIGHTS_CONNECTION_STRING\";\n/**\n * Instrumentation key environment variable name.\n * @internal\n */\nexport const ENV_INSTRUMENTATION_KEY = \"APPINSIGHTS_INSTRUMENTATIONKEY\";\n\n/**\n * QuickPulse metric counter names.\n * @internal\n */\nexport enum QuickPulseCounter {\n // Memory\n COMMITTED_BYTES = \"\\\\Memory\\\\Committed Bytes\",\n\n // CPU\n PROCESSOR_TIME = \"\\\\Processor(_Total)\\\\% Processor Time\",\n\n // Request\n REQUEST_RATE = \"\\\\ApplicationInsights\\\\Requests/Sec\",\n REQUEST_FAILURE_RATE = \"\\\\ApplicationInsights\\\\Requests Failed/Sec\",\n REQUEST_DURATION = \"\\\\ApplicationInsights\\\\Request Duration\",\n\n // Dependency\n DEPENDENCY_RATE = \"\\\\ApplicationInsights\\\\Dependency Calls/Sec\",\n DEPENDENCY_FAILURE_RATE = \"\\\\ApplicationInsights\\\\Dependency Calls Failed/Sec\",\n DEPENDENCY_DURATION = \"\\\\ApplicationInsights\\\\Dependency Call Duration\",\n\n // Exception\n EXCEPTION_RATE = \"\\\\ApplicationInsights\\\\Exceptions/Sec\",\n}\n\n/**\n * Performance metric counter names.\n * @internal\n */\nexport enum PerformanceCounter {\n // Memory\n PRIVATE_BYTES = \"\\\\Process(??APP_WIN32_PROC??)\\\\Private Bytes\",\n AVAILABLE_BYTES = \"\\\\Memory\\\\Available Bytes\",\n\n // CPU\n PROCESSOR_TIME = \"\\\\Processor(_Total)\\\\% Processor Time\",\n PROCESS_TIME = \"\\\\Process(??APP_WIN32_PROC??)\\\\% Processor Time\",\n\n // Requests\n REQUEST_RATE = \"\\\\ASP.NET Applications(??APP_W3SVC_PROC??)\\\\Requests/Sec\",\n REQUEST_DURATION = \"\\\\ASP.NET Applications(??APP_W3SVC_PROC??)\\\\Request Execution Time\",\n}\n\n/**\n * Map a PerformanceCounter/QuickPulseCounter to a QuickPulseCounter. If no mapping exists, mapping is *undefined*\n * @internal\n */\nexport const PerformanceToQuickPulseCounter: { [key: string]: QuickPulseCounter } = {\n [PerformanceCounter.PROCESSOR_TIME]: QuickPulseCounter.PROCESSOR_TIME,\n [PerformanceCounter.REQUEST_RATE]: QuickPulseCounter.REQUEST_RATE,\n [PerformanceCounter.REQUEST_DURATION]: QuickPulseCounter.REQUEST_DURATION,\n\n // Remap quick pulse only counters\n [QuickPulseCounter.COMMITTED_BYTES]: QuickPulseCounter.COMMITTED_BYTES,\n [QuickPulseCounter.REQUEST_FAILURE_RATE]: QuickPulseCounter.REQUEST_FAILURE_RATE,\n [QuickPulseCounter.DEPENDENCY_RATE]: QuickPulseCounter.DEPENDENCY_RATE,\n [QuickPulseCounter.DEPENDENCY_FAILURE_RATE]: QuickPulseCounter.DEPENDENCY_FAILURE_RATE,\n [QuickPulseCounter.DEPENDENCY_DURATION]: QuickPulseCounter.DEPENDENCY_DURATION,\n [QuickPulseCounter.EXCEPTION_RATE]: QuickPulseCounter.EXCEPTION_RATE,\n};\n\n/**\n * QuickPulse document types.\n * @internal\n */\nexport type QuickPulseDocumentType =\n | \"Event\"\n | \"Exception\"\n | \"Trace\"\n | \"Metric\"\n | \"Request\"\n | \"RemoteDependency\"\n | \"Availability\";\n/**\n * QuickPulse telemetry types.\n * @internal\n */\nexport type QuickPulseType =\n | \"EventTelemetryDocument\"\n | \"ExceptionTelemetryDocument\"\n | \"TraceTelemetryDocument\"\n | \"MetricTelemetryDocument\"\n | \"RequestTelemetryDocument\"\n | \"DependencyTelemetryDocument\"\n | \"AvailabilityTelemetryDocument\";\n"]}
|
package/dist-esm/src/config.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { DEFAULT_BREEZE_API_VERSION, DEFAULT_BREEZE_ENDPOINT } from "./Declarations/Constants";
|
|
1
|
+
import { DEFAULT_BREEZE_API_VERSION, DEFAULT_BREEZE_ENDPOINT, } from "./Declarations/Constants";
|
|
4
2
|
const DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60000;
|
|
5
3
|
const DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING = 10;
|
|
6
4
|
/**
|
|
@@ -12,6 +10,6 @@ export const DEFAULT_EXPORTER_CONFIG = {
|
|
|
12
10
|
endpointUrl: DEFAULT_BREEZE_ENDPOINT,
|
|
13
11
|
batchSendRetryIntervalMs: DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS,
|
|
14
12
|
maxConsecutiveFailuresBeforeWarning: DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING,
|
|
15
|
-
apiVersion: DEFAULT_BREEZE_API_VERSION
|
|
13
|
+
apiVersion: DEFAULT_BREEZE_API_VERSION,
|
|
16
14
|
};
|
|
17
15
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GAExB,MAAM,0BAA0B,CAAC;AAElC,MAAM,oCAAoC,GAAG,KAAM,CAAC;AACpD,MAAM,+CAA+C,GAAG,EAAE,CAAC;AAkC3D;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAgC;IAClE,kBAAkB,EAAE,EAAE;IACtB,WAAW,EAAE,uBAAuB;IACpC,wBAAwB,EAAE,oCAAoC;IAC9D,mCAAmC,EAAE,+CAA+C;IACpF,UAAU,EAAE,0BAA0B;CACvC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { TokenCredential } from \"@azure/core-auth\";\nimport {\n DEFAULT_BREEZE_API_VERSION,\n DEFAULT_BREEZE_ENDPOINT,\n ServiceApiVersion,\n} from \"./Declarations/Constants\";\n\nconst DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60_000;\nconst DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING = 10;\n\n/**\n * Provides configuration options for AzureMonitorTraceExporter.\n */\nexport interface AzureExporterConfig {\n /**\n * Azure Monitor Connection String, if not provided the exporter will try to use environment variable APPLICATIONINSIGHTS_CONNECTION_STRING\n * Ex: \"InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://dc.services.visualstudio.com\"\n */\n connectionString?: string;\n /**\n * Azure service API version.\n */\n apiVersion?: ServiceApiVersion;\n /**\n * Azure Active Directory Credential\n */\n aadTokenCredential?: TokenCredential;\n}\n\n/**\n * Internal Azure exporter configuration\n * @internal\n */\nexport interface AzureExporterInternalConfig {\n instrumentationKey: string;\n batchSendRetryIntervalMs: number;\n maxConsecutiveFailuresBeforeWarning: number;\n endpointUrl: string;\n apiVersion: ServiceApiVersion;\n aadTokenCredential?: TokenCredential;\n}\n\n/**\n * Internal default Azure exporter configuration\n * @internal\n */\nexport const DEFAULT_EXPORTER_CONFIG: AzureExporterInternalConfig = {\n instrumentationKey: \"\",\n endpointUrl: DEFAULT_BREEZE_ENDPOINT,\n batchSendRetryIntervalMs: DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS,\n maxConsecutiveFailuresBeforeWarning: DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING,\n apiVersion: DEFAULT_BREEZE_API_VERSION,\n};\n"]}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { diag } from "@opentelemetry/api";
|
|
4
|
+
import { ExportResultCode } from "@opentelemetry/core";
|
|
5
|
+
import { ConnectionStringParser } from "../utils/connectionStringParser";
|
|
6
|
+
import { HttpSender, FileSystemPersist } from "../platform";
|
|
7
|
+
import { DEFAULT_EXPORTER_CONFIG, } from "../config";
|
|
8
|
+
import { isRetriable } from "../utils/breezeUtils";
|
|
9
|
+
import { ENV_CONNECTION_STRING } from "../Declarations/Constants";
|
|
10
|
+
/**
|
|
11
|
+
* Azure Monitor OpenTelemetry Trace Exporter.
|
|
12
|
+
*/
|
|
13
|
+
export class AzureMonitorBaseExporter {
|
|
14
|
+
/**
|
|
15
|
+
* Initializes a new instance of the AzureMonitorBaseExporter class.
|
|
16
|
+
* @param AzureExporterConfig - Exporter configuration.
|
|
17
|
+
*/
|
|
18
|
+
constructor(options = {}) {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
this._numConsecutiveRedirects = 0;
|
|
21
|
+
const connectionString = options.connectionString || process.env[ENV_CONNECTION_STRING];
|
|
22
|
+
this._options = Object.assign({}, DEFAULT_EXPORTER_CONFIG);
|
|
23
|
+
this._options.apiVersion = (_a = options.apiVersion) !== null && _a !== void 0 ? _a : this._options.apiVersion;
|
|
24
|
+
this._options.aadTokenCredential = options.aadTokenCredential;
|
|
25
|
+
if (connectionString) {
|
|
26
|
+
const parsedConnectionString = ConnectionStringParser.parse(connectionString);
|
|
27
|
+
this._options.instrumentationKey =
|
|
28
|
+
(_b = parsedConnectionString.instrumentationkey) !== null && _b !== void 0 ? _b : this._options.instrumentationKey;
|
|
29
|
+
this._options.endpointUrl =
|
|
30
|
+
(_d = (_c = parsedConnectionString.ingestionendpoint) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : this._options.endpointUrl;
|
|
31
|
+
}
|
|
32
|
+
// Instrumentation key is required
|
|
33
|
+
if (!this._options.instrumentationKey) {
|
|
34
|
+
const message = "No instrumentation key or connection string was provided to the Azure Monitor Exporter";
|
|
35
|
+
diag.error(message);
|
|
36
|
+
throw new Error(message);
|
|
37
|
+
}
|
|
38
|
+
this._instrumentationKey = this._options.instrumentationKey;
|
|
39
|
+
this._sender = new HttpSender(this._options);
|
|
40
|
+
this._persister = new FileSystemPersist(this._options);
|
|
41
|
+
this._retryTimer = null;
|
|
42
|
+
diag.debug("AzureMonitorTraceExporter was successfully setup");
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Persist envelopes to disk
|
|
46
|
+
*/
|
|
47
|
+
async _persist(envelopes) {
|
|
48
|
+
try {
|
|
49
|
+
const success = await this._persister.push(envelopes);
|
|
50
|
+
return success
|
|
51
|
+
? { code: ExportResultCode.SUCCESS }
|
|
52
|
+
: {
|
|
53
|
+
code: ExportResultCode.FAILED,
|
|
54
|
+
error: new Error("Failed to persist envelope in disk."),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (ex) {
|
|
58
|
+
return { code: ExportResultCode.FAILED, error: ex };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Shutdown exporter
|
|
63
|
+
*/
|
|
64
|
+
async _shutdown() {
|
|
65
|
+
return this._sender.shutdown();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Export envelopes
|
|
69
|
+
*/
|
|
70
|
+
async _exportEnvelopes(envelopes) {
|
|
71
|
+
diag.info(`Exporting ${envelopes.length} envelope(s)`);
|
|
72
|
+
try {
|
|
73
|
+
const { result, statusCode } = await this._sender.send(envelopes);
|
|
74
|
+
this._numConsecutiveRedirects = 0;
|
|
75
|
+
if (statusCode === 200) {
|
|
76
|
+
// Success -- @todo: start retry timer
|
|
77
|
+
if (!this._retryTimer) {
|
|
78
|
+
this._retryTimer = setTimeout(() => {
|
|
79
|
+
this._retryTimer = null;
|
|
80
|
+
this._sendFirstPersistedFile();
|
|
81
|
+
}, this._options.batchSendRetryIntervalMs);
|
|
82
|
+
this._retryTimer.unref();
|
|
83
|
+
}
|
|
84
|
+
return { code: ExportResultCode.SUCCESS };
|
|
85
|
+
}
|
|
86
|
+
else if (statusCode && isRetriable(statusCode)) {
|
|
87
|
+
// Failed -- persist failed data
|
|
88
|
+
if (result) {
|
|
89
|
+
diag.info(result);
|
|
90
|
+
const breezeResponse = JSON.parse(result);
|
|
91
|
+
const filteredEnvelopes = [];
|
|
92
|
+
if (breezeResponse.errors) {
|
|
93
|
+
breezeResponse.errors.forEach((error) => {
|
|
94
|
+
if (error.statusCode && isRetriable(error.statusCode)) {
|
|
95
|
+
filteredEnvelopes.push(envelopes[error.index]);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (filteredEnvelopes.length > 0) {
|
|
100
|
+
// calls resultCallback(ExportResult) based on result of persister.push
|
|
101
|
+
return await this._persist(filteredEnvelopes);
|
|
102
|
+
}
|
|
103
|
+
// Failed -- not retriable
|
|
104
|
+
return {
|
|
105
|
+
code: ExportResultCode.FAILED,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// calls resultCallback(ExportResult) based on result of persister.push
|
|
110
|
+
return await this._persist(envelopes);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// Failed -- not retriable
|
|
115
|
+
return {
|
|
116
|
+
code: ExportResultCode.FAILED,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
const restError = error;
|
|
122
|
+
if (restError.statusCode &&
|
|
123
|
+
(restError.statusCode === 307 || // Temporary redirect
|
|
124
|
+
restError.statusCode === 308)) {
|
|
125
|
+
// Permanent redirect
|
|
126
|
+
this._numConsecutiveRedirects++;
|
|
127
|
+
// To prevent circular redirects
|
|
128
|
+
if (this._numConsecutiveRedirects < 10) {
|
|
129
|
+
if (restError.response && restError.response.headers) {
|
|
130
|
+
const location = restError.response.headers.get("location");
|
|
131
|
+
if (location) {
|
|
132
|
+
// Update sender URL
|
|
133
|
+
this._sender.handlePermanentRedirect(location);
|
|
134
|
+
// Send to redirect endpoint as HTTPs library doesn't handle redirect automatically
|
|
135
|
+
return this._exportEnvelopes(envelopes);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
return { code: ExportResultCode.FAILED, error: new Error("Circular redirect") };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else if (restError.statusCode && isRetriable(restError.statusCode)) {
|
|
144
|
+
return await this._persist(envelopes);
|
|
145
|
+
}
|
|
146
|
+
if (this._isNetworkError(restError)) {
|
|
147
|
+
diag.error("Retrying due to transient client side error. Error message:", restError.message);
|
|
148
|
+
return await this._persist(envelopes);
|
|
149
|
+
}
|
|
150
|
+
diag.error("Envelopes could not be exported and are not retriable. Error message:", restError.message);
|
|
151
|
+
return { code: ExportResultCode.FAILED, error: restError };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async _sendFirstPersistedFile() {
|
|
155
|
+
try {
|
|
156
|
+
const envelopes = (await this._persister.shift());
|
|
157
|
+
if (envelopes) {
|
|
158
|
+
await this._sender.send(envelopes);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
diag.warn(`Failed to fetch persisted file`, err);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
_isNetworkError(error) {
|
|
166
|
+
if (error && error.code && error.code === "REQUEST_SEND_ERROR") {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|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gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAAC;iBACjF;aACF;iBAAM,IAAI,SAAS,CAAC,UAAU,IAAI,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE;gBACpE,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;aACvC;YACD,IAAI,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE;gBACnC,IAAI,CAAC,KAAK,CACR,6DAA6D,EAC7D,SAAS,CAAC,OAAO,CAClB,CAAC;gBACF,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;aACvC;YAED,IAAI,CAAC,KAAK,CACR,uEAAuE,EACvE,SAAS,CAAC,OAAO,CAClB,CAAC;YACF,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;SAC5D;IACH,CAAC;IAEO,KAAK,CAAC,uBAAuB;QACnC,IAAI;YACF,MAAM,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAsB,CAAC;YACvE,IAAI,SAAS,EAAE;gBACb,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACpC;SACF;QAAC,OAAO,GAAQ,EAAE;YACjB,IAAI,CAAC,IAAI,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAC;SAClD;IACH,CAAC;IAEO,eAAe,CAAC,KAAgB;QACtC,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,oBAAoB,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { diag } from \"@opentelemetry/api\";\nimport { ExportResult, ExportResultCode } from \"@opentelemetry/core\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { ConnectionStringParser } from \"../utils/connectionStringParser\";\nimport { HttpSender, FileSystemPersist } from \"../platform\";\nimport {\n DEFAULT_EXPORTER_CONFIG,\n AzureExporterConfig,\n AzureExporterInternalConfig,\n} from \"../config\";\nimport { PersistentStorage, Sender } from \"../types\";\nimport { isRetriable, BreezeResponse } from \"../utils/breezeUtils\";\nimport { ENV_CONNECTION_STRING } from \"../Declarations/Constants\";\nimport { TelemetryItem as Envelope } from \"../generated\";\n\n/**\n * Azure Monitor OpenTelemetry Trace Exporter.\n */\nexport abstract class AzureMonitorBaseExporter {\n /**\n * Instrumentation key to be used for exported envelopes\n */\n protected readonly _instrumentationKey: string;\n private readonly _persister: PersistentStorage;\n private readonly _sender: Sender;\n private _numConsecutiveRedirects: number;\n private _retryTimer: NodeJS.Timer | null;\n /**\n * Exporter internal configuration\n */\n private readonly _options: AzureExporterInternalConfig;\n\n /**\n * Initializes a new instance of the AzureMonitorBaseExporter class.\n * @param AzureExporterConfig - Exporter configuration.\n */\n constructor(options: AzureExporterConfig = {}) {\n this._numConsecutiveRedirects = 0;\n const connectionString = options.connectionString || process.env[ENV_CONNECTION_STRING];\n this._options = {\n ...DEFAULT_EXPORTER_CONFIG,\n };\n this._options.apiVersion = options.apiVersion ?? this._options.apiVersion;\n this._options.aadTokenCredential = options.aadTokenCredential;\n\n if (connectionString) {\n const parsedConnectionString = ConnectionStringParser.parse(connectionString);\n this._options.instrumentationKey =\n parsedConnectionString.instrumentationkey ?? this._options.instrumentationKey;\n this._options.endpointUrl =\n parsedConnectionString.ingestionendpoint?.trim() ?? this._options.endpointUrl;\n }\n // Instrumentation key is required\n if (!this._options.instrumentationKey) {\n const message =\n \"No instrumentation key or connection string was provided to the Azure Monitor Exporter\";\n diag.error(message);\n throw new Error(message);\n }\n\n this._instrumentationKey = this._options.instrumentationKey;\n this._sender = new HttpSender(this._options);\n this._persister = new FileSystemPersist(this._options);\n this._retryTimer = null;\n diag.debug(\"AzureMonitorTraceExporter was successfully setup\");\n }\n\n /**\n * Persist envelopes to disk\n */\n private async _persist(envelopes: unknown[]): Promise<ExportResult> {\n try {\n const success = await this._persister.push(envelopes);\n return success\n ? { code: ExportResultCode.SUCCESS }\n : {\n code: ExportResultCode.FAILED,\n error: new Error(\"Failed to persist envelope in disk.\"),\n };\n } catch (ex: any) {\n return { code: ExportResultCode.FAILED, error: ex };\n }\n }\n\n /**\n * Shutdown exporter\n */\n protected async _shutdown(): Promise<void> {\n return this._sender.shutdown();\n }\n\n /**\n * Export envelopes\n */\n protected async _exportEnvelopes(envelopes: Envelope[]): Promise<ExportResult> {\n diag.info(`Exporting ${envelopes.length} envelope(s)`);\n\n try {\n const { result, statusCode } = await this._sender.send(envelopes);\n this._numConsecutiveRedirects = 0;\n if (statusCode === 200) {\n // Success -- @todo: start retry timer\n if (!this._retryTimer) {\n this._retryTimer = setTimeout(() => {\n this._retryTimer = null;\n this._sendFirstPersistedFile();\n }, this._options.batchSendRetryIntervalMs);\n this._retryTimer.unref();\n }\n return { code: ExportResultCode.SUCCESS };\n } else if (statusCode && isRetriable(statusCode)) {\n // Failed -- persist failed data\n if (result) {\n diag.info(result);\n const breezeResponse = JSON.parse(result) as BreezeResponse;\n const filteredEnvelopes: Envelope[] = [];\n if (breezeResponse.errors) {\n breezeResponse.errors.forEach((error) => {\n if (error.statusCode && isRetriable(error.statusCode)) {\n filteredEnvelopes.push(envelopes[error.index]);\n }\n });\n }\n if (filteredEnvelopes.length > 0) {\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this._persist(filteredEnvelopes);\n }\n // Failed -- not retriable\n return {\n code: ExportResultCode.FAILED,\n };\n } else {\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this._persist(envelopes);\n }\n } else {\n // Failed -- not retriable\n return {\n code: ExportResultCode.FAILED,\n };\n }\n } catch (error: any) {\n const restError = error as RestError;\n if (\n restError.statusCode &&\n (restError.statusCode === 307 || // Temporary redirect\n restError.statusCode === 308)\n ) {\n // Permanent redirect\n this._numConsecutiveRedirects++;\n // To prevent circular redirects\n if (this._numConsecutiveRedirects < 10) {\n if (restError.response && restError.response.headers) {\n const location = restError.response.headers.get(\"location\");\n if (location) {\n // Update sender URL\n this._sender.handlePermanentRedirect(location);\n // Send to redirect endpoint as HTTPs library doesn't handle redirect automatically\n return this._exportEnvelopes(envelopes);\n }\n }\n } else {\n return { code: ExportResultCode.FAILED, error: new Error(\"Circular redirect\") };\n }\n } else if (restError.statusCode && isRetriable(restError.statusCode)) {\n return await this._persist(envelopes);\n }\n if (this._isNetworkError(restError)) {\n diag.error(\n \"Retrying due to transient client side error. Error message:\",\n restError.message\n );\n return await this._persist(envelopes);\n }\n\n diag.error(\n \"Envelopes could not be exported and are not retriable. Error message:\",\n restError.message\n );\n return { code: ExportResultCode.FAILED, error: restError };\n }\n }\n\n private async _sendFirstPersistedFile(): Promise<void> {\n try {\n const envelopes = (await this._persister.shift()) as Envelope[] | null;\n if (envelopes) {\n await this._sender.send(envelopes);\n }\n } catch (err: any) {\n diag.warn(`Failed to fetch persisted file`, err);\n }\n }\n\n private _isNetworkError(error: RestError): boolean {\n if (error && error.code && error.code === \"REQUEST_SEND_ERROR\") {\n return true;\n }\n return false;\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { diag } from "@opentelemetry/api";
|
|
4
|
+
import { AggregationTemporality, } from "@opentelemetry/sdk-metrics-base";
|
|
5
|
+
import { AzureMonitorBaseExporter } from "./base";
|
|
6
|
+
import { resourceMetricsToEnvelope } from "../utils/metricUtils";
|
|
7
|
+
/**
|
|
8
|
+
* Azure Monitor OpenTelemetry Metric Exporter.
|
|
9
|
+
*/
|
|
10
|
+
export class AzureMonitorMetricExporter extends AzureMonitorBaseExporter {
|
|
11
|
+
/**
|
|
12
|
+
* Initializes a new instance of the AzureMonitorMetricExporter class.
|
|
13
|
+
* @param AzureExporterConfig - Exporter configuration.
|
|
14
|
+
*/
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
super(options);
|
|
17
|
+
diag.debug("AzureMonitorMetricExporter was successfully setup");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Export OpenTelemetry resource metrics.
|
|
21
|
+
* @param metrics - Resource metrics to export.
|
|
22
|
+
* @param resultCallback - Result callback.
|
|
23
|
+
*/
|
|
24
|
+
async export(metrics, resultCallback) {
|
|
25
|
+
diag.info(`Exporting ${metrics.scopeMetrics.length} metrics(s). Converting to envelopes...`);
|
|
26
|
+
let envelopes = resourceMetricsToEnvelope(metrics, this._instrumentationKey);
|
|
27
|
+
resultCallback(await this._exportEnvelopes(envelopes));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Shutdown AzureMonitorMetricExporter.
|
|
31
|
+
*/
|
|
32
|
+
async shutdown() {
|
|
33
|
+
diag.info("Azure Monitor Trace Exporter shutting down");
|
|
34
|
+
return this._shutdown();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Select aggregation temporality
|
|
38
|
+
*/
|
|
39
|
+
selectAggregationTemporality() {
|
|
40
|
+
return AggregationTemporality.CUMULATIVE;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Force flush
|
|
44
|
+
*/
|
|
45
|
+
async forceFlush() {
|
|
46
|
+
// TODO: https://github.com/open-telemetry/opentelemetry-js/issues/3060
|
|
47
|
+
throw new Error("Method not implemented.");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=metric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metric.js","sourceRoot":"","sources":["../../../src/export/metric.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,sBAAsB,GAGvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAGlD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;GAEG;AACH,MAAM,OAAO,0BACX,SAAQ,wBAAwB;IAGhC;;;OAGG;IACH,YAAY,UAA+B,EAAE;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CACV,OAAwB,EACxB,cAA8C;QAE9C,IAAI,CAAC,IAAI,CAAC,aAAa,OAAO,CAAC,YAAY,CAAC,MAAM,yCAAyC,CAAC,CAAC;QAE7F,IAAI,SAAS,GAAe,yBAAyB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACzF,cAAc,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,QAAQ;QACnB,IAAI,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,4BAA4B;QACjC,OAAO,sBAAsB,CAAC,UAAU,CAAC;IAC3C,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,UAAU;QACrB,uEAAuE;QACvE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { diag } from \"@opentelemetry/api\";\nimport {\n AggregationTemporality,\n PushMetricExporter,\n ResourceMetrics,\n} from \"@opentelemetry/sdk-metrics-base\";\nimport { ExportResult } from \"@opentelemetry/core\";\nimport { AzureMonitorBaseExporter } from \"./base\";\nimport { AzureExporterConfig } from \"../config\";\nimport { TelemetryItem as Envelope } from \"../generated\";\nimport { resourceMetricsToEnvelope } from \"../utils/metricUtils\";\n\n/**\n * Azure Monitor OpenTelemetry Metric Exporter.\n */\nexport class AzureMonitorMetricExporter\n extends AzureMonitorBaseExporter\n implements PushMetricExporter\n{\n /**\n * Initializes a new instance of the AzureMonitorMetricExporter class.\n * @param AzureExporterConfig - Exporter configuration.\n */\n constructor(options: AzureExporterConfig = {}) {\n super(options);\n diag.debug(\"AzureMonitorMetricExporter was successfully setup\");\n }\n\n /**\n * Export OpenTelemetry resource metrics.\n * @param metrics - Resource metrics to export.\n * @param resultCallback - Result callback.\n */\n async export(\n metrics: ResourceMetrics,\n resultCallback: (result: ExportResult) => void\n ): Promise<void> {\n diag.info(`Exporting ${metrics.scopeMetrics.length} metrics(s). Converting to envelopes...`);\n\n let envelopes: Envelope[] = resourceMetricsToEnvelope(metrics, this._instrumentationKey);\n resultCallback(await this._exportEnvelopes(envelopes));\n }\n\n /**\n * Shutdown AzureMonitorMetricExporter.\n */\n public async shutdown(): Promise<void> {\n diag.info(\"Azure Monitor Trace Exporter shutting down\");\n return this._shutdown();\n }\n\n /**\n * Select aggregation temporality\n */\n public selectAggregationTemporality() {\n return AggregationTemporality.CUMULATIVE;\n }\n\n /**\n * Force flush\n */\n public async forceFlush() {\n // TODO: https://github.com/open-telemetry/opentelemetry-js/issues/3060\n throw new Error(\"Method not implemented.\");\n }\n}\n"]}
|
|
@@ -1,141 +1,20 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
import { diag } from "@opentelemetry/api";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { HttpSender, FileSystemPersist } from "../platform";
|
|
7
|
-
import { DEFAULT_EXPORTER_CONFIG } from "../config";
|
|
8
|
-
import { isRetriable } from "../utils/breezeUtils";
|
|
9
|
-
import { ENV_CONNECTION_STRING } from "../Declarations/Constants";
|
|
10
|
-
import { readableSpanToEnvelope } from "../utils/spanUtils";
|
|
4
|
+
import { AzureMonitorBaseExporter } from "./base";
|
|
5
|
+
import { readableSpanToEnvelope, spanEventsToEnvelopes } from "../utils/spanUtils";
|
|
11
6
|
/**
|
|
12
7
|
* Azure Monitor OpenTelemetry Trace Exporter.
|
|
13
8
|
*/
|
|
14
|
-
export class AzureMonitorTraceExporter {
|
|
9
|
+
export class AzureMonitorTraceExporter extends AzureMonitorBaseExporter {
|
|
15
10
|
/**
|
|
16
11
|
* Initializes a new instance of the AzureMonitorTraceExporter class.
|
|
17
12
|
* @param AzureExporterConfig - Exporter configuration.
|
|
18
13
|
*/
|
|
19
14
|
constructor(options = {}) {
|
|
20
|
-
|
|
21
|
-
this._numConsecutiveRedirects = 0;
|
|
22
|
-
const connectionString = options.connectionString || process.env[ENV_CONNECTION_STRING];
|
|
23
|
-
this._options = Object.assign({}, DEFAULT_EXPORTER_CONFIG);
|
|
24
|
-
this._options.apiVersion = (_a = options.apiVersion) !== null && _a !== void 0 ? _a : this._options.apiVersion;
|
|
25
|
-
if (connectionString) {
|
|
26
|
-
const parsedConnectionString = ConnectionStringParser.parse(connectionString);
|
|
27
|
-
this._options.instrumentationKey =
|
|
28
|
-
(_b = parsedConnectionString.instrumentationkey) !== null && _b !== void 0 ? _b : this._options.instrumentationKey;
|
|
29
|
-
this._options.endpointUrl =
|
|
30
|
-
(_d = (_c = parsedConnectionString.ingestionendpoint) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : this._options.endpointUrl;
|
|
31
|
-
}
|
|
32
|
-
// Instrumentation key is required
|
|
33
|
-
if (!this._options.instrumentationKey) {
|
|
34
|
-
const message = "No instrumentation key or connection string was provided to the Azure Monitor Exporter";
|
|
35
|
-
diag.error(message);
|
|
36
|
-
throw new Error(message);
|
|
37
|
-
}
|
|
38
|
-
this._sender = new HttpSender(this._options);
|
|
39
|
-
this._persister = new FileSystemPersist(this._options);
|
|
40
|
-
this._retryTimer = null;
|
|
15
|
+
super(options);
|
|
41
16
|
diag.debug("AzureMonitorTraceExporter was successfully setup");
|
|
42
17
|
}
|
|
43
|
-
async _persist(envelopes) {
|
|
44
|
-
try {
|
|
45
|
-
const success = await this._persister.push(envelopes);
|
|
46
|
-
return success
|
|
47
|
-
? { code: ExportResultCode.SUCCESS }
|
|
48
|
-
: {
|
|
49
|
-
code: ExportResultCode.FAILED,
|
|
50
|
-
error: new Error("Failed to persist envelope in disk.")
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
catch (ex) {
|
|
54
|
-
return { code: ExportResultCode.FAILED, error: ex };
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async exportEnvelopes(envelopes) {
|
|
58
|
-
diag.info(`Exporting ${envelopes.length} envelope(s)`);
|
|
59
|
-
try {
|
|
60
|
-
const { result, statusCode } = await this._sender.send(envelopes);
|
|
61
|
-
this._numConsecutiveRedirects = 0;
|
|
62
|
-
if (statusCode === 200) {
|
|
63
|
-
// Success -- @todo: start retry timer
|
|
64
|
-
if (!this._retryTimer) {
|
|
65
|
-
this._retryTimer = setTimeout(() => {
|
|
66
|
-
this._retryTimer = null;
|
|
67
|
-
this._sendFirstPersistedFile();
|
|
68
|
-
}, this._options.batchSendRetryIntervalMs);
|
|
69
|
-
this._retryTimer.unref();
|
|
70
|
-
}
|
|
71
|
-
return { code: ExportResultCode.SUCCESS };
|
|
72
|
-
}
|
|
73
|
-
else if (statusCode && isRetriable(statusCode)) {
|
|
74
|
-
// Failed -- persist failed data
|
|
75
|
-
if (result) {
|
|
76
|
-
diag.info(result);
|
|
77
|
-
const breezeResponse = JSON.parse(result);
|
|
78
|
-
const filteredEnvelopes = [];
|
|
79
|
-
breezeResponse.errors.forEach((error) => {
|
|
80
|
-
if (error.statusCode && isRetriable(error.statusCode)) {
|
|
81
|
-
filteredEnvelopes.push(envelopes[error.index]);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
if (filteredEnvelopes.length > 0) {
|
|
85
|
-
// calls resultCallback(ExportResult) based on result of persister.push
|
|
86
|
-
return await this._persist(filteredEnvelopes);
|
|
87
|
-
}
|
|
88
|
-
// Failed -- not retriable
|
|
89
|
-
return {
|
|
90
|
-
code: ExportResultCode.FAILED
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
// calls resultCallback(ExportResult) based on result of persister.push
|
|
95
|
-
return await this._persist(envelopes);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
// Failed -- not retriable
|
|
100
|
-
return {
|
|
101
|
-
code: ExportResultCode.FAILED
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
const restError = error;
|
|
107
|
-
if (restError.statusCode &&
|
|
108
|
-
(restError.statusCode === 307 || // Temporary redirect
|
|
109
|
-
restError.statusCode === 308)) {
|
|
110
|
-
// Permanent redirect
|
|
111
|
-
this._numConsecutiveRedirects++;
|
|
112
|
-
// To prevent circular redirects
|
|
113
|
-
if (this._numConsecutiveRedirects < 10) {
|
|
114
|
-
if (restError.response && restError.response.headers) {
|
|
115
|
-
const location = restError.response.headers.get("location");
|
|
116
|
-
if (location) {
|
|
117
|
-
// Update sender URL
|
|
118
|
-
this._sender.handlePermanentRedirect(location);
|
|
119
|
-
// Send to redirect endpoint as HTTPs library doesn't handle redirect automatically
|
|
120
|
-
return this.exportEnvelopes(envelopes);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
return { code: ExportResultCode.FAILED, error: new Error("Circular redirect") };
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else if (restError.statusCode && isRetriable(restError.statusCode)) {
|
|
129
|
-
return await this._persist(envelopes);
|
|
130
|
-
}
|
|
131
|
-
if (this._isNetworkError(restError)) {
|
|
132
|
-
diag.error("Retrying due to transient client side error. Error message:", restError.message);
|
|
133
|
-
return await this._persist(envelopes);
|
|
134
|
-
}
|
|
135
|
-
diag.error("Envelopes could not be exported and are not retriable. Error message:", restError.message);
|
|
136
|
-
return { code: ExportResultCode.FAILED, error: restError };
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
18
|
/**
|
|
140
19
|
* Export OpenTelemetry spans.
|
|
141
20
|
* @param spans - Spans to export.
|
|
@@ -143,32 +22,22 @@ export class AzureMonitorTraceExporter {
|
|
|
143
22
|
*/
|
|
144
23
|
async export(spans, resultCallback) {
|
|
145
24
|
diag.info(`Exporting ${spans.length} span(s). Converting to envelopes...`);
|
|
146
|
-
|
|
147
|
-
|
|
25
|
+
let envelopes = [];
|
|
26
|
+
spans.forEach((span) => {
|
|
27
|
+
envelopes.push(readableSpanToEnvelope(span, this._instrumentationKey));
|
|
28
|
+
let spanEventEnvelopes = spanEventsToEnvelopes(span, this._instrumentationKey);
|
|
29
|
+
if (spanEventEnvelopes.length > 0) {
|
|
30
|
+
envelopes.push(...spanEventEnvelopes);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
resultCallback(await this._exportEnvelopes(envelopes));
|
|
148
34
|
}
|
|
149
35
|
/**
|
|
150
36
|
* Shutdown AzureMonitorTraceExporter.
|
|
151
37
|
*/
|
|
152
38
|
async shutdown() {
|
|
153
39
|
diag.info("Azure Monitor Trace Exporter shutting down");
|
|
154
|
-
return this.
|
|
155
|
-
}
|
|
156
|
-
async _sendFirstPersistedFile() {
|
|
157
|
-
try {
|
|
158
|
-
const envelopes = (await this._persister.shift());
|
|
159
|
-
if (envelopes) {
|
|
160
|
-
await this._sender.send(envelopes);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
catch (err) {
|
|
164
|
-
diag.warn(`Failed to fetch persisted file`, err);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
_isNetworkError(error) {
|
|
168
|
-
if (error && error.code && error.code === "REQUEST_SEND_ERROR") {
|
|
169
|
-
return true;
|
|
170
|
-
}
|
|
171
|
-
return false;
|
|
40
|
+
return this._shutdown();
|
|
172
41
|
}
|
|
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eAAe,CAAC,KAAgB;QACtC,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,oBAAoB,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { diag } from \"@opentelemetry/api\";\nimport { ExportResult, ExportResultCode } from \"@opentelemetry/core\";\nimport { ReadableSpan, SpanExporter } from \"@opentelemetry/tracing\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { ConnectionStringParser } from \"../utils/connectionStringParser\";\nimport { HttpSender, FileSystemPersist } from \"../platform\";\nimport {\n DEFAULT_EXPORTER_CONFIG,\n AzureExporterConfig,\n AzureExporterInternalConfig\n} from \"../config\";\nimport { PersistentStorage, Sender } from \"../types\";\nimport { isRetriable, BreezeResponse } from \"../utils/breezeUtils\";\nimport { ENV_CONNECTION_STRING } from \"../Declarations/Constants\";\nimport { TelemetryItem as Envelope } from \"../generated\";\nimport { readableSpanToEnvelope } from \"../utils/spanUtils\";\n\n/**\n * Azure Monitor OpenTelemetry Trace Exporter.\n */\nexport class AzureMonitorTraceExporter implements SpanExporter {\n private readonly _persister: PersistentStorage;\n private readonly _sender: Sender;\n private _numConsecutiveRedirects: number;\n private _retryTimer: NodeJS.Timer | null;\n private readonly _options: AzureExporterInternalConfig;\n\n /**\n * Initializes a new instance of the AzureMonitorTraceExporter class.\n * @param AzureExporterConfig - Exporter configuration.\n */\n constructor(options: AzureExporterConfig = {}) {\n this._numConsecutiveRedirects = 0;\n const connectionString = options.connectionString || process.env[ENV_CONNECTION_STRING];\n this._options = {\n ...DEFAULT_EXPORTER_CONFIG\n };\n this._options.apiVersion = options.apiVersion ?? this._options.apiVersion;\n\n if (connectionString) {\n const parsedConnectionString = ConnectionStringParser.parse(connectionString);\n this._options.instrumentationKey =\n parsedConnectionString.instrumentationkey ?? this._options.instrumentationKey;\n this._options.endpointUrl =\n parsedConnectionString.ingestionendpoint?.trim() ?? this._options.endpointUrl;\n }\n // Instrumentation key is required\n if (!this._options.instrumentationKey) {\n const message =\n \"No instrumentation key or connection string was provided to the Azure Monitor Exporter\";\n diag.error(message);\n throw new Error(message);\n }\n\n this._sender = new HttpSender(this._options);\n this._persister = new FileSystemPersist(this._options);\n this._retryTimer = null;\n diag.debug(\"AzureMonitorTraceExporter was successfully setup\");\n }\n\n private async _persist(envelopes: unknown[]): Promise<ExportResult> {\n try {\n const success = await this._persister.push(envelopes);\n return success\n ? { code: ExportResultCode.SUCCESS }\n : {\n code: ExportResultCode.FAILED,\n error: new Error(\"Failed to persist envelope in disk.\")\n };\n } catch (ex) {\n return { code: ExportResultCode.FAILED, error: ex };\n }\n }\n\n private async exportEnvelopes(envelopes: Envelope[]): Promise<ExportResult> {\n diag.info(`Exporting ${envelopes.length} envelope(s)`);\n\n try {\n const { result, statusCode } = await this._sender.send(envelopes);\n this._numConsecutiveRedirects = 0;\n if (statusCode === 200) {\n // Success -- @todo: start retry timer\n if (!this._retryTimer) {\n this._retryTimer = setTimeout(() => {\n this._retryTimer = null;\n this._sendFirstPersistedFile();\n }, this._options.batchSendRetryIntervalMs);\n this._retryTimer.unref();\n }\n return { code: ExportResultCode.SUCCESS };\n } else if (statusCode && isRetriable(statusCode)) {\n // Failed -- persist failed data\n if (result) {\n diag.info(result);\n const breezeResponse = JSON.parse(result) as BreezeResponse;\n const filteredEnvelopes: Envelope[] = [];\n breezeResponse.errors.forEach((error) => {\n if (error.statusCode && isRetriable(error.statusCode)) {\n filteredEnvelopes.push(envelopes[error.index]);\n }\n });\n if (filteredEnvelopes.length > 0) {\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this._persist(filteredEnvelopes);\n }\n // Failed -- not retriable\n return {\n code: ExportResultCode.FAILED\n };\n } else {\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this._persist(envelopes);\n }\n } else {\n // Failed -- not retriable\n return {\n code: ExportResultCode.FAILED\n };\n }\n } catch (error) {\n const restError = error as RestError;\n if (\n restError.statusCode &&\n (restError.statusCode === 307 || // Temporary redirect\n restError.statusCode === 308)\n ) {\n // Permanent redirect\n this._numConsecutiveRedirects++;\n // To prevent circular redirects\n if (this._numConsecutiveRedirects < 10) {\n if (restError.response && restError.response.headers) {\n const location = restError.response.headers.get(\"location\");\n if (location) {\n // Update sender URL\n this._sender.handlePermanentRedirect(location);\n // Send to redirect endpoint as HTTPs library doesn't handle redirect automatically\n return this.exportEnvelopes(envelopes);\n }\n }\n } else {\n return { code: ExportResultCode.FAILED, error: new Error(\"Circular redirect\") };\n }\n } else if (restError.statusCode && isRetriable(restError.statusCode)) {\n return await this._persist(envelopes);\n }\n if (this._isNetworkError(restError)) {\n diag.error(\n \"Retrying due to transient client side error. Error message:\",\n restError.message\n );\n return await this._persist(envelopes);\n }\n\n diag.error(\n \"Envelopes could not be exported and are not retriable. Error message:\",\n restError.message\n );\n return { code: ExportResultCode.FAILED, error: restError };\n }\n }\n\n /**\n * Export OpenTelemetry spans.\n * @param spans - Spans to export.\n * @param resultCallback - Result callback.\n */\n async export(\n spans: ReadableSpan[],\n resultCallback: (result: ExportResult) => void\n ): Promise<void> {\n diag.info(`Exporting ${spans.length} span(s). Converting to envelopes...`);\n const envelopes = spans.map((span) =>\n readableSpanToEnvelope(span, this._options.instrumentationKey)\n );\n resultCallback(await this.exportEnvelopes(envelopes));\n }\n\n /**\n * Shutdown AzureMonitorTraceExporter.\n */\n async shutdown(): Promise<void> {\n diag.info(\"Azure Monitor Trace Exporter shutting down\");\n return this._sender.shutdown();\n }\n\n private async _sendFirstPersistedFile(): Promise<void> {\n try {\n const envelopes = (await this._persister.shift()) as Envelope[] | null;\n if (envelopes) {\n await this._sender.send(envelopes);\n }\n } catch (err) {\n diag.warn(`Failed to fetch persisted file`, err);\n }\n }\n\n private _isNetworkError(error: RestError): boolean {\n if (error && error.code && error.code === \"REQUEST_SEND_ERROR\") {\n return true;\n }\n return false;\n }\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AAE,CAAC;IAC1B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { diag } from \"@opentelemetry/api\";\nimport { ExportResult } from \"@opentelemetry/core\";\nimport { ReadableSpan, SpanExporter } from \"@opentelemetry/sdk-trace-base\";\nimport { AzureMonitorBaseExporter } from \"./base\";\nimport { AzureExporterConfig } from \"../config\";\nimport { TelemetryItem as Envelope } from \"../generated\";\nimport { readableSpanToEnvelope, spanEventsToEnvelopes } from \"../utils/spanUtils\";\n\n/**\n * Azure Monitor OpenTelemetry Trace Exporter.\n */\nexport class AzureMonitorTraceExporter extends AzureMonitorBaseExporter implements SpanExporter {\n /**\n * Initializes a new instance of the AzureMonitorTraceExporter class.\n * @param AzureExporterConfig - Exporter configuration.\n */\n constructor(options: AzureExporterConfig = {}) {\n super(options);\n diag.debug(\"AzureMonitorTraceExporter was successfully setup\");\n }\n\n /**\n * Export OpenTelemetry spans.\n * @param spans - Spans to export.\n * @param resultCallback - Result callback.\n */\n async export(\n spans: ReadableSpan[],\n resultCallback: (result: ExportResult) => void\n ): Promise<void> {\n diag.info(`Exporting ${spans.length} span(s). Converting to envelopes...`);\n\n let envelopes: Envelope[] = [];\n spans.forEach((span) => {\n envelopes.push(readableSpanToEnvelope(span, this._instrumentationKey));\n let spanEventEnvelopes = spanEventsToEnvelopes(span, this._instrumentationKey);\n if (spanEventEnvelopes.length > 0) {\n envelopes.push(...spanEventEnvelopes);\n }\n });\n resultCallback(await this._exportEnvelopes(envelopes));\n }\n\n /**\n * Shutdown AzureMonitorTraceExporter.\n */\n async shutdown(): Promise<void> {\n diag.info(\"Azure Monitor Trace Exporter shutting down\");\n return this._shutdown();\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applicationInsightsClient.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAQtF,MAAM,OAAO,yBAA0B,SAAQ,gCAAgC;IAC7E;;;OAGG;IACH,YAAY,OAAiD;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,KAAK,CACH,IAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"applicationInsightsClient.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAQtF,MAAM,OAAO,yBAA0B,SAAQ,gCAAgC;IAC7E;;;OAGG;IACH,YAAY,OAAiD;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,KAAK,CACH,IAAqB,EACrB,OAA6B;QAE7B,OAAO,IAAI,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,kBAAkB,CAAC,CAAC;IAC1E,CAAC;CACF;AACD,2BAA2B;AAC3B,MAAM,UAAU,GAAG,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAE3E,MAAM,kBAAkB,GAA6B;IACnD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;KACF;IACD,WAAW,EAAE,UAAU,CAAC,IAAI;IAC5B,aAAa,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;IAChC,gBAAgB,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC;IAC7D,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport * as Parameters from \"./models/parameters\";\nimport * as Mappers from \"./models/mappers\";\nimport { ApplicationInsightsClientContext } from \"./applicationInsightsClientContext\";\nimport {\n ApplicationInsightsClientOptionalParams,\n TelemetryItem,\n TrackOptionalParams,\n TrackOperationResponse\n} from \"./models\";\n\nexport class ApplicationInsightsClient extends ApplicationInsightsClientContext {\n /**\n * Initializes a new instance of the ApplicationInsightsClient class.\n * @param options The parameter options\n */\n constructor(options?: ApplicationInsightsClientOptionalParams) {\n super(options);\n }\n\n /**\n * This operation sends a sequence of telemetry events that will be monitored by Azure Monitor.\n * @param body The list of telemetry events to track.\n * @param options The options parameters.\n */\n track(\n body: TelemetryItem[],\n options?: TrackOptionalParams\n ): Promise<TrackOperationResponse> {\n return this.sendOperationRequest({ body, options }, trackOperationSpec);\n }\n}\n// Operation Specifications\nconst serializer = coreClient.createSerializer(Mappers, /* isXml */ false);\n\nconst trackOperationSpec: coreClient.OperationSpec = {\n path: \"/track\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.TrackResponse\n },\n 206: {\n bodyMapper: Mappers.TrackResponse\n },\n 400: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 402: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 429: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 500: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 503: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n }\n },\n requestBody: Parameters.body,\n urlParameters: [Parameters.host],\n headerParameters: [Parameters.contentType, Parameters.accept],\n mediaType: \"json\",\n serializer\n};\n"]}
|
|
@@ -19,13 +19,13 @@ export class ApplicationInsightsClientContext extends coreClient.ServiceClient {
|
|
|
19
19
|
const defaults = {
|
|
20
20
|
requestContentType: "application/json; charset=utf-8"
|
|
21
21
|
};
|
|
22
|
-
const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.
|
|
22
|
+
const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.7`;
|
|
23
23
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
24
24
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
25
25
|
: `${packageDetails}`;
|
|
26
26
|
const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
|
|
27
27
|
userAgentPrefix
|
|
28
|
-
}, baseUri: options.endpoint || "{Host}/v2" });
|
|
28
|
+
}, baseUri: options.endpoint || "{Host}/v2.1" });
|
|
29
29
|
super(optionsWithDefaults);
|
|
30
30
|
// Assigning values to Constant parameters
|
|
31
31
|
this.host = options.host || "https://dc.services.visualstudio.com";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applicationInsightsClientContext.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,MAAM,OAAO,gCAAiC,SAAQ,UAAU,CAAC,aAAa;IAG5E;;;OAGG;IACH,YAAY,OAAiD;QAC3D,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAA4C;YACxD,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,sDAAsD,CAAC;QAC9E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,
|
|
1
|
+
{"version":3,"file":"applicationInsightsClientContext.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,MAAM,OAAO,gCAAiC,SAAQ,UAAU,CAAC,aAAa;IAG5E;;;OAGG;IACH,YAAY,OAAiD;QAC3D,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAA4C;YACxD,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,sDAAsD,CAAC;QAC9E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,aAAa,GAC3C,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE3B,0CAA0C;QAC1C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,sCAAsC,CAAC;IACrE,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { ApplicationInsightsClientOptionalParams } from \"./models\";\n\nexport class ApplicationInsightsClientContext extends coreClient.ServiceClient {\n host: string;\n\n /**\n * Initializes a new instance of the ApplicationInsightsClientContext class.\n * @param options The parameter options\n */\n constructor(options?: ApplicationInsightsClientOptionalParams) {\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: ApplicationInsightsClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.7`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{Host}/v2.1\"\n };\n super(optionsWithDefaults);\n\n // Assigning values to Constant parameters\n this.host = options.host || \"https://dc.services.visualstudio.com\";\n }\n}\n"]}
|