@opentelemetry/otlp-exporter-base 0.52.1 → 0.54.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 +0 -5
- package/build/esm/OTLPExporterBase.js +0 -8
- package/build/esm/OTLPExporterBase.js.map +1 -1
- package/build/esm/configuration/otlp-http-configuration.d.ts +13 -0
- package/build/esm/configuration/otlp-http-configuration.js +67 -0
- package/build/esm/configuration/otlp-http-configuration.js.map +1 -0
- package/build/esm/configuration/otlp-http-env-configuration.d.ts +9 -0
- package/build/esm/configuration/otlp-http-env-configuration.js +104 -0
- package/build/esm/configuration/otlp-http-env-configuration.js.map +1 -0
- package/build/esm/configuration/shared-configuration.d.ts +22 -0
- package/build/esm/configuration/shared-configuration.js +44 -0
- package/build/esm/configuration/shared-configuration.js.map +1 -0
- package/build/esm/configuration/shared-env-configuration.d.ts +3 -0
- package/build/esm/configuration/shared-env-configuration.js +44 -0
- package/build/esm/configuration/shared-env-configuration.js.map +1 -0
- package/build/esm/export-response.d.ts +14 -0
- package/build/esm/export-response.js +17 -0
- package/build/esm/export-response.js.map +1 -0
- package/build/esm/exporter-transport.d.ts +6 -0
- package/build/esm/exporter-transport.js +17 -0
- package/build/esm/exporter-transport.js.map +1 -0
- package/build/esm/index.d.ts +5 -1
- package/build/esm/index.js +6 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/is-export-retryable.d.ts +3 -0
- package/build/esm/is-export-retryable.js +35 -0
- package/build/esm/is-export-retryable.js.map +1 -0
- package/build/esm/platform/browser/OTLPExporterBrowserBase.d.ts +7 -9
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js +49 -32
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/esm/platform/browser/index.d.ts +0 -1
- package/build/esm/platform/browser/index.js +0 -1
- package/build/esm/platform/browser/index.js.map +1 -1
- package/build/esm/platform/browser/send-beacon-transport.d.ts +10 -0
- package/build/esm/platform/browser/send-beacon-transport.js +47 -0
- package/build/esm/platform/browser/send-beacon-transport.js.map +1 -0
- package/build/esm/platform/browser/xhr-transport.d.ts +11 -0
- package/build/esm/platform/browser/xhr-transport.js +101 -0
- package/build/esm/platform/browser/xhr-transport.js.map +1 -0
- package/build/esm/platform/index.d.ts +2 -2
- package/build/esm/platform/index.js +2 -2
- package/build/esm/platform/index.js.map +1 -1
- package/build/esm/platform/node/OTLPExporterNodeBase.d.ts +6 -13
- package/build/esm/platform/node/OTLPExporterNodeBase.js +45 -14
- package/build/esm/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/esm/platform/node/convert-legacy-agent-options.d.ts +12 -0
- package/build/esm/platform/node/convert-legacy-agent-options.js +27 -0
- package/build/esm/platform/node/convert-legacy-agent-options.js.map +1 -0
- package/build/esm/platform/node/http-exporter-transport.d.ts +4 -0
- package/build/esm/platform/node/http-exporter-transport.js +87 -0
- package/build/esm/platform/node/http-exporter-transport.js.map +1 -0
- package/build/esm/platform/node/http-transport-types.d.ts +12 -0
- package/build/esm/platform/node/http-transport-types.js +17 -0
- package/build/esm/platform/node/http-transport-types.js.map +1 -0
- package/build/esm/platform/node/http-transport-utils.d.ts +16 -0
- package/build/esm/platform/node/http-transport-utils.js +127 -0
- package/build/esm/platform/node/http-transport-utils.js.map +1 -0
- package/build/esm/platform/node/index.d.ts +0 -1
- package/build/esm/platform/node/index.js +0 -1
- package/build/esm/platform/node/index.js.map +1 -1
- package/build/esm/retrying-transport.d.ts +8 -0
- package/build/esm/retrying-transport.js +119 -0
- package/build/esm/retrying-transport.js.map +1 -0
- package/build/esm/types.d.ts +1 -2
- package/build/esm/types.js.map +1 -1
- package/build/esm/util.d.ts +1 -27
- package/build/esm/util.js +1 -89
- package/build/esm/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 +0 -5
- package/build/esnext/OTLPExporterBase.js +0 -8
- package/build/esnext/OTLPExporterBase.js.map +1 -1
- package/build/esnext/configuration/otlp-http-configuration.d.ts +13 -0
- package/build/esnext/configuration/otlp-http-configuration.js +56 -0
- package/build/esnext/configuration/otlp-http-configuration.js.map +1 -0
- package/build/esnext/configuration/otlp-http-env-configuration.d.ts +9 -0
- package/build/esnext/configuration/otlp-http-env-configuration.js +93 -0
- package/build/esnext/configuration/otlp-http-env-configuration.js.map +1 -0
- package/build/esnext/configuration/shared-configuration.d.ts +22 -0
- package/build/esnext/configuration/shared-configuration.js +44 -0
- package/build/esnext/configuration/shared-configuration.js.map +1 -0
- package/build/esnext/configuration/shared-env-configuration.d.ts +3 -0
- package/build/esnext/configuration/shared-env-configuration.js +44 -0
- package/build/esnext/configuration/shared-env-configuration.js.map +1 -0
- package/build/esnext/export-response.d.ts +14 -0
- package/build/esnext/export-response.js +17 -0
- package/build/esnext/export-response.js.map +1 -0
- package/build/esnext/exporter-transport.d.ts +6 -0
- package/build/esnext/exporter-transport.js +17 -0
- package/build/esnext/exporter-transport.js.map +1 -0
- package/build/esnext/index.d.ts +5 -1
- package/build/esnext/index.js +6 -1
- package/build/esnext/index.js.map +1 -1
- package/build/esnext/is-export-retryable.d.ts +3 -0
- package/build/esnext/is-export-retryable.js +35 -0
- package/build/esnext/is-export-retryable.js.map +1 -0
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.d.ts +7 -9
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.js +49 -21
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/esnext/platform/browser/index.d.ts +0 -1
- package/build/esnext/platform/browser/index.js +0 -1
- package/build/esnext/platform/browser/index.js.map +1 -1
- package/build/esnext/platform/browser/send-beacon-transport.d.ts +10 -0
- package/build/esnext/platform/browser/send-beacon-transport.js +45 -0
- package/build/esnext/platform/browser/send-beacon-transport.js.map +1 -0
- package/build/esnext/platform/browser/xhr-transport.d.ts +11 -0
- package/build/esnext/platform/browser/xhr-transport.js +82 -0
- package/build/esnext/platform/browser/xhr-transport.js.map +1 -0
- package/build/esnext/platform/index.d.ts +2 -2
- package/build/esnext/platform/index.js +2 -2
- package/build/esnext/platform/index.js.map +1 -1
- package/build/esnext/platform/node/OTLPExporterNodeBase.d.ts +6 -13
- package/build/esnext/platform/node/OTLPExporterNodeBase.js +45 -14
- package/build/esnext/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/esnext/platform/node/convert-legacy-agent-options.d.ts +12 -0
- package/build/esnext/platform/node/convert-legacy-agent-options.js +27 -0
- package/build/esnext/platform/node/convert-legacy-agent-options.js.map +1 -0
- package/build/esnext/platform/node/http-exporter-transport.d.ts +4 -0
- package/build/esnext/platform/node/http-exporter-transport.js +47 -0
- package/build/esnext/platform/node/http-exporter-transport.js.map +1 -0
- package/build/esnext/platform/node/http-transport-types.d.ts +12 -0
- package/build/esnext/platform/node/http-transport-types.js +17 -0
- package/build/esnext/platform/node/http-transport-types.js.map +1 -0
- package/build/esnext/platform/node/http-transport-utils.d.ts +16 -0
- package/build/esnext/platform/node/http-transport-utils.js +116 -0
- package/build/esnext/platform/node/http-transport-utils.js.map +1 -0
- package/build/esnext/platform/node/index.d.ts +0 -1
- package/build/esnext/platform/node/index.js +0 -1
- package/build/esnext/platform/node/index.js.map +1 -1
- package/build/esnext/retrying-transport.d.ts +8 -0
- package/build/esnext/retrying-transport.js +69 -0
- package/build/esnext/retrying-transport.js.map +1 -0
- package/build/esnext/types.d.ts +1 -2
- package/build/esnext/types.js.map +1 -1
- package/build/esnext/util.d.ts +1 -27
- package/build/esnext/util.js +1 -89
- package/build/esnext/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 +0 -5
- package/build/src/OTLPExporterBase.js +0 -8
- package/build/src/OTLPExporterBase.js.map +1 -1
- package/build/src/configuration/otlp-http-configuration.d.ts +13 -0
- package/build/src/configuration/otlp-http-configuration.js +61 -0
- package/build/src/configuration/otlp-http-configuration.js.map +1 -0
- package/build/src/configuration/otlp-http-env-configuration.d.ts +9 -0
- package/build/src/configuration/otlp-http-env-configuration.js +97 -0
- package/build/src/configuration/otlp-http-env-configuration.js.map +1 -0
- package/build/src/configuration/shared-configuration.d.ts +22 -0
- package/build/src/configuration/shared-configuration.js +50 -0
- package/build/src/configuration/shared-configuration.js.map +1 -0
- package/build/src/configuration/shared-env-configuration.d.ts +3 -0
- package/build/src/configuration/shared-env-configuration.js +48 -0
- package/build/src/configuration/shared-env-configuration.js.map +1 -0
- package/build/src/export-response.d.ts +14 -0
- package/build/src/export-response.js +18 -0
- package/build/src/export-response.js.map +1 -0
- package/build/src/exporter-transport.d.ts +6 -0
- package/build/src/exporter-transport.js +18 -0
- package/build/src/exporter-transport.js.map +1 -0
- package/build/src/index.d.ts +5 -1
- package/build/src/index.js +21 -17
- package/build/src/index.js.map +1 -1
- package/build/src/is-export-retryable.d.ts +3 -0
- package/build/src/is-export-retryable.js +40 -0
- package/build/src/is-export-retryable.js.map +1 -0
- package/build/src/platform/browser/OTLPExporterBrowserBase.d.ts +7 -9
- package/build/src/platform/browser/OTLPExporterBrowserBase.js +49 -21
- package/build/src/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/src/platform/browser/index.d.ts +0 -1
- package/build/src/platform/browser/index.js +1 -3
- package/build/src/platform/browser/index.js.map +1 -1
- package/build/src/platform/browser/send-beacon-transport.d.ts +10 -0
- package/build/src/platform/browser/send-beacon-transport.js +49 -0
- package/build/src/platform/browser/send-beacon-transport.js.map +1 -0
- package/build/src/platform/browser/xhr-transport.d.ts +11 -0
- package/build/src/platform/browser/xhr-transport.js +86 -0
- package/build/src/platform/browser/xhr-transport.js.map +1 -0
- package/build/src/platform/index.d.ts +2 -2
- package/build/src/platform/index.js +1 -5
- package/build/src/platform/index.js.map +1 -1
- package/build/src/platform/node/OTLPExporterNodeBase.d.ts +6 -13
- package/build/src/platform/node/OTLPExporterNodeBase.js +45 -14
- package/build/src/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/src/platform/node/convert-legacy-agent-options.d.ts +12 -0
- package/build/src/platform/node/convert-legacy-agent-options.js +31 -0
- package/build/src/platform/node/convert-legacy-agent-options.js.map +1 -0
- package/build/src/platform/node/http-exporter-transport.d.ts +4 -0
- package/build/src/platform/node/http-exporter-transport.js +51 -0
- package/build/src/platform/node/http-exporter-transport.js.map +1 -0
- package/build/src/platform/node/http-transport-types.d.ts +12 -0
- package/build/src/platform/node/http-transport-types.js +18 -0
- package/build/src/platform/node/http-transport-types.js.map +1 -0
- package/build/src/platform/node/http-transport-utils.d.ts +16 -0
- package/build/src/platform/node/http-transport-utils.js +121 -0
- package/build/src/platform/node/http-transport-utils.js.map +1 -0
- package/build/src/platform/node/index.d.ts +0 -1
- package/build/src/platform/node/index.js +1 -5
- package/build/src/platform/node/index.js.map +1 -1
- package/build/src/retrying-transport.d.ts +8 -0
- package/build/src/retrying-transport.js +73 -0
- package/build/src/retrying-transport.js.map +1 -0
- package/build/src/types.d.ts +1 -2
- package/build/src/types.js.map +1 -1
- package/build/src/util.d.ts +1 -27
- package/build/src/util.js +3 -97
- package/build/src/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 -17
- package/build/esm/platform/browser/util.d.ts +0 -21
- package/build/esm/platform/browser/util.js +0 -152
- package/build/esm/platform/browser/util.js.map +0 -1
- package/build/esm/platform/node/util.d.ts +0 -19
- package/build/esm/platform/node/util.js +0 -194
- package/build/esm/platform/node/util.js.map +0 -1
- package/build/esnext/platform/browser/util.d.ts +0 -21
- package/build/esnext/platform/browser/util.js +0 -122
- package/build/esnext/platform/browser/util.js.map +0 -1
- package/build/esnext/platform/node/util.d.ts +0 -19
- package/build/esnext/platform/node/util.js +0 -181
- package/build/esnext/platform/node/util.js.map +0 -1
- package/build/src/platform/browser/util.d.ts +0 -21
- package/build/src/platform/browser/util.js +0 -127
- package/build/src/platform/browser/util.js.map +0 -1
- package/build/src/platform/node/util.d.ts +0 -19
- package/build/src/platform/node/util.js +0 -187
- package/build/src/platform/node/util.js.map +0 -1
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
2
|
-
import { OTLPExporterConfigBase } from '../../types';
|
|
3
|
-
import * as otlpTypes from '../../types';
|
|
2
|
+
import { OTLPExporterConfigBase, OTLPExporterError } from '../../types';
|
|
4
3
|
import { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
5
4
|
/**
|
|
6
5
|
* Collector Metric Exporter abstract base class
|
|
7
6
|
*/
|
|
8
7
|
export declare abstract class OTLPExporterBrowserBase<ExportItem, ServiceResponse> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem> {
|
|
9
|
-
protected _headers: Record<string, string>;
|
|
10
|
-
private _useXHR;
|
|
11
|
-
private _contentType;
|
|
12
8
|
private _serializer;
|
|
9
|
+
private _transport;
|
|
10
|
+
private _timeoutMillis;
|
|
13
11
|
/**
|
|
14
12
|
* @param config
|
|
15
13
|
* @param serializer
|
|
16
|
-
* @param
|
|
14
|
+
* @param requiredHeaders
|
|
15
|
+
* @param signalResourcePath
|
|
17
16
|
*/
|
|
18
|
-
constructor(config: OTLPExporterConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>,
|
|
19
|
-
onInit(): void;
|
|
17
|
+
constructor(config: OTLPExporterConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, requiredHeaders: Record<string, string>, signalResourcePath: string);
|
|
20
18
|
onShutdown(): void;
|
|
21
|
-
send(
|
|
19
|
+
send(objects: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
22
20
|
}
|
|
23
21
|
//# sourceMappingURL=OTLPExporterBrowserBase.d.ts.map
|
|
@@ -28,22 +28,13 @@ 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
|
-
};
|
|
42
31
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
43
|
-
import {
|
|
44
|
-
import { sendWithBeacon, sendWithXhr } from './util';
|
|
32
|
+
import { OTLPExporterError } from '../../types';
|
|
45
33
|
import { diag } from '@opentelemetry/api';
|
|
46
|
-
import {
|
|
34
|
+
import { createXhrTransport } from './xhr-transport';
|
|
35
|
+
import { createSendBeaconTransport } from './send-beacon-transport';
|
|
36
|
+
import { createRetryingTransport } from '../../retrying-transport';
|
|
37
|
+
import { getHttpConfigurationDefaults, mergeOtlpHttpConfigurationWithDefaults, } from '../../configuration/otlp-http-configuration';
|
|
47
38
|
/**
|
|
48
39
|
* Collector Metric Exporter abstract base class
|
|
49
40
|
*/
|
|
@@ -52,42 +43,68 @@ var OTLPExporterBrowserBase = /** @class */ (function (_super) {
|
|
|
52
43
|
/**
|
|
53
44
|
* @param config
|
|
54
45
|
* @param serializer
|
|
55
|
-
* @param
|
|
46
|
+
* @param requiredHeaders
|
|
47
|
+
* @param signalResourcePath
|
|
56
48
|
*/
|
|
57
|
-
function OTLPExporterBrowserBase(config, serializer,
|
|
49
|
+
function OTLPExporterBrowserBase(config, serializer, requiredHeaders, signalResourcePath) {
|
|
58
50
|
if (config === void 0) { config = {}; }
|
|
59
51
|
var _this = _super.call(this, config) || this;
|
|
60
|
-
_this._useXHR = false;
|
|
61
52
|
_this._serializer = serializer;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
var useXhr = !!config.headers || typeof navigator.sendBeacon !== 'function';
|
|
54
|
+
var actualConfig = mergeOtlpHttpConfigurationWithDefaults({
|
|
55
|
+
url: config.url,
|
|
56
|
+
timeoutMillis: config.timeoutMillis,
|
|
57
|
+
headers: config.headers,
|
|
58
|
+
concurrencyLimit: config.concurrencyLimit,
|
|
59
|
+
}, {}, // no fallback for browser case
|
|
60
|
+
getHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
|
|
61
|
+
_this._timeoutMillis = actualConfig.timeoutMillis;
|
|
62
|
+
_this._concurrencyLimit = actualConfig.concurrencyLimit;
|
|
63
|
+
if (useXhr) {
|
|
64
|
+
_this._transport = createRetryingTransport({
|
|
65
|
+
transport: createXhrTransport({
|
|
66
|
+
headers: actualConfig.headers,
|
|
67
|
+
url: actualConfig.url,
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
67
70
|
}
|
|
68
71
|
else {
|
|
69
|
-
|
|
72
|
+
// sendBeacon has no way to signal retry, so we do not wrap it in a RetryingTransport
|
|
73
|
+
_this._transport = createSendBeaconTransport({
|
|
74
|
+
url: actualConfig.url,
|
|
75
|
+
blobType: actualConfig.headers['Content-Type'],
|
|
76
|
+
});
|
|
70
77
|
}
|
|
71
78
|
return _this;
|
|
72
79
|
}
|
|
73
|
-
OTLPExporterBrowserBase.prototype.onInit = function () { };
|
|
74
80
|
OTLPExporterBrowserBase.prototype.onShutdown = function () { };
|
|
75
|
-
OTLPExporterBrowserBase.prototype.send = function (
|
|
81
|
+
OTLPExporterBrowserBase.prototype.send = function (objects, onSuccess, onError) {
|
|
76
82
|
var _this = this;
|
|
77
|
-
var _a;
|
|
78
83
|
if (this._shutdownOnce.isCalled) {
|
|
79
84
|
diag.debug('Shutdown already started. Cannot send objects');
|
|
80
85
|
return;
|
|
81
86
|
}
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
var data = this._serializer.serializeRequest(objects);
|
|
88
|
+
if (data == null) {
|
|
89
|
+
onError(new Error('Could not serialize message'));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
var promise = this._transport
|
|
93
|
+
.send(data, this._timeoutMillis)
|
|
94
|
+
.then(function (response) {
|
|
95
|
+
if (response.status === 'success') {
|
|
96
|
+
onSuccess();
|
|
97
|
+
}
|
|
98
|
+
else if (response.status === 'failure' && response.error) {
|
|
99
|
+
onError(response.error);
|
|
100
|
+
}
|
|
101
|
+
else if (response.status === 'retryable') {
|
|
102
|
+
onError(new OTLPExporterError('Export failed with retryable status'));
|
|
86
103
|
}
|
|
87
104
|
else {
|
|
88
|
-
|
|
105
|
+
onError(new OTLPExporterError('Export failed with unknown error'));
|
|
89
106
|
}
|
|
90
|
-
}
|
|
107
|
+
}, onError);
|
|
91
108
|
this._sendingPromises.push(promise);
|
|
92
109
|
var popPromise = function () {
|
|
93
110
|
var index = _this._sendingPromises.indexOf(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;AAC1D,OAAO,EAA0B,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,uBAAuB,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CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;IACH,8BAAC;AAAD,CAAC,AA/FD,CAGU,gBAAgB,GA4FzB","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, OTLPExporterError } from '../../types';\nimport { diag } from '@opentelemetry/api';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { IExporterTransport } from '../../exporter-transport';\nimport { createXhrTransport } from './xhr-transport';\nimport { createSendBeaconTransport } from './send-beacon-transport';\nimport { createRetryingTransport } from '../../retrying-transport';\nimport {\n getHttpConfigurationDefaults,\n mergeOtlpHttpConfigurationWithDefaults,\n} from '../../configuration/otlp-http-configuration';\n\n/**\n * Collector Metric Exporter abstract base class\n */\nexport abstract class OTLPExporterBrowserBase<\n ExportItem,\n ServiceResponse,\n> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem> {\n private _serializer: ISerializer<ExportItem[], ServiceResponse>;\n private _transport: IExporterTransport;\n private _timeoutMillis: number;\n\n /**\n * @param config\n * @param serializer\n * @param requiredHeaders\n * @param signalResourcePath\n */\n constructor(\n config: OTLPExporterConfigBase = {},\n serializer: ISerializer<ExportItem[], ServiceResponse>,\n requiredHeaders: Record<string, string>,\n signalResourcePath: string\n ) {\n super(config);\n this._serializer = serializer;\n const useXhr =\n !!config.headers || typeof navigator.sendBeacon !== 'function';\n\n const actualConfig = mergeOtlpHttpConfigurationWithDefaults(\n {\n url: config.url,\n timeoutMillis: config.timeoutMillis,\n headers: config.headers,\n concurrencyLimit: config.concurrencyLimit,\n },\n {}, // no fallback for browser case\n getHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n\n this._timeoutMillis = actualConfig.timeoutMillis;\n this._concurrencyLimit = actualConfig.concurrencyLimit;\n\n if (useXhr) {\n this._transport = createRetryingTransport({\n transport: createXhrTransport({\n headers: actualConfig.headers,\n url: actualConfig.url,\n }),\n });\n } else {\n // sendBeacon has no way to signal retry, so we do not wrap it in a RetryingTransport\n this._transport = createSendBeaconTransport({\n url: actualConfig.url,\n blobType: actualConfig.headers['Content-Type'],\n });\n }\n }\n\n onShutdown(): void {}\n\n send(\n objects: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n diag.debug('Shutdown already started. Cannot send objects');\n return;\n }\n\n const data = this._serializer.serializeRequest(objects);\n\n if (data == null) {\n onError(new Error('Could not serialize message'));\n return;\n }\n\n const promise = this._transport\n .send(data, this._timeoutMillis)\n .then(response => {\n if (response.status === 'success') {\n onSuccess();\n } else if (response.status === 'failure' && response.error) {\n onError(response.error);\n } else if (response.status === 'retryable') {\n onError(new OTLPExporterError('Export failed with retryable status'));\n } else {\n onError(new OTLPExporterError('Export failed with unknown error'));\n }\n }, 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/browser/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/browser/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,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\nexport { OTLPExporterBrowserBase } from './OTLPExporterBrowserBase';\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IExporterTransport } from '../../exporter-transport';
|
|
2
|
+
export interface SendBeaconParameters {
|
|
3
|
+
url: string;
|
|
4
|
+
/**
|
|
5
|
+
* for instance 'application/x-protobuf'
|
|
6
|
+
*/
|
|
7
|
+
blobType: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function createSendBeaconTransport(parameters: SendBeaconParameters): IExporterTransport;
|
|
10
|
+
//# sourceMappingURL=send-beacon-transport.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright The OpenTelemetry Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { diag } from '@opentelemetry/api';
|
|
17
|
+
var SendBeaconTransport = /** @class */ (function () {
|
|
18
|
+
function SendBeaconTransport(_params) {
|
|
19
|
+
this._params = _params;
|
|
20
|
+
}
|
|
21
|
+
SendBeaconTransport.prototype.send = function (data) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
return new Promise(function (resolve) {
|
|
24
|
+
if (navigator.sendBeacon(_this._params.url, new Blob([data], { type: _this._params.blobType }))) {
|
|
25
|
+
// no way to signal retry, treat everything as success
|
|
26
|
+
diag.debug('SendBeacon success');
|
|
27
|
+
resolve({
|
|
28
|
+
status: 'success',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
resolve({
|
|
33
|
+
status: 'failure',
|
|
34
|
+
error: new Error('SendBeacon failed'),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
SendBeaconTransport.prototype.shutdown = function () {
|
|
40
|
+
// Intentionally left empty, nothing to do.
|
|
41
|
+
};
|
|
42
|
+
return SendBeaconTransport;
|
|
43
|
+
}());
|
|
44
|
+
export function createSendBeaconTransport(parameters) {
|
|
45
|
+
return new SendBeaconTransport(parameters);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=send-beacon-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-beacon-transport.js","sourceRoot":"","sources":["../../../../src/platform/browser/send-beacon-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAU1C;IACE,6BAAoB,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;IAAG,CAAC;IACrD,kCAAI,GAAJ,UAAK,IAAgB;QAArB,iBAoBC;QAnBC,OAAO,IAAI,OAAO,CAAiB,UAAA,OAAO;YACxC,IACE,SAAS,CAAC,UAAU,CAClB,KAAI,CAAC,OAAO,CAAC,GAAG,EAChB,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAClD,EACD;gBACA,sDAAsD;gBACtD,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;gBACjC,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;iBAClB,CAAC,CAAC;aACJ;iBAAM;gBACL,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,mBAAmB,CAAC;iBACtC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,sCAAQ,GAAR;QACE,2CAA2C;IAC7C,CAAC;IACH,0BAAC;AAAD,CAAC,AA3BD,IA2BC;AAED,MAAM,UAAU,yBAAyB,CACvC,UAAgC;IAEhC,OAAO,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAC7C,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\nimport { IExporterTransport } from '../../exporter-transport';\nimport { ExportResponse } from '../../export-response';\nimport { diag } from '@opentelemetry/api';\n\nexport interface SendBeaconParameters {\n url: string;\n /**\n * for instance 'application/x-protobuf'\n */\n blobType: string;\n}\n\nclass SendBeaconTransport implements IExporterTransport {\n constructor(private _params: SendBeaconParameters) {}\n send(data: Uint8Array): Promise<ExportResponse> {\n return new Promise<ExportResponse>(resolve => {\n if (\n navigator.sendBeacon(\n this._params.url,\n new Blob([data], { type: this._params.blobType })\n )\n ) {\n // no way to signal retry, treat everything as success\n diag.debug('SendBeacon success');\n resolve({\n status: 'success',\n });\n } else {\n resolve({\n status: 'failure',\n error: new Error('SendBeacon failed'),\n });\n }\n });\n }\n\n shutdown(): void {\n // Intentionally left empty, nothing to do.\n }\n}\n\nexport function createSendBeaconTransport(\n parameters: SendBeaconParameters\n): IExporterTransport {\n return new SendBeaconTransport(parameters);\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IExporterTransport } from '../../exporter-transport';
|
|
2
|
+
export interface XhrRequestParameters {
|
|
3
|
+
url: string;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates an exporter transport that uses XHR to send the data
|
|
8
|
+
* @param parameters applied to each request made by transport
|
|
9
|
+
*/
|
|
10
|
+
export declare function createXhrTransport(parameters: XhrRequestParameters): IExporterTransport;
|
|
11
|
+
//# sourceMappingURL=xhr-transport.d.ts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright The OpenTelemetry Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
17
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18
|
+
if (!m) return o;
|
|
19
|
+
var i = m.call(o), r, ar = [], e;
|
|
20
|
+
try {
|
|
21
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
22
|
+
}
|
|
23
|
+
catch (error) { e = { error: error }; }
|
|
24
|
+
finally {
|
|
25
|
+
try {
|
|
26
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
27
|
+
}
|
|
28
|
+
finally { if (e) throw e.error; }
|
|
29
|
+
}
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
import { diag } from '@opentelemetry/api';
|
|
33
|
+
import { isExportRetryable, parseRetryAfterToMills, } from '../../is-export-retryable';
|
|
34
|
+
var XhrTransport = /** @class */ (function () {
|
|
35
|
+
function XhrTransport(_parameters) {
|
|
36
|
+
this._parameters = _parameters;
|
|
37
|
+
}
|
|
38
|
+
XhrTransport.prototype.send = function (data, timeoutMillis) {
|
|
39
|
+
var _this = this;
|
|
40
|
+
return new Promise(function (resolve) {
|
|
41
|
+
var xhr = new XMLHttpRequest();
|
|
42
|
+
xhr.timeout = timeoutMillis;
|
|
43
|
+
xhr.open('POST', _this._parameters.url);
|
|
44
|
+
Object.entries(_this._parameters.headers).forEach(function (_a) {
|
|
45
|
+
var _b = __read(_a, 2), k = _b[0], v = _b[1];
|
|
46
|
+
xhr.setRequestHeader(k, v);
|
|
47
|
+
});
|
|
48
|
+
xhr.ontimeout = function (_) {
|
|
49
|
+
resolve({
|
|
50
|
+
status: 'failure',
|
|
51
|
+
error: new Error('XHR request timed out'),
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
xhr.onreadystatechange = function () {
|
|
55
|
+
if (xhr.status >= 200 && xhr.status <= 299) {
|
|
56
|
+
diag.debug('XHR success');
|
|
57
|
+
resolve({
|
|
58
|
+
status: 'success',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else if (xhr.status && isExportRetryable(xhr.status)) {
|
|
62
|
+
resolve({
|
|
63
|
+
status: 'retryable',
|
|
64
|
+
retryInMillis: parseRetryAfterToMills(xhr.getResponseHeader('Retry-After')),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else if (xhr.status !== 0) {
|
|
68
|
+
resolve({
|
|
69
|
+
status: 'failure',
|
|
70
|
+
error: new Error('XHR request failed with non-retryable status'),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
xhr.onabort = function () {
|
|
75
|
+
resolve({
|
|
76
|
+
status: 'failure',
|
|
77
|
+
error: new Error('XHR request aborted'),
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
xhr.onerror = function () {
|
|
81
|
+
resolve({
|
|
82
|
+
status: 'failure',
|
|
83
|
+
error: new Error('XHR request errored'),
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
xhr.send(new Blob([data], { type: _this._parameters.headers['Content-Type'] }));
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
XhrTransport.prototype.shutdown = function () {
|
|
90
|
+
// Intentionally left empty, nothing to do.
|
|
91
|
+
};
|
|
92
|
+
return XhrTransport;
|
|
93
|
+
}());
|
|
94
|
+
/**
|
|
95
|
+
* Creates an exporter transport that uses XHR to send the data
|
|
96
|
+
* @param parameters applied to each request made by transport
|
|
97
|
+
*/
|
|
98
|
+
export function createXhrTransport(parameters) {
|
|
99
|
+
return new XhrTransport(parameters);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=xhr-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xhr-transport.js","sourceRoot":"","sources":["../../../../src/platform/browser/xhr-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAOnC;IACE,sBAAoB,WAAiC;QAAjC,gBAAW,GAAX,WAAW,CAAsB;IAAG,CAAC;IAEzD,2BAAI,GAAJ,UAAK,IAAgB,EAAE,aAAqB;QAA5C,iBAsDC;QAr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AA8C,CAAC;qBACjE,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC;YAEF,GAAG,CAAC,OAAO,GAAG;gBACZ,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,qBAAqB,CAAC;iBACxC,CAAC,CAAC;YACL,CAAC,CAAC;YACF,GAAG,CAAC,OAAO,GAAG;gBACZ,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,qBAAqB,CAAC;iBACxC,CAAC,CAAC;YACL,CAAC,CAAC;YAEF,GAAG,CAAC,IAAI,CACN,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAI,CAAC,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CACrE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,+BAAQ,GAAR;QACE,2CAA2C;IAC7C,CAAC;IACH,mBAAC;AAAD,CAAC,AA9DD,IA8DC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAAgC;IAEhC,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;AACtC,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\nimport { IExporterTransport } from '../../exporter-transport';\nimport { ExportResponse } from '../../export-response';\nimport { diag } from '@opentelemetry/api';\nimport {\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../../is-export-retryable';\n\nexport interface XhrRequestParameters {\n url: string;\n headers: Record<string, string>;\n}\n\nclass XhrTransport implements IExporterTransport {\n constructor(private _parameters: XhrRequestParameters) {}\n\n send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n return new Promise<ExportResponse>(resolve => {\n const xhr = new XMLHttpRequest();\n xhr.timeout = timeoutMillis;\n xhr.open('POST', this._parameters.url);\n Object.entries(this._parameters.headers).forEach(([k, v]) => {\n xhr.setRequestHeader(k, v);\n });\n\n xhr.ontimeout = _ => {\n resolve({\n status: 'failure',\n error: new Error('XHR request timed out'),\n });\n };\n\n xhr.onreadystatechange = () => {\n if (xhr.status >= 200 && xhr.status <= 299) {\n diag.debug('XHR success');\n resolve({\n status: 'success',\n });\n } else if (xhr.status && isExportRetryable(xhr.status)) {\n resolve({\n status: 'retryable',\n retryInMillis: parseRetryAfterToMills(\n xhr.getResponseHeader('Retry-After')\n ),\n });\n } else if (xhr.status !== 0) {\n resolve({\n status: 'failure',\n error: new Error('XHR request failed with non-retryable status'),\n });\n }\n };\n\n xhr.onabort = () => {\n resolve({\n status: 'failure',\n error: new Error('XHR request aborted'),\n });\n };\n xhr.onerror = () => {\n resolve({\n status: 'failure',\n error: new Error('XHR request errored'),\n });\n };\n\n xhr.send(\n new Blob([data], { type: this._parameters.headers['Content-Type'] })\n );\n });\n }\n\n shutdown() {\n // Intentionally left empty, nothing to do.\n }\n}\n\n/**\n * Creates an exporter transport that uses XHR to send the data\n * @param parameters applied to each request made by transport\n */\nexport function createXhrTransport(\n parameters: XhrRequestParameters\n): IExporterTransport {\n return new XhrTransport(parameters);\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { OTLPExporterNodeBase,
|
|
2
|
-
export { OTLPExporterBrowserBase
|
|
1
|
+
export { OTLPExporterNodeBase, OTLPExporterNodeConfigBase, CompressionAlgorithm, } from './node';
|
|
2
|
+
export { OTLPExporterBrowserBase } from './browser';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export { OTLPExporterNodeBase,
|
|
17
|
-
export { OTLPExporterBrowserBase
|
|
16
|
+
export { OTLPExporterNodeBase, CompressionAlgorithm, } from './node';
|
|
17
|
+
export { OTLPExporterBrowserBase } from './browser';
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,oBAAoB,EAEpB,oBAAoB,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,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\nexport {\n OTLPExporterNodeBase,\n OTLPExporterNodeConfigBase,\n CompressionAlgorithm,\n} from './node';\nexport { OTLPExporterBrowserBase } from './browser';\n"]}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type * as http from 'http';
|
|
3
|
-
import type * as https from 'https';
|
|
4
1
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
5
|
-
import { OTLPExporterNodeConfigBase
|
|
6
|
-
import * as otlpTypes from '../../types';
|
|
2
|
+
import { OTLPExporterNodeConfigBase } from './types';
|
|
7
3
|
import { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
4
|
+
import { OTLPExporterError } from '../../types';
|
|
8
5
|
/**
|
|
9
6
|
* Collector Metric Exporter abstract base class
|
|
10
7
|
*/
|
|
11
8
|
export declare abstract class OTLPExporterNodeBase<ExportItem, ServiceResponse> extends OTLPExporterBase<OTLPExporterNodeConfigBase, ExportItem> {
|
|
12
|
-
DEFAULT_HEADERS: Record<string, string>;
|
|
13
|
-
headers: Record<string, string>;
|
|
14
|
-
agent: http.Agent | https.Agent | undefined;
|
|
15
|
-
compression: CompressionAlgorithm;
|
|
16
9
|
private _serializer;
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
send(objects: ExportItem[], onSuccess: () => void, onError: (error:
|
|
10
|
+
private _transport;
|
|
11
|
+
private _timeoutMillis;
|
|
12
|
+
constructor(config: OTLPExporterNodeConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, requiredHeaders: Record<string, string>, signalIdentifier: string, signalResourcePath: string);
|
|
13
|
+
send(objects: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
21
14
|
onShutdown(): void;
|
|
22
15
|
}
|
|
23
16
|
//# sourceMappingURL=OTLPExporterNodeBase.d.ts.map
|
|
@@ -29,41 +29,72 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
29
29
|
};
|
|
30
30
|
})();
|
|
31
31
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
32
|
-
import { parseHeaders } from '../../util';
|
|
33
|
-
import { createHttpAgent, sendWithHttp, configureCompression } from './util';
|
|
34
32
|
import { diag } from '@opentelemetry/api';
|
|
35
|
-
import {
|
|
33
|
+
import { createHttpExporterTransport } from './http-exporter-transport';
|
|
34
|
+
import { OTLPExporterError } from '../../types';
|
|
35
|
+
import { createRetryingTransport } from '../../retrying-transport';
|
|
36
|
+
import { convertLegacyAgentOptions } from './convert-legacy-agent-options';
|
|
37
|
+
import { getHttpConfigurationDefaults, mergeOtlpHttpConfigurationWithDefaults, } from '../../configuration/otlp-http-configuration';
|
|
38
|
+
import { getHttpConfigurationFromEnvironment } from '../../configuration/otlp-http-env-configuration';
|
|
36
39
|
/**
|
|
37
40
|
* Collector Metric Exporter abstract base class
|
|
38
41
|
*/
|
|
39
42
|
var OTLPExporterNodeBase = /** @class */ (function (_super) {
|
|
40
43
|
__extends(OTLPExporterNodeBase, _super);
|
|
41
|
-
function OTLPExporterNodeBase(config, serializer,
|
|
44
|
+
function OTLPExporterNodeBase(config, serializer, requiredHeaders, signalIdentifier, signalResourcePath) {
|
|
42
45
|
if (config === void 0) { config = {}; }
|
|
43
46
|
var _this = _super.call(this, config) || this;
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
var actualConfig = mergeOtlpHttpConfigurationWithDefaults({
|
|
48
|
+
url: config.url,
|
|
49
|
+
headers: config.headers,
|
|
50
|
+
concurrencyLimit: config.concurrencyLimit,
|
|
51
|
+
timeoutMillis: config.timeoutMillis,
|
|
52
|
+
compression: config.compression,
|
|
53
|
+
}, getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath), getHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
|
|
54
|
+
_this._timeoutMillis = actualConfig.timeoutMillis;
|
|
55
|
+
_this._concurrencyLimit = actualConfig.concurrencyLimit;
|
|
46
56
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
57
|
if (config.metadata) {
|
|
48
58
|
diag.warn('Metadata cannot be set when using http');
|
|
49
59
|
}
|
|
50
|
-
_this.headers = Object.assign(_this.DEFAULT_HEADERS, parseHeaders(config.headers), baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_HEADERS));
|
|
51
|
-
_this.agent = createHttpAgent(config);
|
|
52
|
-
_this.compression = configureCompression(config.compression);
|
|
53
60
|
_this._serializer = serializer;
|
|
61
|
+
_this._transport = createRetryingTransport({
|
|
62
|
+
transport: createHttpExporterTransport({
|
|
63
|
+
agentOptions: convertLegacyAgentOptions(config),
|
|
64
|
+
compression: actualConfig.compression,
|
|
65
|
+
headers: actualConfig.headers,
|
|
66
|
+
url: actualConfig.url,
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
54
69
|
return _this;
|
|
55
70
|
}
|
|
56
|
-
OTLPExporterNodeBase.prototype.onInit = function (_config) { };
|
|
57
71
|
OTLPExporterNodeBase.prototype.send = function (objects, onSuccess, onError) {
|
|
58
72
|
var _this = this;
|
|
59
73
|
if (this._shutdownOnce.isCalled) {
|
|
60
74
|
diag.debug('Shutdown already started. Cannot send objects');
|
|
61
75
|
return;
|
|
62
76
|
}
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
var data = this._serializer.serializeRequest(objects);
|
|
78
|
+
if (data == null) {
|
|
79
|
+
onError(new Error('Could not serialize message'));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
var promise = this._transport
|
|
83
|
+
.send(data, this._timeoutMillis)
|
|
84
|
+
.then(function (response) {
|
|
85
|
+
if (response.status === 'success') {
|
|
86
|
+
onSuccess();
|
|
87
|
+
}
|
|
88
|
+
else if (response.status === 'failure' && response.error) {
|
|
89
|
+
onError(response.error);
|
|
90
|
+
}
|
|
91
|
+
else if (response.status === 'retryable') {
|
|
92
|
+
onError(new OTLPExporterError('Export failed with retryable status'));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
onError(new OTLPExporterError('Export failed with unknown error'));
|
|
96
|
+
}
|
|
97
|
+
}, onError);
|
|
67
98
|
this._sendingPromises.push(promise);
|
|
68
99
|
var popPromise = function () {
|
|
69
100
|
var index = _this._sendingPromises.indexOf(promise);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPExporterNodeBase.js","sourceRoot":"","sources":["../../../../src/platform/node/OTLPExporterNodeBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;G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,CAAC,IAAI,iBAAiB,CAAC,qCAAqC,CAAC,CAAC,CAAC;aACvE;iBAAM;gBACL,OAAO,CAAC,IAAI,iBAAiB,CAAC,kCAAkC,CAAC,CAAC,CAAC;aACpE;QACH,CAAC,EAAE,OAAO,CAAC,CAAC;QAEd,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,IAAM,UAAU,GAAG;YACjB,IAAM,KAAK,GAAG,KAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACrD,KAAI,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;IAED,yCAAU,GAAV,cAAoB,CAAC;IACvB,2BAAC;AAAD,CAAC,AAvFD,CAGU,gBAAgB,GAoFzB","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 { OTLPExporterNodeConfigBase } from './types';\nimport { diag } from '@opentelemetry/api';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { IExporterTransport } from '../../exporter-transport';\nimport { createHttpExporterTransport } from './http-exporter-transport';\nimport { OTLPExporterError } from '../../types';\nimport { createRetryingTransport } from '../../retrying-transport';\nimport { convertLegacyAgentOptions } from './convert-legacy-agent-options';\nimport {\n getHttpConfigurationDefaults,\n mergeOtlpHttpConfigurationWithDefaults,\n} from '../../configuration/otlp-http-configuration';\nimport { getHttpConfigurationFromEnvironment } from '../../configuration/otlp-http-env-configuration';\n\n/**\n * Collector Metric Exporter abstract base class\n */\nexport abstract class OTLPExporterNodeBase<\n ExportItem,\n ServiceResponse,\n> extends OTLPExporterBase<OTLPExporterNodeConfigBase, ExportItem> {\n private _serializer: ISerializer<ExportItem[], ServiceResponse>;\n private _transport: IExporterTransport;\n private _timeoutMillis: number;\n\n constructor(\n config: OTLPExporterNodeConfigBase = {},\n serializer: ISerializer<ExportItem[], ServiceResponse>,\n requiredHeaders: Record<string, string>,\n signalIdentifier: string,\n signalResourcePath: string\n ) {\n super(config);\n const actualConfig = mergeOtlpHttpConfigurationWithDefaults(\n {\n url: config.url,\n headers: config.headers,\n concurrencyLimit: config.concurrencyLimit,\n timeoutMillis: config.timeoutMillis,\n compression: config.compression,\n },\n getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath),\n getHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n\n this._timeoutMillis = actualConfig.timeoutMillis;\n this._concurrencyLimit = actualConfig.concurrencyLimit;\n\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._serializer = serializer;\n\n this._transport = createRetryingTransport({\n transport: createHttpExporterTransport({\n agentOptions: convertLegacyAgentOptions(config),\n compression: actualConfig.compression,\n headers: actualConfig.headers,\n url: actualConfig.url,\n }),\n });\n }\n\n send(\n objects: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n diag.debug('Shutdown already started. Cannot send objects');\n return;\n }\n\n const data = this._serializer.serializeRequest(objects);\n\n if (data == null) {\n onError(new Error('Could not serialize message'));\n return;\n }\n\n const promise = this._transport\n .send(data, this._timeoutMillis)\n .then(response => {\n if (response.status === 'success') {\n onSuccess();\n } else if (response.status === 'failure' && response.error) {\n onError(response.error);\n } else if (response.status === 'retryable') {\n onError(new OTLPExporterError('Export failed with retryable status'));\n } else {\n onError(new OTLPExporterError('Export failed with unknown error'));\n }\n }, 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"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { OTLPExporterNodeConfigBase } from './types';
|
|
3
|
+
import type * as http from 'http';
|
|
4
|
+
import type * as https from 'https';
|
|
5
|
+
/**
|
|
6
|
+
* Replicates old config behavior where there's two ways to set keepAlive.
|
|
7
|
+
* This function sets keepAlive in AgentOptions if it is defined. In the future, we will remove
|
|
8
|
+
* this duplicate to only allow setting keepAlive in AgentOptions.
|
|
9
|
+
* @param config
|
|
10
|
+
*/
|
|
11
|
+
export declare function convertLegacyAgentOptions(config: OTLPExporterNodeConfigBase): http.AgentOptions | https.AgentOptions;
|
|
12
|
+
//# sourceMappingURL=convert-legacy-agent-options.d.ts.map
|