@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
package/build/src/util.js
CHANGED
|
@@ -15,19 +15,13 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.validateAndNormalizeHeaders = void 0;
|
|
19
19
|
const api_1 = require("@opentelemetry/api");
|
|
20
|
-
const core_1 = require("@opentelemetry/core");
|
|
21
|
-
const DEFAULT_TRACE_TIMEOUT = 10000;
|
|
22
|
-
exports.DEFAULT_EXPORT_MAX_ATTEMPTS = 5;
|
|
23
|
-
exports.DEFAULT_EXPORT_INITIAL_BACKOFF = 1000;
|
|
24
|
-
exports.DEFAULT_EXPORT_MAX_BACKOFF = 5000;
|
|
25
|
-
exports.DEFAULT_EXPORT_BACKOFF_MULTIPLIER = 1.5;
|
|
26
20
|
/**
|
|
27
21
|
* Parses headers from config leaving only those that have defined values
|
|
28
22
|
* @param partialHeaders
|
|
29
23
|
*/
|
|
30
|
-
function
|
|
24
|
+
function validateAndNormalizeHeaders(partialHeaders = {}) {
|
|
31
25
|
const headers = {};
|
|
32
26
|
Object.entries(partialHeaders).forEach(([key, value]) => {
|
|
33
27
|
if (typeof value !== 'undefined') {
|
|
@@ -39,93 +33,5 @@ function parseHeaders(partialHeaders = {}) {
|
|
|
39
33
|
});
|
|
40
34
|
return headers;
|
|
41
35
|
}
|
|
42
|
-
exports.
|
|
43
|
-
/**
|
|
44
|
-
* Adds path (version + signal) to a no per-signal endpoint
|
|
45
|
-
* @param url
|
|
46
|
-
* @param path
|
|
47
|
-
* @returns url + path
|
|
48
|
-
*/
|
|
49
|
-
function appendResourcePathToUrl(url, path) {
|
|
50
|
-
if (!url.endsWith('/')) {
|
|
51
|
-
url = url + '/';
|
|
52
|
-
}
|
|
53
|
-
return url + path;
|
|
54
|
-
}
|
|
55
|
-
exports.appendResourcePathToUrl = appendResourcePathToUrl;
|
|
56
|
-
/**
|
|
57
|
-
* Adds root path to signal specific endpoint when endpoint contains no path part and no root path
|
|
58
|
-
* @param url
|
|
59
|
-
* @returns url
|
|
60
|
-
*/
|
|
61
|
-
function appendRootPathToUrlIfNeeded(url) {
|
|
62
|
-
try {
|
|
63
|
-
const parsedUrl = new URL(url);
|
|
64
|
-
if (parsedUrl.pathname === '') {
|
|
65
|
-
parsedUrl.pathname = parsedUrl.pathname + '/';
|
|
66
|
-
}
|
|
67
|
-
return parsedUrl.toString();
|
|
68
|
-
}
|
|
69
|
-
catch (_a) {
|
|
70
|
-
api_1.diag.warn(`Could not parse export URL: '${url}'`);
|
|
71
|
-
return url;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.appendRootPathToUrlIfNeeded = appendRootPathToUrlIfNeeded;
|
|
75
|
-
/**
|
|
76
|
-
* Configure exporter trace timeout value from passed in value or environment variables
|
|
77
|
-
* @param timeoutMillis
|
|
78
|
-
* @returns timeout value in milliseconds
|
|
79
|
-
*/
|
|
80
|
-
function configureExporterTimeout(timeoutMillis) {
|
|
81
|
-
if (typeof timeoutMillis === 'number') {
|
|
82
|
-
if (timeoutMillis <= 0) {
|
|
83
|
-
// OTLP exporter configured timeout - using default value of 10000ms
|
|
84
|
-
return invalidTimeout(timeoutMillis, DEFAULT_TRACE_TIMEOUT);
|
|
85
|
-
}
|
|
86
|
-
return timeoutMillis;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
return getExporterTimeoutFromEnv();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.configureExporterTimeout = configureExporterTimeout;
|
|
93
|
-
function getExporterTimeoutFromEnv() {
|
|
94
|
-
var _a;
|
|
95
|
-
const definedTimeout = Number((_a = (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_TRACES_TIMEOUT) !== null && _a !== void 0 ? _a : (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_TIMEOUT);
|
|
96
|
-
if (definedTimeout <= 0) {
|
|
97
|
-
// OTLP exporter configured timeout - using default value of 10000ms
|
|
98
|
-
return invalidTimeout(definedTimeout, DEFAULT_TRACE_TIMEOUT);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
return definedTimeout;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
// OTLP exporter configured timeout - using default value of 10000ms
|
|
105
|
-
function invalidTimeout(timeout, defaultTimeout) {
|
|
106
|
-
api_1.diag.warn('Timeout must be greater than 0', timeout);
|
|
107
|
-
return defaultTimeout;
|
|
108
|
-
}
|
|
109
|
-
exports.invalidTimeout = invalidTimeout;
|
|
110
|
-
function isExportRetryable(statusCode) {
|
|
111
|
-
const retryCodes = [429, 502, 503, 504];
|
|
112
|
-
return retryCodes.includes(statusCode);
|
|
113
|
-
}
|
|
114
|
-
exports.isExportRetryable = isExportRetryable;
|
|
115
|
-
function parseRetryAfterToMills(retryAfter) {
|
|
116
|
-
if (retryAfter == null) {
|
|
117
|
-
return -1;
|
|
118
|
-
}
|
|
119
|
-
const seconds = Number.parseInt(retryAfter, 10);
|
|
120
|
-
if (Number.isInteger(seconds)) {
|
|
121
|
-
return seconds > 0 ? seconds * 1000 : -1;
|
|
122
|
-
}
|
|
123
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#directives
|
|
124
|
-
const delay = new Date(retryAfter).getTime() - Date.now();
|
|
125
|
-
if (delay >= 0) {
|
|
126
|
-
return delay;
|
|
127
|
-
}
|
|
128
|
-
return 0;
|
|
129
|
-
}
|
|
130
|
-
exports.parseRetryAfterToMills = parseRetryAfterToMills;
|
|
36
|
+
exports.validateAndNormalizeHeaders = validateAndNormalizeHeaders;
|
|
131
37
|
//# sourceMappingURL=util.js.map
|
package/build/src/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAE1C;;;GAGG;AACH,SAAgB,2BAA2B,CACzC,iBAAmD,EAAE;IAErD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACtD,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;SAC9B;aAAM;YACL,UAAI,CAAC,IAAI,CACP,WAAW,GAAG,wBAAwB,KAAK,uBAAuB,CACnE,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAdD,kEAcC","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';\n\n/**\n * Parses headers from config leaving only those that have defined values\n * @param partialHeaders\n */\nexport function validateAndNormalizeHeaders(\n partialHeaders: Partial<Record<string, unknown>> = {}\n): Record<string, string> {\n const headers: Record<string, string> = {};\n Object.entries(partialHeaders).forEach(([key, value]) => {\n if (typeof value !== 'undefined') {\n headers[key] = String(value);\n } else {\n diag.warn(\n `Header \"${key}\" has invalid value (${value}) and will be ignored`\n );\n }\n });\n return headers;\n}\n"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.54.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,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;AAC/C,QAAA,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.54.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/otlp-exporter-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "OpenTelemetry OTLP Exporter base (for internal use only)",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"module": "build/esm/index.js",
|
|
@@ -17,13 +17,11 @@
|
|
|
17
17
|
"prepublishOnly": "npm run compile",
|
|
18
18
|
"compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
|
|
19
19
|
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
|
|
20
|
-
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
|
|
21
|
-
"codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
|
|
22
20
|
"lint": "eslint . --ext .ts",
|
|
23
21
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
24
22
|
"tdd": "npm run test -- --watch-extensions ts --watch",
|
|
25
23
|
"tdd:browser": "karma start",
|
|
26
|
-
"test": "nyc
|
|
24
|
+
"test": "nyc mocha 'test/**/*.test.ts' --exclude 'test/browser/**/*.ts'",
|
|
27
25
|
"test:browser": "karma start --single-run",
|
|
28
26
|
"version": "node ../../../scripts/version-update.js",
|
|
29
27
|
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
|
|
@@ -62,40 +60,38 @@
|
|
|
62
60
|
"access": "public"
|
|
63
61
|
},
|
|
64
62
|
"dependencies": {
|
|
65
|
-
"@opentelemetry/core": "1.
|
|
66
|
-
"@opentelemetry/otlp-transformer": "0.
|
|
63
|
+
"@opentelemetry/core": "1.27.0",
|
|
64
|
+
"@opentelemetry/otlp-transformer": "0.54.0"
|
|
67
65
|
},
|
|
68
66
|
"devDependencies": {
|
|
69
|
-
"@babel/core": "7.
|
|
70
|
-
"@babel/preset-env": "7.
|
|
67
|
+
"@babel/core": "7.25.2",
|
|
68
|
+
"@babel/preset-env": "7.25.4",
|
|
71
69
|
"@opentelemetry/api": "1.9.0",
|
|
72
|
-
"@types/mocha": "10.0.
|
|
70
|
+
"@types/mocha": "10.0.8",
|
|
73
71
|
"@types/node": "18.6.5",
|
|
74
72
|
"@types/sinon": "17.0.3",
|
|
75
|
-
"babel-plugin-istanbul": "
|
|
76
|
-
"codecov": "3.8.3",
|
|
73
|
+
"babel-plugin-istanbul": "7.0.0",
|
|
77
74
|
"cross-var": "1.1.0",
|
|
78
|
-
"karma": "6.4.
|
|
75
|
+
"karma": "6.4.4",
|
|
79
76
|
"karma-chrome-launcher": "3.1.0",
|
|
80
77
|
"karma-coverage": "2.2.1",
|
|
81
78
|
"karma-mocha": "2.0.1",
|
|
82
79
|
"karma-spec-reporter": "0.0.36",
|
|
83
80
|
"karma-webpack": "5.0.1",
|
|
84
81
|
"lerna": "6.6.2",
|
|
85
|
-
"mocha": "10.
|
|
82
|
+
"mocha": "10.7.3",
|
|
86
83
|
"nyc": "15.1.0",
|
|
87
84
|
"sinon": "15.1.2",
|
|
88
85
|
"ts-loader": "9.5.1",
|
|
89
|
-
"ts-mocha": "10.0.0",
|
|
90
86
|
"typescript": "4.4.4",
|
|
91
|
-
"webpack": "5.
|
|
87
|
+
"webpack": "5.94.0",
|
|
92
88
|
"webpack-cli": "5.1.4",
|
|
93
89
|
"webpack-merge": "5.10.0"
|
|
94
90
|
},
|
|
95
91
|
"peerDependencies": {
|
|
96
|
-
"@opentelemetry/api": "^1.
|
|
92
|
+
"@opentelemetry/api": "^1.3.0"
|
|
97
93
|
},
|
|
98
94
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/otlp-exporter-base",
|
|
99
95
|
"sideEffects": false,
|
|
100
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "eb3ca4fb07ee31c62093f5fcec56575573c902ce"
|
|
101
97
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { OTLPExporterError } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Send metrics/spans using browser navigator.sendBeacon
|
|
4
|
-
* @param body
|
|
5
|
-
* @param url
|
|
6
|
-
* @param blobPropertyBag
|
|
7
|
-
* @param onSuccess
|
|
8
|
-
* @param onError
|
|
9
|
-
*/
|
|
10
|
-
export declare function sendWithBeacon(body: Uint8Array, url: string, blobPropertyBag: BlobPropertyBag, onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
11
|
-
/**
|
|
12
|
-
* function to send metrics/spans using browser XMLHttpRequest
|
|
13
|
-
* used when navigator.sendBeacon is not available
|
|
14
|
-
* @param body
|
|
15
|
-
* @param url
|
|
16
|
-
* @param headers
|
|
17
|
-
* @param onSuccess
|
|
18
|
-
* @param onError
|
|
19
|
-
*/
|
|
20
|
-
export declare function sendWithXhr(body: Uint8Array, url: string, headers: Record<string, string>, exporterTimeout: number, onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
21
|
-
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
-
if (!m) return o;
|
|
15
|
-
var i = m.call(o), r, ar = [], e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
}
|
|
19
|
-
catch (error) { e = { error: error }; }
|
|
20
|
-
finally {
|
|
21
|
-
try {
|
|
22
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
-
}
|
|
24
|
-
finally { if (e) throw e.error; }
|
|
25
|
-
}
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
/*
|
|
29
|
-
* Copyright The OpenTelemetry Authors
|
|
30
|
-
*
|
|
31
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
32
|
-
* you may not use this file except in compliance with the License.
|
|
33
|
-
* You may obtain a copy of the License at
|
|
34
|
-
*
|
|
35
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
36
|
-
*
|
|
37
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
38
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
39
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
40
|
-
* See the License for the specific language governing permissions and
|
|
41
|
-
* limitations under the License.
|
|
42
|
-
*/
|
|
43
|
-
import { diag } from '@opentelemetry/api';
|
|
44
|
-
import { OTLPExporterError } from '../../types';
|
|
45
|
-
import { DEFAULT_EXPORT_MAX_ATTEMPTS, DEFAULT_EXPORT_INITIAL_BACKOFF, DEFAULT_EXPORT_BACKOFF_MULTIPLIER, DEFAULT_EXPORT_MAX_BACKOFF, isExportRetryable, parseRetryAfterToMills, } from '../../util';
|
|
46
|
-
/**
|
|
47
|
-
* Send metrics/spans using browser navigator.sendBeacon
|
|
48
|
-
* @param body
|
|
49
|
-
* @param url
|
|
50
|
-
* @param blobPropertyBag
|
|
51
|
-
* @param onSuccess
|
|
52
|
-
* @param onError
|
|
53
|
-
*/
|
|
54
|
-
export function sendWithBeacon(body, url, blobPropertyBag, onSuccess, onError) {
|
|
55
|
-
if (navigator.sendBeacon(url, new Blob([body], blobPropertyBag))) {
|
|
56
|
-
diag.debug('sendBeacon - can send', body);
|
|
57
|
-
onSuccess();
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
var error = new OTLPExporterError("sendBeacon - cannot send " + body);
|
|
61
|
-
onError(error);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* function to send metrics/spans using browser XMLHttpRequest
|
|
66
|
-
* used when navigator.sendBeacon is not available
|
|
67
|
-
* @param body
|
|
68
|
-
* @param url
|
|
69
|
-
* @param headers
|
|
70
|
-
* @param onSuccess
|
|
71
|
-
* @param onError
|
|
72
|
-
*/
|
|
73
|
-
export function sendWithXhr(body, url, headers, exporterTimeout, onSuccess, onError) {
|
|
74
|
-
var retryTimer;
|
|
75
|
-
var xhr;
|
|
76
|
-
var reqIsDestroyed = false;
|
|
77
|
-
var exporterTimer = setTimeout(function () {
|
|
78
|
-
clearTimeout(retryTimer);
|
|
79
|
-
reqIsDestroyed = true;
|
|
80
|
-
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
81
|
-
var err = new OTLPExporterError('Request Timeout');
|
|
82
|
-
onError(err);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
xhr.abort();
|
|
86
|
-
}
|
|
87
|
-
}, exporterTimeout);
|
|
88
|
-
var sendWithRetry = function (retries, minDelay) {
|
|
89
|
-
if (retries === void 0) { retries = DEFAULT_EXPORT_MAX_ATTEMPTS; }
|
|
90
|
-
if (minDelay === void 0) { minDelay = DEFAULT_EXPORT_INITIAL_BACKOFF; }
|
|
91
|
-
xhr = new XMLHttpRequest();
|
|
92
|
-
xhr.open('POST', url);
|
|
93
|
-
var defaultHeaders = {
|
|
94
|
-
Accept: 'application/json',
|
|
95
|
-
'Content-Type': 'application/json',
|
|
96
|
-
};
|
|
97
|
-
Object.entries(__assign(__assign({}, defaultHeaders), headers)).forEach(function (_a) {
|
|
98
|
-
var _b = __read(_a, 2), k = _b[0], v = _b[1];
|
|
99
|
-
xhr.setRequestHeader(k, v);
|
|
100
|
-
});
|
|
101
|
-
xhr.send(body);
|
|
102
|
-
xhr.onreadystatechange = function () {
|
|
103
|
-
if (xhr.readyState === XMLHttpRequest.DONE && reqIsDestroyed === false) {
|
|
104
|
-
if (xhr.status >= 200 && xhr.status <= 299) {
|
|
105
|
-
diag.debug('xhr success', body);
|
|
106
|
-
onSuccess();
|
|
107
|
-
clearTimeout(exporterTimer);
|
|
108
|
-
clearTimeout(retryTimer);
|
|
109
|
-
}
|
|
110
|
-
else if (xhr.status && isExportRetryable(xhr.status) && retries > 0) {
|
|
111
|
-
var retryTime = void 0;
|
|
112
|
-
minDelay = DEFAULT_EXPORT_BACKOFF_MULTIPLIER * minDelay;
|
|
113
|
-
// retry after interval specified in Retry-After header
|
|
114
|
-
if (xhr.getResponseHeader('Retry-After')) {
|
|
115
|
-
retryTime = parseRetryAfterToMills(xhr.getResponseHeader('Retry-After'));
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// exponential backoff with jitter
|
|
119
|
-
retryTime = Math.round(Math.random() * (DEFAULT_EXPORT_MAX_BACKOFF - minDelay) + minDelay);
|
|
120
|
-
}
|
|
121
|
-
retryTimer = setTimeout(function () {
|
|
122
|
-
sendWithRetry(retries - 1, minDelay);
|
|
123
|
-
}, retryTime);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
var error = new OTLPExporterError("Failed to export with XHR (status: " + xhr.status + ")", xhr.status);
|
|
127
|
-
onError(error);
|
|
128
|
-
clearTimeout(exporterTimer);
|
|
129
|
-
clearTimeout(retryTimer);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
xhr.onabort = function () {
|
|
134
|
-
if (reqIsDestroyed) {
|
|
135
|
-
var err = new OTLPExporterError('Request Timeout');
|
|
136
|
-
onError(err);
|
|
137
|
-
}
|
|
138
|
-
clearTimeout(exporterTimer);
|
|
139
|
-
clearTimeout(retryTimer);
|
|
140
|
-
};
|
|
141
|
-
xhr.onerror = function () {
|
|
142
|
-
if (reqIsDestroyed) {
|
|
143
|
-
var err = new OTLPExporterError('Request Timeout');
|
|
144
|
-
onError(err);
|
|
145
|
-
}
|
|
146
|
-
clearTimeout(exporterTimer);
|
|
147
|
-
clearTimeout(retryTimer);
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
sendWithRetry();
|
|
151
|
-
}
|
|
152
|
-
//# sourceMappingURL=util.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/platform/browser/util.ts"],"names":[],"mappings":"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","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"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import * as http from 'http';
|
|
3
|
-
import * as https from 'https';
|
|
4
|
-
import { OTLPExporterNodeBase } from './OTLPExporterNodeBase';
|
|
5
|
-
import { OTLPExporterNodeConfigBase } from '.';
|
|
6
|
-
import { CompressionAlgorithm } from './types';
|
|
7
|
-
import { OTLPExporterError } from '../../types';
|
|
8
|
-
/**
|
|
9
|
-
* Sends data using http
|
|
10
|
-
* @param collector
|
|
11
|
-
* @param data
|
|
12
|
-
* @param contentType
|
|
13
|
-
* @param onSuccess
|
|
14
|
-
* @param onError
|
|
15
|
-
*/
|
|
16
|
-
export declare function sendWithHttp<ExportItem, ServiceResponse>(collector: OTLPExporterNodeBase<ExportItem, ServiceResponse>, data: string | Uint8Array, contentType: string, onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
17
|
-
export declare function createHttpAgent(config: OTLPExporterNodeConfigBase): http.Agent | https.Agent | undefined;
|
|
18
|
-
export declare function configureCompression(compression: CompressionAlgorithm | undefined): CompressionAlgorithm;
|
|
19
|
-
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
/*
|
|
13
|
-
* Copyright The OpenTelemetry Authors
|
|
14
|
-
*
|
|
15
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16
|
-
* you may not use this file except in compliance with the License.
|
|
17
|
-
* You may obtain a copy of the License at
|
|
18
|
-
*
|
|
19
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
-
*
|
|
21
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
-
* See the License for the specific language governing permissions and
|
|
25
|
-
* limitations under the License.
|
|
26
|
-
*/
|
|
27
|
-
import * as url from 'url';
|
|
28
|
-
import * as http from 'http';
|
|
29
|
-
import * as https from 'https';
|
|
30
|
-
import * as zlib from 'zlib';
|
|
31
|
-
import { Readable } from 'stream';
|
|
32
|
-
import { diag } from '@opentelemetry/api';
|
|
33
|
-
import { CompressionAlgorithm } from './types';
|
|
34
|
-
import { getEnv } from '@opentelemetry/core';
|
|
35
|
-
import { OTLPExporterError } from '../../types';
|
|
36
|
-
import { DEFAULT_EXPORT_MAX_ATTEMPTS, DEFAULT_EXPORT_INITIAL_BACKOFF, DEFAULT_EXPORT_BACKOFF_MULTIPLIER, DEFAULT_EXPORT_MAX_BACKOFF, isExportRetryable, parseRetryAfterToMills, } from '../../util';
|
|
37
|
-
/**
|
|
38
|
-
* Sends data using http
|
|
39
|
-
* @param collector
|
|
40
|
-
* @param data
|
|
41
|
-
* @param contentType
|
|
42
|
-
* @param onSuccess
|
|
43
|
-
* @param onError
|
|
44
|
-
*/
|
|
45
|
-
export function sendWithHttp(collector, data, contentType, onSuccess, onError) {
|
|
46
|
-
var exporterTimeout = collector.timeoutMillis;
|
|
47
|
-
var parsedUrl = new url.URL(collector.url);
|
|
48
|
-
var nodeVersion = Number(process.versions.node.split('.')[0]);
|
|
49
|
-
var retryTimer;
|
|
50
|
-
var req;
|
|
51
|
-
var reqIsDestroyed = false;
|
|
52
|
-
var exporterTimer = setTimeout(function () {
|
|
53
|
-
clearTimeout(retryTimer);
|
|
54
|
-
reqIsDestroyed = true;
|
|
55
|
-
if (req.destroyed) {
|
|
56
|
-
var err = new OTLPExporterError('Request Timeout');
|
|
57
|
-
onError(err);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// req.abort() was deprecated since v14
|
|
61
|
-
nodeVersion >= 14 ? req.destroy() : req.abort();
|
|
62
|
-
}
|
|
63
|
-
}, exporterTimeout);
|
|
64
|
-
var options = {
|
|
65
|
-
hostname: parsedUrl.hostname,
|
|
66
|
-
port: parsedUrl.port,
|
|
67
|
-
path: parsedUrl.pathname,
|
|
68
|
-
method: 'POST',
|
|
69
|
-
headers: __assign({ 'Content-Type': contentType }, collector.headers),
|
|
70
|
-
agent: collector.agent,
|
|
71
|
-
};
|
|
72
|
-
var request = parsedUrl.protocol === 'http:' ? http.request : https.request;
|
|
73
|
-
var sendWithRetry = function (retries, minDelay) {
|
|
74
|
-
if (retries === void 0) { retries = DEFAULT_EXPORT_MAX_ATTEMPTS; }
|
|
75
|
-
if (minDelay === void 0) { minDelay = DEFAULT_EXPORT_INITIAL_BACKOFF; }
|
|
76
|
-
req = request(options, function (res) {
|
|
77
|
-
var responseData = '';
|
|
78
|
-
res.on('data', function (chunk) { return (responseData += chunk); });
|
|
79
|
-
res.on('aborted', function () {
|
|
80
|
-
if (reqIsDestroyed) {
|
|
81
|
-
var err = new OTLPExporterError('Request Timeout');
|
|
82
|
-
onError(err);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
res.on('end', function () {
|
|
86
|
-
if (reqIsDestroyed === false) {
|
|
87
|
-
if (res.statusCode && res.statusCode < 299) {
|
|
88
|
-
diag.debug("statusCode: " + res.statusCode, responseData);
|
|
89
|
-
onSuccess();
|
|
90
|
-
// clear all timers since request was completed and promise was resolved
|
|
91
|
-
clearTimeout(exporterTimer);
|
|
92
|
-
clearTimeout(retryTimer);
|
|
93
|
-
}
|
|
94
|
-
else if (res.statusCode &&
|
|
95
|
-
isExportRetryable(res.statusCode) &&
|
|
96
|
-
retries > 0) {
|
|
97
|
-
var retryTime = void 0;
|
|
98
|
-
minDelay = DEFAULT_EXPORT_BACKOFF_MULTIPLIER * minDelay;
|
|
99
|
-
// retry after interval specified in Retry-After header
|
|
100
|
-
if (res.headers['retry-after']) {
|
|
101
|
-
retryTime = parseRetryAfterToMills(res.headers['retry-after']);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
// exponential backoff with jitter
|
|
105
|
-
retryTime = Math.round(Math.random() * (DEFAULT_EXPORT_MAX_BACKOFF - minDelay) +
|
|
106
|
-
minDelay);
|
|
107
|
-
}
|
|
108
|
-
retryTimer = setTimeout(function () {
|
|
109
|
-
sendWithRetry(retries - 1, minDelay);
|
|
110
|
-
}, retryTime);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
var error = new OTLPExporterError(res.statusMessage, res.statusCode, responseData);
|
|
114
|
-
onError(error);
|
|
115
|
-
// clear all timers since request was completed and promise was resolved
|
|
116
|
-
clearTimeout(exporterTimer);
|
|
117
|
-
clearTimeout(retryTimer);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
req.on('error', function (error) {
|
|
123
|
-
if (reqIsDestroyed) {
|
|
124
|
-
var err = new OTLPExporterError('Request Timeout', error.code);
|
|
125
|
-
onError(err);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
onError(error);
|
|
129
|
-
}
|
|
130
|
-
clearTimeout(exporterTimer);
|
|
131
|
-
clearTimeout(retryTimer);
|
|
132
|
-
});
|
|
133
|
-
req.on('abort', function () {
|
|
134
|
-
if (reqIsDestroyed) {
|
|
135
|
-
var err = new OTLPExporterError('Request Timeout');
|
|
136
|
-
onError(err);
|
|
137
|
-
}
|
|
138
|
-
clearTimeout(exporterTimer);
|
|
139
|
-
clearTimeout(retryTimer);
|
|
140
|
-
});
|
|
141
|
-
switch (collector.compression) {
|
|
142
|
-
case CompressionAlgorithm.GZIP: {
|
|
143
|
-
req.setHeader('Content-Encoding', 'gzip');
|
|
144
|
-
var dataStream = readableFromUnit8Array(data);
|
|
145
|
-
dataStream
|
|
146
|
-
.on('error', onError)
|
|
147
|
-
.pipe(zlib.createGzip())
|
|
148
|
-
.on('error', onError)
|
|
149
|
-
.pipe(req);
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
default:
|
|
153
|
-
req.end(Buffer.from(data));
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
sendWithRetry();
|
|
158
|
-
}
|
|
159
|
-
function readableFromUnit8Array(buff) {
|
|
160
|
-
var readable = new Readable();
|
|
161
|
-
readable.push(buff);
|
|
162
|
-
readable.push(null);
|
|
163
|
-
return readable;
|
|
164
|
-
}
|
|
165
|
-
export function createHttpAgent(config) {
|
|
166
|
-
if (config.httpAgentOptions && config.keepAlive === false) {
|
|
167
|
-
diag.warn('httpAgentOptions is used only when keepAlive is true');
|
|
168
|
-
return undefined;
|
|
169
|
-
}
|
|
170
|
-
if (config.keepAlive === false || !config.url)
|
|
171
|
-
return undefined;
|
|
172
|
-
try {
|
|
173
|
-
var parsedUrl = new url.URL(config.url);
|
|
174
|
-
var Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent;
|
|
175
|
-
return new Agent(__assign({ keepAlive: true }, config.httpAgentOptions));
|
|
176
|
-
}
|
|
177
|
-
catch (err) {
|
|
178
|
-
diag.error("collector exporter failed to create http agent. err: " + err.message);
|
|
179
|
-
return undefined;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
export function configureCompression(compression) {
|
|
183
|
-
if (compression) {
|
|
184
|
-
return compression;
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
var definedCompression = getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION ||
|
|
188
|
-
getEnv().OTEL_EXPORTER_OTLP_COMPRESSION;
|
|
189
|
-
return definedCompression === CompressionAlgorithm.GZIP
|
|
190
|
-
? CompressionAlgorithm.GZIP
|
|
191
|
-
: CompressionAlgorithm.NONE;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
//# sourceMappingURL=util.js.map
|