@azure/monitor-opentelemetry-exporter 1.0.0-beta.31 → 1.0.0-beta.32
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 +4 -4
- package/dist/commonjs/export/statsbeat/longIntervalStatsbeatMetrics.d.ts +7 -7
- package/dist/commonjs/export/statsbeat/longIntervalStatsbeatMetrics.d.ts.map +1 -1
- package/dist/commonjs/export/statsbeat/longIntervalStatsbeatMetrics.js +35 -20
- package/dist/commonjs/export/statsbeat/longIntervalStatsbeatMetrics.js.map +1 -1
- package/dist/commonjs/export/statsbeat/networkStatsbeatMetrics.d.ts +6 -1
- package/dist/commonjs/export/statsbeat/networkStatsbeatMetrics.d.ts.map +1 -1
- package/dist/commonjs/export/statsbeat/networkStatsbeatMetrics.js +71 -30
- package/dist/commonjs/export/statsbeat/networkStatsbeatMetrics.js.map +1 -1
- package/dist/commonjs/generated/applicationInsightsClient.js +1 -1
- package/dist/commonjs/generated/applicationInsightsClient.js.map +1 -1
- package/dist/commonjs/platform/nodejs/baseSender.d.ts.map +1 -1
- package/dist/commonjs/platform/nodejs/baseSender.js +41 -20
- package/dist/commonjs/platform/nodejs/baseSender.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/types.d.ts.map +1 -1
- package/dist/commonjs/types.js +1 -0
- package/dist/commonjs/types.js.map +1 -1
- package/dist/commonjs/utils/constants/applicationinsights.d.ts +1 -1
- package/dist/commonjs/utils/constants/applicationinsights.js +1 -1
- package/dist/commonjs/utils/constants/applicationinsights.js.map +1 -1
- package/dist/commonjs/utils/spanUtils.js +6 -6
- package/dist/commonjs/utils/spanUtils.js.map +1 -1
- package/dist/esm/export/statsbeat/longIntervalStatsbeatMetrics.d.ts +7 -7
- package/dist/esm/export/statsbeat/longIntervalStatsbeatMetrics.d.ts.map +1 -1
- package/dist/esm/export/statsbeat/longIntervalStatsbeatMetrics.js +34 -20
- package/dist/esm/export/statsbeat/longIntervalStatsbeatMetrics.js.map +1 -1
- package/dist/esm/export/statsbeat/networkStatsbeatMetrics.d.ts +6 -1
- package/dist/esm/export/statsbeat/networkStatsbeatMetrics.d.ts.map +1 -1
- package/dist/esm/export/statsbeat/networkStatsbeatMetrics.js +71 -30
- package/dist/esm/export/statsbeat/networkStatsbeatMetrics.js.map +1 -1
- package/dist/esm/generated/applicationInsightsClient.js +1 -1
- package/dist/esm/generated/applicationInsightsClient.js.map +1 -1
- package/dist/esm/platform/nodejs/baseSender.d.ts.map +1 -1
- package/dist/esm/platform/nodejs/baseSender.js +42 -21
- package/dist/esm/platform/nodejs/baseSender.js.map +1 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +2 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/constants/applicationinsights.d.ts +1 -1
- package/dist/esm/utils/constants/applicationinsights.js +1 -1
- package/dist/esm/utils/constants/applicationinsights.js.map +1 -1
- package/dist/esm/utils/spanUtils.js +6 -6
- package/dist/esm/utils/spanUtils.js.map +1 -1
- package/package.json +16 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applicationInsightsClient.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClient.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AACjD,2EAAqD;AACrD,qEAA+C;AAQ/C,MAAa,yBAA0B,SAAQ,UAAU,CAAC,aAAa;IAGrE;;;OAGG;IACH,YAAY,OAAiD;;QAC3D,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAA4C;YACxD,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,uDAAuD,CAAC;QAC/E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GA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;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.js\";\nimport * as Mappers from \"./models/mappers.js\";\nimport {\n ApplicationInsightsClientOptionalParams,\n TelemetryItem,\n TrackOptionalParams,\n TrackOperationResponse,\n} from \"./models/index.js\";\n\nexport class ApplicationInsightsClient extends coreClient.ServiceClient {\n host: string;\n\n /**\n * Initializes a new instance of the ApplicationInsightsClient 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.
|
|
1
|
+
{"version":3,"file":"applicationInsightsClient.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClient.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AACjD,2EAAqD;AACrD,qEAA+C;AAQ/C,MAAa,yBAA0B,SAAQ,UAAU,CAAC,aAAa;IAGrE;;;OAGG;IACH,YAAY,OAAiD;;QAC3D,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;QACD,MAAM,QAA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AAC,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.js\";\nimport * as Mappers from \"./models/mappers.js\";\nimport {\n ApplicationInsightsClientOptionalParams,\n TelemetryItem,\n TrackOptionalParams,\n TrackOperationResponse,\n} from \"./models/index.js\";\n\nexport class ApplicationInsightsClient extends coreClient.ServiceClient {\n host: string;\n\n /**\n * Initializes a new instance of the ApplicationInsightsClient 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.32`;\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 endpoint: options.endpoint ?? options.baseUri ?? \"{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 /**\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseSender.d.ts","sourceRoot":"","sources":["../../../../src/platform/nodejs/baseSender.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAqB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK1E;;;GAGG;AAC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qB,CAAU;gBAE3B,OAAO,EAAE;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,OAAO,CAAC;QACxB,eAAe,EAAE,2BAA2B,CAAC;QAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAC7B;IAoBD,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IACxD,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAClC,QAAQ,CAAC,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAEpE;;OAEG;IACU,eAAe,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAoK1E;;OAEG;YACW,OAAO;IAiBrB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAOjC;;OAEG;IACH,OAAO,CAAC,iBAAiB;YAQX,sBAAsB;IAcpC,OAAO,CAAC,oBAAoB;CAO7B"}
|
|
@@ -24,13 +24,12 @@ class BaseSender {
|
|
|
24
24
|
this.disableOfflineStorage = options.exporterOptions.disableOfflineStorage || false;
|
|
25
25
|
this.persister = new index_js_1.FileSystemPersist(options.instrumentationKey, options.exporterOptions);
|
|
26
26
|
if (options.trackStatsbeat) {
|
|
27
|
-
|
|
28
|
-
this.networkStatsbeatMetrics = new networkStatsbeatMetrics_js_1.NetworkStatsbeatMetrics({
|
|
27
|
+
this.networkStatsbeatMetrics = networkStatsbeatMetrics_js_1.NetworkStatsbeatMetrics.getInstance({
|
|
29
28
|
instrumentationKey: options.instrumentationKey,
|
|
30
29
|
endpointUrl: options.endpointUrl,
|
|
31
30
|
disableOfflineStorage: this.disableOfflineStorage,
|
|
32
31
|
});
|
|
33
|
-
this.longIntervalStatsbeatMetrics =
|
|
32
|
+
this.longIntervalStatsbeatMetrics = longIntervalStatsbeatMetrics_js_1.LongIntervalStatsbeatMetrics.getInstance({
|
|
34
33
|
instrumentationKey: options.instrumentationKey,
|
|
35
34
|
endpointUrl: options.endpointUrl,
|
|
36
35
|
disableOfflineStorage: this.disableOfflineStorage,
|
|
@@ -63,21 +62,28 @@ class BaseSender {
|
|
|
63
62
|
}, this.batchSendRetryIntervalMs);
|
|
64
63
|
this.retryTimer.unref();
|
|
65
64
|
}
|
|
66
|
-
// If we are not
|
|
67
|
-
(
|
|
65
|
+
// If we are not exporting statsbeat and statsbeat is not disabled -- count success
|
|
66
|
+
if (!this.isStatsbeatSender) {
|
|
67
|
+
(_a = this.networkStatsbeatMetrics) === null || _a === void 0 ? void 0 : _a.countSuccess(duration);
|
|
68
|
+
}
|
|
68
69
|
return { code: core_1.ExportResultCode.SUCCESS };
|
|
69
70
|
}
|
|
70
71
|
else if (statusCode && (0, breezeUtils_js_1.isRetriable)(statusCode)) {
|
|
71
72
|
// Failed -- persist failed data
|
|
72
73
|
if (statusCode === 429 || statusCode === 439) {
|
|
73
|
-
(
|
|
74
|
+
if (!this.isStatsbeatSender) {
|
|
75
|
+
(_b = this.networkStatsbeatMetrics) === null || _b === void 0 ? void 0 : _b.countThrottle(statusCode);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
code: core_1.ExportResultCode.SUCCESS,
|
|
79
|
+
};
|
|
74
80
|
}
|
|
75
81
|
if (result) {
|
|
76
82
|
api_1.diag.info(result);
|
|
77
83
|
const breezeResponse = JSON.parse(result);
|
|
78
84
|
const filteredEnvelopes = [];
|
|
79
85
|
// If we have a partial success, count the succeeded envelopes
|
|
80
|
-
if (breezeResponse.
|
|
86
|
+
if (breezeResponse.itemsAccepted > 0 && statusCode === 206 && !this.isStatsbeatSender) {
|
|
81
87
|
(_c = this.networkStatsbeatMetrics) === null || _c === void 0 ? void 0 : _c.countSuccess(duration);
|
|
82
88
|
}
|
|
83
89
|
// Figure out if we need to either retry or count failures
|
|
@@ -89,25 +95,31 @@ class BaseSender {
|
|
|
89
95
|
});
|
|
90
96
|
}
|
|
91
97
|
if (filteredEnvelopes.length > 0) {
|
|
92
|
-
(
|
|
98
|
+
if (!this.isStatsbeatSender) {
|
|
99
|
+
(_d = this.networkStatsbeatMetrics) === null || _d === void 0 ? void 0 : _d.countRetry(statusCode);
|
|
100
|
+
}
|
|
93
101
|
// calls resultCallback(ExportResult) based on result of persister.push
|
|
94
102
|
return await this.persist(filteredEnvelopes);
|
|
95
103
|
}
|
|
96
104
|
// Failed -- not retriable
|
|
97
|
-
(
|
|
105
|
+
if (!this.isStatsbeatSender) {
|
|
106
|
+
(_e = this.networkStatsbeatMetrics) === null || _e === void 0 ? void 0 : _e.countFailure(duration, statusCode);
|
|
107
|
+
}
|
|
98
108
|
return {
|
|
99
109
|
code: core_1.ExportResultCode.FAILED,
|
|
100
110
|
};
|
|
101
111
|
}
|
|
102
112
|
else {
|
|
103
113
|
// calls resultCallback(ExportResult) based on result of persister.push
|
|
104
|
-
(
|
|
114
|
+
if (!this.isStatsbeatSender) {
|
|
115
|
+
(_f = this.networkStatsbeatMetrics) === null || _f === void 0 ? void 0 : _f.countRetry(statusCode);
|
|
116
|
+
}
|
|
105
117
|
return await this.persist(envelopes);
|
|
106
118
|
}
|
|
107
119
|
}
|
|
108
120
|
else {
|
|
109
121
|
// Failed -- not retriable
|
|
110
|
-
if (this.networkStatsbeatMetrics) {
|
|
122
|
+
if (this.networkStatsbeatMetrics && !this.isStatsbeatSender) {
|
|
111
123
|
if (statusCode) {
|
|
112
124
|
this.networkStatsbeatMetrics.countFailure(duration, statusCode);
|
|
113
125
|
}
|
|
@@ -142,7 +154,9 @@ class BaseSender {
|
|
|
142
154
|
}
|
|
143
155
|
else {
|
|
144
156
|
const redirectError = new Error("Circular redirect");
|
|
145
|
-
(
|
|
157
|
+
if (!this.isStatsbeatSender) {
|
|
158
|
+
(_g = this.networkStatsbeatMetrics) === null || _g === void 0 ? void 0 : _g.countException(redirectError);
|
|
159
|
+
}
|
|
146
160
|
return { code: core_1.ExportResultCode.FAILED, error: redirectError };
|
|
147
161
|
}
|
|
148
162
|
}
|
|
@@ -166,7 +180,7 @@ class BaseSender {
|
|
|
166
180
|
return { code: core_1.ExportResultCode.SUCCESS };
|
|
167
181
|
}
|
|
168
182
|
if (this.isRetriableRestError(restError)) {
|
|
169
|
-
if (restError.statusCode) {
|
|
183
|
+
if (restError.statusCode && !this.isStatsbeatSender) {
|
|
170
184
|
(_j = this.networkStatsbeatMetrics) === null || _j === void 0 ? void 0 : _j.countRetry(restError.statusCode);
|
|
171
185
|
}
|
|
172
186
|
if (!this.isStatsbeatSender) {
|
|
@@ -174,7 +188,9 @@ class BaseSender {
|
|
|
174
188
|
}
|
|
175
189
|
return this.persist(envelopes);
|
|
176
190
|
}
|
|
177
|
-
(
|
|
191
|
+
if (!this.isStatsbeatSender) {
|
|
192
|
+
(_k = this.networkStatsbeatMetrics) === null || _k === void 0 ? void 0 : _k.countException(restError);
|
|
193
|
+
}
|
|
178
194
|
if (!this.isStatsbeatSender) {
|
|
179
195
|
api_1.diag.error("Envelopes could not be exported and are not retriable. Error message:", restError.message);
|
|
180
196
|
}
|
|
@@ -196,7 +212,9 @@ class BaseSender {
|
|
|
196
212
|
};
|
|
197
213
|
}
|
|
198
214
|
catch (ex) {
|
|
199
|
-
(
|
|
215
|
+
if (!this.isStatsbeatSender) {
|
|
216
|
+
(_a = this.networkStatsbeatMetrics) === null || _a === void 0 ? void 0 : _a.countWriteFailure();
|
|
217
|
+
}
|
|
200
218
|
return { code: core_1.ExportResultCode.FAILED, error: ex };
|
|
201
219
|
}
|
|
202
220
|
}
|
|
@@ -213,10 +231,11 @@ class BaseSender {
|
|
|
213
231
|
* Shutdown statsbeat metrics
|
|
214
232
|
*/
|
|
215
233
|
shutdownStatsbeat() {
|
|
216
|
-
var _a
|
|
217
|
-
(
|
|
218
|
-
|
|
219
|
-
|
|
234
|
+
var _a;
|
|
235
|
+
if (this.networkStatsbeatMetrics) {
|
|
236
|
+
this.networkStatsbeatMetrics.shutdown();
|
|
237
|
+
}
|
|
238
|
+
(_a = this.longIntervalStatsbeatMetrics) === null || _a === void 0 ? void 0 : _a.shutdown();
|
|
220
239
|
this.statsbeatFailureCount = 0;
|
|
221
240
|
}
|
|
222
241
|
async sendFirstPersistedFile() {
|
|
@@ -228,7 +247,9 @@ class BaseSender {
|
|
|
228
247
|
}
|
|
229
248
|
}
|
|
230
249
|
catch (err) {
|
|
231
|
-
(
|
|
250
|
+
if (!this.isStatsbeatSender) {
|
|
251
|
+
(_a = this.networkStatsbeatMetrics) === null || _a === void 0 ? void 0 : _a.countReadFailure();
|
|
252
|
+
}
|
|
232
253
|
api_1.diag.warn(`Failed to fetch persisted file`, err);
|
|
233
254
|
}
|
|
234
255
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseSender.js","sourceRoot":"","sources":["../../../../src/platform/nodejs/baseSender.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,4CAA0C;AAG1C,iDAAuD;AAEvD,8CAAuD;AACvD,kGAA4F;AAC5F,4GAAqF;AAErF,8DAAoG;AAEpG,+DAAyD;AAEzD,kEAA0E;AAE1E,MAAM,oCAAoC,GAAG,KAAM,CAAC;AAEpD;;;GAGG;AACH,MAAsB,UAAU;IAW9B,YAAY,OAOX;QAZO,0BAAqB,GAAW,CAAC,CAAC;QAClC,6BAAwB,GAAW,oCAAoC,CAAC;QAY9E,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,qBAAqB,IAAI,KAAK,CAAC;QACpF,IAAI,CAAC,SAAS,GAAG,IAAI,4BAAiB,CAAC,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;QAC5F,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,8BAA8B;YAC9B,IAAI,CAAC,uBAAu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nD,CAAC;IACH,CAAC;IAEO,oBAAoB,CAAC,KAAgB;QAC3C,MAAM,cAAc,GAAa,MAAM,CAAC,MAAM,CAAC,sCAAuB,CAAC,CAAC;QACxE,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA1PD,gCA0PC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { diag } from \"@opentelemetry/api\";\nimport type { PersistentStorage, SenderResult } from \"../../types.js\";\nimport type { AzureMonitorExporterOptions } from \"../../config.js\";\nimport { FileSystemPersist } from \"./persist/index.js\";\nimport type { ExportResult } from \"@opentelemetry/core\";\nimport { ExportResultCode } from \"@opentelemetry/core\";\nimport { NetworkStatsbeatMetrics } from \"../../export/statsbeat/networkStatsbeatMetrics.js\";\nimport { getInstance } from \"../../export/statsbeat/longIntervalStatsbeatMetrics.js\";\nimport type { RestError } from \"@azure/core-rest-pipeline\";\nimport { MAX_STATSBEAT_FAILURES, isStatsbeatShutdownStatus } from \"../../export/statsbeat/types.js\";\nimport type { BreezeResponse } from \"../../utils/breezeUtils.js\";\nimport { isRetriable } from \"../../utils/breezeUtils.js\";\nimport type { TelemetryItem as Envelope } from \"../../generated/index.js\";\nimport { RetriableRestErrorTypes } from \"../../Declarations/Constants.js\";\n\nconst DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60_000;\n\n/**\n * Base sender class\n * @internal\n */\nexport abstract class BaseSender {\n private readonly persister: PersistentStorage;\n private numConsecutiveRedirects: number;\n private retryTimer: NodeJS.Timeout | null;\n private networkStatsbeatMetrics: NetworkStatsbeatMetrics | undefined;\n private longIntervalStatsbeatMetrics;\n private statsbeatFailureCount: number = 0;\n private batchSendRetryIntervalMs: number = DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS;\n private isStatsbeatSender: boolean;\n private disableOfflineStorage: boolean;\n\n constructor(options: {\n endpointUrl: string;\n instrumentationKey: string;\n trackStatsbeat: boolean;\n exporterOptions: AzureMonitorExporterOptions;\n aadAudience?: string;\n isStatsbeatSender?: boolean;\n }) {\n this.numConsecutiveRedirects = 0;\n this.disableOfflineStorage = options.exporterOptions.disableOfflineStorage || false;\n this.persister = new FileSystemPersist(options.instrumentationKey, options.exporterOptions);\n if (options.trackStatsbeat) {\n // Initialize statsbeatMetrics\n this.networkStatsbeatMetrics = new NetworkStatsbeatMetrics({\n instrumentationKey: options.instrumentationKey,\n endpointUrl: options.endpointUrl,\n disableOfflineStorage: this.disableOfflineStorage,\n });\n this.longIntervalStatsbeatMetrics = getInstance({\n instrumentationKey: options.instrumentationKey,\n endpointUrl: options.endpointUrl,\n disableOfflineStorage: this.disableOfflineStorage,\n });\n }\n this.retryTimer = null;\n this.isStatsbeatSender = options.isStatsbeatSender || false;\n }\n\n abstract send(payload: unknown[]): Promise<SenderResult>;\n abstract shutdown(): Promise<void>;\n abstract handlePermanentRedirect(location: string | undefined): void;\n\n /**\n * Export envelopes\n */\n public async exportEnvelopes(envelopes: Envelope[]): Promise<ExportResult> {\n diag.info(`Exporting ${envelopes.length} envelope(s)`);\n\n if (envelopes.length < 1) {\n return { code: ExportResultCode.SUCCESS };\n }\n\n try {\n const startTime = new Date().getTime();\n const { result, statusCode } = await this.send(envelopes);\n const endTime = new Date().getTime();\n const duration = endTime - startTime;\n this.numConsecutiveRedirects = 0;\n\n if (statusCode === 200) {\n // Success -- @todo: start retry timer\n if (!this.retryTimer) {\n this.retryTimer = setTimeout(() => {\n this.retryTimer = null;\n this.sendFirstPersistedFile();\n }, this.batchSendRetryIntervalMs);\n this.retryTimer.unref();\n }\n // If we are not exportings statsbeat and statsbeat is not disabled -- count success\n this.networkStatsbeatMetrics?.countSuccess(duration);\n return { code: ExportResultCode.SUCCESS };\n } else if (statusCode && isRetriable(statusCode)) {\n // Failed -- persist failed data\n if (statusCode === 429 || statusCode === 439) {\n this.networkStatsbeatMetrics?.countThrottle(statusCode);\n }\n if (result) {\n diag.info(result);\n const breezeResponse = JSON.parse(result) as BreezeResponse;\n const filteredEnvelopes: Envelope[] = [];\n // If we have a partial success, count the succeeded envelopes\n if (breezeResponse.itemsReceived > 0) {\n this.networkStatsbeatMetrics?.countSuccess(duration);\n }\n // Figure out if we need to either retry or count failures\n if (breezeResponse.errors) {\n breezeResponse.errors.forEach((error) => {\n if (error.statusCode && isRetriable(error.statusCode)) {\n filteredEnvelopes.push(envelopes[error.index]);\n }\n });\n }\n if (filteredEnvelopes.length > 0) {\n this.networkStatsbeatMetrics?.countRetry(statusCode);\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this.persist(filteredEnvelopes);\n }\n // Failed -- not retriable\n this.networkStatsbeatMetrics?.countFailure(duration, statusCode);\n return {\n code: ExportResultCode.FAILED,\n };\n } else {\n // calls resultCallback(ExportResult) based on result of persister.push\n this.networkStatsbeatMetrics?.countRetry(statusCode);\n return await this.persist(envelopes);\n }\n } else {\n // Failed -- not retriable\n if (this.networkStatsbeatMetrics) {\n if (statusCode) {\n this.networkStatsbeatMetrics.countFailure(duration, statusCode);\n }\n } else {\n // Handles all other status codes or client exceptions for Statsbeat\n this.incrementStatsbeatFailure();\n }\n return {\n code: ExportResultCode.FAILED,\n };\n }\n } catch (error: any) {\n const restError = error as RestError;\n if (\n restError.statusCode &&\n (restError.statusCode === 307 || // Temporary redirect\n restError.statusCode === 308)\n ) {\n // Permanent redirect\n this.numConsecutiveRedirects++;\n // To prevent circular redirects\n if (this.numConsecutiveRedirects < 10) {\n if (restError.response && restError.response.headers) {\n const location = restError.response.headers.get(\"location\");\n if (location) {\n // Update sender URL\n this.handlePermanentRedirect(location);\n // Send to redirect endpoint as HTTPs library doesn't handle redirect automatically\n return this.exportEnvelopes(envelopes);\n }\n }\n } else {\n const redirectError = new Error(\"Circular redirect\");\n this.networkStatsbeatMetrics?.countException(redirectError);\n return { code: ExportResultCode.FAILED, error: redirectError };\n }\n } else if (\n restError.statusCode &&\n isRetriable(restError.statusCode) &&\n !this.isStatsbeatSender\n ) {\n this.networkStatsbeatMetrics?.countRetry(restError.statusCode);\n return this.persist(envelopes);\n } else if (\n restError.statusCode === 400 &&\n restError.message.includes(\"Invalid instrumentation key\")\n ) {\n // Invalid instrumentation key, shutdown statsbeat, fail silently\n this.shutdownStatsbeat();\n return { code: ExportResultCode.SUCCESS };\n } else if (\n restError.statusCode &&\n this.isStatsbeatSender &&\n isStatsbeatShutdownStatus(restError.statusCode)\n ) {\n // If the status code is a shutdown status code for statsbeat, shutdown statsbeat and fail silently\n this.incrementStatsbeatFailure();\n return { code: ExportResultCode.SUCCESS };\n }\n if (this.isRetriableRestError(restError)) {\n if (restError.statusCode) {\n this.networkStatsbeatMetrics?.countRetry(restError.statusCode);\n }\n if (!this.isStatsbeatSender) {\n diag.error(\n \"Retrying due to transient client side error. Error message:\",\n restError.message,\n );\n }\n return this.persist(envelopes);\n }\n this.networkStatsbeatMetrics?.countException(restError);\n if (!this.isStatsbeatSender) {\n diag.error(\n \"Envelopes could not be exported and are not retriable. Error message:\",\n restError.message,\n );\n }\n return { code: ExportResultCode.FAILED, error: restError };\n }\n }\n\n /**\n * Persist envelopes to disk\n */\n private async persist(envelopes: unknown[]): Promise<ExportResult> {\n try {\n const success = await this.persister.push(envelopes);\n return success\n ? { code: ExportResultCode.SUCCESS }\n : {\n code: ExportResultCode.FAILED,\n error: new Error(\"Failed to persist envelope in disk.\"),\n };\n } catch (ex: any) {\n this.networkStatsbeatMetrics?.countWriteFailure();\n return { code: ExportResultCode.FAILED, error: ex };\n }\n }\n\n /**\n * Disable collection of statsbeat metrics after max failures\n */\n private incrementStatsbeatFailure(): void {\n this.statsbeatFailureCount++;\n if (this.statsbeatFailureCount > MAX_STATSBEAT_FAILURES) {\n this.shutdownStatsbeat();\n }\n }\n\n /**\n * Shutdown statsbeat metrics\n */\n private shutdownStatsbeat(): void {\n this.networkStatsbeatMetrics?.shutdown();\n this.longIntervalStatsbeatMetrics?.shutdown();\n this.networkStatsbeatMetrics = undefined;\n this.statsbeatFailureCount = 0;\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.send(envelopes);\n }\n } catch (err: any) {\n this.networkStatsbeatMetrics?.countReadFailure();\n diag.warn(`Failed to fetch persisted file`, err);\n }\n }\n\n private isRetriableRestError(error: RestError): boolean {\n const restErrorTypes: string[] = Object.values(RetriableRestErrorTypes);\n if (error && error.code && restErrorTypes.includes(error.code)) {\n return true;\n }\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"baseSender.js","sourceRoot":"","sources":["../../../../src/platform/nodejs/baseSender.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,4CAA0C;AAG1C,iDAAuD;AAEvD,8CAAuD;AACvD,kGAA4F;AAC5F,4GAAsG;AAEtG,8DAAoG;AAEpG,+DAAyD;AAEzD,kEAA0E;AAE1E,MAAM,oCAAoC,GAAG,KAAM,CAAC;AAEpD;;;GAGG;AACH,MAAsB,UAAU;IAW9B,YAAY,OAOX;QAZO,0BAAqB,GAAW,CAAC,CAAC;QAClC,6BAAwB,GAAW,oCAAoC,CAAC;QAY9E,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,qBAAqB,IAAI,KAAK,CAAC;QACpF,IAAI,CAAC,SAAS,GAAG,IAAI,4BAAiB,CAAC,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;QAC5F,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,IAAI,CAAC,uBAAuB,GAAG,oDAAuB,CAAC,WAAW,CAAC;gBACjE,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;gBAC9C,WAAW,EAAE,OAAO,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;;QACvB,IAAI,IAAI,CAAC,uBAAuB,EAAE,CAAC;YACjC,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,CAAC;QAC1C,CAAC;QACD,MAAA,IAAI,CAAC,4BAA4B,0CAAE,QAAQ,EAAE,CAAC;QAC9C,IAAI,CAAC,qBAAqB,GAAG,CAAC,CAAC;IACjC,CAAC;IAEO,KAAK,CAAC,sBAAsB;;QAClC,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAsB,CAAC;YACtE,IAAI,SAAS,EAAE,CAAC;gBACd,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBAC5B,MAAA,IAAI,CAAC,uBAAuB,0CAAE,gBAAgB,EAAE,CAAC;YACnD,CAAC;YACD,UAAI,CAAC,IAAI,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAEO,oBAAoB,CAAC,KAAgB;QAC3C,MAAM,cAAc,GAAa,MAAM,CAAC,MAAM,CAAC,sCAAuB,CAAC,CAAC;QACxE,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA/QD,gCA+QC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { diag } from \"@opentelemetry/api\";\nimport type { PersistentStorage, SenderResult } from \"../../types.js\";\nimport type { AzureMonitorExporterOptions } from \"../../config.js\";\nimport { FileSystemPersist } from \"./persist/index.js\";\nimport type { ExportResult } from \"@opentelemetry/core\";\nimport { ExportResultCode } from \"@opentelemetry/core\";\nimport { NetworkStatsbeatMetrics } from \"../../export/statsbeat/networkStatsbeatMetrics.js\";\nimport { LongIntervalStatsbeatMetrics } from \"../../export/statsbeat/longIntervalStatsbeatMetrics.js\";\nimport type { RestError } from \"@azure/core-rest-pipeline\";\nimport { MAX_STATSBEAT_FAILURES, isStatsbeatShutdownStatus } from \"../../export/statsbeat/types.js\";\nimport type { BreezeResponse } from \"../../utils/breezeUtils.js\";\nimport { isRetriable } from \"../../utils/breezeUtils.js\";\nimport type { TelemetryItem as Envelope } from \"../../generated/index.js\";\nimport { RetriableRestErrorTypes } from \"../../Declarations/Constants.js\";\n\nconst DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60_000;\n\n/**\n * Base sender class\n * @internal\n */\nexport abstract class BaseSender {\n private readonly persister: PersistentStorage;\n private numConsecutiveRedirects: number;\n private retryTimer: NodeJS.Timeout | null;\n private networkStatsbeatMetrics: NetworkStatsbeatMetrics | undefined;\n private longIntervalStatsbeatMetrics;\n private statsbeatFailureCount: number = 0;\n private batchSendRetryIntervalMs: number = DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS;\n private isStatsbeatSender: boolean;\n private disableOfflineStorage: boolean;\n\n constructor(options: {\n endpointUrl: string;\n instrumentationKey: string;\n trackStatsbeat: boolean;\n exporterOptions: AzureMonitorExporterOptions;\n aadAudience?: string;\n isStatsbeatSender?: boolean;\n }) {\n this.numConsecutiveRedirects = 0;\n this.disableOfflineStorage = options.exporterOptions.disableOfflineStorage || false;\n this.persister = new FileSystemPersist(options.instrumentationKey, options.exporterOptions);\n if (options.trackStatsbeat) {\n this.networkStatsbeatMetrics = NetworkStatsbeatMetrics.getInstance({\n instrumentationKey: options.instrumentationKey,\n endpointUrl: options.endpointUrl,\n disableOfflineStorage: this.disableOfflineStorage,\n });\n this.longIntervalStatsbeatMetrics = LongIntervalStatsbeatMetrics.getInstance({\n instrumentationKey: options.instrumentationKey,\n endpointUrl: options.endpointUrl,\n disableOfflineStorage: this.disableOfflineStorage,\n });\n }\n this.retryTimer = null;\n this.isStatsbeatSender = options.isStatsbeatSender || false;\n }\n\n abstract send(payload: unknown[]): Promise<SenderResult>;\n abstract shutdown(): Promise<void>;\n abstract handlePermanentRedirect(location: string | undefined): void;\n\n /**\n * Export envelopes\n */\n public async exportEnvelopes(envelopes: Envelope[]): Promise<ExportResult> {\n diag.info(`Exporting ${envelopes.length} envelope(s)`);\n\n if (envelopes.length < 1) {\n return { code: ExportResultCode.SUCCESS };\n }\n\n try {\n const startTime = new Date().getTime();\n const { result, statusCode } = await this.send(envelopes);\n const endTime = new Date().getTime();\n const duration = endTime - startTime;\n this.numConsecutiveRedirects = 0;\n\n if (statusCode === 200) {\n // Success -- @todo: start retry timer\n if (!this.retryTimer) {\n this.retryTimer = setTimeout(() => {\n this.retryTimer = null;\n this.sendFirstPersistedFile();\n }, this.batchSendRetryIntervalMs);\n this.retryTimer.unref();\n }\n // If we are not exporting statsbeat and statsbeat is not disabled -- count success\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countSuccess(duration);\n }\n return { code: ExportResultCode.SUCCESS };\n } else if (statusCode && isRetriable(statusCode)) {\n // Failed -- persist failed data\n if (statusCode === 429 || statusCode === 439) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countThrottle(statusCode);\n }\n return {\n code: ExportResultCode.SUCCESS,\n };\n }\n if (result) {\n diag.info(result);\n const breezeResponse = JSON.parse(result) as BreezeResponse;\n const filteredEnvelopes: Envelope[] = [];\n // If we have a partial success, count the succeeded envelopes\n if (breezeResponse.itemsAccepted > 0 && statusCode === 206 && !this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countSuccess(duration);\n }\n // Figure out if we need to either retry or count failures\n if (breezeResponse.errors) {\n breezeResponse.errors.forEach((error) => {\n if (error.statusCode && isRetriable(error.statusCode)) {\n filteredEnvelopes.push(envelopes[error.index]);\n }\n });\n }\n if (filteredEnvelopes.length > 0) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countRetry(statusCode);\n }\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this.persist(filteredEnvelopes);\n }\n // Failed -- not retriable\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countFailure(duration, statusCode);\n }\n return {\n code: ExportResultCode.FAILED,\n };\n } else {\n // calls resultCallback(ExportResult) based on result of persister.push\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countRetry(statusCode);\n }\n return await this.persist(envelopes);\n }\n } else {\n // Failed -- not retriable\n if (this.networkStatsbeatMetrics && !this.isStatsbeatSender) {\n if (statusCode) {\n this.networkStatsbeatMetrics.countFailure(duration, statusCode);\n }\n } else {\n // Handles all other status codes or client exceptions for Statsbeat\n this.incrementStatsbeatFailure();\n }\n return {\n code: ExportResultCode.FAILED,\n };\n }\n } catch (error: any) {\n const restError = error as RestError;\n if (\n restError.statusCode &&\n (restError.statusCode === 307 || // Temporary redirect\n restError.statusCode === 308)\n ) {\n // Permanent redirect\n this.numConsecutiveRedirects++;\n // To prevent circular redirects\n if (this.numConsecutiveRedirects < 10) {\n if (restError.response && restError.response.headers) {\n const location = restError.response.headers.get(\"location\");\n if (location) {\n // Update sender URL\n this.handlePermanentRedirect(location);\n // Send to redirect endpoint as HTTPs library doesn't handle redirect automatically\n return this.exportEnvelopes(envelopes);\n }\n }\n } else {\n const redirectError = new Error(\"Circular redirect\");\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countException(redirectError);\n }\n return { code: ExportResultCode.FAILED, error: redirectError };\n }\n } else if (\n restError.statusCode &&\n isRetriable(restError.statusCode) &&\n !this.isStatsbeatSender\n ) {\n this.networkStatsbeatMetrics?.countRetry(restError.statusCode);\n return this.persist(envelopes);\n } else if (\n restError.statusCode === 400 &&\n restError.message.includes(\"Invalid instrumentation key\")\n ) {\n // Invalid instrumentation key, shutdown statsbeat, fail silently\n this.shutdownStatsbeat();\n return { code: ExportResultCode.SUCCESS };\n } else if (\n restError.statusCode &&\n this.isStatsbeatSender &&\n isStatsbeatShutdownStatus(restError.statusCode)\n ) {\n // If the status code is a shutdown status code for statsbeat, shutdown statsbeat and fail silently\n this.incrementStatsbeatFailure();\n return { code: ExportResultCode.SUCCESS };\n }\n if (this.isRetriableRestError(restError)) {\n if (restError.statusCode && !this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countRetry(restError.statusCode);\n }\n if (!this.isStatsbeatSender) {\n diag.error(\n \"Retrying due to transient client side error. Error message:\",\n restError.message,\n );\n }\n return this.persist(envelopes);\n }\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countException(restError);\n }\n if (!this.isStatsbeatSender) {\n diag.error(\n \"Envelopes could not be exported and are not retriable. Error message:\",\n restError.message,\n );\n }\n return { code: ExportResultCode.FAILED, error: restError };\n }\n }\n\n /**\n * Persist envelopes to disk\n */\n private async persist(envelopes: unknown[]): Promise<ExportResult> {\n try {\n const success = await this.persister.push(envelopes);\n return success\n ? { code: ExportResultCode.SUCCESS }\n : {\n code: ExportResultCode.FAILED,\n error: new Error(\"Failed to persist envelope in disk.\"),\n };\n } catch (ex: any) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countWriteFailure();\n }\n return { code: ExportResultCode.FAILED, error: ex };\n }\n }\n\n /**\n * Disable collection of statsbeat metrics after max failures\n */\n private incrementStatsbeatFailure(): void {\n this.statsbeatFailureCount++;\n if (this.statsbeatFailureCount > MAX_STATSBEAT_FAILURES) {\n this.shutdownStatsbeat();\n }\n }\n\n /**\n * Shutdown statsbeat metrics\n */\n private shutdownStatsbeat(): void {\n if (this.networkStatsbeatMetrics) {\n this.networkStatsbeatMetrics.shutdown();\n }\n this.longIntervalStatsbeatMetrics?.shutdown();\n this.statsbeatFailureCount = 0;\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.send(envelopes);\n }\n } catch (err: any) {\n if (!this.isStatsbeatSender) {\n this.networkStatsbeatMetrics?.countReadFailure();\n }\n diag.warn(`Failed to fetch persisted file`, err);\n }\n }\n\n private isRetriableRestError(error: RestError): boolean {\n const restErrorTypes: string[] = Object.values(RetriableRestErrorTypes);\n if (error && error.code && restErrorTypes.includes(error.code)) {\n return true;\n }\n return false;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAuDA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG;KAAG,GAAG,IAAI,cAAc,GAAG,MAAM;CAAE,CAAC;AACvD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;AACpF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,CAAA;CAAE,CAAC;AACtE;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;CACZ;AACD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AACrD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1C;AAED;;;GAGG;AACH,oBAAY,2BAA2B;IACrC,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;IACnC,cAAc,mBAAmB;IACjC,qBAAqB,0BAA0B;IAC/C,YAAY,iBAAiB;IAC7B,gBAAgB,2BAA2B;IAC3C,uBAAuB,4BAA4B;IACnD,cAAc,mBAAmB;CAClC;AAED;;;GAGG;AACH,oBAAY,6BAA6B;IACvC,aAAa,iDAAiD;IAC9D,eAAe,8BAA8B;IAC7C,cAAc,0CAA0C;IACxD,qBAAqB,oDAAoD;IACzE,YAAY,6DAA6D;IACzE,gBAAgB,uEAAuE;IACvF,uBAAuB,+DAA+D;IACtF,cAAc,sEAAsE;CACrF;AAED;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B,QAAQ,MAAM;IACd,OAAO,OAAO;IACd,YAAY,OAAO;IACnB,WAAW,QAAQ;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,UA8BhC,CAAC;AAEF;;;GAGG;AACH,oBAAY,+BAA+B;IACzC,cAAc,8BAA8B;CAC7C;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,8eAwB9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,UAAsC,CAAC"}
|
package/dist/commonjs/types.js
CHANGED
|
@@ -77,6 +77,7 @@ exports.legacySemanticValues = [
|
|
|
77
77
|
semantic_conventions_1.SEMATTRS_NET_HOST_PORT,
|
|
78
78
|
semantic_conventions_1.SEMATTRS_NET_PEER_PORT,
|
|
79
79
|
semantic_conventions_1.SEMATTRS_HTTP_CLIENT_IP,
|
|
80
|
+
semantic_conventions_1.SEMATTRS_ENDUSER_ID,
|
|
80
81
|
"http.status_text",
|
|
81
82
|
];
|
|
82
83
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,8EAmD6C;AA8C7C;;;GAGG;AACH,IAAY,2BASX;AATD,WAAY,2BAA2B;IACrC,8DAA+B,CAAA;IAC/B,kEAAmC,CAAA;IACnC,gEAAiC,CAAA;IACjC,8EAA+C,CAAA;IAC/C,4DAA6B,CAAA;IAC7B,0EAA2C,CAAA;IAC3C,kFAAmD,CAAA;IACnD,gEAAiC,CAAA;AACnC,CAAC,EATW,2BAA2B,2CAA3B,2BAA2B,QAStC;AAED;;;GAGG;AACH,IAAY,6BASX;AATD,WAAY,6BAA6B;IACvC,+FAA8D,CAAA;IAC9D,8EAA6C,CAAA;IAC7C,yFAAwD,CAAA;IACxD,0GAAyE,CAAA;IACzE,0GAAyE,CAAA;IACzE,wHAAuF,CAAA;IACvF,uHAAsF,CAAA;IACtF,qHAAoF,CAAA;AACtF,CAAC,EATW,6BAA6B,6CAA7B,6BAA6B,QASxC;AAED;;;GAGG;AACH,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,qEAAc,CAAA;IACd,oEAAc,CAAA;IACd,8EAAmB,CAAA;IACnB,6EAAmB,CAAA;AACrB,CAAC,EALW,kBAAkB,kCAAlB,kBAAkB,QAK7B;AAED;;;GAGG;AACU,QAAA,oBAAoB,GAAG;IAClC,2CAAoB;IACpB,6CAAsB;IACtB,2CAAoB;IACpB,4CAAqB;IACrB,+CAAwB;IACxB,2CAAoB;IACpB,wCAAiB;IACjB,gDAAyB;IACzB,0CAAmB;IACnB,yCAAkB;IAClB,yCAAkB;IAClB,4CAAqB;IACrB,4CAAqB;IACrB,uCAAgB;IAChB,0CAAmB;IACnB,oDAA6B;IAC7B,8CAAuB;IACvB,iDAA0B;IAC1B,oDAA6B;IAC7B,2CAAoB;IACpB,2CAAoB;IACpB,2CAAoB;IACpB,6CAAsB;IACtB,6CAAsB;IACtB,6CAAsB;IACtB,6CAAsB;IACtB,8CAAuB;IACvB,0CAAmB;IACnB,kBAAkB;CACnB,CAAC;AAEF;;;GAGG;AACH,IAAY,+BAEX;AAFD,WAAY,+BAA+B;IACzC,+EAA4C,CAAA;AAC9C,CAAC,EAFW,+BAA+B,+CAA/B,+BAA+B,QAE1C;AAED;;;GAGG;AACU,QAAA,kBAAkB,GAAG;IAChC,0CAAmB;IACnB,uCAAgB;IAChB,0CAAmB;IACnB,uCAAgB;IAChB,oCAAa;IACb,oCAAa;IACb,qCAAc;IACd,sCAAe;IACf,sCAAe;IACf,iDAA0B;IAC1B,8CAAuB;IACvB,iDAA0B;IAC1B,gDAAyB;IACzB,6CAAsB;IACtB,oDAA6B;IAC7B,6CAAsB;IACtB,+CAAwB;IACxB,+CAAwB;IACxB,qDAA8B;IAC9B,0CAAmB;IACnB,6CAAsB;IACtB,gDAAyB;IACzB,+BAA+B,CAAC,cAAc;CAC/C,CAAC;AAEF;;;GAGG;AACU,QAAA,2BAA2B,GAAG,CAAC,iCAAiC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n ATTR_CLIENT_ADDRESS,\n ATTR_CLIENT_PORT,\n ATTR_ERROR_TYPE,\n ATTR_EXCEPTION_MESSAGE,\n ATTR_EXCEPTION_STACKTRACE,\n ATTR_EXCEPTION_TYPE,\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n ATTR_NETWORK_LOCAL_ADDRESS,\n ATTR_NETWORK_LOCAL_PORT,\n ATTR_NETWORK_PEER_ADDRESS,\n ATTR_NETWORK_PEER_PORT,\n ATTR_NETWORK_PROTOCOL_NAME,\n ATTR_NETWORK_PROTOCOL_VERSION,\n ATTR_NETWORK_TRANSPORT,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n ATTR_URL_FULL,\n ATTR_URL_PATH,\n ATTR_URL_QUERY,\n ATTR_URL_SCHEME,\n ATTR_USER_AGENT_ORIGINAL,\n SEMATTRS_DB_NAME,\n SEMATTRS_DB_OPERATION,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_SYSTEM,\n SEMATTRS_ENDUSER_ID,\n SEMATTRS_EXCEPTION_MESSAGE,\n SEMATTRS_EXCEPTION_STACKTRACE,\n SEMATTRS_EXCEPTION_TYPE,\n SEMATTRS_HTTP_CLIENT_IP,\n SEMATTRS_HTTP_FLAVOR,\n SEMATTRS_HTTP_HOST,\n SEMATTRS_HTTP_METHOD,\n SEMATTRS_HTTP_ROUTE,\n SEMATTRS_HTTP_SCHEME,\n SEMATTRS_HTTP_STATUS_CODE,\n SEMATTRS_HTTP_TARGET,\n SEMATTRS_HTTP_URL,\n SEMATTRS_HTTP_USER_AGENT,\n SEMATTRS_NET_HOST_IP,\n SEMATTRS_NET_HOST_NAME,\n SEMATTRS_NET_HOST_PORT,\n SEMATTRS_NET_PEER_IP,\n SEMATTRS_NET_PEER_NAME,\n SEMATTRS_NET_PEER_PORT,\n SEMATTRS_NET_TRANSPORT,\n SEMATTRS_PEER_SERVICE,\n SEMATTRS_RPC_GRPC_STATUS_CODE,\n SEMATTRS_RPC_SYSTEM,\n} from \"@opentelemetry/semantic-conventions\";\nimport type { ContextTagKeys } from \"./generated/index.js\";\n\n/**\n * Azure Monitor envelope tags.\n * @internal\n */\nexport type Tags = { [key in ContextTagKeys]: string };\n/**\n * Azure Monitor envelope property type.\n * @internal\n */\nexport type PropertyType = string | number | boolean | object | Array<PropertyType>;\n/**\n * Azure Monitor envelope properties.\n * @internal\n */\nexport type Properties = { [key: string]: Properties | PropertyType };\n/**\n * Azure Monitor envelope links.\n * @internal\n */\nexport interface MSLink {\n operation_Id: string;\n id: string;\n}\n/**\n * Azure Monitor envelope measurements.\n * @internal\n */\nexport type Measurements = { [key: string]: number };\n/**\n * Exporter sender result.\n * @internal\n */\nexport type SenderResult = { statusCode: number | undefined; result: string };\n\n/**\n * Exporter persistent storage.\n * @internal\n */\nexport interface PersistentStorage {\n shift(): Promise<unknown>;\n push(value: unknown[]): Promise<boolean>;\n}\n\n/**\n * Performance Counter OpenTelemetry compliant names.\n * @internal\n */\nexport enum OTelPerformanceCounterNames {\n PRIVATE_BYTES = \"Private_Bytes\",\n AVAILABLE_BYTES = \"Available_Bytes\",\n PROCESSOR_TIME = \"Processor_Time\",\n PROCESS_TIME_STANDARD = \"Process_Time_Standard\",\n REQUEST_RATE = \"Request_Rate\",\n REQUEST_DURATION = \"Request_Execution_Time\",\n PROCESS_TIME_NORMALIZED = \"Process_Time_Normalized\",\n EXCEPTION_RATE = \"Exception_Rate\",\n}\n\n/**\n * Breeze Performance Counter names.\n * @internal\n */\nexport enum BreezePerformanceCounterNames {\n PRIVATE_BYTES = \"\\\\Process(??APP_WIN32_PROC??)\\\\Private Bytes\",\n AVAILABLE_BYTES = \"\\\\Memory\\\\Available Bytes\",\n PROCESSOR_TIME = \"\\\\Processor(_Total)\\\\% Processor Time\",\n PROCESS_TIME_STANDARD = \"\\\\Process(??APP_WIN32_PROC??)\\\\% Processor Time\",\n REQUEST_RATE = \"\\\\ASP.NET Applications(??APP_W3SVC_PROC??)\\\\Requests/Sec\",\n REQUEST_DURATION = \"\\\\ASP.NET Applications(??APP_W3SVC_PROC??)\\\\Request Execution Time\",\n PROCESS_TIME_NORMALIZED = \"\\\\Process(??APP_WIN32_PROC??)\\\\% Processor Time Normalized\",\n EXCEPTION_RATE = \"\\\\.NET CLR Exceptions(??APP_CLR_PROC??)\\\\# of Exceps Thrown / sec\",\n}\n\n/**\n * Property Max Lengths\n * @internal\n */\nexport enum MaxPropertyLengths {\n NINE_BIT = 512,\n TEN_BIT = 1024,\n THIRTEEN_BIT = 8192,\n FIFTEEN_BIT = 32768,\n}\n\n/**\n * Legacy HTTP semantic convention values\n * @internal\n */\nexport const legacySemanticValues = [\n SEMATTRS_NET_PEER_IP,\n SEMATTRS_NET_PEER_NAME,\n SEMATTRS_NET_HOST_IP,\n SEMATTRS_PEER_SERVICE,\n SEMATTRS_HTTP_USER_AGENT,\n SEMATTRS_HTTP_METHOD,\n SEMATTRS_HTTP_URL,\n SEMATTRS_HTTP_STATUS_CODE,\n SEMATTRS_HTTP_ROUTE,\n SEMATTRS_HTTP_HOST,\n SEMATTRS_DB_SYSTEM,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_OPERATION,\n SEMATTRS_DB_NAME,\n SEMATTRS_RPC_SYSTEM,\n SEMATTRS_RPC_GRPC_STATUS_CODE,\n SEMATTRS_EXCEPTION_TYPE,\n SEMATTRS_EXCEPTION_MESSAGE,\n SEMATTRS_EXCEPTION_STACKTRACE,\n SEMATTRS_HTTP_SCHEME,\n SEMATTRS_HTTP_TARGET,\n SEMATTRS_HTTP_FLAVOR,\n SEMATTRS_NET_TRANSPORT,\n SEMATTRS_NET_HOST_NAME,\n SEMATTRS_NET_HOST_PORT,\n SEMATTRS_NET_PEER_PORT,\n SEMATTRS_HTTP_CLIENT_IP,\n SEMATTRS_ENDUSER_ID,\n \"http.status_text\",\n];\n\n/**\n * Experimental OpenTelemetry semantic convention values\n * @internal\n */\nexport enum experimentalOpenTelemetryValues {\n SYNTHETIC_TYPE = \"user_agent.synthetic.type\",\n}\n\n/**\n * HTTP semantic convention values\n * @internal\n */\nexport const httpSemanticValues = [\n ATTR_CLIENT_ADDRESS,\n ATTR_CLIENT_PORT,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n ATTR_URL_FULL,\n ATTR_URL_PATH,\n ATTR_URL_QUERY,\n ATTR_URL_SCHEME,\n ATTR_ERROR_TYPE,\n ATTR_NETWORK_LOCAL_ADDRESS,\n ATTR_NETWORK_LOCAL_PORT,\n ATTR_NETWORK_PROTOCOL_NAME,\n ATTR_NETWORK_PEER_ADDRESS,\n ATTR_NETWORK_PEER_PORT,\n ATTR_NETWORK_PROTOCOL_VERSION,\n ATTR_NETWORK_TRANSPORT,\n ATTR_USER_AGENT_ORIGINAL,\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n ATTR_EXCEPTION_TYPE,\n ATTR_EXCEPTION_MESSAGE,\n ATTR_EXCEPTION_STACKTRACE,\n experimentalOpenTelemetryValues.SYNTHETIC_TYPE,\n];\n\n/**\n * Internal Microsoft attributes\n * @internal\n */\nexport const internalMicrosoftAttributes = [\"_MS.ProcessedByMetricExtractors\"];\n"]}
|
|
@@ -17,7 +17,7 @@ export declare const TIME_SINCE_ENQUEUED = "timeSinceEnqueued";
|
|
|
17
17
|
* AzureMonitorTraceExporter version.
|
|
18
18
|
* @internal
|
|
19
19
|
*/
|
|
20
|
-
export declare const packageVersion = "1.0.0-beta.
|
|
20
|
+
export declare const packageVersion = "1.0.0-beta.32";
|
|
21
21
|
export declare enum DependencyTypes {
|
|
22
22
|
InProc = "InProc",
|
|
23
23
|
QueueMessage = "Queue Message",
|
|
@@ -22,7 +22,7 @@ exports.TIME_SINCE_ENQUEUED = "timeSinceEnqueued";
|
|
|
22
22
|
* AzureMonitorTraceExporter version.
|
|
23
23
|
* @internal
|
|
24
24
|
*/
|
|
25
|
-
exports.packageVersion = "1.0.0-beta.
|
|
25
|
+
exports.packageVersion = "1.0.0-beta.32";
|
|
26
26
|
var DependencyTypes;
|
|
27
27
|
(function (DependencyTypes) {
|
|
28
28
|
DependencyTypes["InProc"] = "InProc";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applicationinsights.js","sourceRoot":"","sources":["../../../../src/utils/constants/applicationinsights.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;;GAGG;AACU,QAAA,QAAQ,GAAG,WAAW,CAAC;AACpC;;;GAGG;AACU,QAAA,aAAa,GAAG,cAAc,CAAC;AAC5C;;;GAGG;AACU,QAAA,mBAAmB,GAAG,mBAAmB,CAAC;AACvD;;;GAGG;AACU,QAAA,cAAc,GAAG,eAAe,CAAC;AAE9C,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,+BAAf,eAAe,QAO1B;AAEY,QAAA,sBAAsB,GAAG,uBAAuB,CAAC;AACjD,QAAA,2BAA2B,GAAG,cAAc,CAAC;AAC7C,QAAA,kCAAkC,GAAG,6BAA6B,CAAC;AAEnE,QAAA,8BAA8B,GAAG,uCAAuC,CAAC;AACzE,QAAA,gCAAgC,GAAG,yCAAyC,CAAC;AAC7E,QAAA,+BAA+B,GAAG,wCAAwC,CAAC;AAC3E,QAAA,mCAAmC,GAAG,4CAA4C,CAAC;AACnF,QAAA,4BAA4B,GAAG,qCAAqC,CAAC;AAErE,QAAA,kCAAkC,GAAG,aAAa,CAAC;AACnD,QAAA,oCAAoC,GAAG,eAAe,CAAC;AACvD,QAAA,mCAAmC,GAAG,cAAc,CAAC;AACrD,QAAA,uCAAuC,GAAG,kBAAkB,CAAC;AAC7D,QAAA,gCAAgC,GAAG,WAAW,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * AI MS Links.\n * @internal\n */\nexport const MS_LINKS = \"_MS.links\";\n/**\n * AI enqueued time attribute.\n * @internal\n */\nexport const ENQUEUED_TIME = \"enqueuedTime\";\n/**\n * AI time since enqueued attribute.\n * @internal\n */\nexport const TIME_SINCE_ENQUEUED = \"timeSinceEnqueued\";\n/**\n * AzureMonitorTraceExporter version.\n * @internal\n */\nexport const packageVersion = \"1.0.0-beta.
|
|
1
|
+
{"version":3,"file":"applicationinsights.js","sourceRoot":"","sources":["../../../../src/utils/constants/applicationinsights.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;;GAGG;AACU,QAAA,QAAQ,GAAG,WAAW,CAAC;AACpC;;;GAGG;AACU,QAAA,aAAa,GAAG,cAAc,CAAC;AAC5C;;;GAGG;AACU,QAAA,mBAAmB,GAAG,mBAAmB,CAAC;AACvD;;;GAGG;AACU,QAAA,cAAc,GAAG,eAAe,CAAC;AAE9C,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,+BAAf,eAAe,QAO1B;AAEY,QAAA,sBAAsB,GAAG,uBAAuB,CAAC;AACjD,QAAA,2BAA2B,GAAG,cAAc,CAAC;AAC7C,QAAA,kCAAkC,GAAG,6BAA6B,CAAC;AAEnE,QAAA,8BAA8B,GAAG,uCAAuC,CAAC;AACzE,QAAA,gCAAgC,GAAG,yCAAyC,CAAC;AAC7E,QAAA,+BAA+B,GAAG,wCAAwC,CAAC;AAC3E,QAAA,mCAAmC,GAAG,4CAA4C,CAAC;AACnF,QAAA,4BAA4B,GAAG,qCAAqC,CAAC;AAErE,QAAA,kCAAkC,GAAG,aAAa,CAAC;AACnD,QAAA,oCAAoC,GAAG,eAAe,CAAC;AACvD,QAAA,mCAAmC,GAAG,cAAc,CAAC;AACrD,QAAA,uCAAuC,GAAG,kBAAkB,CAAC;AAC7D,QAAA,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.32\";\n\nexport enum DependencyTypes {\n InProc = \"InProc\",\n QueueMessage = \"Queue Message\",\n Sql = \"SQL\",\n Http = \"Http\",\n Grpc = \"GRPC\",\n Wcf = \"WCF Service\",\n}\n\nexport const AzureMonitorSampleRate = \"microsoft.sample_rate\";\nexport const ApplicationInsightsBaseType = \"_MS.baseType\";\nexport const ApplicationInsightsCustomEventName = \"microsoft.custom_event.name\";\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"]}
|
|
@@ -27,10 +27,11 @@ const azAttributes_js_1 = require("./constants/span/azAttributes.js");
|
|
|
27
27
|
const index_js_1 = require("../generated/index.js");
|
|
28
28
|
const breezeUtils_js_1 = require("./breezeUtils.js");
|
|
29
29
|
function createTagsFromSpan(span) {
|
|
30
|
+
var _a;
|
|
30
31
|
const tags = (0, common_js_1.createTagsFromResource)(span.resource);
|
|
31
32
|
tags[index_js_1.KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;
|
|
32
|
-
if (span.
|
|
33
|
-
tags[index_js_1.KnownContextTagKeys.AiOperationParentId] = span.
|
|
33
|
+
if ((_a = span.parentSpanContext) === null || _a === void 0 ? void 0 : _a.spanId) {
|
|
34
|
+
tags[index_js_1.KnownContextTagKeys.AiOperationParentId] = span.parentSpanContext.spanId;
|
|
34
35
|
}
|
|
35
36
|
const endUserId = span.attributes[semantic_conventions_1.SEMATTRS_ENDUSER_ID];
|
|
36
37
|
if (endUserId) {
|
|
@@ -61,7 +62,7 @@ function createTagsFromSpan(span) {
|
|
|
61
62
|
const url = new URL(String(httpUrl));
|
|
62
63
|
tags[index_js_1.KnownContextTagKeys.AiOperationName] = String(`${httpMethod} ${url.pathname}`).substring(0, types_js_1.MaxPropertyLengths.TEN_BIT);
|
|
63
64
|
}
|
|
64
|
-
catch (
|
|
65
|
+
catch (_b) {
|
|
65
66
|
/* no-op */
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -122,7 +123,7 @@ function createDependencyData(span) {
|
|
|
122
123
|
if (span.kind === api_1.SpanKind.PRODUCER) {
|
|
123
124
|
remoteDependencyData.type = applicationinsights_js_1.DependencyTypes.QueueMessage;
|
|
124
125
|
}
|
|
125
|
-
if (span.kind === api_1.SpanKind.INTERNAL && span.
|
|
126
|
+
if (span.kind === api_1.SpanKind.INTERNAL && span.parentSpanContext) {
|
|
126
127
|
remoteDependencyData.type = applicationinsights_js_1.DependencyTypes.InProc;
|
|
127
128
|
}
|
|
128
129
|
const httpMethod = getHttpMethod(span.attributes);
|
|
@@ -343,7 +344,6 @@ function spanEventsToEnvelopes(span, ikey) {
|
|
|
343
344
|
const envelopes = [];
|
|
344
345
|
if (span.events) {
|
|
345
346
|
span.events.forEach((event) => {
|
|
346
|
-
var _a;
|
|
347
347
|
let baseType;
|
|
348
348
|
const time = (0, common_js_1.hrTimeToDate)(event.time);
|
|
349
349
|
let name = "";
|
|
@@ -351,7 +351,7 @@ function spanEventsToEnvelopes(span, ikey) {
|
|
|
351
351
|
const properties = createPropertiesFromSpanAttributes(event.attributes);
|
|
352
352
|
const tags = (0, common_js_1.createTagsFromResource)(span.resource);
|
|
353
353
|
tags[index_js_1.KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;
|
|
354
|
-
const spanId =
|
|
354
|
+
const spanId = span.spanContext().spanId;
|
|
355
355
|
if (spanId) {
|
|
356
356
|
tags[index_js_1.KnownContextTagKeys.AiOperationParentId] = spanId;
|
|
357
357
|
}
|