@opentelemetry/otlp-exporter-base 0.52.1 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/esm/OTLPExporterBase.d.ts +0 -5
- package/build/esm/OTLPExporterBase.js +0 -8
- package/build/esm/OTLPExporterBase.js.map +1 -1
- package/build/esm/configuration/otlp-http-configuration.d.ts +13 -0
- package/build/esm/configuration/otlp-http-configuration.js +67 -0
- package/build/esm/configuration/otlp-http-configuration.js.map +1 -0
- package/build/esm/configuration/otlp-http-env-configuration.d.ts +9 -0
- package/build/esm/configuration/otlp-http-env-configuration.js +104 -0
- package/build/esm/configuration/otlp-http-env-configuration.js.map +1 -0
- package/build/esm/configuration/shared-configuration.d.ts +22 -0
- package/build/esm/configuration/shared-configuration.js +44 -0
- package/build/esm/configuration/shared-configuration.js.map +1 -0
- package/build/esm/configuration/shared-env-configuration.d.ts +3 -0
- package/build/esm/configuration/shared-env-configuration.js +44 -0
- package/build/esm/configuration/shared-env-configuration.js.map +1 -0
- package/build/esm/export-response.d.ts +14 -0
- package/build/esm/export-response.js +17 -0
- package/build/esm/export-response.js.map +1 -0
- package/build/esm/exporter-transport.d.ts +6 -0
- package/build/esm/exporter-transport.js +17 -0
- package/build/esm/exporter-transport.js.map +1 -0
- package/build/esm/index.d.ts +5 -1
- package/build/esm/index.js +6 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/is-export-retryable.d.ts +3 -0
- package/build/esm/is-export-retryable.js +35 -0
- package/build/esm/is-export-retryable.js.map +1 -0
- package/build/esm/platform/browser/OTLPExporterBrowserBase.d.ts +7 -9
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js +49 -32
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/esm/platform/browser/index.d.ts +0 -1
- package/build/esm/platform/browser/index.js +0 -1
- package/build/esm/platform/browser/index.js.map +1 -1
- package/build/esm/platform/browser/send-beacon-transport.d.ts +10 -0
- package/build/esm/platform/browser/send-beacon-transport.js +47 -0
- package/build/esm/platform/browser/send-beacon-transport.js.map +1 -0
- package/build/esm/platform/browser/xhr-transport.d.ts +11 -0
- package/build/esm/platform/browser/xhr-transport.js +101 -0
- package/build/esm/platform/browser/xhr-transport.js.map +1 -0
- package/build/esm/platform/index.d.ts +2 -2
- package/build/esm/platform/index.js +2 -2
- package/build/esm/platform/index.js.map +1 -1
- package/build/esm/platform/node/OTLPExporterNodeBase.d.ts +6 -13
- package/build/esm/platform/node/OTLPExporterNodeBase.js +45 -14
- package/build/esm/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/esm/platform/node/convert-legacy-agent-options.d.ts +12 -0
- package/build/esm/platform/node/convert-legacy-agent-options.js +27 -0
- package/build/esm/platform/node/convert-legacy-agent-options.js.map +1 -0
- package/build/esm/platform/node/http-exporter-transport.d.ts +4 -0
- package/build/esm/platform/node/http-exporter-transport.js +87 -0
- package/build/esm/platform/node/http-exporter-transport.js.map +1 -0
- package/build/esm/platform/node/http-transport-types.d.ts +12 -0
- package/build/esm/platform/node/http-transport-types.js +17 -0
- package/build/esm/platform/node/http-transport-types.js.map +1 -0
- package/build/esm/platform/node/http-transport-utils.d.ts +16 -0
- package/build/esm/platform/node/http-transport-utils.js +127 -0
- package/build/esm/platform/node/http-transport-utils.js.map +1 -0
- package/build/esm/platform/node/index.d.ts +0 -1
- package/build/esm/platform/node/index.js +0 -1
- package/build/esm/platform/node/index.js.map +1 -1
- package/build/esm/retrying-transport.d.ts +8 -0
- package/build/esm/retrying-transport.js +119 -0
- package/build/esm/retrying-transport.js.map +1 -0
- package/build/esm/types.d.ts +1 -2
- package/build/esm/types.js.map +1 -1
- package/build/esm/util.d.ts +1 -27
- package/build/esm/util.js +1 -89
- package/build/esm/util.js.map +1 -1
- package/build/esm/version.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esnext/OTLPExporterBase.d.ts +0 -5
- package/build/esnext/OTLPExporterBase.js +0 -8
- package/build/esnext/OTLPExporterBase.js.map +1 -1
- package/build/esnext/configuration/otlp-http-configuration.d.ts +13 -0
- package/build/esnext/configuration/otlp-http-configuration.js +56 -0
- package/build/esnext/configuration/otlp-http-configuration.js.map +1 -0
- package/build/esnext/configuration/otlp-http-env-configuration.d.ts +9 -0
- package/build/esnext/configuration/otlp-http-env-configuration.js +93 -0
- package/build/esnext/configuration/otlp-http-env-configuration.js.map +1 -0
- package/build/esnext/configuration/shared-configuration.d.ts +22 -0
- package/build/esnext/configuration/shared-configuration.js +44 -0
- package/build/esnext/configuration/shared-configuration.js.map +1 -0
- package/build/esnext/configuration/shared-env-configuration.d.ts +3 -0
- package/build/esnext/configuration/shared-env-configuration.js +44 -0
- package/build/esnext/configuration/shared-env-configuration.js.map +1 -0
- package/build/esnext/export-response.d.ts +14 -0
- package/build/esnext/export-response.js +17 -0
- package/build/esnext/export-response.js.map +1 -0
- package/build/esnext/exporter-transport.d.ts +6 -0
- package/build/esnext/exporter-transport.js +17 -0
- package/build/esnext/exporter-transport.js.map +1 -0
- package/build/esnext/index.d.ts +5 -1
- package/build/esnext/index.js +6 -1
- package/build/esnext/index.js.map +1 -1
- package/build/esnext/is-export-retryable.d.ts +3 -0
- package/build/esnext/is-export-retryable.js +35 -0
- package/build/esnext/is-export-retryable.js.map +1 -0
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.d.ts +7 -9
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.js +49 -21
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/esnext/platform/browser/index.d.ts +0 -1
- package/build/esnext/platform/browser/index.js +0 -1
- package/build/esnext/platform/browser/index.js.map +1 -1
- package/build/esnext/platform/browser/send-beacon-transport.d.ts +10 -0
- package/build/esnext/platform/browser/send-beacon-transport.js +45 -0
- package/build/esnext/platform/browser/send-beacon-transport.js.map +1 -0
- package/build/esnext/platform/browser/xhr-transport.d.ts +11 -0
- package/build/esnext/platform/browser/xhr-transport.js +82 -0
- package/build/esnext/platform/browser/xhr-transport.js.map +1 -0
- package/build/esnext/platform/index.d.ts +2 -2
- package/build/esnext/platform/index.js +2 -2
- package/build/esnext/platform/index.js.map +1 -1
- package/build/esnext/platform/node/OTLPExporterNodeBase.d.ts +6 -13
- package/build/esnext/platform/node/OTLPExporterNodeBase.js +45 -14
- package/build/esnext/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/esnext/platform/node/convert-legacy-agent-options.d.ts +12 -0
- package/build/esnext/platform/node/convert-legacy-agent-options.js +27 -0
- package/build/esnext/platform/node/convert-legacy-agent-options.js.map +1 -0
- package/build/esnext/platform/node/http-exporter-transport.d.ts +4 -0
- package/build/esnext/platform/node/http-exporter-transport.js +47 -0
- package/build/esnext/platform/node/http-exporter-transport.js.map +1 -0
- package/build/esnext/platform/node/http-transport-types.d.ts +12 -0
- package/build/esnext/platform/node/http-transport-types.js +17 -0
- package/build/esnext/platform/node/http-transport-types.js.map +1 -0
- package/build/esnext/platform/node/http-transport-utils.d.ts +16 -0
- package/build/esnext/platform/node/http-transport-utils.js +116 -0
- package/build/esnext/platform/node/http-transport-utils.js.map +1 -0
- package/build/esnext/platform/node/index.d.ts +0 -1
- package/build/esnext/platform/node/index.js +0 -1
- package/build/esnext/platform/node/index.js.map +1 -1
- package/build/esnext/retrying-transport.d.ts +8 -0
- package/build/esnext/retrying-transport.js +69 -0
- package/build/esnext/retrying-transport.js.map +1 -0
- package/build/esnext/types.d.ts +1 -2
- package/build/esnext/types.js.map +1 -1
- package/build/esnext/util.d.ts +1 -27
- package/build/esnext/util.js +1 -89
- package/build/esnext/util.js.map +1 -1
- package/build/esnext/version.d.ts +1 -1
- package/build/esnext/version.js +1 -1
- package/build/esnext/version.js.map +1 -1
- package/build/src/OTLPExporterBase.d.ts +0 -5
- package/build/src/OTLPExporterBase.js +0 -8
- package/build/src/OTLPExporterBase.js.map +1 -1
- package/build/src/configuration/otlp-http-configuration.d.ts +13 -0
- package/build/src/configuration/otlp-http-configuration.js +61 -0
- package/build/src/configuration/otlp-http-configuration.js.map +1 -0
- package/build/src/configuration/otlp-http-env-configuration.d.ts +9 -0
- package/build/src/configuration/otlp-http-env-configuration.js +97 -0
- package/build/src/configuration/otlp-http-env-configuration.js.map +1 -0
- package/build/src/configuration/shared-configuration.d.ts +22 -0
- package/build/src/configuration/shared-configuration.js +50 -0
- package/build/src/configuration/shared-configuration.js.map +1 -0
- package/build/src/configuration/shared-env-configuration.d.ts +3 -0
- package/build/src/configuration/shared-env-configuration.js +48 -0
- package/build/src/configuration/shared-env-configuration.js.map +1 -0
- package/build/src/export-response.d.ts +14 -0
- package/build/src/export-response.js +18 -0
- package/build/src/export-response.js.map +1 -0
- package/build/src/exporter-transport.d.ts +6 -0
- package/build/src/exporter-transport.js +18 -0
- package/build/src/exporter-transport.js.map +1 -0
- package/build/src/index.d.ts +5 -1
- package/build/src/index.js +21 -17
- package/build/src/index.js.map +1 -1
- package/build/src/is-export-retryable.d.ts +3 -0
- package/build/src/is-export-retryable.js +40 -0
- package/build/src/is-export-retryable.js.map +1 -0
- package/build/src/platform/browser/OTLPExporterBrowserBase.d.ts +7 -9
- package/build/src/platform/browser/OTLPExporterBrowserBase.js +49 -21
- package/build/src/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/src/platform/browser/index.d.ts +0 -1
- package/build/src/platform/browser/index.js +1 -3
- package/build/src/platform/browser/index.js.map +1 -1
- package/build/src/platform/browser/send-beacon-transport.d.ts +10 -0
- package/build/src/platform/browser/send-beacon-transport.js +49 -0
- package/build/src/platform/browser/send-beacon-transport.js.map +1 -0
- package/build/src/platform/browser/xhr-transport.d.ts +11 -0
- package/build/src/platform/browser/xhr-transport.js +86 -0
- package/build/src/platform/browser/xhr-transport.js.map +1 -0
- package/build/src/platform/index.d.ts +2 -2
- package/build/src/platform/index.js +1 -5
- package/build/src/platform/index.js.map +1 -1
- package/build/src/platform/node/OTLPExporterNodeBase.d.ts +6 -13
- package/build/src/platform/node/OTLPExporterNodeBase.js +45 -14
- package/build/src/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/src/platform/node/convert-legacy-agent-options.d.ts +12 -0
- package/build/src/platform/node/convert-legacy-agent-options.js +31 -0
- package/build/src/platform/node/convert-legacy-agent-options.js.map +1 -0
- package/build/src/platform/node/http-exporter-transport.d.ts +4 -0
- package/build/src/platform/node/http-exporter-transport.js +51 -0
- package/build/src/platform/node/http-exporter-transport.js.map +1 -0
- package/build/src/platform/node/http-transport-types.d.ts +12 -0
- package/build/src/platform/node/http-transport-types.js +18 -0
- package/build/src/platform/node/http-transport-types.js.map +1 -0
- package/build/src/platform/node/http-transport-utils.d.ts +16 -0
- package/build/src/platform/node/http-transport-utils.js +121 -0
- package/build/src/platform/node/http-transport-utils.js.map +1 -0
- package/build/src/platform/node/index.d.ts +0 -1
- package/build/src/platform/node/index.js +1 -5
- package/build/src/platform/node/index.js.map +1 -1
- package/build/src/retrying-transport.d.ts +8 -0
- package/build/src/retrying-transport.js +73 -0
- package/build/src/retrying-transport.js.map +1 -0
- package/build/src/types.d.ts +1 -2
- package/build/src/types.js.map +1 -1
- package/build/src/util.d.ts +1 -27
- package/build/src/util.js +3 -97
- package/build/src/util.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/package.json +13 -17
- package/build/esm/platform/browser/util.d.ts +0 -21
- package/build/esm/platform/browser/util.js +0 -152
- package/build/esm/platform/browser/util.js.map +0 -1
- package/build/esm/platform/node/util.d.ts +0 -19
- package/build/esm/platform/node/util.js +0 -194
- package/build/esm/platform/node/util.js.map +0 -1
- package/build/esnext/platform/browser/util.d.ts +0 -21
- package/build/esnext/platform/browser/util.js +0 -122
- package/build/esnext/platform/browser/util.js.map +0 -1
- package/build/esnext/platform/node/util.d.ts +0 -19
- package/build/esnext/platform/node/util.js +0 -181
- package/build/esnext/platform/node/util.js.map +0 -1
- package/build/src/platform/browser/util.d.ts +0 -21
- package/build/src/platform/browser/util.js +0 -127
- package/build/src/platform/browser/util.js.map +0 -1
- package/build/src/platform/node/util.d.ts +0 -19
- package/build/src/platform/node/util.js +0 -187
- package/build/src/platform/node/util.js.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=exporter-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exporter-transport.js","sourceRoot":"","sources":["../../src/exporter-transport.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 { ExportResponse } from './export-response';\n\nexport interface IExporterTransport {\n send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse>;\n shutdown(): void;\n}\n"]}
|
package/build/esnext/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from './platform';
|
|
2
2
|
export { OTLPExporterBase } from './OTLPExporterBase';
|
|
3
3
|
export { OTLPExporterError, OTLPExporterConfigBase, ExportServiceError, } from './types';
|
|
4
|
-
export {
|
|
4
|
+
export { validateAndNormalizeHeaders } from './util';
|
|
5
|
+
export { ExportResponse, ExportResponseFailure, ExportResponseSuccess, ExportResponseRetryable, } from './export-response';
|
|
6
|
+
export { IExporterTransport } from './exporter-transport';
|
|
7
|
+
export { OtlpSharedConfiguration, mergeOtlpSharedConfigurationWithDefaults, getSharedConfigurationDefaults, } from './configuration/shared-configuration';
|
|
8
|
+
export { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
package/build/esnext/index.js
CHANGED
|
@@ -13,8 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
/* eslint no-restricted-syntax: ["warn", "ExportAllDeclaration"] --
|
|
17
|
+
* TODO: Replace export * with named exports before next major version
|
|
18
|
+
*/
|
|
16
19
|
export * from './platform';
|
|
17
20
|
export { OTLPExporterBase } from './OTLPExporterBase';
|
|
18
21
|
export { OTLPExporterError, } from './types';
|
|
19
|
-
export {
|
|
22
|
+
export { validateAndNormalizeHeaders } from './util';
|
|
23
|
+
export { mergeOtlpSharedConfigurationWithDefaults, getSharedConfigurationDefaults, } from './configuration/shared-configuration';
|
|
24
|
+
export { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';
|
|
20
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,iBAAiB,GAGlB,MAAM,SAAS,CAAC;AACjB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,iBAAiB,GAGlB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAWrD,OAAO,EAEL,wCAAwC,EACxC,8BAA8B,GAC/B,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,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/* eslint no-restricted-syntax: [\"warn\", \"ExportAllDeclaration\"] --\n * TODO: Replace export * with named exports before next major version\n */\nexport * from './platform';\nexport { OTLPExporterBase } from './OTLPExporterBase';\nexport {\n OTLPExporterError,\n OTLPExporterConfigBase,\n ExportServiceError,\n} from './types';\nexport { validateAndNormalizeHeaders } from './util';\n\nexport {\n ExportResponse,\n ExportResponseFailure,\n ExportResponseSuccess,\n ExportResponseRetryable,\n} from './export-response';\n\nexport { IExporterTransport } from './exporter-transport';\n\nexport {\n OtlpSharedConfiguration,\n mergeOtlpSharedConfigurationWithDefaults,\n getSharedConfigurationDefaults,\n} from './configuration/shared-configuration';\n\nexport { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
export function isExportRetryable(statusCode) {
|
|
17
|
+
const retryCodes = [429, 502, 503, 504];
|
|
18
|
+
return retryCodes.includes(statusCode);
|
|
19
|
+
}
|
|
20
|
+
export function parseRetryAfterToMills(retryAfter) {
|
|
21
|
+
if (retryAfter == null) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const seconds = Number.parseInt(retryAfter, 10);
|
|
25
|
+
if (Number.isInteger(seconds)) {
|
|
26
|
+
return seconds > 0 ? seconds * 1000 : -1;
|
|
27
|
+
}
|
|
28
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#directives
|
|
29
|
+
const delay = new Date(retryAfter).getTime() - Date.now();
|
|
30
|
+
if (delay >= 0) {
|
|
31
|
+
return delay;
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=is-export-retryable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-export-retryable.js","sourceRoot":"","sources":["../../src/is-export-retryable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACzC,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 *\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 function isExportRetryable(statusCode: number): boolean {\n const retryCodes = [429, 502, 503, 504];\n return retryCodes.includes(statusCode);\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,23 +1,21 @@
|
|
|
1
1
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
2
|
-
import { OTLPExporterConfigBase } from '../../types';
|
|
3
|
-
import * as otlpTypes from '../../types';
|
|
2
|
+
import { OTLPExporterConfigBase, OTLPExporterError } from '../../types';
|
|
4
3
|
import { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
5
4
|
/**
|
|
6
5
|
* Collector Metric Exporter abstract base class
|
|
7
6
|
*/
|
|
8
7
|
export declare abstract class OTLPExporterBrowserBase<ExportItem, ServiceResponse> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem> {
|
|
9
|
-
protected _headers: Record<string, string>;
|
|
10
|
-
private _useXHR;
|
|
11
|
-
private _contentType;
|
|
12
8
|
private _serializer;
|
|
9
|
+
private _transport;
|
|
10
|
+
private _timeoutMillis;
|
|
13
11
|
/**
|
|
14
12
|
* @param config
|
|
15
13
|
* @param serializer
|
|
16
|
-
* @param
|
|
14
|
+
* @param requiredHeaders
|
|
15
|
+
* @param signalResourcePath
|
|
17
16
|
*/
|
|
18
|
-
constructor(config: OTLPExporterConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>,
|
|
19
|
-
onInit(): void;
|
|
17
|
+
constructor(config: OTLPExporterConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, requiredHeaders: Record<string, string>, signalResourcePath: string);
|
|
20
18
|
onShutdown(): void;
|
|
21
|
-
send(
|
|
19
|
+
send(objects: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
22
20
|
}
|
|
23
21
|
//# sourceMappingURL=OTLPExporterBrowserBase.d.ts.map
|
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
17
|
-
import {
|
|
18
|
-
import { sendWithBeacon, sendWithXhr } from './util';
|
|
17
|
+
import { OTLPExporterError } from '../../types';
|
|
19
18
|
import { diag } from '@opentelemetry/api';
|
|
20
|
-
import {
|
|
19
|
+
import { createXhrTransport } from './xhr-transport';
|
|
20
|
+
import { createSendBeaconTransport } from './send-beacon-transport';
|
|
21
|
+
import { createRetryingTransport } from '../../retrying-transport';
|
|
22
|
+
import { getHttpConfigurationDefaults, mergeOtlpHttpConfigurationWithDefaults, } from '../../configuration/otlp-http-configuration';
|
|
21
23
|
/**
|
|
22
24
|
* Collector Metric Exporter abstract base class
|
|
23
25
|
*/
|
|
@@ -25,39 +27,65 @@ export class OTLPExporterBrowserBase extends OTLPExporterBase {
|
|
|
25
27
|
/**
|
|
26
28
|
* @param config
|
|
27
29
|
* @param serializer
|
|
28
|
-
* @param
|
|
30
|
+
* @param requiredHeaders
|
|
31
|
+
* @param signalResourcePath
|
|
29
32
|
*/
|
|
30
|
-
constructor(config = {}, serializer,
|
|
33
|
+
constructor(config = {}, serializer, requiredHeaders, signalResourcePath) {
|
|
31
34
|
super(config);
|
|
32
|
-
this._useXHR = false;
|
|
33
35
|
this._serializer = serializer;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const useXhr = !!config.headers || typeof navigator.sendBeacon !== 'function';
|
|
37
|
+
const actualConfig = mergeOtlpHttpConfigurationWithDefaults({
|
|
38
|
+
url: config.url,
|
|
39
|
+
timeoutMillis: config.timeoutMillis,
|
|
40
|
+
headers: config.headers,
|
|
41
|
+
concurrencyLimit: config.concurrencyLimit,
|
|
42
|
+
}, {}, // no fallback for browser case
|
|
43
|
+
getHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
|
|
44
|
+
this._timeoutMillis = actualConfig.timeoutMillis;
|
|
45
|
+
this._concurrencyLimit = actualConfig.concurrencyLimit;
|
|
46
|
+
if (useXhr) {
|
|
47
|
+
this._transport = createRetryingTransport({
|
|
48
|
+
transport: createXhrTransport({
|
|
49
|
+
headers: actualConfig.headers,
|
|
50
|
+
url: actualConfig.url,
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
39
53
|
}
|
|
40
54
|
else {
|
|
41
|
-
|
|
55
|
+
// sendBeacon has no way to signal retry, so we do not wrap it in a RetryingTransport
|
|
56
|
+
this._transport = createSendBeaconTransport({
|
|
57
|
+
url: actualConfig.url,
|
|
58
|
+
blobType: actualConfig.headers['Content-Type'],
|
|
59
|
+
});
|
|
42
60
|
}
|
|
43
61
|
}
|
|
44
|
-
onInit() { }
|
|
45
62
|
onShutdown() { }
|
|
46
|
-
send(
|
|
47
|
-
var _a;
|
|
63
|
+
send(objects, onSuccess, onError) {
|
|
48
64
|
if (this._shutdownOnce.isCalled) {
|
|
49
65
|
diag.debug('Shutdown already started. Cannot send objects');
|
|
50
66
|
return;
|
|
51
67
|
}
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
const data = this._serializer.serializeRequest(objects);
|
|
69
|
+
if (data == null) {
|
|
70
|
+
onError(new Error('Could not serialize message'));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const promise = this._transport
|
|
74
|
+
.send(data, this._timeoutMillis)
|
|
75
|
+
.then(response => {
|
|
76
|
+
if (response.status === 'success') {
|
|
77
|
+
onSuccess();
|
|
78
|
+
}
|
|
79
|
+
else if (response.status === 'failure' && response.error) {
|
|
80
|
+
onError(response.error);
|
|
81
|
+
}
|
|
82
|
+
else if (response.status === 'retryable') {
|
|
83
|
+
onError(new OTLPExporterError('Export failed with retryable status'));
|
|
56
84
|
}
|
|
57
85
|
else {
|
|
58
|
-
|
|
86
|
+
onError(new OTLPExporterError('Export failed with unknown error'));
|
|
59
87
|
}
|
|
60
|
-
}
|
|
88
|
+
}, onError);
|
|
61
89
|
this._sendingPromises.push(promise);
|
|
62
90
|
const popPromise = () => {
|
|
63
91
|
const index = this._sendingPromises.indexOf(promise);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPExporterBrowserBase.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPExporterBrowserBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"OTLPExporterBrowserBase.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPExporterBrowserBase.ts"],"names":[],"mappings":"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","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OTLPExporterBase } from '../../OTLPExporterBase';\nimport { OTLPExporterConfigBase, OTLPExporterError } from '../../types';\nimport { diag } from '@opentelemetry/api';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { IExporterTransport } from '../../exporter-transport';\nimport { createXhrTransport } from './xhr-transport';\nimport { createSendBeaconTransport } from './send-beacon-transport';\nimport { createRetryingTransport } from '../../retrying-transport';\nimport {\n getHttpConfigurationDefaults,\n mergeOtlpHttpConfigurationWithDefaults,\n} from '../../configuration/otlp-http-configuration';\n\n/**\n * Collector Metric Exporter abstract base class\n */\nexport abstract class OTLPExporterBrowserBase<\n ExportItem,\n ServiceResponse,\n> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem> {\n private _serializer: ISerializer<ExportItem[], ServiceResponse>;\n private _transport: IExporterTransport;\n private _timeoutMillis: number;\n\n /**\n * @param config\n * @param serializer\n * @param requiredHeaders\n * @param signalResourcePath\n */\n constructor(\n config: OTLPExporterConfigBase = {},\n serializer: ISerializer<ExportItem[], ServiceResponse>,\n requiredHeaders: Record<string, string>,\n signalResourcePath: string\n ) {\n super(config);\n this._serializer = serializer;\n const useXhr =\n !!config.headers || typeof navigator.sendBeacon !== 'function';\n\n const actualConfig = mergeOtlpHttpConfigurationWithDefaults(\n {\n url: config.url,\n timeoutMillis: config.timeoutMillis,\n headers: config.headers,\n concurrencyLimit: config.concurrencyLimit,\n },\n {}, // no fallback for browser case\n getHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n\n this._timeoutMillis = actualConfig.timeoutMillis;\n this._concurrencyLimit = actualConfig.concurrencyLimit;\n\n if (useXhr) {\n this._transport = createRetryingTransport({\n transport: createXhrTransport({\n headers: actualConfig.headers,\n url: actualConfig.url,\n }),\n });\n } else {\n // sendBeacon has no way to signal retry, so we do not wrap it in a RetryingTransport\n this._transport = createSendBeaconTransport({\n url: actualConfig.url,\n blobType: actualConfig.headers['Content-Type'],\n });\n }\n }\n\n onShutdown(): void {}\n\n send(\n objects: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n diag.debug('Shutdown already started. Cannot send objects');\n return;\n }\n\n const data = this._serializer.serializeRequest(objects);\n\n if (data == null) {\n onError(new Error('Could not serialize message'));\n return;\n }\n\n const promise = this._transport\n .send(data, this._timeoutMillis)\n .then(response => {\n if (response.status === 'success') {\n onSuccess();\n } else if (response.status === 'failure' && response.error) {\n onError(response.error);\n } else if (response.status === 'retryable') {\n onError(new OTLPExporterError('Export failed with retryable status'));\n } else {\n onError(new OTLPExporterError('Export failed with unknown error'));\n }\n }, onError);\n\n this._sendingPromises.push(promise);\n const popPromise = () => {\n const index = this._sendingPromises.indexOf(promise);\n this._sendingPromises.splice(index, 1);\n };\n promise.then(popPromise, popPromise);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/browser/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/browser/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,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 { OTLPExporterBrowserBase } from './OTLPExporterBrowserBase';\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IExporterTransport } from '../../exporter-transport';
|
|
2
|
+
export interface SendBeaconParameters {
|
|
3
|
+
url: string;
|
|
4
|
+
/**
|
|
5
|
+
* for instance 'application/x-protobuf'
|
|
6
|
+
*/
|
|
7
|
+
blobType: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function createSendBeaconTransport(parameters: SendBeaconParameters): IExporterTransport;
|
|
10
|
+
//# sourceMappingURL=send-beacon-transport.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
class SendBeaconTransport {
|
|
18
|
+
constructor(_params) {
|
|
19
|
+
this._params = _params;
|
|
20
|
+
}
|
|
21
|
+
send(data) {
|
|
22
|
+
return new Promise(resolve => {
|
|
23
|
+
if (navigator.sendBeacon(this._params.url, new Blob([data], { type: this._params.blobType }))) {
|
|
24
|
+
// no way to signal retry, treat everything as success
|
|
25
|
+
diag.debug('SendBeacon success');
|
|
26
|
+
resolve({
|
|
27
|
+
status: 'success',
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
resolve({
|
|
32
|
+
status: 'failure',
|
|
33
|
+
error: new Error('SendBeacon failed'),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
shutdown() {
|
|
39
|
+
// Intentionally left empty, nothing to do.
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function createSendBeaconTransport(parameters) {
|
|
43
|
+
return new SendBeaconTransport(parameters);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=send-beacon-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-beacon-transport.js","sourceRoot":"","sources":["../../../../src/platform/browser/send-beacon-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAU1C,MAAM,mBAAmB;IACvB,YAAoB,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;IAAG,CAAC;IACrD,IAAI,CAAC,IAAgB;QACnB,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3C,IACE,SAAS,CAAC,UAAU,CAClB,IAAI,CAAC,OAAO,CAAC,GAAG,EAChB,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAClD,EACD;gBACA,sDAAsD;gBACtD,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;gBACjC,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;iBAClB,CAAC,CAAC;aACJ;iBAAM;gBACL,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,mBAAmB,CAAC;iBACtC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;AAED,MAAM,UAAU,yBAAyB,CACvC,UAAgC;IAEhC,OAAO,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { IExporterTransport } from '../../exporter-transport';\nimport { ExportResponse } from '../../export-response';\nimport { diag } from '@opentelemetry/api';\n\nexport interface SendBeaconParameters {\n url: string;\n /**\n * for instance 'application/x-protobuf'\n */\n blobType: string;\n}\n\nclass SendBeaconTransport implements IExporterTransport {\n constructor(private _params: SendBeaconParameters) {}\n send(data: Uint8Array): Promise<ExportResponse> {\n return new Promise<ExportResponse>(resolve => {\n if (\n navigator.sendBeacon(\n this._params.url,\n new Blob([data], { type: this._params.blobType })\n )\n ) {\n // no way to signal retry, treat everything as success\n diag.debug('SendBeacon success');\n resolve({\n status: 'success',\n });\n } else {\n resolve({\n status: 'failure',\n error: new Error('SendBeacon failed'),\n });\n }\n });\n }\n\n shutdown(): void {\n // Intentionally left empty, nothing to do.\n }\n}\n\nexport function createSendBeaconTransport(\n parameters: SendBeaconParameters\n): IExporterTransport {\n return new SendBeaconTransport(parameters);\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IExporterTransport } from '../../exporter-transport';
|
|
2
|
+
export interface XhrRequestParameters {
|
|
3
|
+
url: string;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates an exporter transport that uses XHR to send the data
|
|
8
|
+
* @param parameters applied to each request made by transport
|
|
9
|
+
*/
|
|
10
|
+
export declare function createXhrTransport(parameters: XhrRequestParameters): IExporterTransport;
|
|
11
|
+
//# sourceMappingURL=xhr-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 XhrTransport {
|
|
19
|
+
constructor(_parameters) {
|
|
20
|
+
this._parameters = _parameters;
|
|
21
|
+
}
|
|
22
|
+
send(data, timeoutMillis) {
|
|
23
|
+
return new Promise(resolve => {
|
|
24
|
+
const xhr = new XMLHttpRequest();
|
|
25
|
+
xhr.timeout = timeoutMillis;
|
|
26
|
+
xhr.open('POST', this._parameters.url);
|
|
27
|
+
Object.entries(this._parameters.headers).forEach(([k, v]) => {
|
|
28
|
+
xhr.setRequestHeader(k, v);
|
|
29
|
+
});
|
|
30
|
+
xhr.ontimeout = _ => {
|
|
31
|
+
resolve({
|
|
32
|
+
status: 'failure',
|
|
33
|
+
error: new Error('XHR request timed out'),
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
xhr.onreadystatechange = () => {
|
|
37
|
+
if (xhr.status >= 200 && xhr.status <= 299) {
|
|
38
|
+
diag.debug('XHR success');
|
|
39
|
+
resolve({
|
|
40
|
+
status: 'success',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
else if (xhr.status && isExportRetryable(xhr.status)) {
|
|
44
|
+
resolve({
|
|
45
|
+
status: 'retryable',
|
|
46
|
+
retryInMillis: parseRetryAfterToMills(xhr.getResponseHeader('Retry-After')),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else if (xhr.status !== 0) {
|
|
50
|
+
resolve({
|
|
51
|
+
status: 'failure',
|
|
52
|
+
error: new Error('XHR request failed with non-retryable status'),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
xhr.onabort = () => {
|
|
57
|
+
resolve({
|
|
58
|
+
status: 'failure',
|
|
59
|
+
error: new Error('XHR request aborted'),
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
xhr.onerror = () => {
|
|
63
|
+
resolve({
|
|
64
|
+
status: 'failure',
|
|
65
|
+
error: new Error('XHR request errored'),
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
xhr.send(new Blob([data], { type: this._parameters.headers['Content-Type'] }));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
shutdown() {
|
|
72
|
+
// Intentionally left empty, nothing to do.
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Creates an exporter transport that uses XHR to send the data
|
|
77
|
+
* @param parameters applied to each request made by transport
|
|
78
|
+
*/
|
|
79
|
+
export function createXhrTransport(parameters) {
|
|
80
|
+
return new XhrTransport(parameters);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=xhr-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xhr-transport.js","sourceRoot":"","sources":["../../../../src/platform/browser/xhr-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAOnC,MAAM,YAAY;IAChB,YAAoB,WAAiC;QAAjC,gBAAW,GAAX,WAAW,CAAsB;IAAG,CAAC;IAEzD,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAC1C,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3C,MAAM,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;YACjC,GAAG,CAAC,OAAO,GAAG,aAAa,CAAC;YAC5B,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACvC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;gBAC1D,GAAG,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;YAEH,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE;gBAClB,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,uBAAuB,CAAC;iBAC1C,CAAC,CAAC;YACL,CAAC,CAAC;YAEF,GAAG,CAAC,kBAAkB,GAAG,GAAG,EAAE;gBAC5B,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE;oBAC1C,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;oBAC1B,OAAO,CAAC;wBACN,MAAM,EAAE,SAAS;qBAClB,CAAC,CAAC;iBACJ;qBAAM,IAAI,GAAG,CAAC,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oBACtD,OAAO,CAAC;wBACN,MAAM,EAAE,WAAW;wBACnB,aAAa,EAAE,sBAAsB,CACnC,GAAG,CAAC,iBAAiB,CAAC,aAAa,CAAC,CACrC;qBACF,CAAC,CAAC;iBACJ;qBAAM,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;oBAC3B,OAAO,CAAC;wBACN,MAAM,EAAE,SAAS;wBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,8CAA8C,CAAC;qBACjE,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC;YAEF,GAAG,CAAC,OAAO,GAAG,GAAG,EAAE;gBACjB,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,qBAAqB,CAAC;iBACxC,CAAC,CAAC;YACL,CAAC,CAAC;YACF,GAAG,CAAC,OAAO,GAAG,GAAG,EAAE;gBACjB,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,qBAAqB,CAAC;iBACxC,CAAC,CAAC;YACL,CAAC,CAAC;YAEF,GAAG,CAAC,IAAI,CACN,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CACrE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;AAED;;;GAGG;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\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 Object.entries(this._parameters.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(\n new Blob([data], { type: this._parameters.headers['Content-Type'] })\n );\n });\n }\n\n shutdown() {\n // Intentionally left empty, nothing to do.\n }\n}\n\n/**\n * Creates an exporter transport that uses XHR to send the data\n * @param parameters applied to each request made by transport\n */\nexport function createXhrTransport(\n parameters: XhrRequestParameters\n): IExporterTransport {\n return new XhrTransport(parameters);\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { OTLPExporterNodeBase,
|
|
2
|
-
export { OTLPExporterBrowserBase
|
|
1
|
+
export { OTLPExporterNodeBase, OTLPExporterNodeConfigBase, CompressionAlgorithm, } from './node';
|
|
2
|
+
export { OTLPExporterBrowserBase } from './browser';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export { OTLPExporterNodeBase,
|
|
17
|
-
export { OTLPExporterBrowserBase
|
|
16
|
+
export { OTLPExporterNodeBase, CompressionAlgorithm, } from './node';
|
|
17
|
+
export { OTLPExporterBrowserBase } from './browser';
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,oBAAoB,EAEpB,oBAAoB,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,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 {\n OTLPExporterNodeBase,\n OTLPExporterNodeConfigBase,\n CompressionAlgorithm,\n} from './node';\nexport { OTLPExporterBrowserBase } from './browser';\n"]}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type * as http from 'http';
|
|
3
|
-
import type * as https from 'https';
|
|
4
1
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
5
|
-
import { OTLPExporterNodeConfigBase
|
|
6
|
-
import * as otlpTypes from '../../types';
|
|
2
|
+
import { OTLPExporterNodeConfigBase } from './types';
|
|
7
3
|
import { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
4
|
+
import { OTLPExporterError } from '../../types';
|
|
8
5
|
/**
|
|
9
6
|
* Collector Metric Exporter abstract base class
|
|
10
7
|
*/
|
|
11
8
|
export declare abstract class OTLPExporterNodeBase<ExportItem, ServiceResponse> extends OTLPExporterBase<OTLPExporterNodeConfigBase, ExportItem> {
|
|
12
|
-
DEFAULT_HEADERS: Record<string, string>;
|
|
13
|
-
headers: Record<string, string>;
|
|
14
|
-
agent: http.Agent | https.Agent | undefined;
|
|
15
|
-
compression: CompressionAlgorithm;
|
|
16
9
|
private _serializer;
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
send(objects: ExportItem[], onSuccess: () => void, onError: (error:
|
|
10
|
+
private _transport;
|
|
11
|
+
private _timeoutMillis;
|
|
12
|
+
constructor(config: OTLPExporterNodeConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, requiredHeaders: Record<string, string>, signalIdentifier: string, signalResourcePath: string);
|
|
13
|
+
send(objects: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
21
14
|
onShutdown(): void;
|
|
22
15
|
}
|
|
23
16
|
//# sourceMappingURL=OTLPExporterNodeBase.d.ts.map
|
|
@@ -14,37 +14,68 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
17
|
-
import { parseHeaders } from '../../util';
|
|
18
|
-
import { createHttpAgent, sendWithHttp, configureCompression } from './util';
|
|
19
17
|
import { diag } from '@opentelemetry/api';
|
|
20
|
-
import {
|
|
18
|
+
import { createHttpExporterTransport } from './http-exporter-transport';
|
|
19
|
+
import { OTLPExporterError } from '../../types';
|
|
20
|
+
import { createRetryingTransport } from '../../retrying-transport';
|
|
21
|
+
import { convertLegacyAgentOptions } from './convert-legacy-agent-options';
|
|
22
|
+
import { getHttpConfigurationDefaults, mergeOtlpHttpConfigurationWithDefaults, } from '../../configuration/otlp-http-configuration';
|
|
23
|
+
import { getHttpConfigurationFromEnvironment } from '../../configuration/otlp-http-env-configuration';
|
|
21
24
|
/**
|
|
22
25
|
* Collector Metric Exporter abstract base class
|
|
23
26
|
*/
|
|
24
27
|
export class OTLPExporterNodeBase extends OTLPExporterBase {
|
|
25
|
-
constructor(config = {}, serializer,
|
|
28
|
+
constructor(config = {}, serializer, requiredHeaders, signalIdentifier, signalResourcePath) {
|
|
26
29
|
super(config);
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
const actualConfig = mergeOtlpHttpConfigurationWithDefaults({
|
|
31
|
+
url: config.url,
|
|
32
|
+
headers: config.headers,
|
|
33
|
+
concurrencyLimit: config.concurrencyLimit,
|
|
34
|
+
timeoutMillis: config.timeoutMillis,
|
|
35
|
+
compression: config.compression,
|
|
36
|
+
}, getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath), getHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
|
|
37
|
+
this._timeoutMillis = actualConfig.timeoutMillis;
|
|
38
|
+
this._concurrencyLimit = actualConfig.concurrencyLimit;
|
|
29
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
40
|
if (config.metadata) {
|
|
31
41
|
diag.warn('Metadata cannot be set when using http');
|
|
32
42
|
}
|
|
33
|
-
this.headers = Object.assign(this.DEFAULT_HEADERS, parseHeaders(config.headers), baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_HEADERS));
|
|
34
|
-
this.agent = createHttpAgent(config);
|
|
35
|
-
this.compression = configureCompression(config.compression);
|
|
36
43
|
this._serializer = serializer;
|
|
44
|
+
this._transport = createRetryingTransport({
|
|
45
|
+
transport: createHttpExporterTransport({
|
|
46
|
+
agentOptions: convertLegacyAgentOptions(config),
|
|
47
|
+
compression: actualConfig.compression,
|
|
48
|
+
headers: actualConfig.headers,
|
|
49
|
+
url: actualConfig.url,
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
37
52
|
}
|
|
38
|
-
onInit(_config) { }
|
|
39
53
|
send(objects, onSuccess, onError) {
|
|
40
54
|
if (this._shutdownOnce.isCalled) {
|
|
41
55
|
diag.debug('Shutdown already started. Cannot send objects');
|
|
42
56
|
return;
|
|
43
57
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
const data = this._serializer.serializeRequest(objects);
|
|
59
|
+
if (data == null) {
|
|
60
|
+
onError(new Error('Could not serialize message'));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const promise = this._transport
|
|
64
|
+
.send(data, this._timeoutMillis)
|
|
65
|
+
.then(response => {
|
|
66
|
+
if (response.status === 'success') {
|
|
67
|
+
onSuccess();
|
|
68
|
+
}
|
|
69
|
+
else if (response.status === 'failure' && response.error) {
|
|
70
|
+
onError(response.error);
|
|
71
|
+
}
|
|
72
|
+
else if (response.status === 'retryable') {
|
|
73
|
+
onError(new OTLPExporterError('Export failed with retryable status'));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
onError(new OTLPExporterError('Export failed with unknown error'));
|
|
77
|
+
}
|
|
78
|
+
}, onError);
|
|
48
79
|
this._sendingPromises.push(promise);
|
|
49
80
|
const popPromise = () => {
|
|
50
81
|
const index = this._sendingPromises.indexOf(promise);
|