@opentelemetry/otlp-exporter-base 0.51.1 → 0.52.0
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/build/esm/OTLPExporterBase.d.ts +1 -2
- package/build/esm/OTLPExporterBase.js.map +1 -1
- package/build/esm/platform/browser/OTLPExporterBrowserBase.d.ts +7 -2
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js +20 -5
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/esm/platform/browser/util.d.ts +2 -2
- package/build/esm/platform/browser/util.js.map +1 -1
- package/build/esm/platform/node/OTLPExporterNodeBase.d.ts +5 -2
- package/build/esm/platform/node/OTLPExporterNodeBase.js +5 -3
- package/build/esm/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/esm/platform/node/util.d.ts +1 -1
- package/build/esm/platform/node/util.js +3 -3
- package/build/esm/platform/node/util.js.map +1 -1
- package/build/esm/version.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esnext/OTLPExporterBase.d.ts +1 -2
- package/build/esnext/OTLPExporterBase.js.map +1 -1
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.d.ts +7 -2
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.js +9 -5
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/esnext/platform/browser/util.d.ts +2 -2
- package/build/esnext/platform/browser/util.js.map +1 -1
- package/build/esnext/platform/node/OTLPExporterNodeBase.d.ts +5 -2
- package/build/esnext/platform/node/OTLPExporterNodeBase.js +5 -3
- package/build/esnext/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/esnext/platform/node/util.d.ts +1 -1
- package/build/esnext/platform/node/util.js +3 -3
- package/build/esnext/platform/node/util.js.map +1 -1
- package/build/esnext/version.d.ts +1 -1
- package/build/esnext/version.js +1 -1
- package/build/esnext/version.js.map +1 -1
- package/build/src/OTLPExporterBase.d.ts +1 -2
- package/build/src/OTLPExporterBase.js.map +1 -1
- package/build/src/platform/browser/OTLPExporterBrowserBase.d.ts +7 -2
- package/build/src/platform/browser/OTLPExporterBrowserBase.js +9 -5
- package/build/src/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/src/platform/browser/util.d.ts +2 -2
- package/build/src/platform/browser/util.js.map +1 -1
- package/build/src/platform/node/OTLPExporterNodeBase.d.ts +5 -2
- package/build/src/platform/node/OTLPExporterNodeBase.js +5 -3
- package/build/src/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/src/platform/node/util.d.ts +1 -1
- package/build/src/platform/node/util.js +3 -3
- package/build/src/platform/node/util.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/package.json +13 -11
|
@@ -3,7 +3,7 @@ import { OTLPExporterError, OTLPExporterConfigBase } from './types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Collector Exporter abstract base class
|
|
5
5
|
*/
|
|
6
|
-
export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase, ExportItem
|
|
6
|
+
export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase, ExportItem> {
|
|
7
7
|
readonly url: string;
|
|
8
8
|
readonly hostname: string | undefined;
|
|
9
9
|
readonly timeoutMillis: number;
|
|
@@ -37,6 +37,5 @@ export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase,
|
|
|
37
37
|
abstract onInit(config: T): void;
|
|
38
38
|
abstract send(items: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
39
39
|
abstract getDefaultUrl(config: T): string;
|
|
40
|
-
abstract convert(objects: ExportItem[]): ServiceRequest;
|
|
41
40
|
}
|
|
42
41
|
//# sourceMappingURL=OTLPExporterBase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts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QACE,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,qCAAU,GAAV;QACE,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC;YAC7C,6BAA6B;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,oCAAS,GAAjB;QACE,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC/B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;IAUH,uBAAC;AAAD,CAAC,AAhHD,IAgHC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { diag } from '@opentelemetry/api';\nimport {\n ExportResult,\n ExportResultCode,\n BindOnceFuture,\n} from '@opentelemetry/core';\nimport {\n OTLPExporterError,\n OTLPExporterConfigBase,\n ExportServiceError,\n} from './types';\nimport { configureExporterTimeout } from './util';\n\n/**\n * Collector Exporter abstract base class\n */\nexport abstract class OTLPExporterBase<\n T extends OTLPExporterConfigBase,\n ExportItem,\n> {\n public readonly url: string;\n public readonly hostname: string | undefined;\n public readonly timeoutMillis: number;\n protected _concurrencyLimit: number;\n protected _sendingPromises: Promise<unknown>[] = [];\n protected _shutdownOnce: BindOnceFuture<void>;\n\n /**\n * @param config\n */\n constructor(config: T = {} as T) {\n this.url = this.getDefaultUrl(config);\n if (typeof config.hostname === 'string') {\n this.hostname = config.hostname;\n }\n\n this.shutdown = this.shutdown.bind(this);\n this._shutdownOnce = new BindOnceFuture(this._shutdown, this);\n\n this._concurrencyLimit =\n typeof config.concurrencyLimit === 'number'\n ? config.concurrencyLimit\n : 30;\n\n this.timeoutMillis = configureExporterTimeout(config.timeoutMillis);\n\n // platform dependent\n this.onInit(config);\n }\n\n /**\n * Export items.\n * @param items\n * @param resultCallback\n */\n export(\n items: ExportItem[],\n resultCallback: (result: ExportResult) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Exporter has been shutdown'),\n });\n return;\n }\n\n if (this._sendingPromises.length >= this._concurrencyLimit) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Concurrent export limit reached'),\n });\n return;\n }\n\n this._export(items)\n .then(() => {\n resultCallback({ code: ExportResultCode.SUCCESS });\n })\n .catch((error: ExportServiceError) => {\n resultCallback({ code: ExportResultCode.FAILED, error });\n });\n }\n\n private _export(items: ExportItem[]): Promise<unknown> {\n return new Promise<void>((resolve, reject) => {\n try {\n diag.debug('items to be sent', items);\n this.send(items, resolve, reject);\n } catch (e) {\n reject(e);\n }\n });\n }\n\n /**\n * Shutdown the exporter.\n */\n shutdown(): Promise<void> {\n return this._shutdownOnce.call();\n }\n\n /**\n * Exports any pending spans in the exporter\n */\n forceFlush(): Promise<void> {\n return Promise.all(this._sendingPromises).then(() => {\n /** ignore resolved values */\n });\n }\n\n /**\n * Called by _shutdownOnce with BindOnceFuture\n */\n private _shutdown(): Promise<void> {\n diag.debug('shutdown started');\n this.onShutdown();\n return this.forceFlush();\n }\n\n abstract onShutdown(): void;\n abstract onInit(config: T): void;\n abstract send(\n items: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void;\n abstract getDefaultUrl(config: T): string;\n}\n"]}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
2
2
|
import { OTLPExporterConfigBase } from '../../types';
|
|
3
3
|
import * as otlpTypes from '../../types';
|
|
4
|
+
import { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
4
5
|
/**
|
|
5
6
|
* Collector Metric Exporter abstract base class
|
|
6
7
|
*/
|
|
7
|
-
export declare abstract class OTLPExporterBrowserBase<ExportItem,
|
|
8
|
+
export declare abstract class OTLPExporterBrowserBase<ExportItem, ServiceResponse> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem> {
|
|
8
9
|
protected _headers: Record<string, string>;
|
|
9
10
|
private _useXHR;
|
|
11
|
+
private _contentType;
|
|
12
|
+
private _serializer;
|
|
10
13
|
/**
|
|
11
14
|
* @param config
|
|
15
|
+
* @param serializer
|
|
16
|
+
* @param contentType
|
|
12
17
|
*/
|
|
13
|
-
constructor(config
|
|
18
|
+
constructor(config: OTLPExporterConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, contentType: string);
|
|
14
19
|
onInit(): void;
|
|
15
20
|
onShutdown(): void;
|
|
16
21
|
send(items: ExportItem[], onSuccess: () => void, onError: (error: otlpTypes.OTLPExporterError) => void): void;
|
|
@@ -28,6 +28,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
28
28
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29
29
|
};
|
|
30
30
|
})();
|
|
31
|
+
var __assign = (this && this.__assign) || function () {
|
|
32
|
+
__assign = Object.assign || function(t) {
|
|
33
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
34
|
+
s = arguments[i];
|
|
35
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
36
|
+
t[p] = s[p];
|
|
37
|
+
}
|
|
38
|
+
return t;
|
|
39
|
+
};
|
|
40
|
+
return __assign.apply(this, arguments);
|
|
41
|
+
};
|
|
31
42
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
32
43
|
import { parseHeaders } from '../../util';
|
|
33
44
|
import { sendWithBeacon, sendWithXhr } from './util';
|
|
@@ -40,11 +51,15 @@ var OTLPExporterBrowserBase = /** @class */ (function (_super) {
|
|
|
40
51
|
__extends(OTLPExporterBrowserBase, _super);
|
|
41
52
|
/**
|
|
42
53
|
* @param config
|
|
54
|
+
* @param serializer
|
|
55
|
+
* @param contentType
|
|
43
56
|
*/
|
|
44
|
-
function OTLPExporterBrowserBase(config) {
|
|
57
|
+
function OTLPExporterBrowserBase(config, serializer, contentType) {
|
|
45
58
|
if (config === void 0) { config = {}; }
|
|
46
59
|
var _this = _super.call(this, config) || this;
|
|
47
60
|
_this._useXHR = false;
|
|
61
|
+
_this._serializer = serializer;
|
|
62
|
+
_this._contentType = contentType;
|
|
48
63
|
_this._useXHR =
|
|
49
64
|
!!config.headers || typeof navigator.sendBeacon !== 'function';
|
|
50
65
|
if (_this._useXHR) {
|
|
@@ -59,18 +74,18 @@ var OTLPExporterBrowserBase = /** @class */ (function (_super) {
|
|
|
59
74
|
OTLPExporterBrowserBase.prototype.onShutdown = function () { };
|
|
60
75
|
OTLPExporterBrowserBase.prototype.send = function (items, onSuccess, onError) {
|
|
61
76
|
var _this = this;
|
|
77
|
+
var _a;
|
|
62
78
|
if (this._shutdownOnce.isCalled) {
|
|
63
79
|
diag.debug('Shutdown already started. Cannot send objects');
|
|
64
80
|
return;
|
|
65
81
|
}
|
|
66
|
-
var
|
|
67
|
-
var body = JSON.stringify(serviceRequest);
|
|
82
|
+
var body = (_a = this._serializer.serializeRequest(items)) !== null && _a !== void 0 ? _a : new Uint8Array();
|
|
68
83
|
var promise = new Promise(function (resolve, reject) {
|
|
69
84
|
if (_this._useXHR) {
|
|
70
|
-
sendWithXhr(body, _this.url, _this._headers, _this.timeoutMillis, resolve, reject);
|
|
85
|
+
sendWithXhr(body, _this.url, __assign(__assign({}, _this._headers), { 'Content-Type': _this._contentType }), _this.timeoutMillis, resolve, reject);
|
|
71
86
|
}
|
|
72
87
|
else {
|
|
73
|
-
sendWithBeacon(body, _this.url, { type:
|
|
88
|
+
sendWithBeacon(body, _this.url, { type: _this._contentType }, resolve, reject);
|
|
74
89
|
}
|
|
75
90
|
}).then(onSuccess, onError);
|
|
76
91
|
this._sendingPromises.push(promise);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPExporterBrowserBase.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPExporterBrowserBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"OTLPExporterBrowserBase.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPExporterBrowserBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;GAEG;AACH;IAGU,2CAAoD;IAM5D;;;;OAIG;IACH,iCACE,MAAmC,EACnC,UAAsD,EACtD,WAAmB;QAFnB,uBAAA,EAAA,WAAmC;QADrC,YAKE,kBAAM,MAAM,CAAC,SAgBd;QA9BO,aAAO,GAAY,KAAK,CAAC;QAe/B,KAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,KAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,KAAI,CAAC,OAAO;YACV,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU,CAAC;QACjE,IAAI,KAAI,CAAC,OAAO,EAAE;YAChB,KAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAC3B,EAAE,EACF,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,EA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CAAC,CAAC;QACzC,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;IACH,8BAAC;AAAD,CAAC,AAnFD,CAGU,gBAAgB,GAgFzB","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OTLPExporterBase } from '../../OTLPExporterBase';\nimport { OTLPExporterConfigBase } from '../../types';\nimport * as otlpTypes from '../../types';\nimport { parseHeaders } from '../../util';\nimport { sendWithBeacon, sendWithXhr } from './util';\nimport { diag } from '@opentelemetry/api';\nimport { getEnv, baggageUtils } from '@opentelemetry/core';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\n\n/**\n * Collector Metric Exporter abstract base class\n */\nexport abstract class OTLPExporterBrowserBase<\n ExportItem,\n ServiceResponse,\n> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem> {\n protected _headers: Record<string, string>;\n private _useXHR: boolean = false;\n private _contentType: string;\n private _serializer: ISerializer<ExportItem[], ServiceResponse>;\n\n /**\n * @param config\n * @param serializer\n * @param contentType\n */\n constructor(\n config: OTLPExporterConfigBase = {},\n serializer: ISerializer<ExportItem[], ServiceResponse>,\n contentType: string\n ) {\n super(config);\n this._serializer = serializer;\n this._contentType = contentType;\n this._useXHR =\n !!config.headers || typeof navigator.sendBeacon !== 'function';\n if (this._useXHR) {\n this._headers = Object.assign(\n {},\n parseHeaders(config.headers),\n baggageUtils.parseKeyPairsIntoRecord(\n getEnv().OTEL_EXPORTER_OTLP_HEADERS\n )\n );\n } else {\n this._headers = {};\n }\n }\n\n onInit(): void {}\n\n onShutdown(): void {}\n\n send(\n items: ExportItem[],\n onSuccess: () => void,\n onError: (error: otlpTypes.OTLPExporterError) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n diag.debug('Shutdown already started. Cannot send objects');\n return;\n }\n const body = this._serializer.serializeRequest(items) ?? new Uint8Array();\n\n const promise = new Promise<void>((resolve, reject) => {\n if (this._useXHR) {\n sendWithXhr(\n body,\n this.url,\n {\n ...this._headers,\n 'Content-Type': this._contentType,\n },\n this.timeoutMillis,\n resolve,\n reject\n );\n } else {\n sendWithBeacon(\n body,\n this.url,\n { type: this._contentType },\n resolve,\n reject\n );\n }\n }).then(onSuccess, onError);\n\n this._sendingPromises.push(promise);\n const popPromise = () => {\n const index = this._sendingPromises.indexOf(promise);\n this._sendingPromises.splice(index, 1);\n };\n promise.then(popPromise, popPromise);\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { OTLPExporterError } from '../../types';
|
|
|
7
7
|
* @param onSuccess
|
|
8
8
|
* @param onError
|
|
9
9
|
*/
|
|
10
|
-
export declare function sendWithBeacon(body:
|
|
10
|
+
export declare function sendWithBeacon(body: Uint8Array, url: string, blobPropertyBag: BlobPropertyBag, onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
11
11
|
/**
|
|
12
12
|
* function to send metrics/spans using browser XMLHttpRequest
|
|
13
13
|
* used when navigator.sendBeacon is not available
|
|
@@ -17,5 +17,5 @@ export declare function sendWithBeacon(body: string, url: string, blobPropertyBa
|
|
|
17
17
|
* @param onSuccess
|
|
18
18
|
* @param onError
|
|
19
19
|
*/
|
|
20
|
-
export declare function sendWithXhr(body:
|
|
20
|
+
export declare function sendWithXhr(body: Uint8Array, url: string, headers: Record<string, string>, exporterTimeout: number, onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
21
21
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/platform/browser/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,iCAAiC,EACjC,0BAA0B,EAC1B,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/platform/browser/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,iCAAiC,EACjC,0BAA0B,EAC1B,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAgB,EAChB,GAAW,EACX,eAAgC,EAChC,SAAqB,EACrB,OAA2C;IAE3C,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE;QAChE,IAAI,CAAC,KAAK,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;QAC1C,SAAS,EAAE,CAAC;KACb;SAAM;QACL,IAAM,KAAK,GAAG,IAAI,iBAAiB,CAAC,8BAA4B,IAAM,CAAC,CAAC;QACxE,OAAO,CAAC,KAAK,CAAC,CAAC;KAChB;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CACzB,IA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AC,iBAAiB,CAAC,CAAC;gBACrD,OAAO,CAAC,GAAG,CAAC,CAAC;aACd;YACD,YAAY,CAAC,aAAa,CAAC,CAAC;YAC5B,YAAY,CAAC,UAAU,CAAC,CAAC;QAC3B,CAAC,CAAC;QAEF,GAAG,CAAC,OAAO,GAAG;YACZ,IAAI,cAAc,EAAE;gBAClB,IAAM,GAAG,GAAG,IAAI,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;gBACrD,OAAO,CAAC,GAAG,CAAC,CAAC;aACd;YACD,YAAY,CAAC,aAAa,CAAC,CAAC;YAC5B,YAAY,CAAC,UAAU,CAAC,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,aAAa,EAAE,CAAC;AAClB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { diag } from '@opentelemetry/api';\nimport { OTLPExporterError } from '../../types';\nimport {\n DEFAULT_EXPORT_MAX_ATTEMPTS,\n DEFAULT_EXPORT_INITIAL_BACKOFF,\n DEFAULT_EXPORT_BACKOFF_MULTIPLIER,\n DEFAULT_EXPORT_MAX_BACKOFF,\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../../util';\n\n/**\n * Send metrics/spans using browser navigator.sendBeacon\n * @param body\n * @param url\n * @param blobPropertyBag\n * @param onSuccess\n * @param onError\n */\nexport function sendWithBeacon(\n body: Uint8Array,\n url: string,\n blobPropertyBag: BlobPropertyBag,\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n): void {\n if (navigator.sendBeacon(url, new Blob([body], blobPropertyBag))) {\n diag.debug('sendBeacon - can send', body);\n onSuccess();\n } else {\n const error = new OTLPExporterError(`sendBeacon - cannot send ${body}`);\n onError(error);\n }\n}\n\n/**\n * function to send metrics/spans using browser XMLHttpRequest\n * used when navigator.sendBeacon is not available\n * @param body\n * @param url\n * @param headers\n * @param onSuccess\n * @param onError\n */\nexport function sendWithXhr(\n body: Uint8Array,\n url: string,\n headers: Record<string, string>,\n exporterTimeout: number,\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n): void {\n let retryTimer: ReturnType<typeof setTimeout>;\n let xhr: XMLHttpRequest;\n let reqIsDestroyed = false;\n\n const exporterTimer = setTimeout(() => {\n clearTimeout(retryTimer);\n reqIsDestroyed = true;\n\n if (xhr.readyState === XMLHttpRequest.DONE) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n } else {\n xhr.abort();\n }\n }, exporterTimeout);\n\n const sendWithRetry = (\n retries = DEFAULT_EXPORT_MAX_ATTEMPTS,\n minDelay = DEFAULT_EXPORT_INITIAL_BACKOFF\n ) => {\n xhr = new XMLHttpRequest();\n xhr.open('POST', url);\n\n const defaultHeaders = {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n };\n\n Object.entries({\n ...defaultHeaders,\n ...headers,\n }).forEach(([k, v]) => {\n xhr.setRequestHeader(k, v);\n });\n\n xhr.send(body);\n\n xhr.onreadystatechange = () => {\n if (xhr.readyState === XMLHttpRequest.DONE && reqIsDestroyed === false) {\n if (xhr.status >= 200 && xhr.status <= 299) {\n diag.debug('xhr success', body);\n onSuccess();\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n } else if (xhr.status && isExportRetryable(xhr.status) && retries > 0) {\n let retryTime: number;\n minDelay = DEFAULT_EXPORT_BACKOFF_MULTIPLIER * minDelay;\n\n // retry after interval specified in Retry-After header\n if (xhr.getResponseHeader('Retry-After')) {\n retryTime = parseRetryAfterToMills(\n xhr.getResponseHeader('Retry-After')!\n );\n } else {\n // exponential backoff with jitter\n retryTime = Math.round(\n Math.random() * (DEFAULT_EXPORT_MAX_BACKOFF - minDelay) + minDelay\n );\n }\n\n retryTimer = setTimeout(() => {\n sendWithRetry(retries - 1, minDelay);\n }, retryTime);\n } else {\n const error = new OTLPExporterError(\n `Failed to export with XHR (status: ${xhr.status})`,\n xhr.status\n );\n onError(error);\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n }\n }\n };\n\n xhr.onabort = () => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n }\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n };\n\n xhr.onerror = () => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n }\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n };\n };\n\n sendWithRetry();\n}\n"]}
|
|
@@ -4,15 +4,18 @@ import type * as https from 'https';
|
|
|
4
4
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
5
5
|
import { OTLPExporterNodeConfigBase, CompressionAlgorithm } from './types';
|
|
6
6
|
import * as otlpTypes from '../../types';
|
|
7
|
+
import { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
7
8
|
/**
|
|
8
9
|
* Collector Metric Exporter abstract base class
|
|
9
10
|
*/
|
|
10
|
-
export declare abstract class OTLPExporterNodeBase<ExportItem,
|
|
11
|
+
export declare abstract class OTLPExporterNodeBase<ExportItem, ServiceResponse> extends OTLPExporterBase<OTLPExporterNodeConfigBase, ExportItem> {
|
|
11
12
|
DEFAULT_HEADERS: Record<string, string>;
|
|
12
13
|
headers: Record<string, string>;
|
|
13
14
|
agent: http.Agent | https.Agent | undefined;
|
|
14
15
|
compression: CompressionAlgorithm;
|
|
15
|
-
|
|
16
|
+
private _serializer;
|
|
17
|
+
private _contentType;
|
|
18
|
+
constructor(config: OTLPExporterNodeConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, contentType: string);
|
|
16
19
|
onInit(_config: OTLPExporterNodeConfigBase): void;
|
|
17
20
|
send(objects: ExportItem[], onSuccess: () => void, onError: (error: otlpTypes.OTLPExporterError) => void): void;
|
|
18
21
|
onShutdown(): void;
|
|
@@ -38,10 +38,11 @@ import { getEnv, baggageUtils } from '@opentelemetry/core';
|
|
|
38
38
|
*/
|
|
39
39
|
var OTLPExporterNodeBase = /** @class */ (function (_super) {
|
|
40
40
|
__extends(OTLPExporterNodeBase, _super);
|
|
41
|
-
function OTLPExporterNodeBase(config) {
|
|
41
|
+
function OTLPExporterNodeBase(config, serializer, contentType) {
|
|
42
42
|
if (config === void 0) { config = {}; }
|
|
43
43
|
var _this = _super.call(this, config) || this;
|
|
44
44
|
_this.DEFAULT_HEADERS = {};
|
|
45
|
+
_this._contentType = contentType;
|
|
45
46
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
47
|
if (config.metadata) {
|
|
47
48
|
diag.warn('Metadata cannot be set when using http');
|
|
@@ -49,6 +50,7 @@ var OTLPExporterNodeBase = /** @class */ (function (_super) {
|
|
|
49
50
|
_this.headers = Object.assign(_this.DEFAULT_HEADERS, parseHeaders(config.headers), baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_HEADERS));
|
|
50
51
|
_this.agent = createHttpAgent(config);
|
|
51
52
|
_this.compression = configureCompression(config.compression);
|
|
53
|
+
_this._serializer = serializer;
|
|
52
54
|
return _this;
|
|
53
55
|
}
|
|
54
56
|
OTLPExporterNodeBase.prototype.onInit = function (_config) { };
|
|
@@ -58,9 +60,9 @@ var OTLPExporterNodeBase = /** @class */ (function (_super) {
|
|
|
58
60
|
diag.debug('Shutdown already started. Cannot send objects');
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
|
-
var serviceRequest = this.convert(objects);
|
|
62
63
|
var promise = new Promise(function (resolve, reject) {
|
|
63
|
-
|
|
64
|
+
var _a;
|
|
65
|
+
sendWithHttp(_this, (_a = _this._serializer.serializeRequest(objects)) !== null && _a !== void 0 ? _a : new Uint8Array(), _this._contentType, resolve, reject);
|
|
64
66
|
}).then(onSuccess, onError);
|
|
65
67
|
this._sendingPromises.push(promise);
|
|
66
68
|
var popPromise = function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPExporterNodeBase.js","sourceRoot":"","sources":["../../../../src/platform/node/OTLPExporterNodeBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAKH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"OTLPExporterNodeBase.js","sourceRoot":"","sources":["../../../../src/platform/node/OTLPExporterNodeBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAKH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;GAEG;AACH;IAGU,wCAAwD;IAQhE,8BACE,MAAuC,EACvC,UAAsD,EACtD,WAAmB;QAFnB,uBAAA,EAAA,WAAuC;QADzC,YAKE,kBAAM,MAAM,CAAC,SAcd;QA1BD,qBAAe,GAA2B,EAAE,CAAC;QAa3C,KAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,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AM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;IAED,yCAAU,GAAV,cAAoB,CAAC;IACvB,2BAAC;AAAD,CAAC,AA/DD,CAGU,gBAAgB,GA4DzB","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as http from 'http';\nimport type * as https from 'https';\n\nimport { OTLPExporterBase } from '../../OTLPExporterBase';\nimport { OTLPExporterNodeConfigBase, CompressionAlgorithm } from './types';\nimport * as otlpTypes from '../../types';\nimport { parseHeaders } from '../../util';\nimport { createHttpAgent, sendWithHttp, configureCompression } from './util';\nimport { diag } from '@opentelemetry/api';\nimport { getEnv, baggageUtils } from '@opentelemetry/core';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\n\n/**\n * Collector Metric Exporter abstract base class\n */\nexport abstract class OTLPExporterNodeBase<\n ExportItem,\n ServiceResponse,\n> extends OTLPExporterBase<OTLPExporterNodeConfigBase, ExportItem> {\n DEFAULT_HEADERS: Record<string, string> = {};\n headers: Record<string, string>;\n agent: http.Agent | https.Agent | undefined;\n compression: CompressionAlgorithm;\n private _serializer: ISerializer<ExportItem[], ServiceResponse>;\n private _contentType: string;\n\n constructor(\n config: OTLPExporterNodeConfigBase = {},\n serializer: ISerializer<ExportItem[], ServiceResponse>,\n contentType: string\n ) {\n super(config);\n this._contentType = contentType;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((config as any).metadata) {\n diag.warn('Metadata cannot be set when using http');\n }\n this.headers = Object.assign(\n this.DEFAULT_HEADERS,\n parseHeaders(config.headers),\n baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_HEADERS)\n );\n this.agent = createHttpAgent(config);\n this.compression = configureCompression(config.compression);\n this._serializer = serializer;\n }\n\n onInit(_config: OTLPExporterNodeConfigBase): void {}\n\n send(\n objects: ExportItem[],\n onSuccess: () => void,\n onError: (error: otlpTypes.OTLPExporterError) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n diag.debug('Shutdown already started. Cannot send objects');\n return;\n }\n\n const promise = new Promise<void>((resolve, reject) => {\n sendWithHttp(\n this,\n this._serializer.serializeRequest(objects) ?? new Uint8Array(),\n this._contentType,\n resolve,\n reject\n );\n }).then(onSuccess, onError);\n\n this._sendingPromises.push(promise);\n const popPromise = () => {\n const index = this._sendingPromises.indexOf(promise);\n this._sendingPromises.splice(index, 1);\n };\n promise.then(popPromise, popPromise);\n }\n\n onShutdown(): void {}\n}\n"]}
|
|
@@ -13,7 +13,7 @@ import { OTLPExporterError } from '../../types';
|
|
|
13
13
|
* @param onSuccess
|
|
14
14
|
* @param onError
|
|
15
15
|
*/
|
|
16
|
-
export declare function sendWithHttp<ExportItem,
|
|
16
|
+
export declare function sendWithHttp<ExportItem, ServiceResponse>(collector: OTLPExporterNodeBase<ExportItem, ServiceResponse>, data: string | Uint8Array, contentType: string, onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
17
17
|
export declare function createHttpAgent(config: OTLPExporterNodeConfigBase): http.Agent | https.Agent | undefined;
|
|
18
18
|
export declare function configureCompression(compression: CompressionAlgorithm | undefined): CompressionAlgorithm;
|
|
19
19
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -141,7 +141,7 @@ export function sendWithHttp(collector, data, contentType, onSuccess, onError) {
|
|
|
141
141
|
switch (collector.compression) {
|
|
142
142
|
case CompressionAlgorithm.GZIP: {
|
|
143
143
|
req.setHeader('Content-Encoding', 'gzip');
|
|
144
|
-
var dataStream =
|
|
144
|
+
var dataStream = readableFromUnit8Array(data);
|
|
145
145
|
dataStream
|
|
146
146
|
.on('error', onError)
|
|
147
147
|
.pipe(zlib.createGzip())
|
|
@@ -150,13 +150,13 @@ export function sendWithHttp(collector, data, contentType, onSuccess, onError) {
|
|
|
150
150
|
break;
|
|
151
151
|
}
|
|
152
152
|
default:
|
|
153
|
-
req.end(data);
|
|
153
|
+
req.end(Buffer.from(data));
|
|
154
154
|
break;
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
157
|
sendWithRetry();
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function readableFromUnit8Array(buff) {
|
|
160
160
|
var readable = new Readable();
|
|
161
161
|
readable.push(buff);
|
|
162
162
|
readable.push(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/platform/node/util.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,iCAAiC,EACjC,0BAA0B,EAC1B,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1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,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;QACxE,OAAO,IAAI,KAAK,YAAG,SAAS,EAAE,IAAI,IAAK,MAAM,CAAC,gBAAgB,EAAG,CAAC;KACnE;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,CAAC,KAAK,CACR,0DAAwD,GAAG,CAAC,OAAS,CACtE,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,WAA6C;IAE7C,IAAI,WAAW,EAAE;QACf,OAAO,WAAW,CAAC;KACpB;SAAM;QACL,IAAM,kBAAkB,GACtB,MAAM,EAAE,CAAC,qCAAqC;YAC9C,MAAM,EAAE,CAAC,8BAA8B,CAAC;QAC1C,OAAO,kBAAkB,KAAK,oBAAoB,CAAC,IAAI;YACrD,CAAC,CAAC,oBAAoB,CAAC,IAAI;YAC3B,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC;KAC/B;AACH,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport * as url from 'url';\nimport * as http from 'http';\nimport * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport { OTLPExporterNodeBase } from './OTLPExporterNodeBase';\nimport { OTLPExporterNodeConfigBase } from '.';\nimport { diag } from '@opentelemetry/api';\nimport { CompressionAlgorithm } from './types';\nimport { getEnv } from '@opentelemetry/core';\nimport { OTLPExporterError } from '../../types';\nimport {\n DEFAULT_EXPORT_MAX_ATTEMPTS,\n DEFAULT_EXPORT_INITIAL_BACKOFF,\n DEFAULT_EXPORT_BACKOFF_MULTIPLIER,\n DEFAULT_EXPORT_MAX_BACKOFF,\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../../util';\n\n/**\n * Sends data using http\n * @param collector\n * @param data\n * @param contentType\n * @param onSuccess\n * @param onError\n */\nexport function sendWithHttp<ExportItem, ServiceRequest>(\n collector: OTLPExporterNodeBase<ExportItem, ServiceRequest>,\n data: string | Buffer,\n contentType: string,\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n): void {\n const exporterTimeout = collector.timeoutMillis;\n const parsedUrl = new url.URL(collector.url);\n const nodeVersion = Number(process.versions.node.split('.')[0]);\n let retryTimer: ReturnType<typeof setTimeout>;\n let req: http.ClientRequest;\n let reqIsDestroyed = false;\n\n const exporterTimer = setTimeout(() => {\n clearTimeout(retryTimer);\n reqIsDestroyed = true;\n\n if (req.destroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n } else {\n // req.abort() was deprecated since v14\n nodeVersion >= 14 ? req.destroy() : req.abort();\n }\n }, exporterTimeout);\n\n const options: http.RequestOptions | https.RequestOptions = {\n hostname: parsedUrl.hostname,\n port: parsedUrl.port,\n path: parsedUrl.pathname,\n method: 'POST',\n headers: {\n 'Content-Type': contentType,\n ...collector.headers,\n },\n agent: collector.agent,\n };\n\n const request = parsedUrl.protocol === 'http:' ? http.request : https.request;\n\n const sendWithRetry = (\n retries = DEFAULT_EXPORT_MAX_ATTEMPTS,\n minDelay = DEFAULT_EXPORT_INITIAL_BACKOFF\n ) => {\n req = request(options, (res: http.IncomingMessage) => {\n let responseData = '';\n res.on('data', chunk => (responseData += chunk));\n\n res.on('aborted', () => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n }\n });\n\n res.on('end', () => {\n if (reqIsDestroyed === false) {\n if (res.statusCode && res.statusCode < 299) {\n diag.debug(`statusCode: ${res.statusCode}`, responseData);\n onSuccess();\n // clear all timers since request was completed and promise was resolved\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n } else if (\n res.statusCode &&\n isExportRetryable(res.statusCode) &&\n retries > 0\n ) {\n let retryTime: number;\n minDelay = DEFAULT_EXPORT_BACKOFF_MULTIPLIER * minDelay;\n\n // retry after interval specified in Retry-After header\n if (res.headers['retry-after']) {\n retryTime = parseRetryAfterToMills(res.headers['retry-after']!);\n } else {\n // exponential backoff with jitter\n retryTime = Math.round(\n Math.random() * (DEFAULT_EXPORT_MAX_BACKOFF - minDelay) +\n minDelay\n );\n }\n\n retryTimer = setTimeout(() => {\n sendWithRetry(retries - 1, minDelay);\n }, retryTime);\n } else {\n const error = new OTLPExporterError(\n res.statusMessage,\n res.statusCode,\n responseData\n );\n onError(error);\n // clear all timers since request was completed and promise was resolved\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n }\n }\n });\n });\n\n req.on('error', (error: Error | any) => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout', error.code);\n onError(err);\n } else {\n onError(error);\n }\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n });\n\n req.on('abort', () => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n }\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n });\n\n switch (collector.compression) {\n case CompressionAlgorithm.GZIP: {\n req.setHeader('Content-Encoding', 'gzip');\n const dataStream = readableFromBuffer(data);\n dataStream\n .on('error', onError)\n .pipe(zlib.createGzip())\n .on('error', onError)\n .pipe(req);\n\n break;\n }\n default:\n req.end(data);\n break;\n }\n };\n sendWithRetry();\n}\n\nfunction readableFromBuffer(buff: string | Buffer): Readable {\n const readable = new Readable();\n readable.push(buff);\n readable.push(null);\n\n return readable;\n}\n\nexport function createHttpAgent(\n config: OTLPExporterNodeConfigBase\n): http.Agent | https.Agent | undefined {\n if (config.httpAgentOptions && config.keepAlive === false) {\n diag.warn('httpAgentOptions is used only when keepAlive is true');\n return undefined;\n }\n\n if (config.keepAlive === false || !config.url) return undefined;\n\n try {\n const parsedUrl = new url.URL(config.url as string);\n const Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent;\n return new Agent({ keepAlive: true, ...config.httpAgentOptions });\n } catch (err) {\n diag.error(\n `collector exporter failed to create http agent. err: ${err.message}`\n );\n return undefined;\n }\n}\n\nexport function configureCompression(\n compression: CompressionAlgorithm | undefined\n): CompressionAlgorithm {\n if (compression) {\n return compression;\n } else {\n const definedCompression =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION ||\n getEnv().OTEL_EXPORTER_OTLP_COMPRESSION;\n return definedCompression === CompressionAlgorithm.GZIP\n ? CompressionAlgorithm.GZIP\n : CompressionAlgorithm.NONE;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/platform/node/util.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,iCAAiC,EACjC,0BAA0B,EAC1B,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,SAA4D,EAC5D,IAAyB,EACzB,WAAmB,EACnB,SAAqB,EACrB,OAA2C;I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C,KAAK,CAAC;QACxE,OAAO,IAAI,KAAK,YAAG,SAAS,EAAE,IAAI,IAAK,MAAM,CAAC,gBAAgB,EAAG,CAAC;KACnE;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,CAAC,KAAK,CACR,0DAAwD,GAAG,CAAC,OAAS,CACtE,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,WAA6C;IAE7C,IAAI,WAAW,EAAE;QACf,OAAO,WAAW,CAAC;KACpB;SAAM;QACL,IAAM,kBAAkB,GACtB,MAAM,EAAE,CAAC,qCAAqC;YAC9C,MAAM,EAAE,CAAC,8BAA8B,CAAC;QAC1C,OAAO,kBAAkB,KAAK,oBAAoB,CAAC,IAAI;YACrD,CAAC,CAAC,oBAAoB,CAAC,IAAI;YAC3B,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC;KAC/B;AACH,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport * as url from 'url';\nimport * as http from 'http';\nimport * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport { OTLPExporterNodeBase } from './OTLPExporterNodeBase';\nimport { OTLPExporterNodeConfigBase } from '.';\nimport { diag } from '@opentelemetry/api';\nimport { CompressionAlgorithm } from './types';\nimport { getEnv } from '@opentelemetry/core';\nimport { OTLPExporterError } from '../../types';\nimport {\n DEFAULT_EXPORT_MAX_ATTEMPTS,\n DEFAULT_EXPORT_INITIAL_BACKOFF,\n DEFAULT_EXPORT_BACKOFF_MULTIPLIER,\n DEFAULT_EXPORT_MAX_BACKOFF,\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../../util';\n\n/**\n * Sends data using http\n * @param collector\n * @param data\n * @param contentType\n * @param onSuccess\n * @param onError\n */\nexport function sendWithHttp<ExportItem, ServiceResponse>(\n collector: OTLPExporterNodeBase<ExportItem, ServiceResponse>,\n data: string | Uint8Array,\n contentType: string,\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n): void {\n const exporterTimeout = collector.timeoutMillis;\n const parsedUrl = new url.URL(collector.url);\n const nodeVersion = Number(process.versions.node.split('.')[0]);\n let retryTimer: ReturnType<typeof setTimeout>;\n let req: http.ClientRequest;\n let reqIsDestroyed = false;\n\n const exporterTimer = setTimeout(() => {\n clearTimeout(retryTimer);\n reqIsDestroyed = true;\n\n if (req.destroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n } else {\n // req.abort() was deprecated since v14\n nodeVersion >= 14 ? req.destroy() : req.abort();\n }\n }, exporterTimeout);\n\n const options: http.RequestOptions | https.RequestOptions = {\n hostname: parsedUrl.hostname,\n port: parsedUrl.port,\n path: parsedUrl.pathname,\n method: 'POST',\n headers: {\n 'Content-Type': contentType,\n ...collector.headers,\n },\n agent: collector.agent,\n };\n\n const request = parsedUrl.protocol === 'http:' ? http.request : https.request;\n\n const sendWithRetry = (\n retries = DEFAULT_EXPORT_MAX_ATTEMPTS,\n minDelay = DEFAULT_EXPORT_INITIAL_BACKOFF\n ) => {\n req = request(options, (res: http.IncomingMessage) => {\n let responseData = '';\n res.on('data', chunk => (responseData += chunk));\n\n res.on('aborted', () => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n }\n });\n\n res.on('end', () => {\n if (reqIsDestroyed === false) {\n if (res.statusCode && res.statusCode < 299) {\n diag.debug(`statusCode: ${res.statusCode}`, responseData);\n onSuccess();\n // clear all timers since request was completed and promise was resolved\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n } else if (\n res.statusCode &&\n isExportRetryable(res.statusCode) &&\n retries > 0\n ) {\n let retryTime: number;\n minDelay = DEFAULT_EXPORT_BACKOFF_MULTIPLIER * minDelay;\n\n // retry after interval specified in Retry-After header\n if (res.headers['retry-after']) {\n retryTime = parseRetryAfterToMills(res.headers['retry-after']!);\n } else {\n // exponential backoff with jitter\n retryTime = Math.round(\n Math.random() * (DEFAULT_EXPORT_MAX_BACKOFF - minDelay) +\n minDelay\n );\n }\n\n retryTimer = setTimeout(() => {\n sendWithRetry(retries - 1, minDelay);\n }, retryTime);\n } else {\n const error = new OTLPExporterError(\n res.statusMessage,\n res.statusCode,\n responseData\n );\n onError(error);\n // clear all timers since request was completed and promise was resolved\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n }\n }\n });\n });\n\n req.on('error', (error: Error | any) => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout', error.code);\n onError(err);\n } else {\n onError(error);\n }\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n });\n\n req.on('abort', () => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n }\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n });\n\n switch (collector.compression) {\n case CompressionAlgorithm.GZIP: {\n req.setHeader('Content-Encoding', 'gzip');\n const dataStream = readableFromUnit8Array(data);\n dataStream\n .on('error', onError)\n .pipe(zlib.createGzip())\n .on('error', onError)\n .pipe(req);\n\n break;\n }\n default:\n req.end(Buffer.from(data));\n break;\n }\n };\n sendWithRetry();\n}\n\nfunction readableFromUnit8Array(buff: string | Uint8Array): Readable {\n const readable = new Readable();\n readable.push(buff);\n readable.push(null);\n\n return readable;\n}\n\nexport function createHttpAgent(\n config: OTLPExporterNodeConfigBase\n): http.Agent | https.Agent | undefined {\n if (config.httpAgentOptions && config.keepAlive === false) {\n diag.warn('httpAgentOptions is used only when keepAlive is true');\n return undefined;\n }\n\n if (config.keepAlive === false || !config.url) return undefined;\n\n try {\n const parsedUrl = new url.URL(config.url as string);\n const Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent;\n return new Agent({ keepAlive: true, ...config.httpAgentOptions });\n } catch (err) {\n diag.error(\n `collector exporter failed to create http agent. err: ${err.message}`\n );\n return undefined;\n }\n}\n\nexport function configureCompression(\n compression: CompressionAlgorithm | undefined\n): CompressionAlgorithm {\n if (compression) {\n return compression;\n } else {\n const definedCompression =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION ||\n getEnv().OTEL_EXPORTER_OTLP_COMPRESSION;\n return definedCompression === CompressionAlgorithm.GZIP\n ? CompressionAlgorithm.GZIP\n : CompressionAlgorithm.NONE;\n }\n}\n"]}
|
package/build/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.52.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/esm/version.js
CHANGED
package/build/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.52.0';\n"]}
|
|
@@ -3,7 +3,7 @@ import { OTLPExporterError, OTLPExporterConfigBase } from './types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Collector Exporter abstract base class
|
|
5
5
|
*/
|
|
6
|
-
export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase, ExportItem
|
|
6
|
+
export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase, ExportItem> {
|
|
7
7
|
readonly url: string;
|
|
8
8
|
readonly hostname: string | undefined;
|
|
9
9
|
readonly timeoutMillis: number;
|
|
@@ -37,6 +37,5 @@ export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase,
|
|
|
37
37
|
abstract onInit(config: T): void;
|
|
38
38
|
abstract send(items: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
39
39
|
abstract getDefaultUrl(config: T): string;
|
|
40
|
-
abstract convert(objects: ExportItem[]): ServiceRequest;
|
|
41
40
|
}
|
|
42
41
|
//# sourceMappingURL=OTLPExporterBase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAA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,UAAU;QACR,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAClD,6BAA6B;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,SAAS;QACf,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC/B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;CAUF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { diag } from '@opentelemetry/api';\nimport {\n ExportResult,\n ExportResultCode,\n BindOnceFuture,\n} from '@opentelemetry/core';\nimport {\n OTLPExporterError,\n OTLPExporterConfigBase,\n ExportServiceError,\n} from './types';\nimport { configureExporterTimeout } from './util';\n\n/**\n * Collector Exporter abstract base class\n */\nexport abstract class OTLPExporterBase<\n T extends OTLPExporterConfigBase,\n ExportItem,\n> {\n public readonly url: string;\n public readonly hostname: string | undefined;\n public readonly timeoutMillis: number;\n protected _concurrencyLimit: number;\n protected _sendingPromises: Promise<unknown>[] = [];\n protected _shutdownOnce: BindOnceFuture<void>;\n\n /**\n * @param config\n */\n constructor(config: T = {} as T) {\n this.url = this.getDefaultUrl(config);\n if (typeof config.hostname === 'string') {\n this.hostname = config.hostname;\n }\n\n this.shutdown = this.shutdown.bind(this);\n this._shutdownOnce = new BindOnceFuture(this._shutdown, this);\n\n this._concurrencyLimit =\n typeof config.concurrencyLimit === 'number'\n ? config.concurrencyLimit\n : 30;\n\n this.timeoutMillis = configureExporterTimeout(config.timeoutMillis);\n\n // platform dependent\n this.onInit(config);\n }\n\n /**\n * Export items.\n * @param items\n * @param resultCallback\n */\n export(\n items: ExportItem[],\n resultCallback: (result: ExportResult) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Exporter has been shutdown'),\n });\n return;\n }\n\n if (this._sendingPromises.length >= this._concurrencyLimit) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Concurrent export limit reached'),\n });\n return;\n }\n\n this._export(items)\n .then(() => {\n resultCallback({ code: ExportResultCode.SUCCESS });\n })\n .catch((error: ExportServiceError) => {\n resultCallback({ code: ExportResultCode.FAILED, error });\n });\n }\n\n private _export(items: ExportItem[]): Promise<unknown> {\n return new Promise<void>((resolve, reject) => {\n try {\n diag.debug('items to be sent', items);\n this.send(items, resolve, reject);\n } catch (e) {\n reject(e);\n }\n });\n }\n\n /**\n * Shutdown the exporter.\n */\n shutdown(): Promise<void> {\n return this._shutdownOnce.call();\n }\n\n /**\n * Exports any pending spans in the exporter\n */\n forceFlush(): Promise<void> {\n return Promise.all(this._sendingPromises).then(() => {\n /** ignore resolved values */\n });\n }\n\n /**\n * Called by _shutdownOnce with BindOnceFuture\n */\n private _shutdown(): Promise<void> {\n diag.debug('shutdown started');\n this.onShutdown();\n return this.forceFlush();\n }\n\n abstract onShutdown(): void;\n abstract onInit(config: T): void;\n abstract send(\n items: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void;\n abstract getDefaultUrl(config: T): string;\n}\n"]}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
2
2
|
import { OTLPExporterConfigBase } from '../../types';
|
|
3
3
|
import * as otlpTypes from '../../types';
|
|
4
|
+
import { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
4
5
|
/**
|
|
5
6
|
* Collector Metric Exporter abstract base class
|
|
6
7
|
*/
|
|
7
|
-
export declare abstract class OTLPExporterBrowserBase<ExportItem,
|
|
8
|
+
export declare abstract class OTLPExporterBrowserBase<ExportItem, ServiceResponse> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem> {
|
|
8
9
|
protected _headers: Record<string, string>;
|
|
9
10
|
private _useXHR;
|
|
11
|
+
private _contentType;
|
|
12
|
+
private _serializer;
|
|
10
13
|
/**
|
|
11
14
|
* @param config
|
|
15
|
+
* @param serializer
|
|
16
|
+
* @param contentType
|
|
12
17
|
*/
|
|
13
|
-
constructor(config
|
|
18
|
+
constructor(config: OTLPExporterConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, contentType: string);
|
|
14
19
|
onInit(): void;
|
|
15
20
|
onShutdown(): void;
|
|
16
21
|
send(items: ExportItem[], onSuccess: () => void, onError: (error: otlpTypes.OTLPExporterError) => void): void;
|
|
@@ -24,10 +24,14 @@ import { getEnv, baggageUtils } from '@opentelemetry/core';
|
|
|
24
24
|
export class OTLPExporterBrowserBase extends OTLPExporterBase {
|
|
25
25
|
/**
|
|
26
26
|
* @param config
|
|
27
|
+
* @param serializer
|
|
28
|
+
* @param contentType
|
|
27
29
|
*/
|
|
28
|
-
constructor(config = {}) {
|
|
30
|
+
constructor(config = {}, serializer, contentType) {
|
|
29
31
|
super(config);
|
|
30
32
|
this._useXHR = false;
|
|
33
|
+
this._serializer = serializer;
|
|
34
|
+
this._contentType = contentType;
|
|
31
35
|
this._useXHR =
|
|
32
36
|
!!config.headers || typeof navigator.sendBeacon !== 'function';
|
|
33
37
|
if (this._useXHR) {
|
|
@@ -40,18 +44,18 @@ export class OTLPExporterBrowserBase extends OTLPExporterBase {
|
|
|
40
44
|
onInit() { }
|
|
41
45
|
onShutdown() { }
|
|
42
46
|
send(items, onSuccess, onError) {
|
|
47
|
+
var _a;
|
|
43
48
|
if (this._shutdownOnce.isCalled) {
|
|
44
49
|
diag.debug('Shutdown already started. Cannot send objects');
|
|
45
50
|
return;
|
|
46
51
|
}
|
|
47
|
-
const
|
|
48
|
-
const body = JSON.stringify(serviceRequest);
|
|
52
|
+
const body = (_a = this._serializer.serializeRequest(items)) !== null && _a !== void 0 ? _a : new Uint8Array();
|
|
49
53
|
const promise = new Promise((resolve, reject) => {
|
|
50
54
|
if (this._useXHR) {
|
|
51
|
-
sendWithXhr(body, this.url, this._headers, this.timeoutMillis, resolve, reject);
|
|
55
|
+
sendWithXhr(body, this.url, Object.assign(Object.assign({}, this._headers), { 'Content-Type': this._contentType }), this.timeoutMillis, resolve, reject);
|
|
52
56
|
}
|
|
53
57
|
else {
|
|
54
|
-
sendWithBeacon(body, this.url, { type:
|
|
58
|
+
sendWithBeacon(body, this.url, { type: this._contentType }, resolve, reject);
|
|
55
59
|
}
|
|
56
60
|
}).then(onSuccess, onError);
|
|
57
61
|
this._sendingPromises.push(promise);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPExporterBrowserBase.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPExporterBrowserBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"OTLPExporterBrowserBase.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPExporterBrowserBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,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AAE;YACpD,IAAI,IAAI,CAAC,OAAO,EAAE;gBAChB,WAAW,CACT,IAAI,EACJ,IAAI,CAAC,GAAG,kCAEH,IAAI,CAAC,QAAQ,KAChB,cAAc,EAAE,IAAI,CAAC,YAAY,KAEnC,IAAI,CAAC,aAAa,EAClB,OAAO,EACP,MAAM,CACP,CAAC;aACH;iBAAM;gBACL,cAAc,CACZ,IAAI,EACJ,IAAI,CAAC,GAAG,EACR,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,EAC3B,OAAO,EACP,MAAM,CACP,CAAC;aACH;QACH,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE5B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,GAAG,EAAE;YACtB,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACrD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OTLPExporterBase } from '../../OTLPExporterBase';\nimport { OTLPExporterConfigBase } from '../../types';\nimport * as otlpTypes from '../../types';\nimport { parseHeaders } from '../../util';\nimport { sendWithBeacon, sendWithXhr } from './util';\nimport { diag } from '@opentelemetry/api';\nimport { getEnv, baggageUtils } from '@opentelemetry/core';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\n\n/**\n * Collector Metric Exporter abstract base class\n */\nexport abstract class OTLPExporterBrowserBase<\n ExportItem,\n ServiceResponse,\n> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem> {\n protected _headers: Record<string, string>;\n private _useXHR: boolean = false;\n private _contentType: string;\n private _serializer: ISerializer<ExportItem[], ServiceResponse>;\n\n /**\n * @param config\n * @param serializer\n * @param contentType\n */\n constructor(\n config: OTLPExporterConfigBase = {},\n serializer: ISerializer<ExportItem[], ServiceResponse>,\n contentType: string\n ) {\n super(config);\n this._serializer = serializer;\n this._contentType = contentType;\n this._useXHR =\n !!config.headers || typeof navigator.sendBeacon !== 'function';\n if (this._useXHR) {\n this._headers = Object.assign(\n {},\n parseHeaders(config.headers),\n baggageUtils.parseKeyPairsIntoRecord(\n getEnv().OTEL_EXPORTER_OTLP_HEADERS\n )\n );\n } else {\n this._headers = {};\n }\n }\n\n onInit(): void {}\n\n onShutdown(): void {}\n\n send(\n items: ExportItem[],\n onSuccess: () => void,\n onError: (error: otlpTypes.OTLPExporterError) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n diag.debug('Shutdown already started. Cannot send objects');\n return;\n }\n const body = this._serializer.serializeRequest(items) ?? new Uint8Array();\n\n const promise = new Promise<void>((resolve, reject) => {\n if (this._useXHR) {\n sendWithXhr(\n body,\n this.url,\n {\n ...this._headers,\n 'Content-Type': this._contentType,\n },\n this.timeoutMillis,\n resolve,\n reject\n );\n } else {\n sendWithBeacon(\n body,\n this.url,\n { type: this._contentType },\n resolve,\n reject\n );\n }\n }).then(onSuccess, onError);\n\n this._sendingPromises.push(promise);\n const popPromise = () => {\n const index = this._sendingPromises.indexOf(promise);\n this._sendingPromises.splice(index, 1);\n };\n promise.then(popPromise, popPromise);\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { OTLPExporterError } from '../../types';
|
|
|
7
7
|
* @param onSuccess
|
|
8
8
|
* @param onError
|
|
9
9
|
*/
|
|
10
|
-
export declare function sendWithBeacon(body:
|
|
10
|
+
export declare function sendWithBeacon(body: Uint8Array, url: string, blobPropertyBag: BlobPropertyBag, onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
11
11
|
/**
|
|
12
12
|
* function to send metrics/spans using browser XMLHttpRequest
|
|
13
13
|
* used when navigator.sendBeacon is not available
|
|
@@ -17,5 +17,5 @@ export declare function sendWithBeacon(body: string, url: string, blobPropertyBa
|
|
|
17
17
|
* @param onSuccess
|
|
18
18
|
* @param onError
|
|
19
19
|
*/
|
|
20
|
-
export declare function sendWithXhr(body:
|
|
20
|
+
export declare function sendWithXhr(body: Uint8Array, url: string, headers: Record<string, string>, exporterTimeout: number, onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
21
21
|
//# sourceMappingURL=util.d.ts.map
|