@opentelemetry/otlp-exporter-base 0.212.0 → 0.213.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/esm/OTLPExporterBase.js +1 -12
- package/build/esm/OTLPExporterBase.js.map +1 -1
- package/build/esm/bounded-queue-export-promise-handler.js +1 -12
- package/build/esm/bounded-queue-export-promise-handler.js.map +1 -1
- package/build/esm/configuration/convert-legacy-browser-http-options.js +1 -12
- package/build/esm/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/build/esm/configuration/convert-legacy-http-options.js +1 -12
- package/build/esm/configuration/convert-legacy-http-options.js.map +1 -1
- package/build/esm/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/esm/configuration/create-legacy-browser-delegate.d.ts +0 -2
- package/build/esm/configuration/create-legacy-browser-delegate.js +2 -9
- package/build/esm/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/build/esm/configuration/legacy-base-configuration.js.map +1 -1
- package/build/esm/configuration/legacy-node-configuration.js +1 -12
- package/build/esm/configuration/legacy-node-configuration.js.map +1 -1
- package/build/esm/configuration/otlp-http-configuration.js +1 -12
- package/build/esm/configuration/otlp-http-configuration.js.map +1 -1
- package/build/esm/configuration/otlp-node-http-configuration.js +1 -12
- package/build/esm/configuration/otlp-node-http-configuration.js.map +1 -1
- package/build/esm/configuration/otlp-node-http-env-configuration.js +1 -12
- package/build/esm/configuration/otlp-node-http-env-configuration.js.map +1 -1
- package/build/esm/configuration/shared-configuration.js +1 -12
- package/build/esm/configuration/shared-configuration.js.map +1 -1
- package/build/esm/configuration/shared-env-configuration.js +1 -12
- package/build/esm/configuration/shared-env-configuration.js.map +1 -1
- package/build/esm/export-response.js +1 -12
- package/build/esm/export-response.js.map +1 -1
- package/build/esm/exporter-transport.js +1 -12
- package/build/esm/exporter-transport.js.map +1 -1
- package/build/esm/index-browser-http.d.ts +3 -0
- package/build/esm/index-browser-http.js +4 -12
- package/build/esm/index-browser-http.js.map +1 -1
- package/build/esm/index-node-http.js +1 -12
- package/build/esm/index-node-http.js.map +1 -1
- package/build/esm/index.js +1 -12
- package/build/esm/index.js.map +1 -1
- package/build/esm/is-export-retryable.js +1 -12
- package/build/esm/is-export-retryable.js.map +1 -1
- package/build/esm/logging-response-handler.js +1 -12
- package/build/esm/logging-response-handler.js.map +1 -1
- package/build/esm/otlp-browser-http-export-delegate.d.ts +3 -0
- package/build/esm/otlp-browser-http-export-delegate.js +4 -7
- package/build/esm/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/esm/otlp-export-delegate.js +1 -12
- package/build/esm/otlp-export-delegate.js.map +1 -1
- package/build/esm/otlp-http-export-delegate.js +1 -12
- package/build/esm/otlp-http-export-delegate.js.map +1 -1
- package/build/esm/otlp-network-export-delegate.js +1 -12
- package/build/esm/otlp-network-export-delegate.js.map +1 -1
- package/build/esm/response-handler.js +1 -12
- package/build/esm/response-handler.js.map +1 -1
- package/build/esm/retrying-transport.js +1 -12
- package/build/esm/retrying-transport.js.map +1 -1
- package/build/esm/transport/fetch-transport.js +52 -18
- package/build/esm/transport/fetch-transport.js.map +1 -1
- package/build/esm/transport/http-exporter-transport.js +1 -12
- package/build/esm/transport/http-exporter-transport.js.map +1 -1
- package/build/esm/transport/http-transport-types.js +1 -12
- package/build/esm/transport/http-transport-types.js.map +1 -1
- package/build/esm/transport/http-transport-utils.d.ts +4 -1
- package/build/esm/transport/http-transport-utils.js +30 -2
- package/build/esm/transport/http-transport-utils.js.map +1 -1
- package/build/esm/transport/node-http-transport-types.js +1 -12
- package/build/esm/transport/node-http-transport-types.js.map +1 -1
- package/build/esm/types.js +1 -12
- package/build/esm/types.js.map +1 -1
- package/build/esm/util.js +1 -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/OTLPExporterBase.js +1 -12
- package/build/esnext/OTLPExporterBase.js.map +1 -1
- package/build/esnext/bounded-queue-export-promise-handler.js +1 -12
- package/build/esnext/bounded-queue-export-promise-handler.js.map +1 -1
- package/build/esnext/configuration/convert-legacy-browser-http-options.js +1 -12
- package/build/esnext/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/build/esnext/configuration/convert-legacy-http-options.js +1 -12
- package/build/esnext/configuration/convert-legacy-http-options.js.map +1 -1
- package/build/esnext/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/esnext/configuration/create-legacy-browser-delegate.d.ts +0 -2
- package/build/esnext/configuration/create-legacy-browser-delegate.js +2 -9
- package/build/esnext/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/build/esnext/configuration/legacy-base-configuration.js.map +1 -1
- package/build/esnext/configuration/legacy-node-configuration.js +1 -12
- package/build/esnext/configuration/legacy-node-configuration.js.map +1 -1
- package/build/esnext/configuration/otlp-http-configuration.js +1 -12
- package/build/esnext/configuration/otlp-http-configuration.js.map +1 -1
- package/build/esnext/configuration/otlp-node-http-configuration.js +1 -12
- package/build/esnext/configuration/otlp-node-http-configuration.js.map +1 -1
- package/build/esnext/configuration/otlp-node-http-env-configuration.js +1 -12
- package/build/esnext/configuration/otlp-node-http-env-configuration.js.map +1 -1
- package/build/esnext/configuration/shared-configuration.js +1 -12
- package/build/esnext/configuration/shared-configuration.js.map +1 -1
- package/build/esnext/configuration/shared-env-configuration.js +1 -12
- package/build/esnext/configuration/shared-env-configuration.js.map +1 -1
- package/build/esnext/export-response.js +1 -12
- package/build/esnext/export-response.js.map +1 -1
- package/build/esnext/exporter-transport.js +1 -12
- package/build/esnext/exporter-transport.js.map +1 -1
- package/build/esnext/index-browser-http.d.ts +3 -0
- package/build/esnext/index-browser-http.js +4 -12
- package/build/esnext/index-browser-http.js.map +1 -1
- package/build/esnext/index-node-http.js +1 -12
- package/build/esnext/index-node-http.js.map +1 -1
- package/build/esnext/index.js +1 -12
- package/build/esnext/index.js.map +1 -1
- package/build/esnext/is-export-retryable.js +1 -12
- package/build/esnext/is-export-retryable.js.map +1 -1
- package/build/esnext/logging-response-handler.js +1 -12
- package/build/esnext/logging-response-handler.js.map +1 -1
- package/build/esnext/otlp-browser-http-export-delegate.d.ts +3 -0
- package/build/esnext/otlp-browser-http-export-delegate.js +4 -7
- package/build/esnext/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/esnext/otlp-export-delegate.js +1 -12
- package/build/esnext/otlp-export-delegate.js.map +1 -1
- package/build/esnext/otlp-http-export-delegate.js +1 -12
- package/build/esnext/otlp-http-export-delegate.js.map +1 -1
- package/build/esnext/otlp-network-export-delegate.js +1 -12
- package/build/esnext/otlp-network-export-delegate.js.map +1 -1
- package/build/esnext/response-handler.js +1 -12
- package/build/esnext/response-handler.js.map +1 -1
- package/build/esnext/retrying-transport.js +1 -12
- package/build/esnext/retrying-transport.js.map +1 -1
- package/build/esnext/transport/fetch-transport.js +52 -18
- package/build/esnext/transport/fetch-transport.js.map +1 -1
- package/build/esnext/transport/http-exporter-transport.js +1 -12
- package/build/esnext/transport/http-exporter-transport.js.map +1 -1
- package/build/esnext/transport/http-transport-types.js +1 -12
- package/build/esnext/transport/http-transport-types.js.map +1 -1
- package/build/esnext/transport/http-transport-utils.d.ts +4 -1
- package/build/esnext/transport/http-transport-utils.js +30 -2
- package/build/esnext/transport/http-transport-utils.js.map +1 -1
- package/build/esnext/transport/node-http-transport-types.js +1 -12
- package/build/esnext/transport/node-http-transport-types.js.map +1 -1
- package/build/esnext/types.js +1 -12
- package/build/esnext/types.js.map +1 -1
- package/build/esnext/util.js +1 -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/OTLPExporterBase.js +1 -12
- package/build/src/OTLPExporterBase.js.map +1 -1
- package/build/src/bounded-queue-export-promise-handler.js +1 -12
- package/build/src/bounded-queue-export-promise-handler.js.map +1 -1
- package/build/src/configuration/convert-legacy-browser-http-options.js +1 -12
- package/build/src/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/build/src/configuration/convert-legacy-http-options.js +1 -12
- package/build/src/configuration/convert-legacy-http-options.js.map +1 -1
- package/build/src/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/src/configuration/create-legacy-browser-delegate.d.ts +0 -2
- package/build/src/configuration/create-legacy-browser-delegate.js +2 -10
- package/build/src/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/build/src/configuration/legacy-base-configuration.js.map +1 -1
- package/build/src/configuration/legacy-node-configuration.js +1 -12
- package/build/src/configuration/legacy-node-configuration.js.map +1 -1
- package/build/src/configuration/otlp-http-configuration.js +1 -12
- package/build/src/configuration/otlp-http-configuration.js.map +1 -1
- package/build/src/configuration/otlp-node-http-configuration.js +1 -12
- package/build/src/configuration/otlp-node-http-configuration.js.map +1 -1
- package/build/src/configuration/otlp-node-http-env-configuration.js +1 -12
- package/build/src/configuration/otlp-node-http-env-configuration.js.map +1 -1
- package/build/src/configuration/shared-configuration.js +1 -12
- package/build/src/configuration/shared-configuration.js.map +1 -1
- package/build/src/configuration/shared-env-configuration.js +1 -12
- package/build/src/configuration/shared-env-configuration.js.map +1 -1
- package/build/src/export-response.js +1 -12
- package/build/src/export-response.js.map +1 -1
- package/build/src/exporter-transport.js +1 -12
- package/build/src/exporter-transport.js.map +1 -1
- package/build/src/index-browser-http.d.ts +3 -0
- package/build/src/index-browser-http.js +4 -12
- package/build/src/index-browser-http.js.map +1 -1
- package/build/src/index-node-http.js +1 -12
- package/build/src/index-node-http.js.map +1 -1
- package/build/src/index.js +1 -12
- package/build/src/index.js.map +1 -1
- package/build/src/is-export-retryable.js +1 -12
- package/build/src/is-export-retryable.js.map +1 -1
- package/build/src/logging-response-handler.js +1 -12
- package/build/src/logging-response-handler.js.map +1 -1
- package/build/src/otlp-browser-http-export-delegate.d.ts +3 -0
- package/build/src/otlp-browser-http-export-delegate.js +4 -7
- package/build/src/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/src/otlp-export-delegate.js +1 -12
- package/build/src/otlp-export-delegate.js.map +1 -1
- package/build/src/otlp-http-export-delegate.js +1 -12
- package/build/src/otlp-http-export-delegate.js.map +1 -1
- package/build/src/otlp-network-export-delegate.js +1 -12
- package/build/src/otlp-network-export-delegate.js.map +1 -1
- package/build/src/response-handler.js +1 -12
- package/build/src/response-handler.js.map +1 -1
- package/build/src/retrying-transport.js +1 -12
- package/build/src/retrying-transport.js.map +1 -1
- package/build/src/transport/fetch-transport.js +52 -18
- package/build/src/transport/fetch-transport.js.map +1 -1
- package/build/src/transport/http-exporter-transport.js +1 -12
- package/build/src/transport/http-exporter-transport.js.map +1 -1
- package/build/src/transport/http-transport-types.js +1 -12
- package/build/src/transport/http-transport-types.js.map +1 -1
- package/build/src/transport/http-transport-utils.d.ts +4 -1
- package/build/src/transport/http-transport-utils.js +30 -2
- package/build/src/transport/http-transport-utils.js.map +1 -1
- package/build/src/transport/node-http-transport-types.js +1 -12
- package/build/src/transport/node-http-transport-types.js.map +1 -1
- package/build/src/types.js +1 -12
- package/build/src/types.js.map +1 -1
- package/build/src/util.js +1 -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 +4 -4
- package/build/esm/transport/send-beacon-transport.d.ts +0 -12
- package/build/esm/transport/send-beacon-transport.js +0 -47
- package/build/esm/transport/send-beacon-transport.js.map +0 -1
- package/build/esnext/transport/send-beacon-transport.d.ts +0 -12
- package/build/esnext/transport/send-beacon-transport.js +0 -47
- package/build/esnext/transport/send-beacon-transport.js.map +0 -1
- package/build/src/transport/send-beacon-transport.d.ts +0 -12
- package/build/src/transport/send-beacon-transport.js +0 -51
- package/build/src/transport/send-beacon-transport.js.map +0 -1
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
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.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
export { httpAgentFactoryFromOptions } from './configuration/otlp-node-http-configuration';
|
|
17
6
|
export { createOtlpHttpExportDelegate } from './otlp-http-export-delegate';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-node-http.js","sourceRoot":"","sources":["../../src/index-node-http.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index-node-http.js","sourceRoot":"","sources":["../../src/index-node-http.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,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 * SPDX-License-Identifier: Apache-2.0\n */\n\nexport { httpAgentFactoryFromOptions } from './configuration/otlp-node-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"]}
|
package/build/esm/index.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
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.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
export { OTLPExporterBase } from './OTLPExporterBase';
|
|
17
6
|
export { OTLPExporterError } from './types';
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAW5C,OAAO,EACL,wCAAwC,EACxC,8BAA8B,GAC/B,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAIjF,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport { OTLPExporterBase } from './OTLPExporterBase';\nexport { OTLPExporterError } from './types';\n\nexport type {\n ExportResponse,\n ExportResponseFailure,\n ExportResponseSuccess,\n ExportResponseRetryable,\n} from './export-response';\n\nexport type { IExporterTransport } from './exporter-transport';\n\nexport {\n mergeOtlpSharedConfigurationWithDefaults,\n getSharedConfigurationDefaults,\n} from './configuration/shared-configuration';\nexport type { OtlpSharedConfiguration } from './configuration/shared-configuration';\n\nexport { CompressionAlgorithm } from './configuration/legacy-node-configuration';\nexport type { OTLPExporterNodeConfigBase } from './configuration/legacy-node-configuration';\nexport type { OTLPExporterConfigBase } from './configuration/legacy-base-configuration';\nexport type { IOtlpExportDelegate } from './otlp-export-delegate';\nexport { createOtlpNetworkExportDelegate } from './otlp-network-export-delegate';\n"]}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
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.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
export function isExportHTTPErrorRetryable(statusCode) {
|
|
17
6
|
return (statusCode === 429 ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-export-retryable.js","sourceRoot":"","sources":["../../src/is-export-retryable.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"is-export-retryable.js","sourceRoot":"","sources":["../../src/is-export-retryable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,UAAU,0BAA0B,CAAC,UAAkB;IAC3D,OAAO,CACL,UAAU,KAAK,GAAG;QAClB,UAAU,KAAK,GAAG;QAClB,UAAU,KAAK,GAAG;QAClB,UAAU,KAAK,GAAG,CACnB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,UAAsC;IAEtC,IAAI,UAAU,IAAI,IAAI,EAAE;QACtB,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAChD,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QAC7B,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC1C;IACD,mFAAmF;IACnF,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE1D,IAAI,KAAK,IAAI,CAAC,EAAE;QACd,OAAO,KAAK,CAAC;KACd;IACD,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport function isExportHTTPErrorRetryable(statusCode: number): boolean {\n return (\n statusCode === 429 ||\n statusCode === 502 ||\n statusCode === 503 ||\n statusCode === 504\n );\n}\n\nexport function parseRetryAfterToMills(\n retryAfter?: string | undefined | null\n): number | undefined {\n if (retryAfter == null) {\n return undefined;\n }\n\n const seconds = Number.parseInt(retryAfter, 10);\n if (Number.isInteger(seconds)) {\n return seconds > 0 ? seconds * 1000 : -1;\n }\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#directives\n const delay = new Date(retryAfter).getTime() - Date.now();\n\n if (delay >= 0) {\n return delay;\n }\n return 0;\n}\n"]}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
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.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
import { diag } from '@opentelemetry/api';
|
|
17
6
|
function isPartialSuccessResponse(response) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging-response-handler.js","sourceRoot":"","sources":["../../src/logging-response-handler.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logging-response-handler.js","sourceRoot":"","sources":["../../src/logging-response-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,SAAS,wBAAwB,CAC/B,QAAiB;IAEjB,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AAC1E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0CAA0C;IAGxD,OAAO;QACL,cAAc,CAAC,QAAW;YACxB,4EAA4E;YAC5E,gEAAgE;YAChE,IACE,QAAQ,IAAI,IAAI;gBAChB,CAAC,wBAAwB,CAAC,QAAQ,CAAC;gBACnC,QAAQ,CAAC,cAAc,IAAI,IAAI;gBAC/B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,MAAM,KAAK,CAAC,EACjD;gBACA,OAAO;aACR;YACD,IAAI,CAAC,IAAI,CACP,oCAAoC,EACpC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,CACxC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { diag } from '@opentelemetry/api';\nimport { IOtlpResponseHandler } from './response-handler';\n\nfunction isPartialSuccessResponse(\n response: unknown\n): response is { partialSuccess: never } {\n return Object.prototype.hasOwnProperty.call(response, 'partialSuccess');\n}\n\n/**\n * Default response handler that logs a partial success to the console.\n */\nexport function createLoggingPartialSuccessResponseHandler<\n T,\n>(): IOtlpResponseHandler<T> {\n return {\n handleResponse(response: T) {\n // Partial success MUST never be an empty object according the specification\n // see https://opentelemetry.io/docs/specs/otlp/#partial-success\n if (\n response == null ||\n !isPartialSuccessResponse(response) ||\n response.partialSuccess == null ||\n Object.keys(response.partialSuccess).length === 0\n ) {\n return;\n }\n diag.warn(\n 'Received Partial Success response:',\n JSON.stringify(response.partialSuccess)\n );\n },\n };\n}\n"]}
|
|
@@ -2,5 +2,8 @@ import { OtlpHttpConfiguration } from './configuration/otlp-http-configuration';
|
|
|
2
2
|
import { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
3
3
|
import { IOtlpExportDelegate } from './otlp-export-delegate';
|
|
4
4
|
export declare function createOtlpFetchExportDelegate<Internal, Response>(options: OtlpHttpConfiguration, serializer: ISerializer<Internal, Response>): IOtlpExportDelegate<Internal>;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use {@link createOtlpFetchExportDelegate} instead. Modern browsers use `fetch` with `keepAlive: true` when `sendBeacon` is used. Use a `fetch` polyfill that mimics this behavior to keep using `sendBeacon`.
|
|
7
|
+
*/
|
|
5
8
|
export declare function createOtlpSendBeaconExportDelegate<Internal, Response>(options: OtlpHttpConfiguration, serializer: ISerializer<Internal, Response>): IOtlpExportDelegate<Internal>;
|
|
6
9
|
//# sourceMappingURL=otlp-browser-http-export-delegate.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createRetryingTransport } from './retrying-transport';
|
|
2
|
-
import { createSendBeaconTransport } from './transport/send-beacon-transport';
|
|
3
2
|
import { createOtlpNetworkExportDelegate } from './otlp-network-export-delegate';
|
|
4
3
|
import { createFetchTransport } from './transport/fetch-transport';
|
|
5
4
|
export function createOtlpFetchExportDelegate(options, serializer) {
|
|
@@ -7,12 +6,10 @@ export function createOtlpFetchExportDelegate(options, serializer) {
|
|
|
7
6
|
transport: createFetchTransport(options),
|
|
8
7
|
}));
|
|
9
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use {@link createOtlpFetchExportDelegate} instead. Modern browsers use `fetch` with `keepAlive: true` when `sendBeacon` is used. Use a `fetch` polyfill that mimics this behavior to keep using `sendBeacon`.
|
|
11
|
+
*/
|
|
10
12
|
export function createOtlpSendBeaconExportDelegate(options, serializer) {
|
|
11
|
-
return
|
|
12
|
-
transport: createSendBeaconTransport({
|
|
13
|
-
url: options.url,
|
|
14
|
-
headers: options.headers,
|
|
15
|
-
}),
|
|
16
|
-
}));
|
|
13
|
+
return createOtlpFetchExportDelegate(options, serializer);
|
|
17
14
|
}
|
|
18
15
|
//# sourceMappingURL=otlp-browser-http-export-delegate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-browser-http-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-browser-http-export-delegate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"otlp-browser-http-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-browser-http-export-delegate.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,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;;GAEG;AACH,MAAM,UAAU,kCAAkC,CAChD,OAA8B,EAC9B,UAA2C;IAE3C,OAAO,6BAA6B,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\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 { createOtlpNetworkExportDelegate } from './otlp-network-export-delegate';\nimport { createFetchTransport } from './transport/fetch-transport';\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\n/**\n * @deprecated Use {@link createOtlpFetchExportDelegate} instead. Modern browsers use `fetch` with `keepAlive: true` when `sendBeacon` is used. Use a `fetch` polyfill that mimics this behavior to keep using `sendBeacon`.\n */\nexport function createOtlpSendBeaconExportDelegate<Internal, Response>(\n options: OtlpHttpConfiguration,\n serializer: ISerializer<Internal, Response>\n): IOtlpExportDelegate<Internal> {\n return createOtlpFetchExportDelegate(options, serializer);\n}\n"]}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
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.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
import { ExportResultCode } from '@opentelemetry/core';
|
|
17
6
|
import { OTLPExporterError } from './types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-export-delegate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"otlp-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-export-delegate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAgB,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,0CAA0C,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAE,IAAI,EAAc,MAAM,oBAAoB,CAAC;AActD,MAAM,kBAAkB;IAGd,WAAW,CAAa;IACxB,UAAU,CAAqB;IAC/B,WAAW,CAAkC;IAC7C,gBAAgB,CAAiC;IACjD,aAAa,CAAwB;IACrC,QAAQ,CAAS;IAEzB,YACE,SAA6B,EAC7B,UAA2C,EAC3C,eAA+C,EAC/C,YAAmC,EACnC,OAAe;QAEf,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,qBAAqB,CAAC;YAC5C,SAAS,EAAE,oBAAoB;SAChC,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CACjB,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ExportResult, ExportResultCode } from '@opentelemetry/core';\nimport { IExporterTransport } from './exporter-transport';\nimport { IExportPromiseHandler } from './bounded-queue-export-promise-handler';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { OTLPExporterError } from './types';\nimport { IOtlpResponseHandler } from './response-handler';\nimport { createLoggingPartialSuccessResponseHandler } from './logging-response-handler';\nimport { diag, DiagLogger } from '@opentelemetry/api';\n\n/**\n * Internally shared export logic for OTLP.\n */\nexport interface IOtlpExportDelegate<Internal> {\n export(\n internalRepresentation: Internal,\n resultCallback: (result: ExportResult) => void\n ): void;\n forceFlush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nclass OTLPExportDelegate<Internal, Response>\n implements IOtlpExportDelegate<Internal>\n{\n private _diagLogger: DiagLogger;\n private _transport: IExporterTransport;\n private _serializer: ISerializer<Internal, Response>;\n private _responseHandler: IOtlpResponseHandler<Response>;\n private _promiseQueue: IExportPromiseHandler;\n private _timeout: number;\n\n constructor(\n transport: IExporterTransport,\n serializer: ISerializer<Internal, Response>,\n responseHandler: IOtlpResponseHandler<Response>,\n promiseQueue: IExportPromiseHandler,\n timeout: number\n ) {\n this._transport = transport;\n this._serializer = serializer;\n this._responseHandler = responseHandler;\n this._promiseQueue = promiseQueue;\n this._timeout = timeout;\n this._diagLogger = diag.createComponentLogger({\n namespace: 'OTLPExportDelegate',\n });\n }\n\n export(\n internalRepresentation: Internal,\n resultCallback: (result: ExportResult) => void\n ): void {\n this._diagLogger.debug('items to be sent', internalRepresentation);\n\n // don't do any work if too many exports are in progress.\n if (this._promiseQueue.hasReachedLimit()) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Concurrent export limit reached'),\n });\n return;\n }\n\n const serializedRequest = this._serializer.serializeRequest(\n internalRepresentation\n );\n\n if (serializedRequest == null) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Nothing to send'),\n });\n return;\n }\n\n this._promiseQueue.pushPromise(\n this._transport.send(serializedRequest, this._timeout).then(\n response => {\n if (response.status === 'success') {\n if (response.data != null) {\n try {\n this._responseHandler.handleResponse(\n this._serializer.deserializeResponse(response.data)\n );\n } catch (e) {\n this._diagLogger.warn(\n 'Export succeeded but could not deserialize response - is the response specification compliant?',\n e,\n response.data\n );\n }\n }\n // No matter the response, we can consider the export still successful.\n resultCallback({\n code: ExportResultCode.SUCCESS,\n });\n return;\n } else if (response.status === 'failure' && response.error) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: response.error,\n });\n return;\n } else if (response.status === 'retryable') {\n resultCallback({\n code: ExportResultCode.FAILED,\n error:\n response.error ??\n new OTLPExporterError('Export failed with retryable status'),\n });\n } else {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new OTLPExporterError('Export failed with unknown error'),\n });\n }\n },\n reason =>\n resultCallback({\n code: ExportResultCode.FAILED,\n error: reason,\n })\n )\n );\n }\n\n forceFlush(): Promise<void> {\n return this._promiseQueue.awaitAll();\n }\n\n async shutdown(): Promise<void> {\n this._diagLogger.debug('shutdown started');\n await this.forceFlush();\n this._transport.shutdown();\n }\n}\n\n/**\n * Creates a generic delegate for OTLP exports which only contains parts of the OTLP export that are shared across all\n * signals.\n */\nexport function createOtlpExportDelegate<Internal, Response>(\n components: {\n transport: IExporterTransport;\n serializer: ISerializer<Internal, Response>;\n promiseHandler: IExportPromiseHandler;\n },\n settings: { timeout: number }\n): IOtlpExportDelegate<Internal> {\n return new OTLPExportDelegate(\n components.transport,\n components.serializer,\n createLoggingPartialSuccessResponseHandler(),\n components.promiseHandler,\n settings.timeout\n );\n}\n"]}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
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.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
import { createOtlpExportDelegate, } from './otlp-export-delegate';
|
|
17
6
|
import { createHttpExporterTransport } from './transport/http-exporter-transport';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-http-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-http-export-delegate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"otlp-http-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-http-export-delegate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,wBAAwB,GAEzB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,sCAAsC,EAAE,MAAM,wCAAwC,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,MAAM,UAAU,4BAA4B,CAC1C,OAAkC,EAClC,UAA2C;IAE3C,OAAO,wBAAwB,CAC7B;QACE,SAAS,EAAE,uBAAuB,CAAC;YACjC,SAAS,EAAE,2BAA2B,CAAC,OAAO,CAAC;SAChD,CAAC;QACF,UAAU,EAAE,UAAU;QACtB,cAAc,EAAE,sCAAsC,CAAC,OAAO,CAAC;KAChE,EACD,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE,CACnC,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n createOtlpExportDelegate,\n IOtlpExportDelegate,\n} from './otlp-export-delegate';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { createHttpExporterTransport } from './transport/http-exporter-transport';\nimport { createBoundedQueueExportPromiseHandler } from './bounded-queue-export-promise-handler';\nimport { createRetryingTransport } from './retrying-transport';\nimport { OtlpNodeHttpConfiguration } from './configuration/otlp-node-http-configuration';\n\nexport function createOtlpHttpExportDelegate<Internal, Response>(\n options: OtlpNodeHttpConfiguration,\n serializer: ISerializer<Internal, Response>\n): IOtlpExportDelegate<Internal> {\n return createOtlpExportDelegate(\n {\n transport: createRetryingTransport({\n transport: createHttpExporterTransport(options),\n }),\n serializer: serializer,\n promiseHandler: createBoundedQueueExportPromiseHandler(options),\n },\n { timeout: options.timeoutMillis }\n );\n}\n"]}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
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.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
import { createBoundedQueueExportPromiseHandler } from './bounded-queue-export-promise-handler';
|
|
17
6
|
import { createOtlpExportDelegate, } from './otlp-export-delegate';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-network-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-network-export-delegate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"otlp-network-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-network-export-delegate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sCAAsC,EAAE,MAAM,wCAAwC,CAAC;AAIhG,OAAO,EACL,wBAAwB,GAEzB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,UAAU,+BAA+B,CAC7C,OAAgC,EAChC,UAA2C,EAC3C,SAA6B;IAE7B,OAAO,wBAAwB,CAC7B;QACE,SAAS,EAAE,SAAS;QACpB,UAAU;QACV,cAAc,EAAE,sCAAsC,CAAC,OAAO,CAAC;KAChE,EACD,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE,CACnC,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { createBoundedQueueExportPromiseHandler } from './bounded-queue-export-promise-handler';\nimport { OtlpSharedConfiguration } from './configuration/shared-configuration';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { IExporterTransport } from './exporter-transport';\nimport {\n createOtlpExportDelegate,\n IOtlpExportDelegate,\n} from './otlp-export-delegate';\n\nexport function createOtlpNetworkExportDelegate<Internal, Response>(\n options: OtlpSharedConfiguration,\n serializer: ISerializer<Internal, Response>,\n transport: IExporterTransport\n): IOtlpExportDelegate<Internal> {\n return createOtlpExportDelegate(\n {\n transport: transport,\n serializer,\n promiseHandler: createBoundedQueueExportPromiseHandler(options),\n },\n { timeout: options.timeoutMillis }\n );\n}\n"]}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
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.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
export {};
|
|
17
6
|
//# sourceMappingURL=response-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-handler.js","sourceRoot":"","sources":["../../src/response-handler.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"response-handler.js","sourceRoot":"","sources":["../../src/response-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Generic export response handler. Can be implemented to handle export responses like partial success.\n */\nexport interface IOtlpResponseHandler<Response> {\n /**\n * Handles an OTLP export response.\n * Implementations MUST NOT throw.\n * @param response\n */\n handleResponse(response: Response): void;\n}\n"]}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
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.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
import { diag } from '@opentelemetry/api';
|
|
17
6
|
const MAX_ATTEMPTS = 5;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrying-transport.js","sourceRoot":"","sources":["../../src/retrying-transport.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"retrying-transport.js","sourceRoot":"","sources":["../../src/retrying-transport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,MAAM,GAAG,GAAG,CAAC;AAEnB;;GAEG;AACH,SAAS,SAAS;IAChB,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AAC/C,CAAC;AAED,MAAM,iBAAiB;IACb,UAAU,CAAqB;IAEvC,YAAY,SAA6B;QACvC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAEO,KAAK,CACX,IAAgB,EAChB,aAAqB,EACrB,QAAgB;QAEhB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAClE,CAAC,EAAE,QAAQ,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAChD,IAAI,QAAQ,GAAG,YAAY,CAAC;QAC5B,IAAI,WAAW,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xC,IAAI,CAAC,IAAI,CACP,+CAA+C,YAAY,IAAI,CAChE,CAAC;SACH;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,2CAA2C,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;SACtE;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAGvC;IACC,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClD,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IExporterTransport } from './exporter-transport';\nimport { ExportResponse } from './export-response';\nimport { diag } from '@opentelemetry/api';\n\nconst MAX_ATTEMPTS = 5;\nconst INITIAL_BACKOFF = 1000;\nconst MAX_BACKOFF = 5000;\nconst BACKOFF_MULTIPLIER = 1.5;\nconst JITTER = 0.2;\n\n/**\n * Get a pseudo-random jitter that falls in the range of [-JITTER, +JITTER]\n */\nfunction getJitter() {\n return Math.random() * (2 * JITTER) - JITTER;\n}\n\nclass RetryingTransport implements IExporterTransport {\n private _transport: IExporterTransport;\n\n constructor(transport: IExporterTransport) {\n this._transport = transport;\n }\n\n private retry(\n data: Uint8Array,\n timeoutMillis: number,\n inMillis: number\n ): Promise<ExportResponse> {\n return new Promise((resolve, reject) => {\n setTimeout(() => {\n this._transport.send(data, timeoutMillis).then(resolve, reject);\n }, inMillis);\n });\n }\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n let attempts = MAX_ATTEMPTS;\n let nextBackoff = INITIAL_BACKOFF;\n\n const deadline = Date.now() + timeoutMillis;\n let result = await this._transport.send(data, timeoutMillis);\n\n while (result.status === 'retryable' && attempts > 0) {\n attempts--;\n\n // use maximum of computed backoff and 0 to avoid negative timeouts\n const backoff = Math.max(\n Math.min(nextBackoff * (1 + getJitter()), MAX_BACKOFF),\n 0\n );\n nextBackoff = nextBackoff * BACKOFF_MULTIPLIER;\n const retryInMillis = result.retryInMillis ?? backoff;\n\n // return when expected retry time is after the export deadline.\n const remainingTimeoutMillis = deadline - Date.now();\n if (retryInMillis > remainingTimeoutMillis) {\n diag.info(\n `Export retry time ${Math.round(retryInMillis)}ms exceeds remaining timeout ${Math.round(\n remainingTimeoutMillis\n )}ms, not retrying further.`\n );\n return result;\n }\n\n diag.verbose(`Scheduling export retry in ${Math.round(retryInMillis)}ms`);\n result = await this.retry(data, remainingTimeoutMillis, retryInMillis);\n }\n\n if (result.status === 'success') {\n diag.verbose(\n `Export succeeded after ${MAX_ATTEMPTS - attempts} retry attempts.`\n );\n } else if (result.status === 'retryable') {\n diag.info(\n `Export failed after maximum retry attempts (${MAX_ATTEMPTS}).`\n );\n } else {\n diag.info(`Export failed with non-retryable error: ${result.error}`);\n }\n\n return result;\n }\n\n shutdown() {\n return this._transport.shutdown();\n }\n}\n\n/**\n * Creates an Exporter Transport that retries on 'retryable' response.\n */\nexport function createRetryingTransport(options: {\n // Underlying transport to wrap.\n transport: IExporterTransport;\n}): IExporterTransport {\n return new RetryingTransport(options.transport);\n}\n"]}
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
/*
|
|
2
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.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
import { diag } from '@opentelemetry/api';
|
|
17
6
|
import { isExportHTTPErrorRetryable, parseRetryAfterToMills, } from '../is-export-retryable';
|
|
7
|
+
/**
|
|
8
|
+
* Maximum total body size for concurrent keepalive requests.
|
|
9
|
+
* Browsers enforce a 64KiB cumulative limit across all pending keepalive requests.
|
|
10
|
+
* We use 60KB to leave headroom for headers.
|
|
11
|
+
* @see https://github.com/whatwg/fetch/issues/679
|
|
12
|
+
* @see https://blog.huli.tw/2025/01/06/en/navigator-sendbeacon-64kib-and-source-code/
|
|
13
|
+
*/
|
|
14
|
+
const MAX_KEEPALIVE_BODY_SIZE = 60 * 1024;
|
|
15
|
+
/**
|
|
16
|
+
* Maximum concurrent keepalive requests.
|
|
17
|
+
* Chrome enforces 9 concurrent keepalive fetch requests per renderer process.
|
|
18
|
+
* @see https://github.com/whatwg/fetch/issues/679
|
|
19
|
+
* Quote: "If the renderer process is processing more than 9 requests with keepalive set, we reject a new request"
|
|
20
|
+
*/
|
|
21
|
+
const MAX_KEEPALIVE_REQUESTS = 9;
|
|
22
|
+
/**
|
|
23
|
+
* Track cumulative pending body size across all in-flight keepalive requests.
|
|
24
|
+
* This is necessary because the 64KiB limit is cumulative, not per-request.
|
|
25
|
+
*/
|
|
26
|
+
let pendingBodySize = 0;
|
|
27
|
+
/**
|
|
28
|
+
* Track number of pending keepalive requests.
|
|
29
|
+
*/
|
|
30
|
+
let pendingKeepaliveCount = 0;
|
|
18
31
|
class FetchTransport {
|
|
19
32
|
_parameters;
|
|
20
33
|
constructor(parameters) {
|
|
@@ -35,37 +48,53 @@ class FetchTransport {
|
|
|
35
48
|
// @ts-expect-error -- fetch could be wrapped
|
|
36
49
|
fetchApi = fetchApi.__original;
|
|
37
50
|
}
|
|
51
|
+
const requestSize = data.byteLength;
|
|
52
|
+
// Determine if we can use keepalive based on cumulative browser limits.
|
|
53
|
+
// We must check BEFORE adding to pending totals to avoid exceeding limits.
|
|
54
|
+
const wouldExceedSize = pendingBodySize + requestSize > MAX_KEEPALIVE_BODY_SIZE;
|
|
55
|
+
const wouldExceedCount = pendingKeepaliveCount >= MAX_KEEPALIVE_REQUESTS;
|
|
56
|
+
const useKeepalive = !wouldExceedSize && !wouldExceedCount;
|
|
57
|
+
if (useKeepalive) {
|
|
58
|
+
pendingBodySize += requestSize;
|
|
59
|
+
pendingKeepaliveCount++;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const reason = wouldExceedSize ? 'size limit' : 'count limit';
|
|
63
|
+
diag.debug(`keepalive disabled: ${(requestSize / 1024).toFixed(1)}KB payload, ${pendingKeepaliveCount} pending (${reason})`);
|
|
64
|
+
}
|
|
38
65
|
try {
|
|
39
|
-
const isBrowserEnvironment = !!globalThis.location;
|
|
40
66
|
const url = new URL(this._parameters.url);
|
|
41
67
|
const response = await fetchApi(url.href, {
|
|
42
68
|
method: 'POST',
|
|
43
69
|
headers: await this._parameters.headers(),
|
|
44
70
|
body: data,
|
|
45
71
|
signal: abortController.signal,
|
|
46
|
-
keepalive:
|
|
47
|
-
mode:
|
|
48
|
-
? globalThis.location
|
|
72
|
+
keepalive: useKeepalive,
|
|
73
|
+
mode: globalThis.location
|
|
74
|
+
? globalThis.location.origin === url.origin
|
|
49
75
|
? 'same-origin'
|
|
50
76
|
: 'cors'
|
|
51
77
|
: 'no-cors',
|
|
52
78
|
});
|
|
53
79
|
if (response.status >= 200 && response.status <= 299) {
|
|
54
|
-
diag.debug(
|
|
80
|
+
diag.debug(`export response success (status: ${response.status})`);
|
|
55
81
|
return { status: 'success' };
|
|
56
82
|
}
|
|
57
83
|
else if (isExportHTTPErrorRetryable(response.status)) {
|
|
84
|
+
diag.warn(`export response retryable (status: ${response.status})`);
|
|
58
85
|
const retryAfter = response.headers.get('Retry-After');
|
|
59
86
|
const retryInMillis = parseRetryAfterToMills(retryAfter);
|
|
60
87
|
return { status: 'retryable', retryInMillis };
|
|
61
88
|
}
|
|
89
|
+
diag.error(`export response failure (status: ${response.status})`);
|
|
62
90
|
return {
|
|
63
91
|
status: 'failure',
|
|
64
|
-
error: new Error(
|
|
92
|
+
error: new Error(`Fetch request failed with non-retryable status ${response.status}`),
|
|
65
93
|
};
|
|
66
94
|
}
|
|
67
95
|
catch (error) {
|
|
68
96
|
if (isFetchNetworkErrorRetryable(error)) {
|
|
97
|
+
diag.warn(`export request retryable (network error: ${error})`);
|
|
69
98
|
return {
|
|
70
99
|
status: 'retryable',
|
|
71
100
|
error: new Error('Fetch request encountered a network error', {
|
|
@@ -73,6 +102,7 @@ class FetchTransport {
|
|
|
73
102
|
}),
|
|
74
103
|
};
|
|
75
104
|
}
|
|
105
|
+
diag.error(`export request failure (error: ${error})`);
|
|
76
106
|
return {
|
|
77
107
|
status: 'failure',
|
|
78
108
|
error: new Error('Fetch request errored', { cause: error }),
|
|
@@ -80,6 +110,10 @@ class FetchTransport {
|
|
|
80
110
|
}
|
|
81
111
|
finally {
|
|
82
112
|
clearTimeout(timeout);
|
|
113
|
+
if (useKeepalive) {
|
|
114
|
+
pendingBodySize -= requestSize;
|
|
115
|
+
pendingKeepaliveCount--;
|
|
116
|
+
}
|
|
83
117
|
}
|
|
84
118
|
}
|
|
85
119
|
shutdown() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-transport.js","sourceRoot":"","sources":["../../../src/transport/fetch-transport.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fetch-transport.js","sourceRoot":"","sources":["../../../src/transport/fetch-transport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAGhC;;;;;;GAMG;AACH,MAAM,uBAAuB,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,sBAAsB,GAA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,CAAC;YACnE,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,KAAK,EAAE,IAAI,KAAK,CACd,kDAAkD,QAAQ,CAAC,MAAM,EAAE,CACpE;aACF,CAAC;SACH;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,4BAA4B,CAAC,KAAK,CAAC,EAAE;gBACvC,IAAI,CAAC,IAAI,CAAC,4CAA4C,KAAK,GAAG,CAAC,CAAC;gBAChE,OAAO;oBACL,MAAM,EAAE,WAAW;oBACnB,KAAK,EAAE,IAAI,KAAK,CAAC,2CAA2C,EAAE;wBAC5D,KAAK,EAAE,KAAK;qBACb,CAAC;iBACH,CAAC;aACH;YACD,IAAI,CAAC,KAAK,CAAC,kCAAkC,KAAK,GAAG,CAAC,CAAC;YACvD,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;aAC5D,CAAC;SACH;gBAAS;YACR,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,IAAI,YAAY,EAAE;gBAChB,eAAe,IAAI,WAAW,CAAC;gBAC/B,qBAAqB,EAAE,CAAC;aACzB;SACF;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;AAED,SAAS,4BAA4B,CAAC,KAAc;IAClD,OAAO,KAAK,YAAY,SAAS,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;AACpD,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IExporterTransport } from '../exporter-transport';\nimport { ExportResponse } from '../export-response';\nimport { diag } from '@opentelemetry/api';\nimport {\n isExportHTTPErrorRetryable,\n parseRetryAfterToMills,\n} from '../is-export-retryable';\nimport { HeadersFactory } from '../configuration/otlp-http-configuration';\n\n/**\n * Maximum total body size for concurrent keepalive requests.\n * Browsers enforce a 64KiB cumulative limit across all pending keepalive requests.\n * We use 60KB to leave headroom for headers.\n * @see https://github.com/whatwg/fetch/issues/679\n * @see https://blog.huli.tw/2025/01/06/en/navigator-sendbeacon-64kib-and-source-code/\n */\nconst MAX_KEEPALIVE_BODY_SIZE = 60 * 1024;\n\n/**\n * Maximum concurrent keepalive requests.\n * Chrome enforces 9 concurrent keepalive fetch requests per renderer process.\n * @see https://github.com/whatwg/fetch/issues/679\n * Quote: \"If the renderer process is processing more than 9 requests with keepalive set, we reject a new request\"\n */\nconst MAX_KEEPALIVE_REQUESTS = 9;\n\n/**\n * Track cumulative pending body size across all in-flight keepalive requests.\n * This is necessary because the 64KiB limit is cumulative, not per-request.\n */\nlet pendingBodySize = 0;\n\n/**\n * Track number of pending keepalive requests.\n */\nlet pendingKeepaliveCount = 0;\n\nexport interface FetchTransportParameters {\n url: string;\n headers: HeadersFactory;\n}\n\nclass FetchTransport implements IExporterTransport {\n private _parameters: FetchTransportParameters;\n\n constructor(parameters: FetchTransportParameters) {\n this._parameters = parameters;\n }\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n const abortController = new AbortController();\n const timeout = setTimeout(() => abortController.abort(), timeoutMillis);\n // Fetch API may be wrapped by an instrumentation like `@opentelemetry/instrumentation-fetch`.\n // In that case the instrumentation would create a new Span for this request\n // because the context manager cannot keep the context after `await` calls.\n // This creates an indirect endless loop Export -> Span -> Export\n // By using the `__original` function the instrumentation can't intercept the call\n // and no Span will be created breaking the vicious cycle\n let fetchApi = globalThis.fetch;\n // @ts-expect-error -- fetch could be wrapped\n if (typeof fetchApi.__original === 'function') {\n // @ts-expect-error -- fetch could be wrapped\n fetchApi = fetchApi.__original;\n }\n\n const requestSize = data.byteLength;\n\n // Determine if we can use keepalive based on cumulative browser limits.\n // We must check BEFORE adding to pending totals to avoid exceeding limits.\n const wouldExceedSize =\n pendingBodySize + requestSize > MAX_KEEPALIVE_BODY_SIZE;\n const wouldExceedCount = pendingKeepaliveCount >= MAX_KEEPALIVE_REQUESTS;\n const useKeepalive = !wouldExceedSize && !wouldExceedCount;\n\n if (useKeepalive) {\n pendingBodySize += requestSize;\n pendingKeepaliveCount++;\n } else {\n const reason = wouldExceedSize ? 'size limit' : 'count limit';\n diag.debug(\n `keepalive disabled: ${(requestSize / 1024).toFixed(1)}KB payload, ${pendingKeepaliveCount} pending (${reason})`\n );\n }\n\n try {\n const url = new URL(this._parameters.url);\n const response = await fetchApi(url.href, {\n method: 'POST',\n headers: await this._parameters.headers(),\n body: data,\n signal: abortController.signal,\n keepalive: useKeepalive,\n mode: globalThis.location\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(`export response success (status: ${response.status})`);\n return { status: 'success' };\n } else if (isExportHTTPErrorRetryable(response.status)) {\n diag.warn(`export response retryable (status: ${response.status})`);\n const retryAfter = response.headers.get('Retry-After');\n const retryInMillis = parseRetryAfterToMills(retryAfter);\n return { status: 'retryable', retryInMillis };\n }\n diag.error(`export response failure (status: ${response.status})`);\n return {\n status: 'failure',\n error: new Error(\n `Fetch request failed with non-retryable status ${response.status}`\n ),\n };\n } catch (error) {\n if (isFetchNetworkErrorRetryable(error)) {\n diag.warn(`export request retryable (network error: ${error})`);\n return {\n status: 'retryable',\n error: new Error('Fetch request encountered a network error', {\n cause: error,\n }),\n };\n }\n diag.error(`export request failure (error: ${error})`);\n return {\n status: 'failure',\n error: new Error('Fetch request errored', { cause: error }),\n };\n } finally {\n clearTimeout(timeout);\n if (useKeepalive) {\n pendingBodySize -= requestSize;\n pendingKeepaliveCount--;\n }\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\nfunction isFetchNetworkErrorRetryable(error: unknown): boolean {\n return error instanceof TypeError && !error.cause;\n}\n"]}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
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.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
import { sendWithHttp } from './http-transport-utils';
|
|
17
6
|
class HttpExporterTransport {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-exporter-transport.js","sourceRoot":"","sources":["../../../src/transport/http-exporter-transport.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"http-exporter-transport.js","sourceRoot":"","sources":["../../../src/transport/http-exporter-transport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAQtD,MAAM,qBAAqB;IACjB,MAAM,GAAiB,IAAI,CAAC;IAC5B,WAAW,CAA4B;IAE/C,YAAY,UAAqC;QAC/C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAChD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,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OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,UAAqC;IAErC,OAAO,IAAI,qBAAqB,CAAC,UAAU,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\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';\nimport { NodeHttpRequestParameters } from './node-http-transport-types';\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 private _parameters: NodeHttpRequestParameters;\n\n constructor(parameters: NodeHttpRequestParameters) {\n this._parameters = parameters;\n }\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n const { agent, request } = await this._loadUtils();\n const headers = await this._parameters.headers();\n\n return new Promise<ExportResponse>(resolve => {\n sendWithHttp(\n request,\n this._parameters.url,\n headers,\n this._parameters.compression,\n this._parameters.userAgent,\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: NodeHttpRequestParameters\n): IExporterTransport {\n return new HttpExporterTransport(parameters);\n}\n"]}
|