@opentelemetry/otlp-exporter-base 0.207.0 → 0.208.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/configuration/convert-legacy-browser-http-options.js +2 -2
- package/build/esm/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/build/esm/configuration/convert-legacy-http-options.d.ts +4 -0
- package/build/esm/configuration/convert-legacy-http-options.js +23 -0
- package/build/esm/configuration/convert-legacy-http-options.js.map +1 -0
- package/build/esm/configuration/convert-legacy-node-http-options.js +2 -2
- package/build/esm/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/esm/configuration/legacy-base-configuration.d.ts +26 -1
- package/build/esm/configuration/legacy-base-configuration.js.map +1 -1
- package/build/esm/configuration/otlp-http-configuration.d.ts +2 -1
- package/build/esm/configuration/otlp-http-configuration.js +9 -9
- package/build/esm/configuration/otlp-http-configuration.js.map +1 -1
- package/build/esm/configuration/shared-configuration.d.ts +2 -1
- package/build/esm/configuration/shared-configuration.js +1 -1
- package/build/esm/configuration/shared-configuration.js.map +1 -1
- package/build/esm/otlp-browser-http-export-delegate.js +1 -1
- package/build/esm/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/esm/transport/fetch-transport.d.ts +2 -1
- package/build/esm/transport/fetch-transport.js +1 -1
- package/build/esm/transport/fetch-transport.js.map +1 -1
- package/build/esm/transport/http-exporter-transport.js +2 -1
- 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-types.js.map +1 -1
- package/build/esm/transport/http-transport-utils.d.ts +1 -2
- package/build/esm/transport/http-transport-utils.js +5 -6
- package/build/esm/transport/http-transport-utils.js.map +1 -1
- package/build/esm/transport/send-beacon-transport.d.ts +4 -2
- package/build/esm/transport/send-beacon-transport.js +3 -2
- package/build/esm/transport/send-beacon-transport.js.map +1 -1
- package/build/esm/transport/xhr-transport.d.ts +2 -1
- package/build/esm/transport/xhr-transport.js +4 -3
- package/build/esm/transport/xhr-transport.js.map +1 -1
- package/build/esm/util.d.ts +1 -1
- package/build/esm/util.js +10 -12
- 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/configuration/convert-legacy-browser-http-options.js +2 -2
- package/build/esnext/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/build/esnext/configuration/convert-legacy-http-options.d.ts +4 -0
- package/build/esnext/configuration/convert-legacy-http-options.js +23 -0
- package/build/esnext/configuration/convert-legacy-http-options.js.map +1 -0
- package/build/esnext/configuration/convert-legacy-node-http-options.js +2 -2
- package/build/esnext/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/esnext/configuration/legacy-base-configuration.d.ts +26 -1
- package/build/esnext/configuration/legacy-base-configuration.js.map +1 -1
- package/build/esnext/configuration/otlp-http-configuration.d.ts +2 -1
- package/build/esnext/configuration/otlp-http-configuration.js +9 -9
- package/build/esnext/configuration/otlp-http-configuration.js.map +1 -1
- package/build/esnext/configuration/shared-configuration.d.ts +2 -1
- package/build/esnext/configuration/shared-configuration.js +1 -1
- package/build/esnext/configuration/shared-configuration.js.map +1 -1
- package/build/esnext/otlp-browser-http-export-delegate.js +1 -1
- package/build/esnext/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/esnext/transport/fetch-transport.d.ts +2 -1
- package/build/esnext/transport/fetch-transport.js +1 -1
- package/build/esnext/transport/fetch-transport.js.map +1 -1
- package/build/esnext/transport/http-exporter-transport.js +2 -1
- 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-types.js.map +1 -1
- package/build/esnext/transport/http-transport-utils.d.ts +1 -2
- package/build/esnext/transport/http-transport-utils.js +5 -6
- package/build/esnext/transport/http-transport-utils.js.map +1 -1
- package/build/esnext/transport/send-beacon-transport.d.ts +4 -2
- package/build/esnext/transport/send-beacon-transport.js +3 -2
- package/build/esnext/transport/send-beacon-transport.js.map +1 -1
- package/build/esnext/transport/xhr-transport.d.ts +2 -1
- package/build/esnext/transport/xhr-transport.js +4 -3
- package/build/esnext/transport/xhr-transport.js.map +1 -1
- package/build/esnext/util.d.ts +1 -1
- package/build/esnext/util.js +10 -12
- 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/configuration/convert-legacy-browser-http-options.js +2 -2
- package/build/src/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/build/src/configuration/convert-legacy-http-options.d.ts +4 -0
- package/build/src/configuration/convert-legacy-http-options.js +27 -0
- package/build/src/configuration/convert-legacy-http-options.js.map +1 -0
- package/build/src/configuration/convert-legacy-node-http-options.js +2 -2
- package/build/src/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/src/configuration/legacy-base-configuration.d.ts +26 -1
- package/build/src/configuration/legacy-base-configuration.js.map +1 -1
- package/build/src/configuration/otlp-http-configuration.d.ts +2 -1
- package/build/src/configuration/otlp-http-configuration.js +9 -9
- package/build/src/configuration/otlp-http-configuration.js.map +1 -1
- package/build/src/configuration/shared-configuration.d.ts +2 -1
- package/build/src/configuration/shared-configuration.js +1 -1
- package/build/src/configuration/shared-configuration.js.map +1 -1
- package/build/src/otlp-browser-http-export-delegate.js +1 -1
- package/build/src/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/src/transport/fetch-transport.d.ts +2 -1
- package/build/src/transport/fetch-transport.js +1 -1
- package/build/src/transport/fetch-transport.js.map +1 -1
- package/build/src/transport/http-exporter-transport.js +2 -1
- 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-types.js.map +1 -1
- package/build/src/transport/http-transport-utils.d.ts +1 -2
- package/build/src/transport/http-transport-utils.js +5 -6
- package/build/src/transport/http-transport-utils.js.map +1 -1
- package/build/src/transport/send-beacon-transport.d.ts +4 -2
- package/build/src/transport/send-beacon-transport.js +3 -2
- package/build/src/transport/send-beacon-transport.js.map +1 -1
- package/build/src/transport/xhr-transport.d.ts +2 -1
- package/build/src/transport/xhr-transport.js +4 -3
- package/build/src/transport/xhr-transport.js.map +1 -1
- package/build/src/util.d.ts +1 -1
- package/build/src/util.js +10 -12
- 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 +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.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 type * as http from 'http';\nimport type * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport { ExportResponse } from '../export-response';\nimport {\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../is-export-retryable';\nimport { OTLPExporterError } from '../types';\nimport { VERSION } from '../version';\n\nconst DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION}`;\n\n/**\n * Sends data using http\n * @param request\n * @param params\n * @param agent\n * @param data\n * @param onDone\n * @param timeoutMillis\n */\nexport function sendWithHttp(\n request: typeof https.request | typeof http.request,\n url: string,\n headers: Record<string, string>,\n compression: 'gzip' | 'none',\n userAgent: string | undefined,\n agent: http.Agent | https.Agent,\n data: Uint8Array,\n onDone: (response: ExportResponse) => void,\n timeoutMillis: number\n): void {\n const parsedUrl = new URL(url);\n\n if (userAgent) {\n headers['User-Agent'] = `${userAgent} ${DEFAULT_USER_AGENT}`;\n } else {\n headers['User-Agent'] = DEFAULT_USER_AGENT;\n }\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 agent,\n };\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\n req.on('error', (error: Error) => {\n onDone({\n status: 'failure',\n error,\n });\n });\n\n compressAndSend(req, 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"]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { IExporterTransport } from '../exporter-transport';
|
|
2
|
+
import { HeadersFactory } from '../configuration/otlp-http-configuration';
|
|
2
3
|
export interface SendBeaconParameters {
|
|
3
4
|
url: string;
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
+
* Only `Content-Type` will be used, sendBeacon does not support custom headers
|
|
7
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
|
|
6
8
|
*/
|
|
7
|
-
|
|
9
|
+
headers: HeadersFactory;
|
|
8
10
|
}
|
|
9
11
|
export declare function createSendBeaconTransport(parameters: SendBeaconParameters): IExporterTransport;
|
|
10
12
|
//# sourceMappingURL=send-beacon-transport.d.ts.map
|
|
@@ -19,9 +19,10 @@ class SendBeaconTransport {
|
|
|
19
19
|
constructor(_params) {
|
|
20
20
|
this._params = _params;
|
|
21
21
|
}
|
|
22
|
-
send(data) {
|
|
22
|
+
async send(data) {
|
|
23
|
+
const blobType = (await this._params.headers())['Content-Type'];
|
|
23
24
|
return new Promise(resolve => {
|
|
24
|
-
if (navigator.sendBeacon(this._params.url, new Blob([data], { type:
|
|
25
|
+
if (navigator.sendBeacon(this._params.url, new Blob([data], { type: blobType }))) {
|
|
25
26
|
// no way to signal retry, treat everything as success
|
|
26
27
|
diag.debug('SendBeacon success');
|
|
27
28
|
resolve({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-beacon-transport.js","sourceRoot":"","sources":["../../../src/transport/send-beacon-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"send-beacon-transport.js","sourceRoot":"","sources":["../../../src/transport/send-beacon-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAY1C,MAAM,mBAAmB;IACH;IAApB,YAAoB,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;IAAG,CAAC;IACrD,KAAK,CAAC,IAAI,CAAC,IAAgB;QACzB,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC;QAChE,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,QAAQ,EAAE,CAAC,CACrC,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,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;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';\nimport { HeadersFactory } from '../configuration/otlp-http-configuration';\n\nexport interface SendBeaconParameters {\n url: string;\n /**\n * Only `Content-Type` will be used, sendBeacon does not support custom headers\n * https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon\n */\n headers: HeadersFactory;\n}\n\nclass SendBeaconTransport implements IExporterTransport {\n constructor(private _params: SendBeaconParameters) {}\n async send(data: Uint8Array): Promise<ExportResponse> {\n const blobType = (await this._params.headers())['Content-Type'];\n return new Promise<ExportResponse>(resolve => {\n if (\n navigator.sendBeacon(\n this._params.url,\n new Blob([data], { type: 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"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IExporterTransport } from '../exporter-transport';
|
|
2
|
+
import { HeadersFactory } from '../configuration/otlp-http-configuration';
|
|
2
3
|
/**
|
|
3
4
|
* @deprecated favor the fetch transport
|
|
4
5
|
* @see {@link createFetchTransport}
|
|
5
6
|
*/
|
|
6
7
|
export interface XhrRequestParameters {
|
|
7
8
|
url: string;
|
|
8
|
-
headers:
|
|
9
|
+
headers: HeadersFactory;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* @deprecated use {@link createFetchTransport} instead
|
|
@@ -20,12 +20,12 @@ class XhrTransport {
|
|
|
20
20
|
constructor(_parameters) {
|
|
21
21
|
this._parameters = _parameters;
|
|
22
22
|
}
|
|
23
|
-
send(data, timeoutMillis) {
|
|
24
|
-
|
|
23
|
+
async send(data, timeoutMillis) {
|
|
24
|
+
const headers = await this._parameters.headers();
|
|
25
|
+
const response = await new Promise(resolve => {
|
|
25
26
|
const xhr = new XMLHttpRequest();
|
|
26
27
|
xhr.timeout = timeoutMillis;
|
|
27
28
|
xhr.open('POST', this._parameters.url);
|
|
28
|
-
const headers = this._parameters.headers();
|
|
29
29
|
Object.entries(headers).forEach(([k, v]) => {
|
|
30
30
|
xhr.setRequestHeader(k, v);
|
|
31
31
|
});
|
|
@@ -69,6 +69,7 @@ class XhrTransport {
|
|
|
69
69
|
};
|
|
70
70
|
xhr.send(data);
|
|
71
71
|
});
|
|
72
|
+
return response;
|
|
72
73
|
}
|
|
73
74
|
shutdown() {
|
|
74
75
|
// Intentionally left empty, nothing to do.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xhr-transport.js","sourceRoot":"","sources":["../../../src/transport/xhr-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"xhr-transport.js","sourceRoot":"","sources":["../../../src/transport/xhr-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAchC,MAAM,YAAY;IACI;IAApB,YAAoB,WAAiC;QAAjC,gBAAW,GAAX,WAAW,CAAsB;IAAG,CAAC;IAEzD,KAAK,CAAC,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAChD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QACjD,MAAM,QAAQ,GAAG,MAAM,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3D,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,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;YAC7B,CAAC,CAAC,CAAC;YAEH,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE;gBAClB,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,uBAAuB,CAAC;iBAC1C,CAAC,CAAC;YACL,CAAC,CAAC;YAEF,GAAG,CAAC,kBAAkB,GAAG,GAAG,EAAE;gBAC5B,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE;oBAC1C,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;oBAC1B,OAAO,CAAC;wBACN,MAAM,EAAE,SAAS;qBAClB,CAAC,CAAC;iBACJ;qBAAM,IAAI,GAAG,CAAC,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oBACtD,OAAO,CAAC;wBACN,MAAM,EAAE,WAAW;wBACnB,aAAa,EAAE,sBAAsB,CACnC,GAAG,CAAC,iBAAiB,CAAC,aAAa,CAAC,CACrC;qBACF,CAAC,CAAC;iBACJ;qBAAM,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;oBAC3B,OAAO,CAAC;wBACN,MAAM,EAAE,SAAS;wBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,8CAA8C,CAAC;qBACjE,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC;YAEF,GAAG,CAAC,OAAO,GAAG,GAAG,EAAE;gBACjB,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,GAAG,EAAE;gBACjB,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,qBAAqB,CAAC;iBACxC,CAAC,CAAC;YACL,CAAC,CAAC;YAEF,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;AAED;;;;;GAKG;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// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { createFetchTransport } from './fetch-transport';\nimport { HeadersFactory } from '../configuration/otlp-http-configuration';\n\n/**\n * @deprecated favor the fetch transport\n * @see {@link createFetchTransport}\n */\nexport interface XhrRequestParameters {\n url: string;\n headers: HeadersFactory;\n}\n\nclass XhrTransport implements IExporterTransport {\n constructor(private _parameters: XhrRequestParameters) {}\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n const headers = await this._parameters.headers();\n const response = await new Promise<ExportResponse>(resolve => {\n const xhr = new XMLHttpRequest();\n xhr.timeout = timeoutMillis;\n xhr.open('POST', this._parameters.url);\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 return response;\n }\n\n shutdown() {\n // Intentionally left empty, nothing to do.\n }\n}\n\n/**\n * @deprecated use {@link createFetchTransport} instead\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/esnext/util.d.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Parses headers from config leaving only those that have defined values
|
|
3
3
|
* @param partialHeaders
|
|
4
4
|
*/
|
|
5
|
-
export declare function validateAndNormalizeHeaders(partialHeaders:
|
|
5
|
+
export declare function validateAndNormalizeHeaders(partialHeaders: Record<string, string> | undefined): Record<string, string>;
|
|
6
6
|
//# sourceMappingURL=util.d.ts.map
|
package/build/esnext/util.js
CHANGED
|
@@ -19,17 +19,15 @@ import { diag } from '@opentelemetry/api';
|
|
|
19
19
|
* @param partialHeaders
|
|
20
20
|
*/
|
|
21
21
|
export function validateAndNormalizeHeaders(partialHeaders) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return headers;
|
|
33
|
-
};
|
|
22
|
+
const headers = {};
|
|
23
|
+
Object.entries(partialHeaders ?? {}).forEach(([key, value]) => {
|
|
24
|
+
if (typeof value !== 'undefined') {
|
|
25
|
+
headers[key] = String(value);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
diag.warn(`Header "${key}" has invalid value (${value}) and will be ignored`);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return headers;
|
|
34
32
|
}
|
|
35
33
|
//# sourceMappingURL=util.js.map
|
package/build/esnext/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,cAAkD;IAElD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC5D,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;SAC9B;aAAM;YACL,IAAI,CAAC,IAAI,CACP,WAAW,GAAG,wBAAwB,KAAK,uBAAuB,CACnE,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,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 { 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 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"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.208.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/esnext/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,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.208.0';\n"]}
|
|
@@ -17,7 +17,7 @@ exports.convertLegacyBrowserHttpOptions = void 0;
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
const otlp_http_configuration_1 = require("./otlp-http-configuration");
|
|
20
|
-
const
|
|
20
|
+
const convert_legacy_http_options_1 = require("./convert-legacy-http-options");
|
|
21
21
|
/**
|
|
22
22
|
* @deprecated this will be removed in 2.0
|
|
23
23
|
*
|
|
@@ -29,7 +29,7 @@ function convertLegacyBrowserHttpOptions(config, signalResourcePath, requiredHea
|
|
|
29
29
|
return (0, otlp_http_configuration_1.mergeOtlpHttpConfigurationWithDefaults)({
|
|
30
30
|
url: config.url,
|
|
31
31
|
timeoutMillis: config.timeoutMillis,
|
|
32
|
-
headers: (0,
|
|
32
|
+
headers: (0, convert_legacy_http_options_1.convertLegacyHeaders)(config),
|
|
33
33
|
concurrencyLimit: config.concurrencyLimit,
|
|
34
34
|
}, {}, // no fallback for browser case
|
|
35
35
|
(0, otlp_http_configuration_1.getHttpConfigurationDefaults)(requiredHeaders, signalResourcePath));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-legacy-browser-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-browser-http-options.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,uEAImC;AAEnC
|
|
1
|
+
{"version":3,"file":"convert-legacy-browser-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-browser-http-options.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,uEAImC;AAEnC,+EAAqE;AAErE;;;;;;GAMG;AACH,SAAgB,+BAA+B,CAC7C,MAAkC,EAClC,kBAA0B,EAC1B,eAAuC;IAEvC,OAAO,IAAA,gEAAsC,EAC3C;QACE,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,OAAO,EAAE,IAAA,kDAAoB,EAAC,MAAM,CAAC;QACrC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,EACD,EAAE,EAAE,+BAA+B;IACnC,IAAA,sDAA4B,EAAC,eAAe,EAAE,kBAAkB,CAAC,CAClE,CAAC;AACJ,CAAC;AAfD,0EAeC","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 {\n getHttpConfigurationDefaults,\n mergeOtlpHttpConfigurationWithDefaults,\n OtlpHttpConfiguration,\n} from './otlp-http-configuration';\nimport { OTLPExporterNodeConfigBase } from './legacy-node-configuration';\nimport { convertLegacyHeaders } from './convert-legacy-http-options';\n\n/**\n * @deprecated this will be removed in 2.0\n *\n * @param config\n * @param signalResourcePath\n * @param requiredHeaders\n */\nexport function convertLegacyBrowserHttpOptions(\n config: OTLPExporterNodeConfigBase,\n signalResourcePath: string,\n requiredHeaders: Record<string, string>\n): OtlpHttpConfiguration {\n return mergeOtlpHttpConfigurationWithDefaults(\n {\n url: config.url,\n timeoutMillis: config.timeoutMillis,\n headers: convertLegacyHeaders(config),\n concurrencyLimit: config.concurrencyLimit,\n },\n {}, // no fallback for browser case\n getHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { OTLPExporterConfigBase } from './legacy-base-configuration';
|
|
2
|
+
import { HeadersFactory } from './otlp-http-configuration';
|
|
3
|
+
export declare function convertLegacyHeaders(config: OTLPExporterConfigBase): HeadersFactory | undefined;
|
|
4
|
+
//# sourceMappingURL=convert-legacy-http-options.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.convertLegacyHeaders = void 0;
|
|
19
|
+
const shared_configuration_1 = require("./shared-configuration");
|
|
20
|
+
function convertLegacyHeaders(config) {
|
|
21
|
+
if (typeof config.headers === 'function') {
|
|
22
|
+
return config.headers;
|
|
23
|
+
}
|
|
24
|
+
return (0, shared_configuration_1.wrapStaticHeadersInFunction)(config.headers);
|
|
25
|
+
}
|
|
26
|
+
exports.convertLegacyHeaders = convertLegacyHeaders;
|
|
27
|
+
//# sourceMappingURL=convert-legacy-http-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-legacy-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-http-options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,iEAAqE;AAGrE,SAAgB,oBAAoB,CAClC,MAA8B;IAE9B,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU,EAAE;QACxC,OAAO,MAAM,CAAC,OAAO,CAAC;KACvB;IACD,OAAO,IAAA,kDAA2B,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC;AAPD,oDAOC","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 { OTLPExporterConfigBase } from './legacy-base-configuration';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\nimport { HeadersFactory } from './otlp-http-configuration';\n\nexport function convertLegacyHeaders(\n config: OTLPExporterConfigBase\n): HeadersFactory | undefined {\n if (typeof config.headers === 'function') {\n return config.headers;\n }\n return wrapStaticHeadersInFunction(config.headers);\n}\n"]}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertLegacyHttpOptions = void 0;
|
|
4
4
|
const api_1 = require("@opentelemetry/api");
|
|
5
|
-
const shared_configuration_1 = require("./shared-configuration");
|
|
6
5
|
const otlp_node_http_configuration_1 = require("./otlp-node-http-configuration");
|
|
7
6
|
const index_node_http_1 = require("../index-node-http");
|
|
8
7
|
const otlp_node_http_env_configuration_1 = require("./otlp-node-http-env-configuration");
|
|
8
|
+
const convert_legacy_http_options_1 = require("./convert-legacy-http-options");
|
|
9
9
|
function convertLegacyAgentOptions(config) {
|
|
10
10
|
if (typeof config.httpAgentOptions === 'function') {
|
|
11
11
|
return config.httpAgentOptions;
|
|
@@ -35,7 +35,7 @@ function convertLegacyHttpOptions(config, signalIdentifier, signalResourcePath,
|
|
|
35
35
|
}
|
|
36
36
|
return (0, otlp_node_http_configuration_1.mergeOtlpNodeHttpConfigurationWithDefaults)({
|
|
37
37
|
url: config.url,
|
|
38
|
-
headers: (0,
|
|
38
|
+
headers: (0, convert_legacy_http_options_1.convertLegacyHeaders)(config),
|
|
39
39
|
concurrencyLimit: config.concurrencyLimit,
|
|
40
40
|
timeoutMillis: config.timeoutMillis,
|
|
41
41
|
compression: config.compression,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-legacy-node-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-node-http-options.ts"],"names":[],"mappings":";;;AAgBA,4CAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"convert-legacy-node-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-node-http-options.ts"],"names":[],"mappings":";;;AAgBA,4CAA0C;AAC1C,iFAKwC;AACxC,wDAAiE;AACjE,yFAA6F;AAC7F,+EAAqE;AAErE,SAAS,yBAAyB,CAChC,MAAkC;IAElC,IAAI,OAAO,MAAM,CAAC,gBAAgB,KAAK,UAAU,EAAE;QACjD,OAAO,MAAM,CAAC,gBAAgB,CAAC;KAChC;IAED,IAAI,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACrC,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,EAAE;QAC5B,MAAM,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC;KACrD;IAED,IAAI,MAAM,IAAI,IAAI,EAAE;QAClB,OAAO,IAAA,6CAA2B,EAAC,MAAM,CAAC,CAAC;KAC5C;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACtC,MAAkC,EAClC,gBAAwB,EACxB,kBAA0B,EAC1B,eAAuC;IAEvC,8DAA8D;IAC9D,IAAK,MAAc,CAAC,QAAQ,EAAE;QAC5B,UAAI,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;KACrD;IAED,OAAO,IAAA,yEAA0C,EAC/C;QACE,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,OAAO,EAAE,IAAA,kDAAoB,EAAC,MAAM,CAAC;QACrC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,YAAY,EAAE,yBAAyB,CAAC,MAAM,CAAC;QAC/C,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,EACD,IAAA,0EAAuC,EACrC,gBAAgB,EAChB,kBAAkB,CACnB,EACD,IAAA,+DAAgC,EAAC,eAAe,EAAE,kBAAkB,CAAC,CACtE,CAAC;AACJ,CAAC;AA3BD,4DA2BC","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 { OTLPExporterNodeConfigBase } from './legacy-node-configuration';\nimport { diag } from '@opentelemetry/api';\nimport {\n getNodeHttpConfigurationDefaults,\n HttpAgentFactory,\n mergeOtlpNodeHttpConfigurationWithDefaults,\n OtlpNodeHttpConfiguration,\n} from './otlp-node-http-configuration';\nimport { httpAgentFactoryFromOptions } from '../index-node-http';\nimport { getNodeHttpConfigurationFromEnvironment } from './otlp-node-http-env-configuration';\nimport { convertLegacyHeaders } from './convert-legacy-http-options';\n\nfunction convertLegacyAgentOptions(\n config: OTLPExporterNodeConfigBase\n): HttpAgentFactory | undefined {\n if (typeof config.httpAgentOptions === 'function') {\n return config.httpAgentOptions;\n }\n\n let legacy = config.httpAgentOptions;\n if (config.keepAlive != null) {\n legacy = { keepAlive: config.keepAlive, ...legacy };\n }\n\n if (legacy != null) {\n return httpAgentFactoryFromOptions(legacy);\n } else {\n return undefined;\n }\n}\n\n/**\n * @deprecated this will be removed in 2.0\n * @param config\n * @param signalIdentifier\n * @param signalResourcePath\n * @param requiredHeaders\n */\nexport function convertLegacyHttpOptions(\n config: OTLPExporterNodeConfigBase,\n signalIdentifier: string,\n signalResourcePath: string,\n requiredHeaders: Record<string, string>\n): OtlpNodeHttpConfiguration {\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\n return mergeOtlpNodeHttpConfigurationWithDefaults(\n {\n url: config.url,\n headers: convertLegacyHeaders(config),\n concurrencyLimit: config.concurrencyLimit,\n timeoutMillis: config.timeoutMillis,\n compression: config.compression,\n agentFactory: convertLegacyAgentOptions(config),\n userAgent: config.userAgent,\n },\n getNodeHttpConfigurationFromEnvironment(\n signalIdentifier,\n signalResourcePath\n ),\n getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n}\n"]}
|
|
@@ -1,5 +1,30 @@
|
|
|
1
|
+
import { HeadersFactory } from './otlp-http-configuration';
|
|
1
2
|
export interface OTLPExporterConfigBase {
|
|
2
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Custom headers that will be attached to the HTTP request that's sent to the endpoint.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Prefer using a plain object over a factory function wherever possible.
|
|
8
|
+
* If using a factory function (`HttpAgentFactory`), **do not import `http` or `https` at the top of the file**
|
|
9
|
+
* Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`
|
|
10
|
+
* module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.
|
|
11
|
+
*
|
|
12
|
+
* Functions passed to the exporter MUST NOT throw errors.
|
|
13
|
+
*
|
|
14
|
+
* @example <caption> Using headers options directly: </caption>
|
|
15
|
+
* headers: {
|
|
16
|
+
* Authorization: "Api-Token my-secret-token",
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* @example <caption> Using a custom factory function </caption>
|
|
20
|
+
* headers: async () => {
|
|
21
|
+
* // ... do whatever you need to obtain the headers, ensuring you `await import('your-library')` to avoid breaking instrumentations ...
|
|
22
|
+
* return {
|
|
23
|
+
* Authorization: `Bearer ${token}`,
|
|
24
|
+
* };
|
|
25
|
+
* };
|
|
26
|
+
*/
|
|
27
|
+
headers?: Record<string, string> | HeadersFactory;
|
|
3
28
|
url?: string;
|
|
4
29
|
concurrencyLimit?: number;
|
|
5
30
|
/** Maximum time the OTLP exporter will wait for each batch export.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-base-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-base-configuration.ts"],"names":[],"mappings":"","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 */\nexport interface OTLPExporterConfigBase {\n headers?: Record<string, string
|
|
1
|
+
{"version":3,"file":"legacy-base-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-base-configuration.ts"],"names":[],"mappings":"","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 { HeadersFactory } from './otlp-http-configuration';\n\nexport interface OTLPExporterConfigBase {\n /**\n * Custom headers that will be attached to the HTTP request that's sent to the endpoint.\n *\n * @remarks\n * Prefer using a plain object over a factory function wherever possible.\n * If using a factory function (`HttpAgentFactory`), **do not import `http` or `https` at the top of the file**\n * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`\n * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.\n *\n * Functions passed to the exporter MUST NOT throw errors.\n *\n * @example <caption> Using headers options directly: </caption>\n * headers: {\n * Authorization: \"Api-Token my-secret-token\",\n * }\n *\n * @example <caption> Using a custom factory function </caption>\n * headers: async () => {\n * // ... do whatever you need to obtain the headers, ensuring you `await import('your-library')` to avoid breaking instrumentations ...\n * return {\n * Authorization: `Bearer ${token}`,\n * };\n * };\n */\n headers?: Record<string, string> | HeadersFactory;\n url?: string;\n concurrencyLimit?: number;\n /** Maximum time the OTLP exporter will wait for each batch export.\n * The default value is 10000ms. */\n timeoutMillis?: number;\n}\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { OtlpSharedConfiguration } from './shared-configuration';
|
|
2
|
+
export type HeadersFactory = () => Promise<Record<string, string>>;
|
|
2
3
|
export interface OtlpHttpConfiguration extends OtlpSharedConfiguration {
|
|
3
4
|
url: string;
|
|
4
|
-
headers:
|
|
5
|
+
headers: HeadersFactory;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* @param userProvidedConfiguration Configuration options provided by the user in code.
|
|
@@ -19,18 +19,18 @@ exports.getHttpConfigurationDefaults = exports.mergeOtlpHttpConfigurationWithDef
|
|
|
19
19
|
const shared_configuration_1 = require("./shared-configuration");
|
|
20
20
|
const util_1 = require("../util");
|
|
21
21
|
function mergeHeaders(userProvidedHeaders, fallbackHeaders, defaultHeaders) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
return async () => {
|
|
23
|
+
const requiredHeaders = {
|
|
24
|
+
...(await defaultHeaders()),
|
|
25
|
+
};
|
|
26
|
+
const headers = {};
|
|
27
27
|
// add fallback ones first
|
|
28
28
|
if (fallbackHeaders != null) {
|
|
29
|
-
Object.assign(headers, fallbackHeaders());
|
|
29
|
+
Object.assign(headers, await fallbackHeaders());
|
|
30
30
|
}
|
|
31
31
|
// override with user-provided ones
|
|
32
32
|
if (userProvidedHeaders != null) {
|
|
33
|
-
Object.assign(headers, userProvidedHeaders());
|
|
33
|
+
Object.assign(headers, (0, util_1.validateAndNormalizeHeaders)(await userProvidedHeaders()));
|
|
34
34
|
}
|
|
35
35
|
// override required ones.
|
|
36
36
|
return Object.assign(headers, requiredHeaders);
|
|
@@ -57,7 +57,7 @@ function validateUserProvidedUrl(url) {
|
|
|
57
57
|
function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
|
|
58
58
|
return {
|
|
59
59
|
...(0, shared_configuration_1.mergeOtlpSharedConfigurationWithDefaults)(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration),
|
|
60
|
-
headers: mergeHeaders(
|
|
60
|
+
headers: mergeHeaders(userProvidedConfiguration.headers, fallbackConfiguration.headers, defaultConfiguration.headers),
|
|
61
61
|
url: validateUserProvidedUrl(userProvidedConfiguration.url) ??
|
|
62
62
|
fallbackConfiguration.url ??
|
|
63
63
|
defaultConfiguration.url,
|
|
@@ -67,7 +67,7 @@ exports.mergeOtlpHttpConfigurationWithDefaults = mergeOtlpHttpConfigurationWithD
|
|
|
67
67
|
function getHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
|
|
68
68
|
return {
|
|
69
69
|
...(0, shared_configuration_1.getSharedConfigurationDefaults)(),
|
|
70
|
-
headers: () => requiredHeaders,
|
|
70
|
+
headers: async () => requiredHeaders,
|
|
71
71
|
url: 'http://localhost:4318/' + signalResourcePath,
|
|
72
72
|
};
|
|
73
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-configuration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iEAIgC;AAChC,kCAAsD;
|
|
1
|
+
{"version":3,"file":"otlp-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-configuration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iEAIgC;AAChC,kCAAsD;AAStD,SAAS,YAAY,CACnB,mBAAsD,EACtD,eAAkD,EAClD,cAA8B;IAE9B,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,eAAe,GAAG;YACtB,GAAG,CAAC,MAAM,cAAc,EAAE,CAAC;SAC5B,CAAC;QACF,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,0BAA0B;QAC1B,IAAI,eAAe,IAAI,IAAI,EAAE;YAC3B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,eAAe,EAAE,CAAC,CAAC;SACjD;QAED,mCAAmC;QACnC,IAAI,mBAAmB,IAAI,IAAI,EAAE;YAC/B,MAAM,CAAC,MAAM,CACX,OAAO,EACP,IAAA,kCAA2B,EAAC,MAAM,mBAAmB,EAAE,CAAC,CACzD,CAAC;SACH;QAED,0BAA0B;QAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACjD,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAuB;IACtD,IAAI,GAAG,IAAI,IAAI,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IACD,IAAI;QACF,gFAAgF;QAChF,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC;QACvC,OAAO,IAAI,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;KAChC;IAAC,MAAM;QACN,MAAM,IAAI,KAAK,CACb,6DAA6D,GAAG,GAAG,CACpE,CAAC;KACH;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,sCAAsC,CACpD,yBAAyD,EACzD,qBAAqD,EACrD,oBAA2C;IAE3C,OAAO;QACL,GAAG,IAAA,+DAAwC,EACzC,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,CACrB;QACD,OAAO,EAAE,YAAY,CACnB,yBAAyB,CAAC,OAAO,EACjC,qBAAqB,CAAC,OAAO,EAC7B,oBAAoB,CAAC,OAAO,CAC7B;QACD,GAAG,EACD,uBAAuB,CAAC,yBAAyB,CAAC,GAAG,CAAC;YACtD,qBAAqB,CAAC,GAAG;YACzB,oBAAoB,CAAC,GAAG;KAC3B,CAAC;AACJ,CAAC;AArBD,wFAqBC;AAED,SAAgB,4BAA4B,CAC1C,eAAuC,EACvC,kBAA0B;IAE1B,OAAO;QACL,GAAG,IAAA,qDAA8B,GAAE;QACnC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,eAAe;QACpC,GAAG,EAAE,wBAAwB,GAAG,kBAAkB;KACnD,CAAC;AACJ,CAAC;AATD,oEASC","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 {\n getSharedConfigurationDefaults,\n mergeOtlpSharedConfigurationWithDefaults,\n OtlpSharedConfiguration,\n} from './shared-configuration';\nimport { validateAndNormalizeHeaders } from '../util';\n\nexport type HeadersFactory = () => Promise<Record<string, string>>;\n\nexport interface OtlpHttpConfiguration extends OtlpSharedConfiguration {\n url: string;\n headers: HeadersFactory;\n}\n\nfunction mergeHeaders(\n userProvidedHeaders: HeadersFactory | undefined | null,\n fallbackHeaders: HeadersFactory | undefined | null,\n defaultHeaders: HeadersFactory\n): HeadersFactory {\n return async () => {\n const requiredHeaders = {\n ...(await defaultHeaders()),\n };\n const headers = {};\n\n // add fallback ones first\n if (fallbackHeaders != null) {\n Object.assign(headers, await fallbackHeaders());\n }\n\n // override with user-provided ones\n if (userProvidedHeaders != null) {\n Object.assign(\n headers,\n validateAndNormalizeHeaders(await userProvidedHeaders())\n );\n }\n\n // override required ones.\n return Object.assign(headers, requiredHeaders);\n };\n}\n\nfunction validateUserProvidedUrl(url: string | undefined): string | undefined {\n if (url == null) {\n return undefined;\n }\n try {\n // NOTE: In non-browser environments, `globalThis.location` will be `undefined`.\n const base = globalThis.location?.href;\n return new URL(url, base).href;\n } catch {\n throw new Error(\n `Configuration: Could not parse user-provided export URL: '${url}'`\n );\n }\n}\n\n/**\n * @param userProvidedConfiguration Configuration options provided by the user in code.\n * @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.\n * @param defaultConfiguration The defaults as defined by the exporter specification\n */\nexport function mergeOtlpHttpConfigurationWithDefaults(\n userProvidedConfiguration: Partial<OtlpHttpConfiguration>,\n fallbackConfiguration: Partial<OtlpHttpConfiguration>,\n defaultConfiguration: OtlpHttpConfiguration\n): OtlpHttpConfiguration {\n return {\n ...mergeOtlpSharedConfigurationWithDefaults(\n userProvidedConfiguration,\n fallbackConfiguration,\n defaultConfiguration\n ),\n headers: mergeHeaders(\n userProvidedConfiguration.headers,\n fallbackConfiguration.headers,\n defaultConfiguration.headers\n ),\n url:\n validateUserProvidedUrl(userProvidedConfiguration.url) ??\n fallbackConfiguration.url ??\n defaultConfiguration.url,\n };\n}\n\nexport function getHttpConfigurationDefaults(\n requiredHeaders: Record<string, string>,\n signalResourcePath: string\n): OtlpHttpConfiguration {\n return {\n ...getSharedConfigurationDefaults(),\n headers: async () => requiredHeaders,\n url: 'http://localhost:4318/' + signalResourcePath,\n };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HeadersFactory } from './otlp-http-configuration';
|
|
1
2
|
/**
|
|
2
3
|
* Configuration shared across all OTLP exporters
|
|
3
4
|
*
|
|
@@ -12,7 +13,7 @@ export interface OtlpSharedConfiguration {
|
|
|
12
13
|
compression: 'gzip' | 'none';
|
|
13
14
|
}
|
|
14
15
|
export declare function validateTimeoutMillis(timeoutMillis: number): number;
|
|
15
|
-
export declare function wrapStaticHeadersInFunction(headers: Record<string, string> | undefined):
|
|
16
|
+
export declare function wrapStaticHeadersInFunction(headers: Record<string, string> | undefined): HeadersFactory | undefined;
|
|
16
17
|
/**
|
|
17
18
|
* @param userProvidedConfiguration Configuration options provided by the user in code.
|
|
18
19
|
* @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-configuration.js","sourceRoot":"","sources":["../../../src/configuration/shared-configuration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;
|
|
1
|
+
{"version":3,"file":"shared-configuration.js","sourceRoot":"","sources":["../../../src/configuration/shared-configuration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAkBH,SAAgB,qBAAqB,CAAC,aAAqB;IACzD,IAAI,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,aAAa,GAAG,CAAC,EAAE;QACvD,OAAO,aAAa,CAAC;KACtB;IACD,MAAM,IAAI,KAAK,CACb,qFAAqF,aAAa,IAAI,CACvG,CAAC;AACJ,CAAC;AAPD,sDAOC;AAED,SAAgB,2BAA2B,CACzC,OAA2C;IAE3C,IAAI,OAAO,IAAI,IAAI,EAAE;QACnB,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC;AAC7B,CAAC;AARD,kEAQC;AAED;;;;GAIG;AACH,SAAgB,wCAAwC,CACtD,yBAA2D,EAC3D,qBAAuD,EACvD,oBAA6C;IAE7C,OAAO;QACL,aAAa,EAAE,qBAAqB,CAClC,yBAAyB,CAAC,aAAa;YACrC,qBAAqB,CAAC,aAAa;YACnC,oBAAoB,CAAC,aAAa,CACrC;QACD,gBAAgB,EACd,yBAAyB,CAAC,gBAAgB;YAC1C,qBAAqB,CAAC,gBAAgB;YACtC,oBAAoB,CAAC,gBAAgB;QACvC,WAAW,EACT,yBAAyB,CAAC,WAAW;YACrC,qBAAqB,CAAC,WAAW;YACjC,oBAAoB,CAAC,WAAW;KACnC,CAAC;AACJ,CAAC;AApBD,4FAoBC;AAED,SAAgB,8BAA8B;IAC5C,OAAO;QACL,aAAa,EAAE,KAAK;QACpB,gBAAgB,EAAE,EAAE;QACpB,WAAW,EAAE,MAAM;KACpB,CAAC;AACJ,CAAC;AAND,wEAMC","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 { HeadersFactory } from './otlp-http-configuration';\n\n/**\n * Configuration shared across all OTLP exporters\n *\n * Implementation note: anything added here MUST be\n * - platform-agnostic\n * - signal-agnostic\n * - transport-agnostic\n */\nexport interface OtlpSharedConfiguration {\n timeoutMillis: number;\n concurrencyLimit: number;\n compression: 'gzip' | 'none';\n}\n\nexport function validateTimeoutMillis(timeoutMillis: number) {\n if (Number.isFinite(timeoutMillis) && timeoutMillis > 0) {\n return timeoutMillis;\n }\n throw new Error(\n `Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${timeoutMillis}')`\n );\n}\n\nexport function wrapStaticHeadersInFunction(\n headers: Record<string, string> | undefined\n): HeadersFactory | undefined {\n if (headers == null) {\n return undefined;\n }\n\n return async () => headers;\n}\n\n/**\n * @param userProvidedConfiguration Configuration options provided by the user in code.\n * @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.\n * @param defaultConfiguration The defaults as defined by the exporter specification\n */\nexport function mergeOtlpSharedConfigurationWithDefaults(\n userProvidedConfiguration: Partial<OtlpSharedConfiguration>,\n fallbackConfiguration: Partial<OtlpSharedConfiguration>,\n defaultConfiguration: OtlpSharedConfiguration\n): OtlpSharedConfiguration {\n return {\n timeoutMillis: validateTimeoutMillis(\n userProvidedConfiguration.timeoutMillis ??\n fallbackConfiguration.timeoutMillis ??\n defaultConfiguration.timeoutMillis\n ),\n concurrencyLimit:\n userProvidedConfiguration.concurrencyLimit ??\n fallbackConfiguration.concurrencyLimit ??\n defaultConfiguration.concurrencyLimit,\n compression:\n userProvidedConfiguration.compression ??\n fallbackConfiguration.compression ??\n defaultConfiguration.compression,\n };\n}\n\nexport function getSharedConfigurationDefaults(): OtlpSharedConfiguration {\n return {\n timeoutMillis: 10000,\n concurrencyLimit: 30,\n compression: 'none',\n };\n}\n"]}
|
|
@@ -25,7 +25,7 @@ function createOtlpSendBeaconExportDelegate(options, serializer) {
|
|
|
25
25
|
return (0, otlp_network_export_delegate_1.createOtlpNetworkExportDelegate)(options, serializer, (0, retrying_transport_1.createRetryingTransport)({
|
|
26
26
|
transport: (0, send_beacon_transport_1.createSendBeaconTransport)({
|
|
27
27
|
url: options.url,
|
|
28
|
-
|
|
28
|
+
headers: options.headers,
|
|
29
29
|
}),
|
|
30
30
|
}));
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-browser-http-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-browser-http-export-delegate.ts"],"names":[],"mappings":";;;AAkBA,6DAA+D;AAC/D,6DAA+D;AAC/D,6EAA8E;AAC9E,iFAAiF;AACjF,iEAAmE;AAEnE;;GAEG;AACH,SAAgB,2BAA2B,CACzC,OAA8B,EAC9B,UAA2C;IAE3C,OAAO,IAAA,8DAA+B,EACpC,OAAO,EACP,UAAU,EACV,IAAA,4CAAuB,EAAC;QACtB,SAAS,EAAE,IAAA,kCAAkB,EAAC,OAAO,CAAC;KACvC,CAAC,CACH,CAAC;AACJ,CAAC;AAXD,kEAWC;AAED,SAAgB,6BAA6B,CAC3C,OAA8B,EAC9B,UAA2C;IAE3C,OAAO,IAAA,8DAA+B,EACpC,OAAO,EACP,UAAU,EACV,IAAA,4CAAuB,EAAC;QACtB,SAAS,EAAE,IAAA,sCAAoB,EAAC,OAAO,CAAC;KACzC,CAAC,CACH,CAAC;AACJ,CAAC;AAXD,sEAWC;AAED,SAAgB,kCAAkC,CAChD,OAA8B,EAC9B,UAA2C;IAE3C,OAAO,IAAA,8DAA+B,EACpC,OAAO,EACP,UAAU,EACV,IAAA,4CAAuB,EAAC;QACtB,SAAS,EAAE,IAAA,iDAAyB,EAAC;YACnC,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,
|
|
1
|
+
{"version":3,"file":"otlp-browser-http-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-browser-http-export-delegate.ts"],"names":[],"mappings":";;;AAkBA,6DAA+D;AAC/D,6DAA+D;AAC/D,6EAA8E;AAC9E,iFAAiF;AACjF,iEAAmE;AAEnE;;GAEG;AACH,SAAgB,2BAA2B,CACzC,OAA8B,EAC9B,UAA2C;IAE3C,OAAO,IAAA,8DAA+B,EACpC,OAAO,EACP,UAAU,EACV,IAAA,4CAAuB,EAAC;QACtB,SAAS,EAAE,IAAA,kCAAkB,EAAC,OAAO,CAAC;KACvC,CAAC,CACH,CAAC;AACJ,CAAC;AAXD,kEAWC;AAED,SAAgB,6BAA6B,CAC3C,OAA8B,EAC9B,UAA2C;IAE3C,OAAO,IAAA,8DAA+B,EACpC,OAAO,EACP,UAAU,EACV,IAAA,4CAAuB,EAAC;QACtB,SAAS,EAAE,IAAA,sCAAoB,EAAC,OAAO,CAAC;KACzC,CAAC,CACH,CAAC;AACJ,CAAC;AAXD,sEAWC;AAED,SAAgB,kCAAkC,CAChD,OAA8B,EAC9B,UAA2C;IAE3C,OAAO,IAAA,8DAA+B,EACpC,OAAO,EACP,UAAU,EACV,IAAA,4CAAuB,EAAC;QACtB,SAAS,EAAE,IAAA,iDAAyB,EAAC;YACnC,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC;KACH,CAAC,CACH,CAAC;AACJ,CAAC;AAdD,gFAcC","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 { OtlpHttpConfiguration } from './configuration/otlp-http-configuration';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { IOtlpExportDelegate } from './otlp-export-delegate';\nimport { createRetryingTransport } from './retrying-transport';\nimport { createXhrTransport } from './transport/xhr-transport';\nimport { createSendBeaconTransport } from './transport/send-beacon-transport';\nimport { createOtlpNetworkExportDelegate } from './otlp-network-export-delegate';\nimport { createFetchTransport } from './transport/fetch-transport';\n\n/**\n * @deprecated use {@link createOtlpFetchExportDelegate}\n */\nexport function createOtlpXhrExportDelegate<Internal, Response>(\n options: OtlpHttpConfiguration,\n serializer: ISerializer<Internal, Response>\n): IOtlpExportDelegate<Internal> {\n return createOtlpNetworkExportDelegate(\n options,\n serializer,\n createRetryingTransport({\n transport: createXhrTransport(options),\n })\n );\n}\n\nexport function createOtlpFetchExportDelegate<Internal, Response>(\n options: OtlpHttpConfiguration,\n serializer: ISerializer<Internal, Response>\n): IOtlpExportDelegate<Internal> {\n return createOtlpNetworkExportDelegate(\n options,\n serializer,\n createRetryingTransport({\n transport: createFetchTransport(options),\n })\n );\n}\n\nexport function createOtlpSendBeaconExportDelegate<Internal, Response>(\n options: OtlpHttpConfiguration,\n serializer: ISerializer<Internal, Response>\n): IOtlpExportDelegate<Internal> {\n return createOtlpNetworkExportDelegate(\n options,\n serializer,\n createRetryingTransport({\n transport: createSendBeaconTransport({\n url: options.url,\n headers: options.headers,\n }),\n })\n );\n}\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { IExporterTransport } from '../exporter-transport';
|
|
2
|
+
import { HeadersFactory } from '../configuration/otlp-http-configuration';
|
|
2
3
|
export interface FetchTransportParameters {
|
|
3
4
|
url: string;
|
|
4
|
-
headers:
|
|
5
|
+
headers: HeadersFactory;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* Creates an exporter transport that uses `fetch` to send the data
|
|
@@ -31,7 +31,7 @@ class FetchTransport {
|
|
|
31
31
|
const url = new URL(this._parameters.url);
|
|
32
32
|
const response = await fetch(url.href, {
|
|
33
33
|
method: 'POST',
|
|
34
|
-
headers: this._parameters.headers(),
|
|
34
|
+
headers: await this._parameters.headers(),
|
|
35
35
|
body: data,
|
|
36
36
|
signal: abortController.signal,
|
|
37
37
|
keepalive: isBrowserEnvironment,
|