@opentelemetry/otlp-exporter-base 0.202.0 → 0.204.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/bounded-queue-export-promise-handler.js +1 -1
- package/build/esm/bounded-queue-export-promise-handler.js.map +1 -1
- package/build/esm/configuration/convert-legacy-node-http-options.js +14 -18
- package/build/esm/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/esm/configuration/create-legacy-browser-delegate.d.ts +2 -0
- package/build/esm/configuration/create-legacy-browser-delegate.js +11 -5
- package/build/esm/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/build/esm/configuration/legacy-node-configuration.d.ts +25 -2
- package/build/esm/configuration/legacy-node-configuration.js.map +1 -1
- package/build/esm/configuration/otlp-http-configuration.d.ts +13 -1
- package/build/esm/configuration/otlp-http-configuration.js +15 -7
- package/build/esm/configuration/otlp-http-configuration.js.map +1 -1
- package/build/esm/configuration/otlp-http-env-configuration.js +7 -7
- package/build/esm/configuration/otlp-http-env-configuration.js.map +1 -1
- package/build/esm/index-node-http.d.ts +1 -0
- package/build/esm/index-node-http.js +1 -0
- package/build/esm/index-node-http.js.map +1 -1
- package/build/esm/otlp-browser-http-export-delegate.d.ts +4 -0
- package/build/esm/otlp-browser-http-export-delegate.js +9 -0
- package/build/esm/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/esm/transport/fetch-transport.d.ts +11 -0
- package/build/esm/transport/fetch-transport.js +82 -0
- package/build/esm/transport/fetch-transport.js.map +1 -0
- package/build/esm/transport/http-exporter-transport.js +15 -11
- package/build/esm/transport/http-exporter-transport.js.map +1 -1
- package/build/esm/transport/http-transport-types.d.ts +2 -7
- package/build/esm/transport/http-transport-types.js.map +1 -1
- package/build/esm/transport/http-transport-utils.d.ts +4 -4
- package/build/esm/transport/http-transport-utils.js +2 -32
- package/build/esm/transport/http-transport-utils.js.map +1 -1
- package/build/esm/transport/xhr-transport.d.ts +6 -0
- package/build/esm/transport/xhr-transport.js +2 -0
- package/build/esm/transport/xhr-transport.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/bounded-queue-export-promise-handler.js +1 -1
- package/build/esnext/bounded-queue-export-promise-handler.js.map +1 -1
- package/build/esnext/configuration/convert-legacy-node-http-options.js +14 -18
- package/build/esnext/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/esnext/configuration/create-legacy-browser-delegate.d.ts +2 -0
- package/build/esnext/configuration/create-legacy-browser-delegate.js +11 -5
- package/build/esnext/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/build/esnext/configuration/legacy-node-configuration.d.ts +25 -2
- package/build/esnext/configuration/legacy-node-configuration.js.map +1 -1
- package/build/esnext/configuration/otlp-http-configuration.d.ts +13 -1
- package/build/esnext/configuration/otlp-http-configuration.js +15 -7
- package/build/esnext/configuration/otlp-http-configuration.js.map +1 -1
- package/build/esnext/configuration/otlp-http-env-configuration.js +7 -7
- package/build/esnext/configuration/otlp-http-env-configuration.js.map +1 -1
- package/build/esnext/index-node-http.d.ts +1 -0
- package/build/esnext/index-node-http.js +1 -0
- package/build/esnext/index-node-http.js.map +1 -1
- package/build/esnext/otlp-browser-http-export-delegate.d.ts +4 -0
- package/build/esnext/otlp-browser-http-export-delegate.js +9 -0
- package/build/esnext/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/esnext/transport/fetch-transport.d.ts +11 -0
- package/build/esnext/transport/fetch-transport.js +82 -0
- package/build/esnext/transport/fetch-transport.js.map +1 -0
- package/build/esnext/transport/http-exporter-transport.js +15 -11
- package/build/esnext/transport/http-exporter-transport.js.map +1 -1
- package/build/esnext/transport/http-transport-types.d.ts +2 -7
- package/build/esnext/transport/http-transport-types.js.map +1 -1
- package/build/esnext/transport/http-transport-utils.d.ts +4 -4
- package/build/esnext/transport/http-transport-utils.js +2 -32
- package/build/esnext/transport/http-transport-utils.js.map +1 -1
- package/build/esnext/transport/xhr-transport.d.ts +6 -0
- package/build/esnext/transport/xhr-transport.js +2 -0
- package/build/esnext/transport/xhr-transport.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/bounded-queue-export-promise-handler.js +1 -1
- package/build/src/bounded-queue-export-promise-handler.js.map +1 -1
- package/build/src/configuration/convert-legacy-node-http-options.js +13 -17
- package/build/src/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/src/configuration/create-legacy-browser-delegate.d.ts +2 -0
- package/build/src/configuration/create-legacy-browser-delegate.js +13 -6
- package/build/src/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/build/src/configuration/legacy-node-configuration.d.ts +25 -2
- package/build/src/configuration/legacy-node-configuration.js.map +1 -1
- package/build/src/configuration/otlp-http-configuration.d.ts +13 -1
- package/build/src/configuration/otlp-http-configuration.js +17 -8
- package/build/src/configuration/otlp-http-configuration.js.map +1 -1
- package/build/src/configuration/otlp-http-env-configuration.js +6 -6
- package/build/src/configuration/otlp-http-env-configuration.js.map +1 -1
- package/build/src/index-node-http.d.ts +1 -0
- package/build/src/index-node-http.js +3 -1
- package/build/src/index-node-http.js.map +1 -1
- package/build/src/otlp-browser-http-export-delegate.d.ts +4 -0
- package/build/src/otlp-browser-http-export-delegate.js +11 -1
- package/build/src/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/src/transport/fetch-transport.d.ts +11 -0
- package/build/src/transport/fetch-transport.js +86 -0
- package/build/src/transport/fetch-transport.js.map +1 -0
- package/build/src/transport/http-exporter-transport.js +15 -11
- package/build/src/transport/http-exporter-transport.js.map +1 -1
- package/build/src/transport/http-transport-types.d.ts +2 -7
- package/build/src/transport/http-transport-types.js.map +1 -1
- package/build/src/transport/http-transport-utils.d.ts +4 -4
- package/build/src/transport/http-transport-utils.js +3 -34
- package/build/src/transport/http-transport-utils.js.map +1 -1
- package/build/src/transport/xhr-transport.d.ts +6 -0
- package/build/src/transport/xhr-transport.js +2 -0
- package/build/src/transport/xhr-transport.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 +12 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,8BAA8B,EAC9B,wCAAwC,GAEzC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"otlp-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,8BAA8B,EAC9B,wCAAwC,GAEzC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AA0BtD,SAAS,YAAY,CACnB,mBAAsE,EACtE,eAAkE,EAClE,cAA4C;IAE5C,MAAM,eAAe,GAAG;QACtB,GAAG,cAAc,EAAE;KACpB,CAAC;IACF,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,OAAO,GAAG,EAAE;QACV,0BAA0B;QAC1B,IAAI,eAAe,IAAI,IAAI,EAAE;YAC3B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;SAC3C;QAED,mCAAmC;QACnC,IAAI,mBAAmB,IAAI,IAAI,EAAE;YAC/B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,mBAAmB,EAAE,CAAC,CAAC;SAC/C;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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O;QACL,GAAG,8BAA8B,EAAE;QACnC,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe;QAC9B,GAAG,EAAE,wBAAwB,GAAG,kBAAkB;QAClD,YAAY,EAAE,2BAA2B,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;KAC/D,CAAC;AACJ,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 {\n getSharedConfigurationDefaults,\n mergeOtlpSharedConfigurationWithDefaults,\n OtlpSharedConfiguration,\n} from './shared-configuration';\nimport { validateAndNormalizeHeaders } from '../util';\n\n// NOTE: do not change these imports to be actual imports, otherwise they WILL break `@opentelemetry/instrumentation-http`\nimport type * as http from 'http';\nimport type * as https from 'https';\n\nexport type HttpAgentFactory = (\n protocol: string\n) => http.Agent | https.Agent | Promise<http.Agent> | Promise<https.Agent>;\n\nexport interface OtlpHttpConfiguration extends OtlpSharedConfiguration {\n url: string;\n headers: () => Record<string, string>;\n /**\n * Factory function for creating agents.\n *\n * @remarks\n * Prefer using {@link httpAgentFactoryFromOptions} over manually writing a factory function wherever possible.\n * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`\n * statically 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 agentFactory: HttpAgentFactory;\n}\n\nfunction mergeHeaders(\n userProvidedHeaders: (() => Record<string, string>) | undefined | null,\n fallbackHeaders: (() => Record<string, string>) | undefined | null,\n defaultHeaders: () => Record<string, string>\n): () => Record<string, string> {\n const requiredHeaders = {\n ...defaultHeaders(),\n };\n const headers = {};\n\n return () => {\n // add fallback ones first\n if (fallbackHeaders != null) {\n Object.assign(headers, fallbackHeaders());\n }\n\n // override with user-provided ones\n if (userProvidedHeaders != null) {\n Object.assign(headers, userProvidedHeaders());\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\nexport function httpAgentFactoryFromOptions(\n options: http.AgentOptions | https.AgentOptions\n): HttpAgentFactory {\n return async protocol => {\n const module = protocol === 'http:' ? import('http') : import('https');\n const { Agent } = await module;\n return new Agent(options);\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 validateAndNormalizeHeaders(userProvidedConfiguration.headers),\n fallbackConfiguration.headers,\n defaultConfiguration.headers\n ),\n url:\n validateUserProvidedUrl(userProvidedConfiguration.url) ??\n fallbackConfiguration.url ??\n defaultConfiguration.url,\n agentFactory:\n userProvidedConfiguration.agentFactory ??\n fallbackConfiguration.agentFactory ??\n defaultConfiguration.agentFactory,\n };\n}\n\nexport function getHttpConfigurationDefaults(\n requiredHeaders: Record<string, string>,\n signalResourcePath: string\n): OtlpHttpConfiguration {\n return {\n ...getSharedConfigurationDefaults(),\n headers: () => requiredHeaders,\n url: 'http://localhost:4318/' + signalResourcePath,\n agentFactory: httpAgentFactoryFromOptions({ keepAlive: true }),\n };\n}\n"]}
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { parseKeyPairsIntoRecord } from '@opentelemetry/core';
|
|
16
|
+
import { getStringFromEnv, parseKeyPairsIntoRecord } from '@opentelemetry/core';
|
|
17
17
|
import { diag } from '@opentelemetry/api';
|
|
18
18
|
import { getSharedConfigurationFromEnvironment } from './shared-env-configuration';
|
|
19
19
|
import { wrapStaticHeadersInFunction } from './shared-configuration';
|
|
20
20
|
function getStaticHeadersFromEnv(signalIdentifier) {
|
|
21
|
-
const signalSpecificRawHeaders =
|
|
22
|
-
const nonSignalSpecificRawHeaders =
|
|
21
|
+
const signalSpecificRawHeaders = getStringFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`);
|
|
22
|
+
const nonSignalSpecificRawHeaders = getStringFromEnv('OTEL_EXPORTER_OTLP_HEADERS');
|
|
23
23
|
const signalSpecificHeaders = parseKeyPairsIntoRecord(signalSpecificRawHeaders);
|
|
24
24
|
const nonSignalSpecificHeaders = parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders);
|
|
25
25
|
if (Object.keys(signalSpecificHeaders).length === 0 &&
|
|
@@ -65,15 +65,15 @@ function appendResourcePathToUrl(url, path) {
|
|
|
65
65
|
return url;
|
|
66
66
|
}
|
|
67
67
|
function getNonSpecificUrlFromEnv(signalResourcePath) {
|
|
68
|
-
const envUrl =
|
|
69
|
-
if (envUrl
|
|
68
|
+
const envUrl = getStringFromEnv('OTEL_EXPORTER_OTLP_ENDPOINT');
|
|
69
|
+
if (envUrl === undefined) {
|
|
70
70
|
return undefined;
|
|
71
71
|
}
|
|
72
72
|
return appendResourcePathToUrl(envUrl, signalResourcePath);
|
|
73
73
|
}
|
|
74
74
|
function getSpecificUrlFromEnv(signalIdentifier) {
|
|
75
|
-
const envUrl =
|
|
76
|
-
if (envUrl
|
|
75
|
+
const envUrl = getStringFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`);
|
|
76
|
+
if (envUrl === undefined) {
|
|
77
77
|
return undefined;
|
|
78
78
|
}
|
|
79
79
|
return appendRootPathToUrlIfNeeded(envUrl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-http-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-env-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"otlp-http-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-env-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AAEnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAErE,SAAS,uBAAuB,CAC9B,gBAAwB;IAExB,MAAM,wBAAwB,GAAG,gBAAgB,CAC/C,sBAAsB,gBAAgB,UAAU,CACjD,CAAC;IACF,MAAM,2BAA2B,GAAG,gBAAgB,CAClD,4BAA4B,CAC7B,CAAC;IAEF,MAAM,qBAAqB,GAAG,uBAAuB,CACnD,wBAAwB,CACzB,CAAC;IACF,MAAM,wBAAwB,GAAG,uBAAuB,CACtD,2BAA2B,CAC5B,CAAC;IAEF,IACE,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,KAAK,CAAC;QAC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AAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,qBAAqB,CAAC,gBAAwB;IACrD,MAAM,MAAM,GAAG,gBAAgB,CAC7B,sBAAsB,gBAAgB,WAAW,CAClD,CAAC;IACF,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,2BAA2B,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAAwB,EACxB,kBAA0B;IAE1B,OAAO;QACL,GAAG,qCAAqC,CAAC,gBAAgB,CAAC;QAC1D,GAAG,EACD,qBAAqB,CAAC,gBAAgB,CAAC;YACvC,wBAAwB,CAAC,kBAAkB,CAAC;QAC9C,OAAO,EAAE,2BAA2B,CAClC,uBAAuB,CAAC,gBAAgB,CAAC,CAC1C;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { getStringFromEnv, parseKeyPairsIntoRecord } from '@opentelemetry/core';\nimport { diag } from '@opentelemetry/api';\nimport { getSharedConfigurationFromEnvironment } from './shared-env-configuration';\nimport { OtlpHttpConfiguration } from './otlp-http-configuration';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\n\nfunction getStaticHeadersFromEnv(\n signalIdentifier: string\n): Record<string, string> | undefined {\n const signalSpecificRawHeaders = getStringFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`\n );\n const nonSignalSpecificRawHeaders = getStringFromEnv(\n 'OTEL_EXPORTER_OTLP_HEADERS'\n );\n\n const signalSpecificHeaders = parseKeyPairsIntoRecord(\n signalSpecificRawHeaders\n );\n const nonSignalSpecificHeaders = parseKeyPairsIntoRecord(\n nonSignalSpecificRawHeaders\n );\n\n if (\n Object.keys(signalSpecificHeaders).length === 0 &&\n Object.keys(nonSignalSpecificHeaders).length === 0\n ) {\n return undefined;\n }\n\n // headers are combined instead of overwritten, with the specific headers taking precedence over\n // the non-specific ones.\n return Object.assign(\n {},\n parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders),\n parseKeyPairsIntoRecord(signalSpecificRawHeaders)\n );\n}\n\nfunction appendRootPathToUrlIfNeeded(url: string): string | undefined {\n try {\n const parsedUrl = new URL(url);\n // This will automatically append '/' if there's no root path.\n return parsedUrl.toString();\n } catch {\n diag.warn(\n `Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`\n );\n return undefined;\n }\n}\n\nfunction appendResourcePathToUrl(\n url: string,\n path: string\n): string | undefined {\n try {\n // just try to parse, if it fails we catch and warn.\n new URL(url);\n } catch {\n diag.warn(\n `Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`\n );\n return undefined;\n }\n\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n url += path;\n\n try {\n // just try to parse, if it fails we catch and warn.\n new URL(url);\n } catch {\n diag.warn(\n `Configuration: Provided URL appended with '${path}' is not a valid URL, using 'undefined' instead of '${url}'`\n );\n return undefined;\n }\n\n return url;\n}\n\nfunction getNonSpecificUrlFromEnv(\n signalResourcePath: string\n): string | undefined {\n const envUrl = getStringFromEnv('OTEL_EXPORTER_OTLP_ENDPOINT');\n if (envUrl === undefined) {\n return undefined;\n }\n return appendResourcePathToUrl(envUrl, signalResourcePath);\n}\n\nfunction getSpecificUrlFromEnv(signalIdentifier: string): string | undefined {\n const envUrl = getStringFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`\n );\n if (envUrl === undefined) {\n return undefined;\n }\n return appendRootPathToUrlIfNeeded(envUrl);\n}\n\n/**\n * Reads and returns configuration from the environment\n *\n * @param signalIdentifier all caps part in environment variables that identifies the signal (e.g.: METRICS, TRACES, LOGS)\n * @param signalResourcePath signal resource path to append if necessary (e.g.: v1/metrics, v1/traces, v1/logs)\n */\nexport function getHttpConfigurationFromEnvironment(\n signalIdentifier: string,\n signalResourcePath: string\n): Partial<OtlpHttpConfiguration> {\n return {\n ...getSharedConfigurationFromEnvironment(signalIdentifier),\n url:\n getSpecificUrlFromEnv(signalIdentifier) ??\n getNonSpecificUrlFromEnv(signalResourcePath),\n headers: wrapStaticHeadersInFunction(\n getStaticHeadersFromEnv(signalIdentifier)\n ),\n };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { httpAgentFactoryFromOptions } from './configuration/otlp-http-configuration';
|
|
1
2
|
export { createOtlpHttpExportDelegate } from './otlp-http-export-delegate';
|
|
2
3
|
export { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';
|
|
3
4
|
export { convertLegacyHttpOptions } from './configuration/convert-legacy-node-http-options';
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export { httpAgentFactoryFromOptions } from './configuration/otlp-http-configuration';
|
|
16
17
|
export { createOtlpHttpExportDelegate } from './otlp-http-export-delegate';
|
|
17
18
|
export { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';
|
|
18
19
|
export { convertLegacyHttpOptions } from './configuration/convert-legacy-node-http-options';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-node-http.js","sourceRoot":"","sources":["../../src/index-node-http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,CAAC;AACjG,OAAO,EAAE,wBAAwB,EAAE,MAAM,kDAAkD,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { createOtlpHttpExportDelegate } from './otlp-http-export-delegate';\nexport { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';\nexport { convertLegacyHttpOptions } from './configuration/convert-legacy-node-http-options';\n"]}
|
|
1
|
+
{"version":3,"file":"index-node-http.js","sourceRoot":"","sources":["../../src/index-node-http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,CAAC;AACjG,OAAO,EAAE,wBAAwB,EAAE,MAAM,kDAAkD,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { httpAgentFactoryFromOptions } from './configuration/otlp-http-configuration';\nexport { createOtlpHttpExportDelegate } from './otlp-http-export-delegate';\nexport { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';\nexport { convertLegacyHttpOptions } from './configuration/convert-legacy-node-http-options';\n"]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { OtlpHttpConfiguration } from './configuration/otlp-http-configuration';
|
|
2
2
|
import { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
3
3
|
import { IOtlpExportDelegate } from './otlp-export-delegate';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use {@link createOtlpFetchExportDelegate}
|
|
6
|
+
*/
|
|
4
7
|
export declare function createOtlpXhrExportDelegate<Internal, Response>(options: OtlpHttpConfiguration, serializer: ISerializer<Internal, Response>): IOtlpExportDelegate<Internal>;
|
|
8
|
+
export declare function createOtlpFetchExportDelegate<Internal, Response>(options: OtlpHttpConfiguration, serializer: ISerializer<Internal, Response>): IOtlpExportDelegate<Internal>;
|
|
5
9
|
export declare function createOtlpSendBeaconExportDelegate<Internal, Response>(options: OtlpHttpConfiguration, serializer: ISerializer<Internal, Response>): IOtlpExportDelegate<Internal>;
|
|
6
10
|
//# sourceMappingURL=otlp-browser-http-export-delegate.d.ts.map
|
|
@@ -2,11 +2,20 @@ import { createRetryingTransport } from './retrying-transport';
|
|
|
2
2
|
import { createXhrTransport } from './transport/xhr-transport';
|
|
3
3
|
import { createSendBeaconTransport } from './transport/send-beacon-transport';
|
|
4
4
|
import { createOtlpNetworkExportDelegate } from './otlp-network-export-delegate';
|
|
5
|
+
import { createFetchTransport } from './transport/fetch-transport';
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use {@link createOtlpFetchExportDelegate}
|
|
8
|
+
*/
|
|
5
9
|
export function createOtlpXhrExportDelegate(options, serializer) {
|
|
6
10
|
return createOtlpNetworkExportDelegate(options, serializer, createRetryingTransport({
|
|
7
11
|
transport: createXhrTransport(options),
|
|
8
12
|
}));
|
|
9
13
|
}
|
|
14
|
+
export function createOtlpFetchExportDelegate(options, serializer) {
|
|
15
|
+
return createOtlpNetworkExportDelegate(options, serializer, createRetryingTransport({
|
|
16
|
+
transport: createFetchTransport(options),
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
10
19
|
export function createOtlpSendBeaconExportDelegate(options, serializer) {
|
|
11
20
|
return createOtlpNetworkExportDelegate(options, serializer, createRetryingTransport({
|
|
12
21
|
transport: createSendBeaconTransport({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-browser-http-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-browser-http-export-delegate.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"otlp-browser-http-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-browser-http-export-delegate.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAA8B,EAC9B,UAA2C;IAE3C,OAAO,+BAA+B,CACpC,OAAO,EACP,UAAU,EACV,uBAAuB,CAAC;QACtB,SAAS,EAAE,kBAAkB,CAAC,OAAO,CAAC;KACvC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,OAA8B,EAC9B,UAA2C;IAE3C,OAAO,+BAA+B,CACpC,OAAO,EACP,UAAU,EACV,uBAAuB,CAAC;QACtB,SAAS,EAAE,oBAAoB,CAAC,OAAO,CAAC;KACzC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,OAA8B,EAC9B,UAA2C;IAE3C,OAAO,+BAA+B,CACpC,OAAO,EACP,UAAU,EACV,uBAAuB,CAAC;QACtB,SAAS,EAAE,yBAAyB,CAAC;YACnC,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC;SAC5C,CAAC;KACH,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { 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 blobType: options.headers()['Content-Type'],\n }),\n })\n );\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IExporterTransport } from '../exporter-transport';
|
|
2
|
+
export interface FetchTransportParameters {
|
|
3
|
+
url: string;
|
|
4
|
+
headers: () => Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates an exporter transport that uses `fetch` to send the data
|
|
8
|
+
* @param parameters applied to each request made by transport
|
|
9
|
+
*/
|
|
10
|
+
export declare function createFetchTransport(parameters: FetchTransportParameters): IExporterTransport;
|
|
11
|
+
//# sourceMappingURL=fetch-transport.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright The OpenTelemetry Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { diag } from '@opentelemetry/api';
|
|
17
|
+
import { isExportRetryable, parseRetryAfterToMills, } from '../is-export-retryable';
|
|
18
|
+
class FetchTransport {
|
|
19
|
+
_parameters;
|
|
20
|
+
constructor(_parameters) {
|
|
21
|
+
this._parameters = _parameters;
|
|
22
|
+
}
|
|
23
|
+
async send(data, timeoutMillis) {
|
|
24
|
+
const abortController = new AbortController();
|
|
25
|
+
const timeout = setTimeout(() => abortController.abort(), timeoutMillis);
|
|
26
|
+
try {
|
|
27
|
+
const isBrowserEnvironment = !!globalThis.location;
|
|
28
|
+
const url = new URL(this._parameters.url);
|
|
29
|
+
const response = await fetch(url.href, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: this._parameters.headers(),
|
|
32
|
+
body: data,
|
|
33
|
+
signal: abortController.signal,
|
|
34
|
+
keepalive: isBrowserEnvironment,
|
|
35
|
+
mode: isBrowserEnvironment
|
|
36
|
+
? globalThis.location?.origin === url.origin
|
|
37
|
+
? 'same-origin'
|
|
38
|
+
: 'cors'
|
|
39
|
+
: 'no-cors',
|
|
40
|
+
});
|
|
41
|
+
if (response.status >= 200 && response.status <= 299) {
|
|
42
|
+
diag.debug('response success');
|
|
43
|
+
return { status: 'success' };
|
|
44
|
+
}
|
|
45
|
+
else if (isExportRetryable(response.status)) {
|
|
46
|
+
const retryAfter = response.headers.get('Retry-After');
|
|
47
|
+
const retryInMillis = parseRetryAfterToMills(retryAfter);
|
|
48
|
+
return { status: 'retryable', retryInMillis };
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
status: 'failure',
|
|
52
|
+
error: new Error('Fetch request failed with non-retryable status'),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error?.name === 'AbortError') {
|
|
57
|
+
return {
|
|
58
|
+
status: 'failure',
|
|
59
|
+
error: new Error('Fetch request timed out', { cause: error }),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
status: 'failure',
|
|
64
|
+
error: new Error('Fetch request errored', { cause: error }),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
clearTimeout(timeout);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
shutdown() {
|
|
72
|
+
// Intentionally left empty, nothing to do.
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Creates an exporter transport that uses `fetch` to send the data
|
|
77
|
+
* @param parameters applied to each request made by transport
|
|
78
|
+
*/
|
|
79
|
+
export function createFetchTransport(parameters) {
|
|
80
|
+
return new FetchTransport(parameters);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=fetch-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-transport.js","sourceRoot":"","sources":["../../../src/transport/fetch-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAOhC,MAAM,cAAc;IACE;IAApB,YAAoB,WAAqC;QAArC,gBAAW,GAAX,WAAW,CAA0B;IAAG,CAAC;IAE7D,KAAK,CAAC,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAChD,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,aAAa,CAAC,CAAC;QACzE,IAAI;YACF,MAAM,oBAAoB,GAAG,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;YACnD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YAC1C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE;gBACrC,MAAM,EAAE,MAAM;gBACd,OA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AC;aAC5D,CAAC;SACH;gBAAS;YACR,YAAY,CAAC,OAAO,CAAC,CAAC;SACvB;IACH,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAoC;IAEpC,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { IExporterTransport } from '../exporter-transport';\nimport { ExportResponse } from '../export-response';\nimport { diag } from '@opentelemetry/api';\nimport {\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../is-export-retryable';\n\nexport interface FetchTransportParameters {\n url: string;\n headers: () => Record<string, string>;\n}\n\nclass FetchTransport implements IExporterTransport {\n constructor(private _parameters: FetchTransportParameters) {}\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n const abortController = new AbortController();\n const timeout = setTimeout(() => abortController.abort(), timeoutMillis);\n try {\n const isBrowserEnvironment = !!globalThis.location;\n const url = new URL(this._parameters.url);\n const response = await fetch(url.href, {\n method: 'POST',\n headers: this._parameters.headers(),\n body: data,\n signal: abortController.signal,\n keepalive: isBrowserEnvironment,\n mode: isBrowserEnvironment\n ? globalThis.location?.origin === url.origin\n ? 'same-origin'\n : 'cors'\n : 'no-cors',\n });\n\n if (response.status >= 200 && response.status <= 299) {\n diag.debug('response success');\n return { status: 'success' };\n } else if (isExportRetryable(response.status)) {\n const retryAfter = response.headers.get('Retry-After');\n const retryInMillis = parseRetryAfterToMills(retryAfter);\n return { status: 'retryable', retryInMillis };\n }\n return {\n status: 'failure',\n error: new Error('Fetch request failed with non-retryable status'),\n };\n } catch (error) {\n if (error?.name === 'AbortError') {\n return {\n status: 'failure',\n error: new Error('Fetch request timed out', { cause: error }),\n };\n }\n return {\n status: 'failure',\n error: new Error('Fetch request errored', { cause: error }),\n };\n } finally {\n clearTimeout(timeout);\n }\n }\n\n shutdown() {\n // Intentionally left empty, nothing to do.\n }\n}\n\n/**\n * Creates an exporter transport that uses `fetch` to send the data\n * @param parameters applied to each request made by transport\n */\nexport function createFetchTransport(\n parameters: FetchTransportParameters\n): IExporterTransport {\n return new FetchTransport(parameters);\n}\n"]}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { sendWithHttp } from './http-transport-utils';
|
|
16
17
|
class HttpExporterTransport {
|
|
17
18
|
_parameters;
|
|
18
19
|
_utils = null;
|
|
@@ -20,9 +21,9 @@ class HttpExporterTransport {
|
|
|
20
21
|
this._parameters = _parameters;
|
|
21
22
|
}
|
|
22
23
|
async send(data, timeoutMillis) {
|
|
23
|
-
const { agent,
|
|
24
|
+
const { agent, request } = await this._loadUtils();
|
|
24
25
|
return new Promise(resolve => {
|
|
25
|
-
|
|
26
|
+
sendWithHttp(request, this._parameters, agent, data, result => {
|
|
26
27
|
resolve(result);
|
|
27
28
|
}, timeoutMillis);
|
|
28
29
|
});
|
|
@@ -30,21 +31,24 @@ class HttpExporterTransport {
|
|
|
30
31
|
shutdown() {
|
|
31
32
|
// intentionally left empty, nothing to do.
|
|
32
33
|
}
|
|
33
|
-
_loadUtils() {
|
|
34
|
+
async _loadUtils() {
|
|
34
35
|
let utils = this._utils;
|
|
35
36
|
if (utils === null) {
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
send: sendWithHttp,
|
|
43
|
-
};
|
|
37
|
+
const protocol = new URL(this._parameters.url).protocol;
|
|
38
|
+
const [agent, request] = await Promise.all([
|
|
39
|
+
this._parameters.agentFactory(protocol),
|
|
40
|
+
requestFunctionFactory(protocol),
|
|
41
|
+
]);
|
|
42
|
+
utils = this._utils = { agent, request };
|
|
44
43
|
}
|
|
45
44
|
return utils;
|
|
46
45
|
}
|
|
47
46
|
}
|
|
47
|
+
async function requestFunctionFactory(protocol) {
|
|
48
|
+
const module = protocol === 'http:' ? import('http') : import('https');
|
|
49
|
+
const { request } = await module;
|
|
50
|
+
return request;
|
|
51
|
+
}
|
|
48
52
|
export function createHttpExporterTransport(parameters) {
|
|
49
53
|
return new HttpExporterTransport(parameters);
|
|
50
54
|
}
|
|
@@ -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;AAUH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAOtD,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,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAEnD,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3C,YAAY,CACV,OAAO,EACP,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,KAAK,CAAC,UAAU;QACtB,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAExB,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;YACxD,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACzC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC;gBACvC,sBAAsB,CAAC,QAAQ,CAAC;aACjC,CAAC,CAAC;YACH,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;SAC1C;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,KAAK,UAAU,sBAAsB,CACnC,QAAgB;IAEhB,MAAM,MAAM,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC;IACjC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,UAAiC;IAEjC,OAAO,IAAI,qBAAqB,CAAC,UAAU,CAAC,CAAC;AAC/C,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 type { HttpRequestParameters } 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';\nimport { sendWithHttp } from './http-transport-utils';\n\ninterface Utils {\n agent: http.Agent | https.Agent;\n request: typeof http.request | typeof https.request;\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, request } = await this._loadUtils();\n\n return new Promise<ExportResponse>(resolve => {\n sendWithHttp(\n request,\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 async _loadUtils(): Promise<Utils> {\n let utils = this._utils;\n\n if (utils === null) {\n const protocol = new URL(this._parameters.url).protocol;\n const [agent, request] = await Promise.all([\n this._parameters.agentFactory(protocol),\n requestFunctionFactory(protocol),\n ]);\n utils = this._utils = { agent, request };\n }\n\n return utils;\n }\n}\n\nasync function requestFunctionFactory(\n protocol: string\n): Promise<typeof http.request | typeof https.request> {\n const module = protocol === 'http:' ? import('http') : import('https');\n const { request } = await module;\n return request;\n}\n\nexport function createHttpExporterTransport(\n parameters: HttpRequestParameters\n): IExporterTransport {\n return new HttpExporterTransport(parameters);\n}\n"]}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import type * as http from 'http';
|
|
4
|
-
import type * as https from 'https';
|
|
5
|
-
import { ExportResponse } from '../export-response';
|
|
6
|
-
export type sendWithHttp = (params: HttpRequestParameters, agent: http.Agent | https.Agent, data: Uint8Array, onDone: (response: ExportResponse) => void, timeoutMillis: number) => void;
|
|
1
|
+
import { HttpAgentFactory } from '../configuration/otlp-http-configuration';
|
|
7
2
|
export interface HttpRequestParameters {
|
|
8
3
|
url: string;
|
|
9
4
|
headers: () => Record<string, string>;
|
|
10
5
|
compression: 'gzip' | 'none';
|
|
11
|
-
|
|
6
|
+
agentFactory: HttpAgentFactory;
|
|
12
7
|
}
|
|
13
8
|
//# sourceMappingURL=http-transport-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/http-transport-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","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
|
|
1
|
+
{"version":3,"file":"http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/http-transport-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","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 { HttpAgentFactory } from '../configuration/otlp-http-configuration';\n\nexport interface HttpRequestParameters {\n url: string;\n headers: () => Record<string, string>;\n compression: 'gzip' | 'none';\n agentFactory: HttpAgentFactory;\n}\n"]}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import * as http from 'http';
|
|
4
|
-
import * as https from 'https';
|
|
3
|
+
import type * as http from 'http';
|
|
4
|
+
import type * as https from 'https';
|
|
5
5
|
import { HttpRequestParameters } from './http-transport-types';
|
|
6
6
|
import { ExportResponse } from '../export-response';
|
|
7
7
|
/**
|
|
8
8
|
* Sends data using http
|
|
9
|
+
* @param requestFunction
|
|
9
10
|
* @param params
|
|
10
11
|
* @param agent
|
|
11
12
|
* @param data
|
|
12
13
|
* @param onDone
|
|
13
14
|
* @param timeoutMillis
|
|
14
15
|
*/
|
|
15
|
-
export declare function sendWithHttp(params: HttpRequestParameters, agent: http.Agent | https.Agent, data: Uint8Array, onDone: (response: ExportResponse) => void, timeoutMillis: number): void;
|
|
16
|
+
export declare function sendWithHttp(request: typeof https.request | typeof http.request, params: HttpRequestParameters, agent: http.Agent | https.Agent, data: Uint8Array, onDone: (response: ExportResponse) => void, timeoutMillis: number): void;
|
|
16
17
|
export declare function compressAndSend(req: http.ClientRequest, compression: 'gzip' | 'none', data: Uint8Array, onError: (error: Error) => void): void;
|
|
17
|
-
export declare function createHttpAgent(rawUrl: string, agentOptions: http.AgentOptions | https.AgentOptions): http.Agent;
|
|
18
18
|
//# sourceMappingURL=http-transport-utils.d.ts.map
|
|
@@ -1,35 +1,18 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright The OpenTelemetry Authors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import * as http from 'http';
|
|
17
|
-
import * as https from 'https';
|
|
18
1
|
import * as zlib from 'zlib';
|
|
19
2
|
import { Readable } from 'stream';
|
|
20
3
|
import { isExportRetryable, parseRetryAfterToMills, } from '../is-export-retryable';
|
|
21
4
|
import { OTLPExporterError } from '../types';
|
|
22
5
|
/**
|
|
23
6
|
* Sends data using http
|
|
7
|
+
* @param requestFunction
|
|
24
8
|
* @param params
|
|
25
9
|
* @param agent
|
|
26
10
|
* @param data
|
|
27
11
|
* @param onDone
|
|
28
12
|
* @param timeoutMillis
|
|
29
13
|
*/
|
|
30
|
-
export function sendWithHttp(params, agent, data, onDone, timeoutMillis) {
|
|
14
|
+
export function sendWithHttp(request, params, agent, data, onDone, timeoutMillis) {
|
|
31
15
|
const parsedUrl = new URL(params.url);
|
|
32
|
-
const nodeVersion = Number(process.versions.node.split('.')[0]);
|
|
33
16
|
const options = {
|
|
34
17
|
hostname: parsedUrl.hostname,
|
|
35
18
|
port: parsedUrl.port,
|
|
@@ -40,7 +23,6 @@ export function sendWithHttp(params, agent, data, onDone, timeoutMillis) {
|
|
|
40
23
|
},
|
|
41
24
|
agent: agent,
|
|
42
25
|
};
|
|
43
|
-
const request = parsedUrl.protocol === 'http:' ? http.request : https.request;
|
|
44
26
|
const req = request(options, (res) => {
|
|
45
27
|
const responseData = [];
|
|
46
28
|
res.on('data', chunk => responseData.push(chunk));
|
|
@@ -79,13 +61,6 @@ export function sendWithHttp(params, agent, data, onDone, timeoutMillis) {
|
|
|
79
61
|
error,
|
|
80
62
|
});
|
|
81
63
|
});
|
|
82
|
-
const reportTimeoutErrorEvent = nodeVersion >= 14 ? 'close' : 'abort';
|
|
83
|
-
req.on(reportTimeoutErrorEvent, () => {
|
|
84
|
-
onDone({
|
|
85
|
-
status: 'failure',
|
|
86
|
-
error: new Error('Request timed out'),
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
64
|
compressAndSend(req, params.compression, data, (error) => {
|
|
90
65
|
onDone({
|
|
91
66
|
status: 'failure',
|
|
@@ -110,9 +85,4 @@ function readableFromUint8Array(buff) {
|
|
|
110
85
|
readable.push(null);
|
|
111
86
|
return readable;
|
|
112
87
|
}
|
|
113
|
-
export function createHttpAgent(rawUrl, agentOptions) {
|
|
114
|
-
const parsedUrl = new URL(rawUrl);
|
|
115
|
-
const Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent;
|
|
116
|
-
return new Agent(agentOptions);
|
|
117
|
-
}
|
|
118
88
|
//# sourceMappingURL=http-transport-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.ts"],"names":[],"mappings":"
|
|
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;AAGlC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAmD,EACnD,MAA6B,EAC7B,KAA+B,EAC/B,IAAgB,EAChB,MAA0C,EAC1C,aAAqB;IAErB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAEtC,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,EAA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AAC,iBAAiB,CAAC;SACpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;QAC/B,MAAM,CAAC;YACL,MAAM,EAAE,SAAS;YACjB,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,KAAY,EAAE,EAAE;QAC9D,MAAM,CAAC;YACL,MAAM,EAAE,SAAS;YACjB,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,GAAuB,EACvB,WAA4B,EAC5B,IAAgB,EAChB,OAA+B;IAE/B,IAAI,UAAU,GAAG,sBAAsB,CAAC,IAAI,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;AAED,SAAS,sBAAsB,CAAC,IAAyB;IACvD,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEpB,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type * as http from 'http';\nimport type * 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 requestFunction\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 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\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 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, 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"]}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { IExporterTransport } from '../exporter-transport';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated favor the fetch transport
|
|
4
|
+
* @see {@link createFetchTransport}
|
|
5
|
+
*/
|
|
2
6
|
export interface XhrRequestParameters {
|
|
3
7
|
url: string;
|
|
4
8
|
headers: () => Record<string, string>;
|
|
5
9
|
}
|
|
6
10
|
/**
|
|
11
|
+
* @deprecated use {@link createFetchTransport} instead
|
|
12
|
+
*
|
|
7
13
|
* Creates an exporter transport that uses XHR to send the data
|
|
8
14
|
* @param parameters applied to each request made by transport
|
|
9
15
|
*/
|
|
@@ -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,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ACtD,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;IACL,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';\n\n/**\n * @deprecated favor the fetch transport\n * @see {@link createFetchTransport}\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 * @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"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.204.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.204.0';\n"]}
|