@opentelemetry/otlp-exporter-base 0.220.0 → 0.222.0-development.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.
Files changed (123) hide show
  1. package/README.md +30 -0
  2. package/build/esm/ExporterMetrics.d.ts +24 -0
  3. package/build/esm/ExporterMetrics.js +104 -0
  4. package/build/esm/ExporterMetrics.js.map +1 -0
  5. package/build/esm/OTLPExporterBase.d.ts +2 -0
  6. package/build/esm/OTLPExporterBase.js +3 -0
  7. package/build/esm/OTLPExporterBase.js.map +1 -1
  8. package/build/esm/configuration/create-legacy-browser-delegate.d.ts +8 -2
  9. package/build/esm/configuration/create-legacy-browser-delegate.js +36 -2
  10. package/build/esm/configuration/create-legacy-browser-delegate.js.map +1 -1
  11. package/build/esm/configuration/legacy-base-configuration.d.ts +26 -8
  12. package/build/esm/configuration/legacy-base-configuration.js.map +1 -1
  13. package/build/esm/configuration/legacy-node-configuration.d.ts +18 -4
  14. package/build/esm/configuration/legacy-node-configuration.js.map +1 -1
  15. package/build/esm/index-browser-http.d.ts +1 -1
  16. package/build/esm/index-browser-http.js +1 -1
  17. package/build/esm/index-browser-http.js.map +1 -1
  18. package/build/esm/index-node-http.d.ts +1 -1
  19. package/build/esm/index-node-http.js +1 -1
  20. package/build/esm/index-node-http.js.map +1 -1
  21. package/build/esm/index.d.ts +1 -0
  22. package/build/esm/index.js +1 -0
  23. package/build/esm/index.js.map +1 -1
  24. package/build/esm/otlp-browser-http-export-delegate.d.ts +3 -2
  25. package/build/esm/otlp-browser-http-export-delegate.js +8 -4
  26. package/build/esm/otlp-browser-http-export-delegate.js.map +1 -1
  27. package/build/esm/otlp-export-delegate.d.ts +3 -0
  28. package/build/esm/otlp-export-delegate.js +19 -6
  29. package/build/esm/otlp-export-delegate.js.map +1 -1
  30. package/build/esm/otlp-http-export-delegate.d.ts +5 -2
  31. package/build/esm/otlp-http-export-delegate.js +30 -1
  32. package/build/esm/otlp-http-export-delegate.js.map +1 -1
  33. package/build/esm/otlp-network-export-delegate.d.ts +2 -1
  34. package/build/esm/otlp-network-export-delegate.js +2 -1
  35. package/build/esm/otlp-network-export-delegate.js.map +1 -1
  36. package/build/esm/semconv.d.ts +91 -0
  37. package/build/esm/semconv.js +100 -0
  38. package/build/esm/semconv.js.map +1 -0
  39. package/build/esm/version.d.ts +1 -1
  40. package/build/esm/version.js +1 -1
  41. package/build/esm/version.js.map +1 -1
  42. package/build/esnext/ExporterMetrics.d.ts +24 -0
  43. package/build/esnext/ExporterMetrics.js +104 -0
  44. package/build/esnext/ExporterMetrics.js.map +1 -0
  45. package/build/esnext/OTLPExporterBase.d.ts +2 -0
  46. package/build/esnext/OTLPExporterBase.js +3 -0
  47. package/build/esnext/OTLPExporterBase.js.map +1 -1
  48. package/build/esnext/configuration/create-legacy-browser-delegate.d.ts +8 -2
  49. package/build/esnext/configuration/create-legacy-browser-delegate.js +36 -2
  50. package/build/esnext/configuration/create-legacy-browser-delegate.js.map +1 -1
  51. package/build/esnext/configuration/legacy-base-configuration.d.ts +26 -8
  52. package/build/esnext/configuration/legacy-base-configuration.js.map +1 -1
  53. package/build/esnext/configuration/legacy-node-configuration.d.ts +18 -4
  54. package/build/esnext/configuration/legacy-node-configuration.js.map +1 -1
  55. package/build/esnext/index-browser-http.d.ts +1 -1
  56. package/build/esnext/index-browser-http.js +1 -1
  57. package/build/esnext/index-browser-http.js.map +1 -1
  58. package/build/esnext/index-node-http.d.ts +1 -1
  59. package/build/esnext/index-node-http.js +1 -1
  60. package/build/esnext/index-node-http.js.map +1 -1
  61. package/build/esnext/index.d.ts +1 -0
  62. package/build/esnext/index.js +1 -0
  63. package/build/esnext/index.js.map +1 -1
  64. package/build/esnext/otlp-browser-http-export-delegate.d.ts +3 -2
  65. package/build/esnext/otlp-browser-http-export-delegate.js +8 -4
  66. package/build/esnext/otlp-browser-http-export-delegate.js.map +1 -1
  67. package/build/esnext/otlp-export-delegate.d.ts +3 -0
  68. package/build/esnext/otlp-export-delegate.js +19 -6
  69. package/build/esnext/otlp-export-delegate.js.map +1 -1
  70. package/build/esnext/otlp-http-export-delegate.d.ts +5 -2
  71. package/build/esnext/otlp-http-export-delegate.js +30 -1
  72. package/build/esnext/otlp-http-export-delegate.js.map +1 -1
  73. package/build/esnext/otlp-network-export-delegate.d.ts +2 -1
  74. package/build/esnext/otlp-network-export-delegate.js +2 -1
  75. package/build/esnext/otlp-network-export-delegate.js.map +1 -1
  76. package/build/esnext/semconv.d.ts +91 -0
  77. package/build/esnext/semconv.js +100 -0
  78. package/build/esnext/semconv.js.map +1 -0
  79. package/build/esnext/version.d.ts +1 -1
  80. package/build/esnext/version.js +1 -1
  81. package/build/esnext/version.js.map +1 -1
  82. package/build/src/ExporterMetrics.d.ts +24 -0
  83. package/build/src/ExporterMetrics.js +108 -0
  84. package/build/src/ExporterMetrics.js.map +1 -0
  85. package/build/src/OTLPExporterBase.d.ts +2 -0
  86. package/build/src/OTLPExporterBase.js +3 -0
  87. package/build/src/OTLPExporterBase.js.map +1 -1
  88. package/build/src/configuration/create-legacy-browser-delegate.d.ts +8 -2
  89. package/build/src/configuration/create-legacy-browser-delegate.js +38 -3
  90. package/build/src/configuration/create-legacy-browser-delegate.js.map +1 -1
  91. package/build/src/configuration/legacy-base-configuration.d.ts +26 -8
  92. package/build/src/configuration/legacy-base-configuration.js.map +1 -1
  93. package/build/src/configuration/legacy-node-configuration.d.ts +18 -4
  94. package/build/src/configuration/legacy-node-configuration.js +1 -1
  95. package/build/src/configuration/legacy-node-configuration.js.map +1 -1
  96. package/build/src/index-browser-http.d.ts +1 -1
  97. package/build/src/index-browser-http.js +2 -1
  98. package/build/src/index-browser-http.js.map +1 -1
  99. package/build/src/index-node-http.d.ts +1 -1
  100. package/build/src/index-node-http.js +2 -1
  101. package/build/src/index-node-http.js.map +1 -1
  102. package/build/src/index.d.ts +1 -0
  103. package/build/src/index.js +3 -1
  104. package/build/src/index.js.map +1 -1
  105. package/build/src/otlp-browser-http-export-delegate.d.ts +3 -2
  106. package/build/src/otlp-browser-http-export-delegate.js +8 -4
  107. package/build/src/otlp-browser-http-export-delegate.js.map +1 -1
  108. package/build/src/otlp-export-delegate.d.ts +3 -0
  109. package/build/src/otlp-export-delegate.js +19 -6
  110. package/build/src/otlp-export-delegate.js.map +1 -1
  111. package/build/src/otlp-http-export-delegate.d.ts +5 -2
  112. package/build/src/otlp-http-export-delegate.js +32 -2
  113. package/build/src/otlp-http-export-delegate.js.map +1 -1
  114. package/build/src/otlp-network-export-delegate.d.ts +2 -1
  115. package/build/src/otlp-network-export-delegate.js +2 -1
  116. package/build/src/otlp-network-export-delegate.js.map +1 -1
  117. package/build/src/semconv.d.ts +91 -0
  118. package/build/src/semconv.js +103 -0
  119. package/build/src/semconv.js.map +1 -0
  120. package/build/src/version.d.ts +1 -1
  121. package/build/src/version.js +1 -1
  122. package/build/src/version.js.map +1 -1
  123. package/package.json +9 -9
package/README.md CHANGED
@@ -15,6 +15,36 @@ This module provides base components for OTLP Exporters, both Web and Node.js.
15
15
  npm install --save @opentelemetry/otlp-exporter-base
16
16
  ```
17
17
 
18
+ ## HTTP exporter configuration
19
+
20
+ HTTP JSON and HTTP/protobuf exporters for traces, metrics, and logs share these configuration options.
21
+ Node.js exporters accept `OTLPExporterNodeConfigBase`, which also includes the options from `OTLPExporterConfigBase`.
22
+ Configuration precedence is: programmatic options, then per-signal environment variables, then general environment variables, then built-in defaults.
23
+
24
+ | Option | Type | Default | Description |
25
+ | ------------------ | ------------------------------------------------------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
26
+ | `url` | `string` | `undefined` (default resolved per precedence above) | Collector endpoint URL. |
27
+ | `headers` | `Record<string, string> \| HeadersFactory` | `undefined` | Custom HTTP headers. A factory function may be async and must not throw. Exporters still apply required transport headers. |
28
+ | `concurrencyLimit` | `number` | `30` | Maximum number of in-flight export requests. |
29
+ | `timeoutMillis` | `number` | `10000` | Maximum time, in milliseconds, to wait for each batch export. |
30
+ | `compression` | `CompressionAlgorithm.NONE \| CompressionAlgorithm.GZIP` | `CompressionAlgorithm.NONE` | Compression for outgoing OTLP HTTP requests in Node.js. |
31
+ | `keepAlive` | `boolean` | `true` | Sets `keepAlive` on the Node.js HTTP or HTTPS agent created by the exporter. A `keepAlive` value in `httpAgentOptions` takes precedence. |
32
+ | `httpAgentOptions` | `http.AgentOptions \| https.AgentOptions \| HttpAgentFactory` | Agent options with `keepAlive: true` | Custom Node.js HTTP or HTTPS agent options, or a factory function that receives the request protocol and returns an agent. |
33
+ | `userAgent` | `string` | The exporter's default user agent | Prefix to add to the exporter's default `User-Agent` header in Node.js. |
34
+
35
+ | Option | General environment variable | Signal-specific environment variables |
36
+ | ----------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
37
+ | `url` | `OTEL_EXPORTER_OTLP_ENDPOINT` | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`, `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` |
38
+ | `headers` | `OTEL_EXPORTER_OTLP_HEADERS` | `OTEL_EXPORTER_OTLP_TRACES_HEADERS`, `OTEL_EXPORTER_OTLP_METRICS_HEADERS`, `OTEL_EXPORTER_OTLP_LOGS_HEADERS` |
39
+ | `timeoutMillis` | `OTEL_EXPORTER_OTLP_TIMEOUT` | `OTEL_EXPORTER_OTLP_TRACES_TIMEOUT`, `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT`, `OTEL_EXPORTER_OTLP_LOGS_TIMEOUT` |
40
+ | `compression` | `OTEL_EXPORTER_OTLP_COMPRESSION` | `OTEL_EXPORTER_OTLP_TRACES_COMPRESSION`, `OTEL_EXPORTER_OTLP_METRICS_COMPRESSION`, `OTEL_EXPORTER_OTLP_LOGS_COMPRESSION` |
41
+ | `concurrencyLimit` | Not supported | Not supported |
42
+ | `keepAlive` | Not supported | Not supported |
43
+ | `httpAgentOptions.ca` | `OTEL_EXPORTER_OTLP_CERTIFICATE` | `OTEL_EXPORTER_OTLP_{TRACES,METRICS,LOGS}_CERTIFICATE` |
44
+ | `httpAgentOptions.cert` | `OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE` | `OTEL_EXPORTER_OTLP_{TRACES,METRICS,LOGS}_CLIENT_CERTIFICATE` |
45
+ | `httpAgentOptions.key` | `OTEL_EXPORTER_OTLP_CLIENT_KEY` | `OTEL_EXPORTER_OTLP_{TRACES,METRICS,LOGS}_CLIENT_KEY` |
46
+ | `userAgent` | Not supported | Not supported |
47
+
18
48
  ## GRPC
19
49
 
20
50
  For GRPC please check [npm-url-grpc]
@@ -0,0 +1,24 @@
1
+ import { type Attributes, type MeterProvider } from '@opentelemetry/api';
2
+ import { type IExporterMetricsHelper } from '@opentelemetry/otlp-transformer';
3
+ export interface ExporterMetricsOptions<Internal> {
4
+ componentType: string;
5
+ metricsHelper: IExporterMetricsHelper<Internal>;
6
+ url: string | undefined;
7
+ meterProvider: MeterProvider | undefined;
8
+ responseAttributesFromError: (error: Error | string | undefined) => Attributes;
9
+ }
10
+ /**
11
+ * Generates `otel.sdk.exporter.*` metrics.
12
+ * https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics
13
+ */
14
+ export declare class ExporterMetrics<Internal> {
15
+ private readonly inflight;
16
+ private readonly exported;
17
+ private readonly duration;
18
+ private readonly standardAttrs;
19
+ private readonly responseAttributesFromError;
20
+ private readonly helper;
21
+ constructor(options: ExporterMetricsOptions<Internal>);
22
+ startExport(request: Internal): (error: Error | string | undefined) => void;
23
+ }
24
+ //# sourceMappingURL=ExporterMetrics.d.ts.map
@@ -0,0 +1,104 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { createNoopMeter, } from '@opentelemetry/api';
6
+ import { hrTime, hrTimeDuration, hrTimeToMilliseconds, } from '@opentelemetry/core';
7
+ import { ATTR_ERROR_TYPE, ATTR_OTEL_COMPONENT_NAME, ATTR_OTEL_COMPONENT_TYPE, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, } from './semconv';
8
+ import { VERSION } from './version';
9
+ const componentCounter = new Map();
10
+ /**
11
+ * Generates `otel.sdk.exporter.*` metrics.
12
+ * https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics
13
+ */
14
+ export class ExporterMetrics {
15
+ inflight;
16
+ exported;
17
+ duration;
18
+ standardAttrs;
19
+ responseAttributesFromError;
20
+ helper;
21
+ constructor(options) {
22
+ const { componentType, metricsHelper, meterProvider, url, responseAttributesFromError, } = options;
23
+ this.responseAttributesFromError = responseAttributesFromError;
24
+ const meter = meterProvider
25
+ ? meterProvider.getMeter('@opentelemetry/otlp-exporter', VERSION)
26
+ : createNoopMeter();
27
+ const counter = componentCounter.get(componentType) ?? 0;
28
+ componentCounter.set(componentType, counter + 1);
29
+ this.standardAttrs = {
30
+ [ATTR_OTEL_COMPONENT_TYPE]: componentType,
31
+ [ATTR_OTEL_COMPONENT_NAME]: `${componentType}/${counter}`,
32
+ };
33
+ if (url) {
34
+ // URLs may exclude scheme for gRPC endpoints, but in this case they always
35
+ // have a port number. Because the URL constructor requires a scheme, we
36
+ // can still handle gRPC endpoints by prepending an arbitrary scheme.
37
+ let urlToParse = url;
38
+ if (!url.includes('://')) {
39
+ urlToParse = `http://${url}`;
40
+ }
41
+ try {
42
+ const parsedUrl = new URL(urlToParse);
43
+ this.standardAttrs[ATTR_SERVER_ADDRESS] = parsedUrl.hostname;
44
+ let port = undefined;
45
+ if (parsedUrl.port) {
46
+ port = Number(parsedUrl.port);
47
+ }
48
+ else if (parsedUrl.protocol === 'http:') {
49
+ port = 80;
50
+ }
51
+ else if (parsedUrl.protocol === 'https:') {
52
+ port = 443;
53
+ }
54
+ if (typeof port === 'number') {
55
+ this.standardAttrs[ATTR_SERVER_PORT] = port;
56
+ }
57
+ }
58
+ catch {
59
+ // In practice, URLs will be valid or something else will break. Better to let that
60
+ // inform the user than an exception in this internal code and proceed best-effort
61
+ // here.
62
+ }
63
+ }
64
+ this.helper = metricsHelper;
65
+ this.inflight = meter.createUpDownCounter(`otel.sdk.exporter.${this.helper.name}.inflight`, {
66
+ unit: `{${this.helper.name}}`,
67
+ description: `The number of ${this.helper.name}s which were passed to the exporter, but that have not been exported yet (neither successful, nor failed).`,
68
+ });
69
+ this.exported = meter.createCounter(`otel.sdk.exporter.${this.helper.name}.exported`, {
70
+ unit: `{${this.helper.name}}`,
71
+ description: `The number of ${this.helper.name}s for which the export has finished, either successful or failed.`,
72
+ });
73
+ this.duration = meter.createHistogram('otel.sdk.exporter.operation.duration', {
74
+ unit: 's',
75
+ description: 'The duration of exporting a batch of telemetry records.',
76
+ advice: {
77
+ explicitBucketBoundaries: [],
78
+ },
79
+ });
80
+ }
81
+ startExport(request) {
82
+ const numItems = this.helper.countItems(request);
83
+ const startTime = hrTime();
84
+ this.inflight.add(numItems, this.standardAttrs);
85
+ return (error) => {
86
+ const endTime = hrTime();
87
+ this.inflight.add(-numItems, this.standardAttrs);
88
+ const exportedAttrs = error
89
+ ? {
90
+ ...this.standardAttrs,
91
+ [ATTR_ERROR_TYPE]: error instanceof Error ? error.name : 'export_failed',
92
+ }
93
+ : this.standardAttrs;
94
+ this.exported.add(numItems, exportedAttrs);
95
+ const durationAttrs = {
96
+ ...exportedAttrs,
97
+ ...this.responseAttributesFromError(error),
98
+ };
99
+ const duration = hrTimeToMilliseconds(hrTimeDuration(startTime, endTime)) / 1000;
100
+ this.duration.record(duration, durationAttrs);
101
+ };
102
+ }
103
+ }
104
+ //# sourceMappingURL=ExporterMetrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExporterMetrics.js","sourceRoot":"","sources":["../../src/ExporterMetrics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAML,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,MAAM,EACN,cAAc,EACd,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,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histogram,\n type MeterProvider,\n type UpDownCounter,\n createNoopMeter,\n} from '@opentelemetry/api';\nimport {\n hrTime,\n hrTimeDuration,\n hrTimeToMilliseconds,\n} from '@opentelemetry/core';\nimport { type IExporterMetricsHelper } from '@opentelemetry/otlp-transformer';\nimport {\n ATTR_ERROR_TYPE,\n ATTR_OTEL_COMPONENT_NAME,\n ATTR_OTEL_COMPONENT_TYPE,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from './semconv';\nimport { VERSION } from './version';\n\nconst componentCounter = new Map<string, number>();\n\nexport interface ExporterMetricsOptions<Internal> {\n componentType: string;\n metricsHelper: IExporterMetricsHelper<Internal>;\n url: string | undefined;\n meterProvider: MeterProvider | undefined;\n responseAttributesFromError: (\n error: Error | string | undefined\n ) => Attributes;\n}\n\n/**\n * Generates `otel.sdk.exporter.*` metrics.\n * https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics\n */\nexport class ExporterMetrics<Internal> {\n private readonly inflight: UpDownCounter;\n private readonly exported: Counter;\n private readonly duration: Histogram;\n private readonly standardAttrs: Attributes;\n private readonly responseAttributesFromError: (\n error: Error | string | undefined\n ) => Attributes;\n\n private readonly helper: IExporterMetricsHelper<Internal>;\n\n constructor(options: ExporterMetricsOptions<Internal>) {\n const {\n componentType,\n metricsHelper,\n meterProvider,\n url,\n responseAttributesFromError,\n } = options;\n this.responseAttributesFromError = responseAttributesFromError;\n const meter = meterProvider\n ? meterProvider.getMeter('@opentelemetry/otlp-exporter', VERSION)\n : createNoopMeter();\n\n const counter = componentCounter.get(componentType) ?? 0;\n componentCounter.set(componentType, counter + 1);\n\n this.standardAttrs = {\n [ATTR_OTEL_COMPONENT_TYPE]: componentType,\n [ATTR_OTEL_COMPONENT_NAME]: `${componentType}/${counter}`,\n };\n if (url) {\n // URLs may exclude scheme for gRPC endpoints, but in this case they always\n // have a port number. Because the URL constructor requires a scheme, we\n // can still handle gRPC endpoints by prepending an arbitrary scheme.\n let urlToParse = url;\n if (!url.includes('://')) {\n urlToParse = `http://${url}`;\n }\n try {\n const parsedUrl = new URL(urlToParse);\n this.standardAttrs[ATTR_SERVER_ADDRESS] = parsedUrl.hostname;\n let port: number | undefined = undefined;\n if (parsedUrl.port) {\n port = Number(parsedUrl.port);\n } else if (parsedUrl.protocol === 'http:') {\n port = 80;\n } else if (parsedUrl.protocol === 'https:') {\n port = 443;\n }\n if (typeof port === 'number') {\n this.standardAttrs[ATTR_SERVER_PORT] = port;\n }\n } catch {\n // In practice, URLs will be valid or something else will break. Better to let that\n // inform the user than an exception in this internal code and proceed best-effort\n // here.\n }\n }\n\n this.helper = metricsHelper;\n\n this.inflight = meter.createUpDownCounter(\n `otel.sdk.exporter.${this.helper.name}.inflight`,\n {\n unit: `{${this.helper.name}}`,\n description: `The number of ${this.helper.name}s which were passed to the exporter, but that have not been exported yet (neither successful, nor failed).`,\n }\n );\n this.exported = meter.createCounter(\n `otel.sdk.exporter.${this.helper.name}.exported`,\n {\n unit: `{${this.helper.name}}`,\n description: `The number of ${this.helper.name}s for which the export has finished, either successful or failed.`,\n }\n );\n this.duration = meter.createHistogram(\n 'otel.sdk.exporter.operation.duration',\n {\n unit: 's',\n description: 'The duration of exporting a batch of telemetry records.',\n advice: {\n explicitBucketBoundaries: [],\n },\n }\n );\n }\n\n startExport(request: Internal): (error: Error | string | undefined) => void {\n const numItems = this.helper.countItems(request);\n const startTime = hrTime();\n this.inflight.add(numItems, this.standardAttrs);\n return (error: Error | string | undefined) => {\n const endTime = hrTime();\n this.inflight.add(-numItems, this.standardAttrs);\n const exportedAttrs = error\n ? {\n ...this.standardAttrs,\n [ATTR_ERROR_TYPE]:\n error instanceof Error ? error.name : 'export_failed',\n }\n : this.standardAttrs;\n this.exported.add(numItems, exportedAttrs);\n const durationAttrs = {\n ...exportedAttrs,\n ...this.responseAttributesFromError(error),\n };\n const duration =\n hrTimeToMilliseconds(hrTimeDuration(startTime, endTime)) / 1000;\n this.duration.record(duration, durationAttrs);\n };\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { ExportResult } from '@opentelemetry/core';
2
2
  import type { IOtlpExportDelegate } from './otlp-export-delegate';
3
+ import { type ExporterMetrics } from './ExporterMetrics';
3
4
  export declare class OTLPExporterBase<Internal> {
4
5
  private _delegate;
5
6
  constructor(delegate: IOtlpExportDelegate<Internal>);
@@ -11,5 +12,6 @@ export declare class OTLPExporterBase<Internal> {
11
12
  export(items: Internal, resultCallback: (result: ExportResult) => void): void;
12
13
  forceFlush(): Promise<void>;
13
14
  shutdown(): Promise<void>;
15
+ protected setMetrics(metrics: ExporterMetrics<Internal>): void;
14
16
  }
15
17
  //# sourceMappingURL=OTLPExporterBase.d.ts.map
@@ -21,5 +21,8 @@ export class OTLPExporterBase {
21
21
  shutdown() {
22
22
  return this._delegate.shutdown();
23
23
  }
24
+ setMetrics(metrics) {
25
+ this._delegate.setMetrics(metrics);
26
+ }
24
27
  }
25
28
  //# sourceMappingURL=OTLPExporterBase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,OAAO,gBAAgB;IACnB,SAAS,CAAgC;IACjD,YAAY,QAAuC;QACjD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,MAAM,CACJ,KAAe,EACf,cAA8C;QAE9C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAC/C,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ExportResult } from '@opentelemetry/core';\nimport type { IOtlpExportDelegate } from './otlp-export-delegate';\n\nexport class OTLPExporterBase<Internal> {\n private _delegate: IOtlpExportDelegate<Internal>;\n constructor(delegate: IOtlpExportDelegate<Internal>) {\n this._delegate = delegate;\n }\n\n /**\n * Export items.\n * @param items\n * @param resultCallback\n */\n export(\n items: Internal,\n resultCallback: (result: ExportResult) => void\n ): void {\n this._delegate.export(items, resultCallback);\n }\n\n forceFlush(): Promise<void> {\n return this._delegate.forceFlush();\n }\n\n shutdown(): Promise<void> {\n return this._delegate.shutdown();\n }\n}\n"]}
1
+ {"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,OAAO,gBAAgB;IACnB,SAAS,CAAgC;IACjD,YAAY,QAAuC;QACjD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,MAAM,CACJ,KAAe,EACf,cAA8C;QAE9C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAC/C,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IAES,UAAU,CAAC,OAAkC;QACrD,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ExportResult } from '@opentelemetry/core';\nimport type { IOtlpExportDelegate } from './otlp-export-delegate';\nimport { type ExporterMetrics } from './ExporterMetrics';\n\nexport class OTLPExporterBase<Internal> {\n private _delegate: IOtlpExportDelegate<Internal>;\n constructor(delegate: IOtlpExportDelegate<Internal>) {\n this._delegate = delegate;\n }\n\n /**\n * Export items.\n * @param items\n * @param resultCallback\n */\n export(\n items: Internal,\n resultCallback: (result: ExportResult) => void\n ): void {\n this._delegate.export(items, resultCallback);\n }\n\n forceFlush(): Promise<void> {\n return this._delegate.forceFlush();\n }\n\n shutdown(): Promise<void> {\n return this._delegate.shutdown();\n }\n\n protected setMetrics(metrics: ExporterMetrics<Internal>) {\n this._delegate.setMetrics(metrics);\n }\n}\n"]}
@@ -1,6 +1,12 @@
1
- import type { ISerializer } from '@opentelemetry/otlp-transformer';
1
+ import type { MeterProvider } from '@opentelemetry/api';
2
+ import type { IExporterMetricsHelper, ISerializer } from '@opentelemetry/otlp-transformer';
2
3
  import type { IOtlpExportDelegate } from '../otlp-export-delegate';
3
4
  import type { OTLPExporterConfigBase } from './legacy-base-configuration';
5
+ import { ExporterMetrics } from '../ExporterMetrics';
6
+ /**
7
+ * @deprecated
8
+ */
9
+ export declare function createLegacyOtlpBrowserExporterMetrics<Internal>(metricsComponentType: string, exporterMetricsHelper: IExporterMetricsHelper<Internal>, url: string | undefined, meterProvider: MeterProvider | undefined): ExporterMetrics<Internal>;
4
10
  /**
5
11
  * @deprecated
6
12
  * @param config
@@ -8,5 +14,5 @@ import type { OTLPExporterConfigBase } from './legacy-base-configuration';
8
14
  * @param signalResourcePath
9
15
  * @param requiredHeaders
10
16
  */
11
- export declare function createLegacyOtlpBrowserExportDelegate<Internal, Response>(config: OTLPExporterConfigBase, serializer: ISerializer<Internal, Response>, signalResourcePath: string, requiredHeaders: Record<string, string>): IOtlpExportDelegate<Internal>;
17
+ export declare function createLegacyOtlpBrowserExportDelegate<Internal, Response>(config: OTLPExporterConfigBase, serializer: ISerializer<Internal, Response>, metricsComponentType: string, exporterMetricsHelper: IExporterMetricsHelper<Internal>, meterProvider: MeterProvider | undefined, signalResourcePath: string, requiredHeaders: Record<string, string>): IOtlpExportDelegate<Internal>;
12
18
  //# sourceMappingURL=create-legacy-browser-delegate.d.ts.map
@@ -1,5 +1,39 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
1
5
  import { createOtlpFetchExportDelegate } from '../otlp-browser-http-export-delegate';
2
6
  import { convertLegacyBrowserHttpOptions } from './convert-legacy-browser-http-options';
7
+ import { ATTR_HTTP_RESPONSE_STATUS_CODE } from '../semconv';
8
+ import { ExporterMetrics } from '../ExporterMetrics';
9
+ /**
10
+ * @deprecated
11
+ */
12
+ export function createLegacyOtlpBrowserExporterMetrics(metricsComponentType, exporterMetricsHelper, url, meterProvider) {
13
+ return new ExporterMetrics({
14
+ componentType: metricsComponentType,
15
+ metricsHelper: exporterMetricsHelper,
16
+ url,
17
+ meterProvider,
18
+ responseAttributesFromError: (error) => {
19
+ if (!error) {
20
+ return {
21
+ [ATTR_HTTP_RESPONSE_STATUS_CODE]: 200,
22
+ };
23
+ }
24
+ if (!(error instanceof Error)) {
25
+ return {};
26
+ }
27
+ if (error.message.startsWith('Fetch request failed with non-retryable status ')) {
28
+ const statusStr = error.message.substring('Fetch request failed with non-retryable status '.length);
29
+ return {
30
+ [ATTR_HTTP_RESPONSE_STATUS_CODE]: Number(statusStr),
31
+ };
32
+ }
33
+ return {};
34
+ },
35
+ });
36
+ }
3
37
  /**
4
38
  * @deprecated
5
39
  * @param config
@@ -7,8 +41,8 @@ import { convertLegacyBrowserHttpOptions } from './convert-legacy-browser-http-o
7
41
  * @param signalResourcePath
8
42
  * @param requiredHeaders
9
43
  */
10
- export function createLegacyOtlpBrowserExportDelegate(config, serializer, signalResourcePath, requiredHeaders) {
44
+ export function createLegacyOtlpBrowserExportDelegate(config, serializer, metricsComponentType, exporterMetricsHelper, meterProvider, signalResourcePath, requiredHeaders) {
11
45
  const options = convertLegacyBrowserHttpOptions(config, signalResourcePath, requiredHeaders);
12
- return createOtlpFetchExportDelegate(options, serializer);
46
+ return createOtlpFetchExportDelegate(options, serializer, createLegacyOtlpBrowserExporterMetrics(metricsComponentType, exporterMetricsHelper, options.url, config.selfObsMeterProvider));
13
47
  }
14
48
  //# sourceMappingURL=create-legacy-browser-delegate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-legacy-browser-delegate.js","sourceRoot":"","sources":["../../../src/configuration/create-legacy-browser-delegate.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AAIxF;;;;;;GAMG;AACH,MAAM,UAAU,qCAAqC,CACnD,MAA8B,EAC9B,UAA2C,EAC3C,kBAA0B,EAC1B,eAAuC;IAEvC,MAAM,OAAO,GAAG,+BAA+B,CAC7C,MAAM,EACN,kBAAkB,EAClB,eAAe,CAChB,CAAC;IAEF,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 type { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { createOtlpFetchExportDelegate } from '../otlp-browser-http-export-delegate';\nimport { convertLegacyBrowserHttpOptions } from './convert-legacy-browser-http-options';\nimport type { IOtlpExportDelegate } from '../otlp-export-delegate';\nimport type { OTLPExporterConfigBase } from './legacy-base-configuration';\n\n/**\n * @deprecated\n * @param config\n * @param serializer\n * @param signalResourcePath\n * @param requiredHeaders\n */\nexport function createLegacyOtlpBrowserExportDelegate<Internal, Response>(\n config: OTLPExporterConfigBase,\n serializer: ISerializer<Internal, Response>,\n signalResourcePath: string,\n requiredHeaders: Record<string, string>\n): IOtlpExportDelegate<Internal> {\n const options = convertLegacyBrowserHttpOptions(\n config,\n signalResourcePath,\n requiredHeaders\n );\n\n return createOtlpFetchExportDelegate(options, serializer);\n}\n"]}
1
+ {"version":3,"file":"create-legacy-browser-delegate.js","sourceRoot":"","sources":["../../../src/configuration/create-legacy-browser-delegate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,6BAA6B,E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rB,OAAO,CAAC,GAAG,EACX,MAAM,CAAC,oBAAoB,CAC5B,CACF,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { MeterProvider } from '@opentelemetry/api';\nimport type {\n IExporterMetricsHelper,\n ISerializer,\n} from '@opentelemetry/otlp-transformer';\nimport { createOtlpFetchExportDelegate } from '../otlp-browser-http-export-delegate';\nimport { convertLegacyBrowserHttpOptions } from './convert-legacy-browser-http-options';\nimport type { IOtlpExportDelegate } from '../otlp-export-delegate';\nimport type { OTLPExporterConfigBase } from './legacy-base-configuration';\nimport { ATTR_HTTP_RESPONSE_STATUS_CODE } from '../semconv';\nimport { ExporterMetrics } from '../ExporterMetrics';\n\n/**\n * @deprecated\n */\nexport function createLegacyOtlpBrowserExporterMetrics<Internal>(\n metricsComponentType: string,\n exporterMetricsHelper: IExporterMetricsHelper<Internal>,\n url: string | undefined,\n meterProvider: MeterProvider | undefined\n): ExporterMetrics<Internal> {\n return new ExporterMetrics({\n componentType: metricsComponentType,\n metricsHelper: exporterMetricsHelper,\n url,\n meterProvider,\n responseAttributesFromError: (error: Error | string | undefined) => {\n if (!error) {\n return {\n [ATTR_HTTP_RESPONSE_STATUS_CODE]: 200,\n };\n }\n if (!(error instanceof Error)) {\n return {};\n }\n if (\n error.message.startsWith(\n 'Fetch request failed with non-retryable status '\n )\n ) {\n const statusStr = error.message.substring(\n 'Fetch request failed with non-retryable status '.length\n );\n return {\n [ATTR_HTTP_RESPONSE_STATUS_CODE]: Number(statusStr),\n };\n }\n return {};\n },\n });\n}\n\n/**\n * @deprecated\n * @param config\n * @param serializer\n * @param signalResourcePath\n * @param requiredHeaders\n */\nexport function createLegacyOtlpBrowserExportDelegate<Internal, Response>(\n config: OTLPExporterConfigBase,\n serializer: ISerializer<Internal, Response>,\n metricsComponentType: string,\n exporterMetricsHelper: IExporterMetricsHelper<Internal>,\n meterProvider: MeterProvider | undefined,\n signalResourcePath: string,\n requiredHeaders: Record<string, string>\n): IOtlpExportDelegate<Internal> {\n const options = convertLegacyBrowserHttpOptions(\n config,\n signalResourcePath,\n requiredHeaders\n );\n\n return createOtlpFetchExportDelegate(\n options,\n serializer,\n createLegacyOtlpBrowserExporterMetrics(\n metricsComponentType,\n exporterMetricsHelper,\n options.url,\n config.selfObsMeterProvider\n )\n );\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { MeterProvider } from '@opentelemetry/api';
1
2
  import type { HeadersFactory } from './otlp-http-configuration';
2
3
  export interface OTLPExporterConfigBase {
3
4
  /**
@@ -5,11 +6,8 @@ export interface OTLPExporterConfigBase {
5
6
  *
6
7
  * @remarks
7
8
  * Prefer using a plain object over a factory function wherever possible.
8
- * If using a factory function (`HttpAgentFactory`), **do not import `http` or `https` at the top of the file**
9
- * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`
10
- * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.
11
- *
12
- * Functions passed to the exporter MUST NOT throw errors.
9
+ * A factory function may be async and MUST NOT throw errors.
10
+ * It should return a string map containing the headers to add to the request.
13
11
  *
14
12
  * @example <caption> Using headers options directly: </caption>
15
13
  * headers: {
@@ -18,17 +16,37 @@ export interface OTLPExporterConfigBase {
18
16
  *
19
17
  * @example <caption> Using a custom factory function </caption>
20
18
  * headers: async () => {
21
- * // ... do whatever you need to obtain the headers, ensuring you `await import('your-library')` to avoid breaking instrumentations ...
22
19
  * return {
23
20
  * Authorization: `Bearer ${token}`,
24
21
  * };
25
22
  * };
26
23
  */
27
24
  headers?: Record<string, string> | HeadersFactory;
25
+ /**
26
+ * Collector endpoint URL for the exporter.
27
+ *
28
+ * @remarks
29
+ * Defaults to the signal-specific endpoint, such as
30
+ * `http://localhost:4318/v1/traces`, `http://localhost:4318/v1/metrics`,
31
+ * or `http://localhost:4318/v1/logs`.
32
+ */
28
33
  url?: string;
34
+ /**
35
+ * Maximum number of in-flight export requests.
36
+ *
37
+ * @defaultValue 30
38
+ */
29
39
  concurrencyLimit?: number;
30
- /** Maximum time the OTLP exporter will wait for each batch export.
31
- * The default value is 10000ms. */
40
+ /**
41
+ * Maximum time, in milliseconds, the OTLP exporter will wait for each batch export.
42
+ *
43
+ * @defaultValue 10000
44
+ */
32
45
  timeoutMillis?: number;
46
+ /**
47
+ * MeterProvider to record metrics for the exporter itself.
48
+ * @experimental This option is experimental and is subject to breaking changes in minor releases.
49
+ */
50
+ selfObsMeterProvider?: MeterProvider;
33
51
  }
34
52
  //# sourceMappingURL=legacy-base-configuration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-base-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-base-configuration.ts"],"names":[],"mappings":"","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { HeadersFactory } from './otlp-http-configuration';\n\nexport interface OTLPExporterConfigBase {\n /**\n * Custom headers that will be attached to the HTTP request that's sent to the endpoint.\n *\n * @remarks\n * Prefer using a plain object over a factory function wherever possible.\n * If using a factory function (`HttpAgentFactory`), **do not import `http` or `https` at the top of the file**\n * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`\n * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.\n *\n * Functions passed to the exporter MUST NOT throw errors.\n *\n * @example <caption> Using headers options directly: </caption>\n * headers: {\n * Authorization: \"Api-Token my-secret-token\",\n * }\n *\n * @example <caption> Using a custom factory function </caption>\n * headers: async () => {\n * // ... do whatever you need to obtain the headers, ensuring you `await import('your-library')` to avoid breaking instrumentations ...\n * return {\n * Authorization: `Bearer ${token}`,\n * };\n * };\n */\n headers?: Record<string, string> | HeadersFactory;\n url?: string;\n concurrencyLimit?: number;\n /** Maximum time the OTLP exporter will wait for each batch export.\n * The default value is 10000ms. */\n timeoutMillis?: number;\n}\n"]}
1
+ {"version":3,"file":"legacy-base-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-base-configuration.ts"],"names":[],"mappings":"","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { MeterProvider } from '@opentelemetry/api';\nimport type { HeadersFactory } from './otlp-http-configuration';\n\nexport interface OTLPExporterConfigBase {\n /**\n * Custom headers that will be attached to the HTTP request that's sent to the endpoint.\n *\n * @remarks\n * Prefer using a plain object over a factory function wherever possible.\n * A factory function may be async and MUST NOT throw errors.\n * It should return a string map containing the headers to add to the request.\n *\n * @example <caption> Using headers options directly: </caption>\n * headers: {\n * Authorization: \"Api-Token my-secret-token\",\n * }\n *\n * @example <caption> Using a custom factory function </caption>\n * headers: async () => {\n * return {\n * Authorization: `Bearer ${token}`,\n * };\n * };\n */\n headers?: Record<string, string> | HeadersFactory;\n /**\n * Collector endpoint URL for the exporter.\n *\n * @remarks\n * Defaults to the signal-specific endpoint, such as\n * `http://localhost:4318/v1/traces`, `http://localhost:4318/v1/metrics`,\n * or `http://localhost:4318/v1/logs`.\n */\n url?: string;\n /**\n * Maximum number of in-flight export requests.\n *\n * @defaultValue 30\n */\n concurrencyLimit?: number;\n /**\n * Maximum time, in milliseconds, the OTLP exporter will wait for each batch export.\n *\n * @defaultValue 10000\n */\n timeoutMillis?: number;\n\n /**\n * MeterProvider to record metrics for the exporter itself.\n * @experimental This option is experimental and is subject to breaking changes in minor releases.\n */\n selfObsMeterProvider?: MeterProvider;\n}\n"]}
@@ -5,10 +5,24 @@ import type * as https from 'https';
5
5
  import type { OTLPExporterConfigBase } from './legacy-base-configuration';
6
6
  import type { HttpAgentFactory } from './otlp-node-http-configuration';
7
7
  /**
8
- * Collector Exporter node base config
8
+ * Node.js HTTP exporter configuration.
9
9
  */
10
10
  export interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {
11
+ /**
12
+ * Sets `keepAlive` on the Node.js HTTP or HTTPS agent created by the exporter.
13
+ *
14
+ * @remarks
15
+ * If `httpAgentOptions` is an object with its own `keepAlive` value, the
16
+ * value in `httpAgentOptions` takes precedence.
17
+ *
18
+ * @defaultValue true
19
+ */
11
20
  keepAlive?: boolean;
21
+ /**
22
+ * Compression algorithm for outgoing OTLP HTTP requests.
23
+ *
24
+ * @defaultValue CompressionAlgorithm.NONE
25
+ */
12
26
  compression?: CompressionAlgorithm;
13
27
  /**
14
28
  * Custom HTTP agent options or a factory function for creating agents.
@@ -17,8 +31,8 @@ export interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {
17
31
  * Prefer using `http.AgentOptions` or `https.AgentOptions` over a factory function wherever possible.
18
32
  * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`
19
33
  * statically at the top of the file**.
20
- * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`
21
- * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.
34
+ * Instead, use dynamic `import()` or `require()` to load the module. This lets
35
+ * `@opentelemetry/instrumentation-http` instrument the module first.
22
36
  *
23
37
  * @example <caption> Using agent options directly: </caption>
24
38
  * httpAgentOptions: {
@@ -35,7 +49,7 @@ export interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {
35
49
  httpAgentOptions?: http.AgentOptions | https.AgentOptions | HttpAgentFactory;
36
50
  /**
37
51
  * User agent header string to be prepended to the exporter's default value.
38
- * Availablie since v1.49.0 of the spec.
52
+ * Available since v1.49.0 of the spec.
39
53
  * Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent
40
54
  */
41
55
  userAgent?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-node-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-node-configuration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8CH,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,qCAAa,CAAA;IACb,qCAAa,CAAA;AACf,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// NOTE: do not change these imports to be actual imports, otherwise they WILL break `@opentelemetry/instrumentation-http`\nimport type * as http from 'http';\nimport type * as https from 'https';\n\nimport type { OTLPExporterConfigBase } from './legacy-base-configuration';\nimport type { HttpAgentFactory } from './otlp-node-http-configuration';\n\n/**\n * Collector Exporter node base config\n */\nexport interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {\n keepAlive?: boolean;\n compression?: CompressionAlgorithm;\n /**\n * Custom HTTP agent options or a factory function for creating agents.\n *\n * @remarks\n * Prefer using `http.AgentOptions` or `https.AgentOptions` over a factory function wherever possible.\n * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`\n * statically at the top of the file**.\n * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`\n * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.\n *\n * @example <caption> Using agent options directly: </caption>\n * httpAgentOptions: {\n * keepAlive: true,\n * maxSockets: 10\n * }\n *\n * @example <caption> Using a factory with dynamic import: </caption>\n * httpAgentOptions: async (protocol) => {\n * const module = protocol === 'http:' ? await import('http') : await import('https');\n * return new module.Agent({ keepAlive: true });\n * }\n */\n httpAgentOptions?: http.AgentOptions | https.AgentOptions | HttpAgentFactory;\n /**\n * User agent header string to be prepended to the exporter's default value.\n * Availablie since v1.49.0 of the spec.\n * Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent\n */\n userAgent?: string;\n}\n\nexport enum CompressionAlgorithm {\n NONE = 'none',\n GZIP = 'gzip',\n}\n"]}
1
+ {"version":3,"file":"legacy-node-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-node-configuration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4DH,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,qCAAa,CAAA;IACb,qCAAa,CAAA;AACf,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// NOTE: do not change these imports to be actual imports, otherwise they WILL break `@opentelemetry/instrumentation-http`\nimport type * as http from 'http';\nimport type * as https from 'https';\n\nimport type { OTLPExporterConfigBase } from './legacy-base-configuration';\nimport type { HttpAgentFactory } from './otlp-node-http-configuration';\n\n/**\n * Node.js HTTP exporter configuration.\n */\nexport interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {\n /**\n * Sets `keepAlive` on the Node.js HTTP or HTTPS agent created by the exporter.\n *\n * @remarks\n * If `httpAgentOptions` is an object with its own `keepAlive` value, the\n * value in `httpAgentOptions` takes precedence.\n *\n * @defaultValue true\n */\n keepAlive?: boolean;\n /**\n * Compression algorithm for outgoing OTLP HTTP requests.\n *\n * @defaultValue CompressionAlgorithm.NONE\n */\n compression?: CompressionAlgorithm;\n /**\n * Custom HTTP agent options or a factory function for creating agents.\n *\n * @remarks\n * Prefer using `http.AgentOptions` or `https.AgentOptions` over a factory function wherever possible.\n * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`\n * statically at the top of the file**.\n * Instead, use dynamic `import()` or `require()` to load the module. This lets\n * `@opentelemetry/instrumentation-http` instrument the module first.\n *\n * @example <caption> Using agent options directly: </caption>\n * httpAgentOptions: {\n * keepAlive: true,\n * maxSockets: 10\n * }\n *\n * @example <caption> Using a factory with dynamic import: </caption>\n * httpAgentOptions: async (protocol) => {\n * const module = protocol === 'http:' ? await import('http') : await import('https');\n * return new module.Agent({ keepAlive: true });\n * }\n */\n httpAgentOptions?: http.AgentOptions | https.AgentOptions | HttpAgentFactory;\n /**\n * User agent header string to be prepended to the exporter's default value.\n * Available since v1.49.0 of the spec.\n * Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent\n */\n userAgent?: string;\n}\n\nexport enum CompressionAlgorithm {\n NONE = 'none',\n GZIP = 'gzip',\n}\n"]}
@@ -3,5 +3,5 @@
3
3
  */
4
4
  export { createOtlpSendBeaconExportDelegate } from './otlp-browser-http-export-delegate';
5
5
  export { convertLegacyBrowserHttpOptions } from './configuration/convert-legacy-browser-http-options';
6
- export { createLegacyOtlpBrowserExportDelegate } from './configuration/create-legacy-browser-delegate';
6
+ export { createLegacyOtlpBrowserExportDelegate, createLegacyOtlpBrowserExporterMetrics, } from './configuration/create-legacy-browser-delegate';
7
7
  //# sourceMappingURL=index-browser-http.d.ts.map
@@ -7,5 +7,5 @@
7
7
  */
8
8
  export { createOtlpSendBeaconExportDelegate } from './otlp-browser-http-export-delegate';
9
9
  export { convertLegacyBrowserHttpOptions } from './configuration/convert-legacy-browser-http-options';
10
- export { createLegacyOtlpBrowserExportDelegate } from './configuration/create-legacy-browser-delegate';
10
+ export { createLegacyOtlpBrowserExportDelegate, createLegacyOtlpBrowserExporterMetrics, } from './configuration/create-legacy-browser-delegate';
11
11
  //# sourceMappingURL=index-browser-http.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-browser-http.js","sourceRoot":"","sources":["../../src/index-browser-http.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,OAAO,EAAE,kCAAkC,EAAE,MAAM,qCAAqC,CAAC;AAEzF,OAAO,EAAE,+BAA+B,EAAE,MAAM,qDAAqD,CAAC;AACtG,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * @deprecated Use `createOtlpFetchExportDelegate` instead.\n */\nexport { createOtlpSendBeaconExportDelegate } from './otlp-browser-http-export-delegate';\n\nexport { convertLegacyBrowserHttpOptions } from './configuration/convert-legacy-browser-http-options';\nexport { createLegacyOtlpBrowserExportDelegate } from './configuration/create-legacy-browser-delegate';\n"]}
1
+ {"version":3,"file":"index-browser-http.js","sourceRoot":"","sources":["../../src/index-browser-http.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,OAAO,EAAE,kCAAkC,EAAE,MAAM,qCAAqC,CAAC;AAEzF,OAAO,EAAE,+BAA+B,EAAE,MAAM,qDAAqD,CAAC;AACtG,OAAO,EACL,qCAAqC,EACrC,sCAAsC,GACvC,MAAM,gDAAgD,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * @deprecated Use `createOtlpFetchExportDelegate` instead.\n */\nexport { createOtlpSendBeaconExportDelegate } from './otlp-browser-http-export-delegate';\n\nexport { convertLegacyBrowserHttpOptions } from './configuration/convert-legacy-browser-http-options';\nexport {\n createLegacyOtlpBrowserExportDelegate,\n createLegacyOtlpBrowserExporterMetrics,\n} from './configuration/create-legacy-browser-delegate';\n"]}
@@ -1,5 +1,5 @@
1
1
  export { httpAgentFactoryFromOptions } from './configuration/otlp-node-http-configuration';
2
- export { createOtlpHttpExportDelegate } from './otlp-http-export-delegate';
2
+ export { createOtlpHttpExportDelegate, createOtlpHttpExporterMetrics, } from './otlp-http-export-delegate';
3
3
  export { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';
4
4
  export { convertLegacyHttpOptions } from './configuration/convert-legacy-node-http-options';
5
5
  //# sourceMappingURL=index-node-http.d.ts.map
@@ -3,7 +3,7 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  export { httpAgentFactoryFromOptions } from './configuration/otlp-node-http-configuration';
6
- export { createOtlpHttpExportDelegate } from './otlp-http-export-delegate';
6
+ export { createOtlpHttpExportDelegate, createOtlpHttpExporterMetrics, } from './otlp-http-export-delegate';
7
7
  export { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';
8
8
  export { convertLegacyHttpOptions } from './configuration/convert-legacy-node-http-options';
9
9
  //# sourceMappingURL=index-node-http.js.map
@@ -1 +1 @@
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"]}
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,EACL,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,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 {\n createOtlpHttpExportDelegate,\n createOtlpHttpExporterMetrics,\n} from './otlp-http-export-delegate';\nexport { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';\nexport { convertLegacyHttpOptions } from './configuration/convert-legacy-node-http-options';\n"]}
@@ -9,4 +9,5 @@ export type { OTLPExporterNodeConfigBase } from './configuration/legacy-node-con
9
9
  export type { OTLPExporterConfigBase } from './configuration/legacy-base-configuration';
10
10
  export type { IOtlpExportDelegate } from './otlp-export-delegate';
11
11
  export { createOtlpNetworkExportDelegate } from './otlp-network-export-delegate';
12
+ export { ExporterMetrics } from './ExporterMetrics';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -7,4 +7,5 @@ export { OTLPExporterError } from './types';
7
7
  export { mergeOtlpSharedConfigurationWithDefaults, getSharedConfigurationDefaults, } from './configuration/shared-configuration';
8
8
  export { CompressionAlgorithm } from './configuration/legacy-node-configuration';
9
9
  export { createOtlpNetworkExportDelegate } from './otlp-network-export-delegate';
10
+ export { ExporterMetrics } from './ExporterMetrics';
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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
+ {"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;AAEjF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,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\nexport { ExporterMetrics } from './ExporterMetrics';\n"]}
@@ -1,9 +1,10 @@
1
1
  import type { OtlpHttpConfiguration } from './configuration/otlp-http-configuration';
2
2
  import type { ISerializer } from '@opentelemetry/otlp-transformer';
3
3
  import type { IOtlpExportDelegate } from './otlp-export-delegate';
4
- export declare function createOtlpFetchExportDelegate<Internal, Response>(options: OtlpHttpConfiguration, serializer: ISerializer<Internal, Response>): IOtlpExportDelegate<Internal>;
4
+ import { type ExporterMetrics } from './ExporterMetrics';
5
+ export declare function createOtlpFetchExportDelegate<Internal, Response>(options: OtlpHttpConfiguration, serializer: ISerializer<Internal, Response>, metrics: ExporterMetrics<Internal>): IOtlpExportDelegate<Internal>;
5
6
  /**
6
7
  * @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
8
  */
8
- export declare function createOtlpSendBeaconExportDelegate<Internal, Response>(options: OtlpHttpConfiguration, serializer: ISerializer<Internal, Response>): IOtlpExportDelegate<Internal>;
9
+ export declare function createOtlpSendBeaconExportDelegate<Internal, Response>(options: OtlpHttpConfiguration, serializer: ISerializer<Internal, Response>, metrics: ExporterMetrics<Internal>): IOtlpExportDelegate<Internal>;
9
10
  //# sourceMappingURL=otlp-browser-http-export-delegate.d.ts.map
@@ -1,15 +1,19 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
1
5
  import { createRetryingTransport } from './retrying-transport';
2
6
  import { createOtlpNetworkExportDelegate } from './otlp-network-export-delegate';
3
7
  import { createFetchTransport } from './transport/fetch-transport';
4
- export function createOtlpFetchExportDelegate(options, serializer) {
5
- return createOtlpNetworkExportDelegate(options, serializer, createRetryingTransport({
8
+ export function createOtlpFetchExportDelegate(options, serializer, metrics) {
9
+ return createOtlpNetworkExportDelegate(options, serializer, metrics, createRetryingTransport({
6
10
  transport: createFetchTransport(options),
7
11
  }));
8
12
  }
9
13
  /**
10
14
  * @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
15
  */
12
- export function createOtlpSendBeaconExportDelegate(options, serializer) {
13
- return createOtlpFetchExportDelegate(options, serializer);
16
+ export function createOtlpSendBeaconExportDelegate(options, serializer, metrics) {
17
+ return createOtlpFetchExportDelegate(options, serializer, metrics);
14
18
  }
15
19
  //# 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":"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 type { OtlpHttpConfiguration } from './configuration/otlp-http-configuration';\nimport type { ISerializer } from '@opentelemetry/otlp-transformer';\nimport type { 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
+ {"version":3,"file":"otlp-browser-http-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-browser-http-export-delegate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,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;AAGnE,MAAM,UAAU,6BAA6B,CAC3C,OAA8B,EAC9B,UAA2C,EAC3C,OAAkC;IAElC,OAAO,+BAA+B,CACpC,OAAO,EACP,UAAU,EACV,OAAO,EACP,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,EAC3C,OAAkC;IAElC,OAAO,6BAA6B,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { OtlpHttpConfiguration } from './configuration/otlp-http-configuration';\nimport type { ISerializer } from '@opentelemetry/otlp-transformer';\nimport type { IOtlpExportDelegate } from './otlp-export-delegate';\nimport { createRetryingTransport } from './retrying-transport';\nimport { createOtlpNetworkExportDelegate } from './otlp-network-export-delegate';\nimport { createFetchTransport } from './transport/fetch-transport';\nimport { type ExporterMetrics } from './ExporterMetrics';\n\nexport function createOtlpFetchExportDelegate<Internal, Response>(\n options: OtlpHttpConfiguration,\n serializer: ISerializer<Internal, Response>,\n metrics: ExporterMetrics<Internal>\n): IOtlpExportDelegate<Internal> {\n return createOtlpNetworkExportDelegate(\n options,\n serializer,\n metrics,\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 metrics: ExporterMetrics<Internal>\n): IOtlpExportDelegate<Internal> {\n return createOtlpFetchExportDelegate(options, serializer, metrics);\n}\n"]}
@@ -2,6 +2,7 @@ import type { ExportResult } from '@opentelemetry/core';
2
2
  import type { IExporterTransport } from './exporter-transport';
3
3
  import type { IExportPromiseHandler } from './bounded-queue-export-promise-handler';
4
4
  import type { ISerializer } from '@opentelemetry/otlp-transformer';
5
+ import { type ExporterMetrics } from './ExporterMetrics';
5
6
  /**
6
7
  * Internally shared export logic for OTLP.
7
8
  */
@@ -9,6 +10,7 @@ export interface IOtlpExportDelegate<Internal> {
9
10
  export(internalRepresentation: Internal, resultCallback: (result: ExportResult) => void): void;
10
11
  forceFlush(): Promise<void>;
11
12
  shutdown(): Promise<void>;
13
+ setMetrics(metrics: ExporterMetrics<Internal>): void;
12
14
  }
13
15
  /**
14
16
  * Creates a generic delegate for OTLP exports which only contains parts of the OTLP export that are shared across all
@@ -18,6 +20,7 @@ export declare function createOtlpExportDelegate<Internal, Response>(components:
18
20
  transport: IExporterTransport;
19
21
  serializer: ISerializer<Internal, Response>;
20
22
  promiseHandler: IExportPromiseHandler;
23
+ metrics: ExporterMetrics<Internal>;
21
24
  }, settings: {
22
25
  timeout: number;
23
26
  }): IOtlpExportDelegate<Internal>;