@opentelemetry/otlp-exporter-base 0.57.2 → 0.200.0-dev.1
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.js +10 -11
- package/build/esm/OTLPExporterBase.js.map +1 -1
- package/build/esm/bounded-queue-export-promise-handler.js +15 -61
- package/build/esm/bounded-queue-export-promise-handler.js.map +1 -1
- package/build/esm/configuration/convert-legacy-node-http-options.js +1 -1
- package/build/esm/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/esm/configuration/create-legacy-browser-delegate.js +2 -2
- package/build/esm/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/build/esm/configuration/legacy-node-configuration.d.ts +1 -0
- package/build/esm/configuration/otlp-http-configuration.d.ts +1 -0
- package/build/esm/configuration/otlp-http-configuration.js +22 -18
- package/build/esm/configuration/otlp-http-configuration.js.map +1 -1
- package/build/esm/configuration/otlp-http-env-configuration.js +21 -31
- package/build/esm/configuration/otlp-http-env-configuration.js.map +1 -1
- package/build/esm/configuration/shared-configuration.js +12 -9
- package/build/esm/configuration/shared-configuration.js.map +1 -1
- package/build/esm/configuration/shared-env-configuration.js +12 -16
- package/build/esm/configuration/shared-env-configuration.js.map +1 -1
- package/build/esm/export-response.d.ts +1 -1
- package/build/esm/is-export-retryable.js +3 -3
- package/build/esm/is-export-retryable.js.map +1 -1
- package/build/esm/logging-response-handler.js +1 -1
- package/build/esm/logging-response-handler.js.map +1 -1
- package/build/esm/otlp-export-delegate.js +26 -70
- package/build/esm/otlp-export-delegate.js.map +1 -1
- package/build/esm/otlp-network-export-delegate.js +1 -1
- package/build/esm/otlp-network-export-delegate.js.map +1 -1
- package/build/esm/retrying-transport.js +36 -86
- package/build/esm/retrying-transport.js.map +1 -1
- package/build/esm/transport/http-exporter-transport.js +28 -64
- package/build/esm/transport/http-exporter-transport.js.map +1 -1
- package/build/esm/transport/http-transport-types.d.ts +2 -1
- package/build/esm/transport/http-transport-utils.d.ts +1 -0
- package/build/esm/transport/http-transport-utils.js +24 -33
- package/build/esm/transport/http-transport-utils.js.map +1 -1
- package/build/esm/transport/send-beacon-transport.js +10 -11
- package/build/esm/transport/send-beacon-transport.js.map +1 -1
- package/build/esm/transport/xhr-transport.js +17 -35
- package/build/esm/transport/xhr-transport.js.map +1 -1
- package/build/esm/types.js +9 -26
- package/build/esm/types.js.map +1 -1
- package/build/esm/util.js +4 -22
- 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.js +1 -0
- package/build/esnext/OTLPExporterBase.js.map +1 -1
- package/build/esnext/bounded-queue-export-promise-handler.js +2 -1
- package/build/esnext/bounded-queue-export-promise-handler.js.map +1 -1
- package/build/esnext/configuration/convert-legacy-node-http-options.js +1 -1
- package/build/esnext/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/esnext/configuration/legacy-node-configuration.d.ts +1 -0
- package/build/esnext/configuration/otlp-http-configuration.d.ts +1 -0
- package/build/esnext/configuration/otlp-http-configuration.js +19 -4
- package/build/esnext/configuration/otlp-http-configuration.js.map +1 -1
- package/build/esnext/configuration/otlp-http-env-configuration.js +17 -16
- package/build/esnext/configuration/otlp-http-env-configuration.js.map +1 -1
- package/build/esnext/configuration/shared-configuration.js +10 -7
- package/build/esnext/configuration/shared-configuration.js.map +1 -1
- package/build/esnext/configuration/shared-env-configuration.js +5 -9
- package/build/esnext/configuration/shared-env-configuration.js.map +1 -1
- package/build/esnext/export-response.d.ts +1 -1
- package/build/esnext/otlp-export-delegate.js +6 -0
- package/build/esnext/otlp-export-delegate.js.map +1 -1
- package/build/esnext/retrying-transport.js +2 -2
- package/build/esnext/retrying-transport.js.map +1 -1
- package/build/esnext/transport/http-exporter-transport.js +18 -14
- package/build/esnext/transport/http-exporter-transport.js.map +1 -1
- package/build/esnext/transport/http-transport-types.d.ts +2 -1
- package/build/esnext/transport/http-transport-utils.d.ts +1 -0
- package/build/esnext/transport/http-transport-utils.js +4 -2
- package/build/esnext/transport/http-transport-utils.js.map +1 -1
- package/build/esnext/transport/send-beacon-transport.js +1 -0
- package/build/esnext/transport/send-beacon-transport.js.map +1 -1
- package/build/esnext/transport/xhr-transport.js +1 -0
- package/build/esnext/transport/xhr-transport.js.map +1 -1
- package/build/esnext/types.js +3 -1
- package/build/esnext/types.js.map +1 -1
- package/build/esnext/util.js +1 -2
- 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.js +1 -0
- package/build/src/OTLPExporterBase.js.map +1 -1
- package/build/src/bounded-queue-export-promise-handler.js +2 -1
- package/build/src/bounded-queue-export-promise-handler.js.map +1 -1
- package/build/src/configuration/convert-legacy-node-http-options.js +1 -1
- package/build/src/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/src/configuration/legacy-node-configuration.d.ts +1 -0
- package/build/src/configuration/otlp-http-configuration.d.ts +1 -0
- package/build/src/configuration/otlp-http-configuration.js +19 -4
- package/build/src/configuration/otlp-http-configuration.js.map +1 -1
- package/build/src/configuration/otlp-http-env-configuration.js +16 -15
- package/build/src/configuration/otlp-http-env-configuration.js.map +1 -1
- package/build/src/configuration/shared-configuration.js +10 -7
- package/build/src/configuration/shared-configuration.js.map +1 -1
- package/build/src/configuration/shared-env-configuration.js +5 -9
- package/build/src/configuration/shared-env-configuration.js.map +1 -1
- package/build/src/export-response.d.ts +1 -1
- package/build/src/otlp-export-delegate.js +6 -0
- package/build/src/otlp-export-delegate.js.map +1 -1
- package/build/src/retrying-transport.js +2 -2
- package/build/src/retrying-transport.js.map +1 -1
- package/build/src/transport/http-exporter-transport.js +18 -14
- package/build/src/transport/http-exporter-transport.js.map +1 -1
- package/build/src/transport/http-transport-types.d.ts +2 -1
- package/build/src/transport/http-transport-utils.d.ts +1 -0
- package/build/src/transport/http-transport-utils.js +4 -2
- package/build/src/transport/http-transport-utils.js.map +1 -1
- package/build/src/transport/send-beacon-transport.js +1 -0
- package/build/src/transport/send-beacon-transport.js.map +1 -1
- package/build/src/transport/xhr-transport.js +1 -0
- package/build/src/transport/xhr-transport.js.map +1 -1
- package/build/src/types.js +3 -1
- package/build/src/types.js.map +1 -1
- package/build/src/util.js +1 -2
- 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 -27
|
@@ -28,6 +28,7 @@ function getJitter() {
|
|
|
28
28
|
return Math.random() * (2 * JITTER) - JITTER;
|
|
29
29
|
}
|
|
30
30
|
class RetryingTransport {
|
|
31
|
+
_transport;
|
|
31
32
|
constructor(_transport) {
|
|
32
33
|
this._transport = _transport;
|
|
33
34
|
}
|
|
@@ -39,7 +40,6 @@ class RetryingTransport {
|
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
async send(data, timeoutMillis) {
|
|
42
|
-
var _a;
|
|
43
43
|
const deadline = Date.now() + timeoutMillis;
|
|
44
44
|
let result = await this._transport.send(data, timeoutMillis);
|
|
45
45
|
let attempts = MAX_ATTEMPTS;
|
|
@@ -49,7 +49,7 @@ class RetryingTransport {
|
|
|
49
49
|
// use maximum of computed backoff and 0 to avoid negative timeouts
|
|
50
50
|
const backoff = Math.max(Math.min(nextBackoff, MAX_BACKOFF) + getJitter(), 0);
|
|
51
51
|
nextBackoff = nextBackoff * BACKOFF_MULTIPLIER;
|
|
52
|
-
const retryInMillis =
|
|
52
|
+
const retryInMillis = result.retryInMillis ?? backoff;
|
|
53
53
|
// return when expected retry time is after the export deadline.
|
|
54
54
|
const remainingTimeoutMillis = deadline - Date.now();
|
|
55
55
|
if (retryInMillis > remainingTimeoutMillis) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrying-transport.js","sourceRoot":"","sources":["../../src/retrying-transport.ts"],"names":[],"mappings":";AAAA;;;;;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IAAI,CAAC,IAAgB,EAAE,aAAqB;QAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC;QAC5C,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC7D,IAAI,QAAQ,GAAG,YAAY,CAAC;QAC5B,IAAI,WAAW,GAAG,eAAe,CAAC;QAElC,OAAO,MAAM,CAAC,MAAM,KAAK,WAAW,IAAI,QAAQ,GAAG,CAAC,EAAE;YACpD,QAAQ,EAAE,CAAC;YAEX,mEAAmE;YACnE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CACtB,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,SAAS,EAAE,EAChD,CAAC,CACF,CAAC;YACF,WAAW,GAAG,WAAW,GAAG,kBAAkB,CAAC;YAC/C,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,OAAO,CAAC;YAEtD,gEAAgE;YAChE,MAAM,sBAAsB,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACrD,IAAI,aAAa,GAAG,sBAAsB,EAAE;gBAC1C,OAAO,MAAM,CAAC;aACf;YAED,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,sBAAsB,EAAE,aAAa,CAAC,CAAC;SACxE;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,SAAgB,uBAAuB,CAAC,OAGvC;IACC,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClD,CAAC;AALD,0DAKC","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';\n\nconst MAX_ATTEMPTS = 5;\nconst INITIAL_BACKOFF = 1000;\nconst MAX_BACKOFF = 5000;\nconst BACKOFF_MULTIPLIER = 1.5;\nconst JITTER = 0.2;\n\n/**\n * Get a pseudo-random jitter that falls in the range of [-JITTER, +JITTER]\n */\nfunction getJitter() {\n return Math.random() * (2 * JITTER) - JITTER;\n}\n\nclass RetryingTransport implements IExporterTransport {\n constructor(private _transport: IExporterTransport) {}\n\n private retry(\n data: Uint8Array,\n timeoutMillis: number,\n inMillis: number\n ): Promise<ExportResponse> {\n return new Promise((resolve, reject) => {\n setTimeout(() => {\n this._transport.send(data, timeoutMillis).then(resolve, reject);\n }, inMillis);\n });\n }\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n const deadline = Date.now() + timeoutMillis;\n let result = await this._transport.send(data, timeoutMillis);\n let attempts = MAX_ATTEMPTS;\n let nextBackoff = INITIAL_BACKOFF;\n\n while (result.status === 'retryable' && attempts > 0) {\n attempts--;\n\n // use maximum of computed backoff and 0 to avoid negative timeouts\n const backoff = Math.max(\n Math.min(nextBackoff, MAX_BACKOFF) + getJitter(),\n 0\n );\n nextBackoff = nextBackoff * BACKOFF_MULTIPLIER;\n const retryInMillis = result.retryInMillis ?? backoff;\n\n // return when expected retry time is after the export deadline.\n const remainingTimeoutMillis = deadline - Date.now();\n if (retryInMillis > remainingTimeoutMillis) {\n return result;\n }\n\n result = await this.retry(data, remainingTimeoutMillis, retryInMillis);\n }\n\n return result;\n }\n\n shutdown() {\n return this._transport.shutdown();\n }\n}\n\n/**\n * Creates an Exporter Transport that retries on 'retryable' response.\n */\nexport function createRetryingTransport(options: {\n // Underlying transport to wrap.\n transport: IExporterTransport;\n}): IExporterTransport {\n return new RetryingTransport(options.transport);\n}\n"]}
|
|
@@ -17,25 +17,15 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.createHttpExporterTransport = void 0;
|
|
19
19
|
class HttpExporterTransport {
|
|
20
|
+
_parameters;
|
|
21
|
+
_utils = null;
|
|
20
22
|
constructor(_parameters) {
|
|
21
23
|
this._parameters = _parameters;
|
|
22
|
-
this._send = null;
|
|
23
|
-
this._agent = null;
|
|
24
24
|
}
|
|
25
25
|
async send(data, timeoutMillis) {
|
|
26
|
-
|
|
27
|
-
// Lazy require to ensure that http/https is not required before instrumentations can wrap it.
|
|
28
|
-
const { sendWithHttp, createHttpAgent,
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
30
|
-
} = require('./http-transport-utils');
|
|
31
|
-
this._agent = createHttpAgent(this._parameters.url, this._parameters.agentOptions);
|
|
32
|
-
this._send = sendWithHttp;
|
|
33
|
-
}
|
|
26
|
+
const { agent, send } = this._loadUtils();
|
|
34
27
|
return new Promise(resolve => {
|
|
35
|
-
|
|
36
|
-
// this will always be defined
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
38
|
-
(_a = this._send) === null || _a === void 0 ? void 0 : _a.call(this, this._parameters, this._agent, data, result => {
|
|
28
|
+
send(this._parameters, agent, data, result => {
|
|
39
29
|
resolve(result);
|
|
40
30
|
}, timeoutMillis);
|
|
41
31
|
});
|
|
@@ -43,6 +33,20 @@ class HttpExporterTransport {
|
|
|
43
33
|
shutdown() {
|
|
44
34
|
// intentionally left empty, nothing to do.
|
|
45
35
|
}
|
|
36
|
+
_loadUtils() {
|
|
37
|
+
let utils = this._utils;
|
|
38
|
+
if (utils === null) {
|
|
39
|
+
// Lazy require to ensure that http/https is not required before instrumentations can wrap it.
|
|
40
|
+
const { sendWithHttp, createHttpAgent,
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
42
|
+
} = require('./http-transport-utils');
|
|
43
|
+
utils = this._utils = {
|
|
44
|
+
agent: createHttpAgent(this._parameters.url, this._parameters.agentOptions),
|
|
45
|
+
send: sendWithHttp,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return utils;
|
|
49
|
+
}
|
|
46
50
|
}
|
|
47
51
|
function createHttpExporterTransport(parameters) {
|
|
48
52
|
return new HttpExporterTransport(parameters);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-exporter-transport.js","sourceRoot":"","sources":["../../../src/transport/http-exporter-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;
|
|
1
|
+
{"version":3,"file":"http-exporter-transport.js","sourceRoot":"","sources":["../../../src/transport/http-exporter-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAmBH,MAAM,qBAAqB;IAGL;IAFZ,MAAM,GAAiB,IAAI,CAAC;IAEpC,YAAoB,WAAkC;QAAlC,gBAAW,GAAX,WAAW,CAAuB;IAAG,CAAC;IAE1D,KAAK,CAAC,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAChD,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAE1C,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3C,IAAI,CACF,IAAI,CAAC,WAAW,EAChB,KAAK,EACL,IAAI,EACJ,MAAM,CAAC,EAAE;gBACP,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,EACD,aAAa,CACd,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;IAEO,UAAU;QAChB,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAExB,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,8FAA8F;YAC9F,MAAM,EACJ,YAAY,EACZ,eAAe;YACf,8DAA8D;cAC/D,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;YAEtC,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG;gBACpB,KAAK,EAAE,eAAe,CACpB,IAAI,CAAC,WAAW,CAAC,GAAG,EACpB,IAAI,CAAC,WAAW,CAAC,YAAY,CAC9B;gBACD,IAAI,EAAE,YAAY;aACnB,CAAC;SACH;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,SAAgB,2BAA2B,CACzC,UAAiC;IAEjC,OAAO,IAAI,qBAAqB,CAAC,UAAU,CAAC,CAAC;AAC/C,CAAC;AAJD,kEAIC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n HttpRequestParameters,\n sendWithHttp,\n} from './http-transport-types';\n\n// NOTE: do not change these type imports to actual imports. Doing so WILL break `@opentelemetry/instrumentation-http`,\n// as they'd be imported before the http/https modules can be wrapped.\nimport type * as https from 'https';\nimport type * as http from 'http';\nimport { ExportResponse } from '../export-response';\nimport { IExporterTransport } from '../exporter-transport';\n\ninterface Utils {\n agent: http.Agent | https.Agent;\n send: sendWithHttp;\n}\n\nclass HttpExporterTransport implements IExporterTransport {\n private _utils: Utils | null = null;\n\n constructor(private _parameters: HttpRequestParameters) {}\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n const { agent, send } = this._loadUtils();\n\n return new Promise<ExportResponse>(resolve => {\n send(\n this._parameters,\n agent,\n data,\n result => {\n resolve(result);\n },\n timeoutMillis\n );\n });\n }\n\n shutdown() {\n // intentionally left empty, nothing to do.\n }\n\n private _loadUtils(): Utils {\n let utils = this._utils;\n\n if (utils === null) {\n // Lazy require to ensure that http/https is not required before instrumentations can wrap it.\n const {\n sendWithHttp,\n createHttpAgent,\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n } = require('./http-transport-utils');\n\n utils = this._utils = {\n agent: createHttpAgent(\n this._parameters.url,\n this._parameters.agentOptions\n ),\n send: sendWithHttp,\n };\n }\n\n return utils;\n }\n}\n\nexport function createHttpExporterTransport(\n parameters: HttpRequestParameters\n): IExporterTransport {\n return new HttpExporterTransport(parameters);\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import type * as http from 'http';
|
|
3
4
|
import type * as https from 'https';
|
|
4
5
|
import { ExportResponse } from '../export-response';
|
|
5
|
-
export
|
|
6
|
+
export type sendWithHttp = (params: HttpRequestParameters, agent: http.Agent | https.Agent, data: Uint8Array, onDone: (response: ExportResponse) => void, timeoutMillis: number) => void;
|
|
6
7
|
export interface HttpRequestParameters {
|
|
7
8
|
url: string;
|
|
8
9
|
headers: () => Record<string, string>;
|
|
@@ -38,7 +38,9 @@ function sendWithHttp(params, agent, data, onDone, timeoutMillis) {
|
|
|
38
38
|
port: parsedUrl.port,
|
|
39
39
|
path: parsedUrl.pathname,
|
|
40
40
|
method: 'POST',
|
|
41
|
-
headers:
|
|
41
|
+
headers: {
|
|
42
|
+
...params.headers(),
|
|
43
|
+
},
|
|
42
44
|
agent: agent,
|
|
43
45
|
};
|
|
44
46
|
const request = parsedUrl.protocol === 'http:' ? http.request : https.request;
|
|
@@ -77,7 +79,7 @@ function sendWithHttp(params, agent, data, onDone, timeoutMillis) {
|
|
|
77
79
|
req.on('error', (error) => {
|
|
78
80
|
onDone({
|
|
79
81
|
status: 'failure',
|
|
80
|
-
error
|
|
82
|
+
error,
|
|
81
83
|
});
|
|
82
84
|
});
|
|
83
85
|
const reportTimeoutErrorEvent = nodeVersion >= 14 ? 'close' : 'abort';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,6BAA6B;AAC7B,+BAA+B;AAC/B,6BAA6B;AAC7B,mCAAkC;AAGlC,gEAGgC;AAChC,oCAA6C;AAE7C;;;;;;;GAOG;AACH,SAAgB,YAAY,CAC1B,MAA6B,EAC7B,KAA+B,EAC/B,IAAgB,EAChB,MAA0C,EAC1C,aAAqB;IAErB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhE,MAAM,OAAO,GAA+C;QAC1D,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,IAAI,EAAE,SAAS,CAAC,QAAQ;QACxB,MAAM,EAAE,MAAM;QACd,OAAO,
|
|
1
|
+
{"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,6BAA6B;AAC7B,+BAA+B;AAC/B,6BAA6B;AAC7B,mCAAkC;AAGlC,gEAGgC;AAChC,oCAA6C;AAE7C;;;;;;;GAOG;AACH,SAAgB,YAAY,CAC1B,MAA6B,EAC7B,KAA+B,EAC/B,IAAgB,EAChB,MAA0C,EAC1C,aAAqB;IAErB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ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AAI,CAAC,CAAC;IAE9C,IAAI,WAAW,KAAK,MAAM,EAAE;QAC1B,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAC1C,UAAU,GAAG,UAAU;aACpB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;aACpB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;aACvB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KACzB;IAED,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAjBD,0CAiBC;AAED,SAAS,sBAAsB,CAAC,IAAyB;IACvD,MAAM,QAAQ,GAAG,IAAI,iBAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEpB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,eAAe,CAC7B,MAAc,EACd,YAAoD;IAEpD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;IACxE,OAAO,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AACjC,CAAC;AAPD,0CAOC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport * as http from 'http';\nimport * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport { HttpRequestParameters } from './http-transport-types';\nimport { ExportResponse } from '../export-response';\nimport {\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../is-export-retryable';\nimport { OTLPExporterError } from '../types';\n\n/**\n * Sends data using http\n * @param params\n * @param agent\n * @param data\n * @param onDone\n * @param timeoutMillis\n */\nexport function sendWithHttp(\n params: HttpRequestParameters,\n agent: http.Agent | https.Agent,\n data: Uint8Array,\n onDone: (response: ExportResponse) => void,\n timeoutMillis: number\n): void {\n const parsedUrl = new URL(params.url);\n const nodeVersion = Number(process.versions.node.split('.')[0]);\n\n const options: http.RequestOptions | https.RequestOptions = {\n hostname: parsedUrl.hostname,\n port: parsedUrl.port,\n path: parsedUrl.pathname,\n method: 'POST',\n headers: {\n ...params.headers(),\n },\n agent: agent,\n };\n\n const request = parsedUrl.protocol === 'http:' ? http.request : https.request;\n\n const req = request(options, (res: http.IncomingMessage) => {\n const responseData: Buffer[] = [];\n res.on('data', chunk => responseData.push(chunk));\n\n res.on('end', () => {\n if (res.statusCode && res.statusCode < 299) {\n onDone({\n status: 'success',\n data: Buffer.concat(responseData),\n });\n } else if (res.statusCode && isExportRetryable(res.statusCode)) {\n onDone({\n status: 'retryable',\n retryInMillis: parseRetryAfterToMills(res.headers['retry-after']),\n });\n } else {\n const error = new OTLPExporterError(\n res.statusMessage,\n res.statusCode,\n Buffer.concat(responseData).toString()\n );\n onDone({\n status: 'failure',\n error,\n });\n }\n });\n });\n\n req.setTimeout(timeoutMillis, () => {\n req.destroy();\n onDone({\n status: 'failure',\n error: new Error('Request Timeout'),\n });\n });\n req.on('error', (error: Error) => {\n onDone({\n status: 'failure',\n error,\n });\n });\n\n const reportTimeoutErrorEvent = nodeVersion >= 14 ? 'close' : 'abort';\n req.on(reportTimeoutErrorEvent, () => {\n onDone({\n status: 'failure',\n error: new Error('Request timed out'),\n });\n });\n\n compressAndSend(req, params.compression, data, (error: Error) => {\n onDone({\n status: 'failure',\n error,\n });\n });\n}\n\nexport function compressAndSend(\n req: http.ClientRequest,\n compression: 'gzip' | 'none',\n data: Uint8Array,\n onError: (error: Error) => void\n) {\n let dataStream = readableFromUint8Array(data);\n\n if (compression === 'gzip') {\n req.setHeader('Content-Encoding', 'gzip');\n dataStream = dataStream\n .on('error', onError)\n .pipe(zlib.createGzip())\n .on('error', onError);\n }\n\n dataStream.pipe(req).on('error', onError);\n}\n\nfunction readableFromUint8Array(buff: string | Uint8Array): Readable {\n const readable = new Readable();\n readable.push(buff);\n readable.push(null);\n\n return readable;\n}\n\nexport function createHttpAgent(\n rawUrl: string,\n agentOptions: http.AgentOptions | https.AgentOptions\n) {\n const parsedUrl = new URL(rawUrl);\n const Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent;\n return new Agent(agentOptions);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-beacon-transport.js","sourceRoot":"","sources":["../../../src/transport/send-beacon-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,4CAA0C;AAU1C,MAAM,mBAAmB;
|
|
1
|
+
{"version":3,"file":"send-beacon-transport.js","sourceRoot":"","sources":["../../../src/transport/send-beacon-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,4CAA0C;AAU1C,MAAM,mBAAmB;IACH;IAApB,YAAoB,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;IAAG,CAAC;IACrD,IAAI,CAAC,IAAgB;QACnB,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3C,IACE,SAAS,CAAC,UAAU,CAClB,IAAI,CAAC,OAAO,CAAC,GAAG,EAChB,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAClD,EACD;gBACA,sDAAsD;gBACtD,UAAI,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,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;AAED,SAAgB,yBAAyB,CACvC,UAAgC;IAEhC,OAAO,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAC7C,CAAC;AAJD,8DAIC","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"]}
|
|
@@ -19,6 +19,7 @@ exports.createXhrTransport = void 0;
|
|
|
19
19
|
const api_1 = require("@opentelemetry/api");
|
|
20
20
|
const is_export_retryable_1 = require("../is-export-retryable");
|
|
21
21
|
class XhrTransport {
|
|
22
|
+
_parameters;
|
|
22
23
|
constructor(_parameters) {
|
|
23
24
|
this._parameters = _parameters;
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xhr-transport.js","sourceRoot":"","sources":["../../../src/transport/xhr-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,4CAA0C;AAC1C,gEAGgC;AAOhC,MAAM,YAAY;
|
|
1
|
+
{"version":3,"file":"xhr-transport.js","sourceRoot":"","sources":["../../../src/transport/xhr-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,4CAA0C;AAC1C,gEAGgC;AAOhC,MAAM,YAAY;IACI;IAApB,YAAoB,WAAiC;QAAjC,gBAAW,GAAX,WAAW,CAAsB;IAAG,CAAC;IAEzD,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAC1C,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3C,MAAM,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;YACjC,GAAG,CAAC,OAAO,GAAG,aAAa,CAAC;YAC5B,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACvC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAC3C,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;gBACzC,GAAG,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YA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AEF,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAChC,UAAgC;IAEhC,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AAJD,gDAIC","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 const headers = this._parameters.headers();\n Object.entries(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(data);\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"]}
|
package/build/src/types.js
CHANGED
|
@@ -20,9 +20,11 @@ exports.OTLPExporterError = void 0;
|
|
|
20
20
|
* Interface for handling error
|
|
21
21
|
*/
|
|
22
22
|
class OTLPExporterError extends Error {
|
|
23
|
+
code;
|
|
24
|
+
name = 'OTLPExporterError';
|
|
25
|
+
data;
|
|
23
26
|
constructor(message, code, data) {
|
|
24
27
|
super(message);
|
|
25
|
-
this.name = 'OTLPExporterError';
|
|
26
28
|
this.data = data;
|
|
27
29
|
this.code = code;
|
|
28
30
|
}
|
package/build/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IACjC,IAAI,CAAU;IACL,IAAI,GAAW,mBAAmB,CAAC;IAC5C,IAAI,CAAU;IAEvB,YAAY,OAAgB,EAAE,IAAa,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAVD,8CAUC","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/**\n * Interface for handling error\n */\nexport class OTLPExporterError extends Error {\n readonly code?: number;\n override readonly name: string = 'OTLPExporterError';\n readonly data?: string;\n\n constructor(message?: string, code?: number, data?: string) {\n super(message);\n this.data = data;\n this.code = code;\n }\n}\n\n/**\n * Interface for handling export service errors\n */\nexport interface ExportServiceError {\n name: string;\n code: number;\n details: string;\n metadata: { [key: string]: unknown };\n message: string;\n stack: string;\n}\n"]}
|
package/build/src/util.js
CHANGED
|
@@ -23,9 +23,8 @@ const api_1 = require("@opentelemetry/api");
|
|
|
23
23
|
*/
|
|
24
24
|
function validateAndNormalizeHeaders(partialHeaders) {
|
|
25
25
|
return () => {
|
|
26
|
-
var _a;
|
|
27
26
|
const headers = {};
|
|
28
|
-
Object.entries(
|
|
27
|
+
Object.entries(partialHeaders?.() ?? {}).forEach(([key, value]) => {
|
|
29
28
|
if (typeof value !== 'undefined') {
|
|
30
29
|
headers[key] = String(value);
|
|
31
30
|
}
|
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;AAE1C;;;GAGG;AACH,SAAgB,2BAA2B,CACzC,cAA0D;IAE1D,OAAO,GAAG,EAAE
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAE1C;;;GAGG;AACH,SAAgB,2BAA2B,CACzC,cAA0D;IAE1D,OAAO,GAAG,EAAE;QACV,MAAM,OAAO,GAA2B,EAAE,CAAC;QAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAChE,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;gBAChC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;aAC9B;iBAAM;gBACL,UAAI,CAAC,IAAI,CACP,WAAW,GAAG,wBAAwB,KAAK,uBAAuB,CACnE,CAAC;aACH;QACH,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC;AAhBD,kEAgBC","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: (() => Record<string, string>) | undefined\n): () => Record<string, string> {\n return () => {\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}\n"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.200.0-dev.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.VERSION = void 0;
|
|
19
19
|
// this is autogenerated file, see scripts/version-update.js
|
|
20
|
-
exports.VERSION = '0.
|
|
20
|
+
exports.VERSION = '0.200.0-dev.1';
|
|
21
21
|
//# sourceMappingURL=version.js.map
|
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,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,eAAe,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.200.0-dev.1';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/otlp-exporter-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.200.0-dev.1",
|
|
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",
|
|
@@ -26,19 +26,6 @@
|
|
|
26
26
|
"default": "./build/src/index-browser-http.js"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
"typesVersions": {
|
|
30
|
-
"*": {
|
|
31
|
-
"*": [
|
|
32
|
-
"./build/src/index.d.ts"
|
|
33
|
-
],
|
|
34
|
-
"node-http": [
|
|
35
|
-
"./build/src/index-node-http.d.ts"
|
|
36
|
-
],
|
|
37
|
-
"browser-http": [
|
|
38
|
-
"./build/src/index-browser-http.d.ts"
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
29
|
"repository": "open-telemetry/opentelemetry-js",
|
|
43
30
|
"scripts": {
|
|
44
31
|
"prepublishOnly": "npm run compile",
|
|
@@ -68,7 +55,7 @@
|
|
|
68
55
|
"author": "OpenTelemetry Authors",
|
|
69
56
|
"license": "Apache-2.0",
|
|
70
57
|
"engines": {
|
|
71
|
-
"node": ">=
|
|
58
|
+
"node": "^18.19.0 || >=20.6.0"
|
|
72
59
|
},
|
|
73
60
|
"files": [
|
|
74
61
|
"build/esm/**/*.js",
|
|
@@ -87,16 +74,16 @@
|
|
|
87
74
|
"access": "public"
|
|
88
75
|
},
|
|
89
76
|
"dependencies": {
|
|
90
|
-
"@opentelemetry/core": "
|
|
91
|
-
"@opentelemetry/otlp-transformer": "0.
|
|
77
|
+
"@opentelemetry/core": "2.0.0-dev.1",
|
|
78
|
+
"@opentelemetry/otlp-transformer": "0.200.0-dev.1"
|
|
92
79
|
},
|
|
93
80
|
"devDependencies": {
|
|
94
|
-
"@babel/core": "7.26.
|
|
95
|
-
"@babel/preset-env": "7.26.
|
|
81
|
+
"@babel/core": "7.26.9",
|
|
82
|
+
"@babel/preset-env": "7.26.9",
|
|
96
83
|
"@opentelemetry/api": "1.9.0",
|
|
97
84
|
"@types/mocha": "10.0.10",
|
|
98
85
|
"@types/node": "18.6.5",
|
|
99
|
-
"@types/sinon": "17.0.
|
|
86
|
+
"@types/sinon": "17.0.4",
|
|
100
87
|
"babel-plugin-istanbul": "7.0.0",
|
|
101
88
|
"cross-var": "1.1.0",
|
|
102
89
|
"karma": "6.4.4",
|
|
@@ -106,19 +93,18 @@
|
|
|
106
93
|
"karma-spec-reporter": "0.0.36",
|
|
107
94
|
"karma-webpack": "5.0.1",
|
|
108
95
|
"lerna": "6.6.2",
|
|
109
|
-
"mocha": "
|
|
110
|
-
"nyc": "
|
|
96
|
+
"mocha": "11.1.0",
|
|
97
|
+
"nyc": "17.1.0",
|
|
111
98
|
"sinon": "15.1.2",
|
|
112
|
-
"ts-loader": "9.5.
|
|
113
|
-
"typescript": "
|
|
99
|
+
"ts-loader": "9.5.2",
|
|
100
|
+
"typescript": "5.0.4",
|
|
114
101
|
"webpack": "5.96.1",
|
|
115
|
-
"webpack-cli": "
|
|
116
|
-
"webpack-merge": "5.10.0"
|
|
102
|
+
"webpack-cli": "6.0.1"
|
|
117
103
|
},
|
|
118
104
|
"peerDependencies": {
|
|
119
105
|
"@opentelemetry/api": "^1.3.0"
|
|
120
106
|
},
|
|
121
107
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/otlp-exporter-base",
|
|
122
108
|
"sideEffects": false,
|
|
123
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "92fde6aa77e464ee85c4a18f279fe12294f625d1"
|
|
124
110
|
}
|