@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.
- package/README.md +30 -0
- package/build/esm/ExporterMetrics.d.ts +24 -0
- package/build/esm/ExporterMetrics.js +104 -0
- package/build/esm/ExporterMetrics.js.map +1 -0
- package/build/esm/OTLPExporterBase.d.ts +2 -0
- package/build/esm/OTLPExporterBase.js +3 -0
- package/build/esm/OTLPExporterBase.js.map +1 -1
- package/build/esm/configuration/create-legacy-browser-delegate.d.ts +8 -2
- package/build/esm/configuration/create-legacy-browser-delegate.js +36 -2
- package/build/esm/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/build/esm/configuration/legacy-base-configuration.d.ts +26 -8
- package/build/esm/configuration/legacy-base-configuration.js.map +1 -1
- package/build/esm/configuration/legacy-node-configuration.d.ts +18 -4
- package/build/esm/configuration/legacy-node-configuration.js.map +1 -1
- package/build/esm/index-browser-http.d.ts +1 -1
- package/build/esm/index-browser-http.js +1 -1
- package/build/esm/index-browser-http.js.map +1 -1
- package/build/esm/index-node-http.d.ts +1 -1
- package/build/esm/index-node-http.js +1 -1
- package/build/esm/index-node-http.js.map +1 -1
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/otlp-browser-http-export-delegate.d.ts +3 -2
- package/build/esm/otlp-browser-http-export-delegate.js +8 -4
- package/build/esm/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/esm/otlp-export-delegate.d.ts +3 -0
- package/build/esm/otlp-export-delegate.js +19 -6
- package/build/esm/otlp-export-delegate.js.map +1 -1
- package/build/esm/otlp-http-export-delegate.d.ts +5 -2
- package/build/esm/otlp-http-export-delegate.js +30 -1
- package/build/esm/otlp-http-export-delegate.js.map +1 -1
- package/build/esm/otlp-network-export-delegate.d.ts +2 -1
- package/build/esm/otlp-network-export-delegate.js +2 -1
- package/build/esm/otlp-network-export-delegate.js.map +1 -1
- package/build/esm/semconv.d.ts +91 -0
- package/build/esm/semconv.js +100 -0
- package/build/esm/semconv.js.map +1 -0
- 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/ExporterMetrics.d.ts +24 -0
- package/build/esnext/ExporterMetrics.js +104 -0
- package/build/esnext/ExporterMetrics.js.map +1 -0
- package/build/esnext/OTLPExporterBase.d.ts +2 -0
- package/build/esnext/OTLPExporterBase.js +3 -0
- package/build/esnext/OTLPExporterBase.js.map +1 -1
- package/build/esnext/configuration/create-legacy-browser-delegate.d.ts +8 -2
- package/build/esnext/configuration/create-legacy-browser-delegate.js +36 -2
- package/build/esnext/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/build/esnext/configuration/legacy-base-configuration.d.ts +26 -8
- package/build/esnext/configuration/legacy-base-configuration.js.map +1 -1
- package/build/esnext/configuration/legacy-node-configuration.d.ts +18 -4
- package/build/esnext/configuration/legacy-node-configuration.js.map +1 -1
- package/build/esnext/index-browser-http.d.ts +1 -1
- package/build/esnext/index-browser-http.js +1 -1
- package/build/esnext/index-browser-http.js.map +1 -1
- package/build/esnext/index-node-http.d.ts +1 -1
- package/build/esnext/index-node-http.js +1 -1
- package/build/esnext/index-node-http.js.map +1 -1
- package/build/esnext/index.d.ts +1 -0
- package/build/esnext/index.js +1 -0
- package/build/esnext/index.js.map +1 -1
- package/build/esnext/otlp-browser-http-export-delegate.d.ts +3 -2
- package/build/esnext/otlp-browser-http-export-delegate.js +8 -4
- package/build/esnext/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/esnext/otlp-export-delegate.d.ts +3 -0
- package/build/esnext/otlp-export-delegate.js +19 -6
- package/build/esnext/otlp-export-delegate.js.map +1 -1
- package/build/esnext/otlp-http-export-delegate.d.ts +5 -2
- package/build/esnext/otlp-http-export-delegate.js +30 -1
- package/build/esnext/otlp-http-export-delegate.js.map +1 -1
- package/build/esnext/otlp-network-export-delegate.d.ts +2 -1
- package/build/esnext/otlp-network-export-delegate.js +2 -1
- package/build/esnext/otlp-network-export-delegate.js.map +1 -1
- package/build/esnext/semconv.d.ts +91 -0
- package/build/esnext/semconv.js +100 -0
- package/build/esnext/semconv.js.map +1 -0
- 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/ExporterMetrics.d.ts +24 -0
- package/build/src/ExporterMetrics.js +108 -0
- package/build/src/ExporterMetrics.js.map +1 -0
- package/build/src/OTLPExporterBase.d.ts +2 -0
- package/build/src/OTLPExporterBase.js +3 -0
- package/build/src/OTLPExporterBase.js.map +1 -1
- package/build/src/configuration/create-legacy-browser-delegate.d.ts +8 -2
- package/build/src/configuration/create-legacy-browser-delegate.js +38 -3
- package/build/src/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/build/src/configuration/legacy-base-configuration.d.ts +26 -8
- package/build/src/configuration/legacy-base-configuration.js.map +1 -1
- package/build/src/configuration/legacy-node-configuration.d.ts +18 -4
- package/build/src/configuration/legacy-node-configuration.js +1 -1
- package/build/src/configuration/legacy-node-configuration.js.map +1 -1
- package/build/src/index-browser-http.d.ts +1 -1
- package/build/src/index-browser-http.js +2 -1
- package/build/src/index-browser-http.js.map +1 -1
- package/build/src/index-node-http.d.ts +1 -1
- package/build/src/index-node-http.js +2 -1
- package/build/src/index-node-http.js.map +1 -1
- package/build/src/index.d.ts +1 -0
- package/build/src/index.js +3 -1
- package/build/src/index.js.map +1 -1
- package/build/src/otlp-browser-http-export-delegate.d.ts +3 -2
- package/build/src/otlp-browser-http-export-delegate.js +8 -4
- package/build/src/otlp-browser-http-export-delegate.js.map +1 -1
- package/build/src/otlp-export-delegate.d.ts +3 -0
- package/build/src/otlp-export-delegate.js +19 -6
- package/build/src/otlp-export-delegate.js.map +1 -1
- package/build/src/otlp-http-export-delegate.d.ts +5 -2
- package/build/src/otlp-http-export-delegate.js +32 -2
- package/build/src/otlp-http-export-delegate.js.map +1 -1
- package/build/src/otlp-network-export-delegate.d.ts +2 -1
- package/build/src/otlp-network-export-delegate.js +2 -1
- package/build/src/otlp-network-export-delegate.js.map +1 -1
- package/build/src/semconv.d.ts +91 -0
- package/build/src/semconv.js +103 -0
- package/build/src/semconv.js.map +1 -0
- 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 +9 -9
|
@@ -7,13 +7,14 @@ import { OTLPExporterError } from './types';
|
|
|
7
7
|
import { createLoggingPartialSuccessResponseHandler } from './logging-response-handler';
|
|
8
8
|
import { diag } from '@opentelemetry/api';
|
|
9
9
|
class OTLPExportDelegate {
|
|
10
|
+
_metrics;
|
|
10
11
|
_diagLogger;
|
|
11
12
|
_transport;
|
|
12
13
|
_serializer;
|
|
13
14
|
_responseHandler;
|
|
14
15
|
_promiseQueue;
|
|
15
16
|
_timeout;
|
|
16
|
-
constructor(transport, serializer, responseHandler, promiseQueue, timeout) {
|
|
17
|
+
constructor(transport, serializer, responseHandler, promiseQueue, metrics, timeout) {
|
|
17
18
|
this._transport = transport;
|
|
18
19
|
this._serializer = serializer;
|
|
19
20
|
this._responseHandler = responseHandler;
|
|
@@ -22,6 +23,7 @@ class OTLPExportDelegate {
|
|
|
22
23
|
this._diagLogger = diag.createComponentLogger({
|
|
23
24
|
namespace: 'OTLPExportDelegate',
|
|
24
25
|
});
|
|
26
|
+
this._metrics = metrics;
|
|
25
27
|
}
|
|
26
28
|
export(internalRepresentation, resultCallback) {
|
|
27
29
|
this._diagLogger.debug('items to be sent', internalRepresentation);
|
|
@@ -41,8 +43,10 @@ class OTLPExportDelegate {
|
|
|
41
43
|
});
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
46
|
+
const finishExport = this._metrics.startExport(internalRepresentation);
|
|
44
47
|
this._promiseQueue.pushPromise(this._transport.send(serializedRequest, this._timeout).then(response => {
|
|
45
48
|
if (response.status === 'success') {
|
|
49
|
+
finishExport(undefined);
|
|
46
50
|
if (response.data != null) {
|
|
47
51
|
try {
|
|
48
52
|
this._responseHandler.handleResponse(this._serializer.deserializeResponse(response.data));
|
|
@@ -58,6 +62,7 @@ class OTLPExportDelegate {
|
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
60
64
|
else if (response.status === 'failure' && response.error) {
|
|
65
|
+
finishExport(response.error);
|
|
61
66
|
resultCallback({
|
|
62
67
|
code: ExportResultCode.FAILED,
|
|
63
68
|
error: response.error,
|
|
@@ -65,6 +70,7 @@ class OTLPExportDelegate {
|
|
|
65
70
|
return;
|
|
66
71
|
}
|
|
67
72
|
else if (response.status === 'retryable') {
|
|
73
|
+
finishExport('export_max_retries');
|
|
68
74
|
resultCallback({
|
|
69
75
|
code: ExportResultCode.FAILED,
|
|
70
76
|
error: response.error ??
|
|
@@ -72,19 +78,26 @@ class OTLPExportDelegate {
|
|
|
72
78
|
});
|
|
73
79
|
}
|
|
74
80
|
else {
|
|
81
|
+
finishExport('export_failed');
|
|
75
82
|
resultCallback({
|
|
76
83
|
code: ExportResultCode.FAILED,
|
|
77
84
|
error: new OTLPExporterError('Export failed with unknown error'),
|
|
78
85
|
});
|
|
79
86
|
}
|
|
80
|
-
}, reason =>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
}, reason => {
|
|
88
|
+
finishExport(reason);
|
|
89
|
+
resultCallback({
|
|
90
|
+
code: ExportResultCode.FAILED,
|
|
91
|
+
error: reason,
|
|
92
|
+
});
|
|
93
|
+
}));
|
|
84
94
|
}
|
|
85
95
|
forceFlush() {
|
|
86
96
|
return this._promiseQueue.awaitAll();
|
|
87
97
|
}
|
|
98
|
+
setMetrics(metrics) {
|
|
99
|
+
this._metrics = metrics;
|
|
100
|
+
}
|
|
88
101
|
async shutdown() {
|
|
89
102
|
this._diagLogger.debug('shutdown started');
|
|
90
103
|
await this.forceFlush();
|
|
@@ -96,6 +109,6 @@ class OTLPExportDelegate {
|
|
|
96
109
|
* signals.
|
|
97
110
|
*/
|
|
98
111
|
export function createOtlpExportDelegate(components, settings) {
|
|
99
|
-
return new OTLPExportDelegate(components.transport, components.serializer, createLoggingPartialSuccessResponseHandler(), components.promiseHandler, settings.timeout);
|
|
112
|
+
return new OTLPExportDelegate(components.transport, components.serializer, createLoggingPartialSuccessResponseHandler(), components.promiseHandler, components.metrics, settings.timeout);
|
|
100
113
|
}
|
|
101
114
|
//# sourceMappingURL=otlp-export-delegate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-export-delegate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,0CAA0C,EAAE,MAAM,4BAA4B,CAAC;AAExF,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"otlp-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-export-delegate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,0CAA0C,EAAE,MAAM,4BAA4B,CAAC;AAExF,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAgB1C,MAAM,kBAAkB;IAGd,QAAQ,CAA4B;IACpC,WAAW,CAAa;IACxB,UAAU,CAAqB;IAC/B,WAAW,CAAkC;IAC7C,gBAAgB,CAAiC;IACjD,aAAa,CAAwB;IACrC,QAAQ,CAAS;IAEzB,YACE,SAA6B,EAC7B,UAA2C,EAC3C,eAA+C,EAC/C,YAAmC,EACnC,OAAkC,EAClC,OAAe;QAEf,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,WAAW,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,gBAAgB,CAAC,MAAM;gBAC7B,KAAK,EAAE,MAAM;aACd,CAAC,CAAC;QACL,CAAC,CACF,CACF,CAAC;IACJ,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;IACvC,CAAC;IAED,UAAU,CAAC,OAAkC;QAC3C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC3C,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,UAKC,EACD,QAA6B;IAE7B,OAAO,IAAI,kBAAkB,CAC3B,UAAU,CAAC,SAAS,EACpB,UAAU,CAAC,UAAU,EACrB,0CAA0C,EAAE,EAC5C,UAAU,CAAC,cAAc,EACzB,UAAU,CAAC,OAAO,EAClB,QAAQ,CAAC,OAAO,CACjB,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ExportResult } from '@opentelemetry/core';\nimport { ExportResultCode } from '@opentelemetry/core';\nimport type { IExporterTransport } from './exporter-transport';\nimport type { IExportPromiseHandler } from './bounded-queue-export-promise-handler';\nimport type { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { OTLPExporterError } from './types';\nimport type { IOtlpResponseHandler } from './response-handler';\nimport { createLoggingPartialSuccessResponseHandler } from './logging-response-handler';\nimport type { DiagLogger } from '@opentelemetry/api';\nimport { diag } from '@opentelemetry/api';\nimport { type ExporterMetrics } from './ExporterMetrics';\n\n/**\n * Internally shared export logic for OTLP.\n */\nexport interface IOtlpExportDelegate<Internal> {\n export(\n internalRepresentation: Internal,\n resultCallback: (result: ExportResult) => void\n ): void;\n forceFlush(): Promise<void>;\n shutdown(): Promise<void>;\n setMetrics(metrics: ExporterMetrics<Internal>): void;\n}\n\nclass OTLPExportDelegate<Internal, Response>\n implements IOtlpExportDelegate<Internal>\n{\n private _metrics: ExporterMetrics<Internal>;\n private _diagLogger: DiagLogger;\n private _transport: IExporterTransport;\n private _serializer: ISerializer<Internal, Response>;\n private _responseHandler: IOtlpResponseHandler<Response>;\n private _promiseQueue: IExportPromiseHandler;\n private _timeout: number;\n\n constructor(\n transport: IExporterTransport,\n serializer: ISerializer<Internal, Response>,\n responseHandler: IOtlpResponseHandler<Response>,\n promiseQueue: IExportPromiseHandler,\n metrics: ExporterMetrics<Internal>,\n timeout: number\n ) {\n this._transport = transport;\n this._serializer = serializer;\n this._responseHandler = responseHandler;\n this._promiseQueue = promiseQueue;\n this._timeout = timeout;\n this._diagLogger = diag.createComponentLogger({\n namespace: 'OTLPExportDelegate',\n });\n this._metrics = metrics;\n }\n\n export(\n internalRepresentation: Internal,\n resultCallback: (result: ExportResult) => void\n ): void {\n this._diagLogger.debug('items to be sent', internalRepresentation);\n\n // don't do any work if too many exports are in progress.\n if (this._promiseQueue.hasReachedLimit()) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Concurrent export limit reached'),\n });\n return;\n }\n\n const serializedRequest = this._serializer.serializeRequest(\n internalRepresentation\n );\n\n if (serializedRequest == null) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Nothing to send'),\n });\n return;\n }\n\n const finishExport = this._metrics.startExport(internalRepresentation);\n this._promiseQueue.pushPromise(\n this._transport.send(serializedRequest, this._timeout).then(\n response => {\n if (response.status === 'success') {\n finishExport(undefined);\n if (response.data != null) {\n try {\n this._responseHandler.handleResponse(\n this._serializer.deserializeResponse(response.data)\n );\n } catch (e) {\n this._diagLogger.warn(\n 'Export succeeded but could not deserialize response - is the response specification compliant?',\n e,\n response.data\n );\n }\n }\n // No matter the response, we can consider the export still successful.\n resultCallback({\n code: ExportResultCode.SUCCESS,\n });\n return;\n } else if (response.status === 'failure' && response.error) {\n finishExport(response.error);\n resultCallback({\n code: ExportResultCode.FAILED,\n error: response.error,\n });\n return;\n } else if (response.status === 'retryable') {\n finishExport('export_max_retries');\n resultCallback({\n code: ExportResultCode.FAILED,\n error:\n response.error ??\n new OTLPExporterError('Export failed with retryable status'),\n });\n } else {\n finishExport('export_failed');\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new OTLPExporterError('Export failed with unknown error'),\n });\n }\n },\n reason => {\n finishExport(reason);\n resultCallback({\n code: ExportResultCode.FAILED,\n error: reason,\n });\n }\n )\n );\n }\n\n forceFlush(): Promise<void> {\n return this._promiseQueue.awaitAll();\n }\n\n setMetrics(metrics: ExporterMetrics<Internal>) {\n this._metrics = metrics;\n }\n\n async shutdown(): Promise<void> {\n this._diagLogger.debug('shutdown started');\n await this.forceFlush();\n this._transport.shutdown();\n }\n}\n\n/**\n * Creates a generic delegate for OTLP exports which only contains parts of the OTLP export that are shared across all\n * signals.\n */\nexport function createOtlpExportDelegate<Internal, Response>(\n components: {\n transport: IExporterTransport;\n serializer: ISerializer<Internal, Response>;\n promiseHandler: IExportPromiseHandler;\n metrics: ExporterMetrics<Internal>;\n },\n settings: { timeout: number }\n): IOtlpExportDelegate<Internal> {\n return new OTLPExportDelegate(\n components.transport,\n components.serializer,\n createLoggingPartialSuccessResponseHandler(),\n components.promiseHandler,\n components.metrics,\n settings.timeout\n );\n}\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { MeterProvider } from '@opentelemetry/api';
|
|
1
2
|
import type { IOtlpExportDelegate } from './otlp-export-delegate';
|
|
2
|
-
import type { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
3
|
+
import type { IExporterMetricsHelper, ISerializer } from '@opentelemetry/otlp-transformer';
|
|
3
4
|
import type { OtlpNodeHttpConfiguration } from './configuration/otlp-node-http-configuration';
|
|
4
|
-
|
|
5
|
+
import { ExporterMetrics } from './ExporterMetrics';
|
|
6
|
+
export declare function createOtlpHttpExporterMetrics<Internal>(metricsComponentType: string, exporterMetricsHelper: IExporterMetricsHelper<Internal>, url: string | undefined, meterProvider: MeterProvider | undefined): ExporterMetrics<Internal>;
|
|
7
|
+
export declare function createOtlpHttpExportDelegate<Internal, Response>(options: OtlpNodeHttpConfiguration, serializer: ISerializer<Internal, Response>, metricsComponentType: string, exporterMetricsHelper: IExporterMetricsHelper<Internal>, meterProvider: MeterProvider | undefined): IOtlpExportDelegate<Internal>;
|
|
5
8
|
//# sourceMappingURL=otlp-http-export-delegate.d.ts.map
|
|
@@ -1,14 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright The OpenTelemetry Authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
1
5
|
import { createOtlpExportDelegate } from './otlp-export-delegate';
|
|
2
6
|
import { createHttpExporterTransport } from './transport/http-exporter-transport';
|
|
3
7
|
import { createBoundedQueueExportPromiseHandler } from './bounded-queue-export-promise-handler';
|
|
4
8
|
import { createRetryingTransport } from './retrying-transport';
|
|
5
|
-
|
|
9
|
+
import { OTLPExporterError } from './types';
|
|
10
|
+
import { ATTR_HTTP_RESPONSE_STATUS_CODE } from './semconv';
|
|
11
|
+
import { ExporterMetrics } from './ExporterMetrics';
|
|
12
|
+
export function createOtlpHttpExporterMetrics(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 OTLPExporterError)) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
[ATTR_HTTP_RESPONSE_STATUS_CODE]: error.code,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function createOtlpHttpExportDelegate(options, serializer, metricsComponentType, exporterMetricsHelper, meterProvider) {
|
|
6
34
|
return createOtlpExportDelegate({
|
|
7
35
|
transport: createRetryingTransport({
|
|
8
36
|
transport: createHttpExporterTransport(options),
|
|
9
37
|
}),
|
|
10
38
|
serializer: serializer,
|
|
11
39
|
promiseHandler: createBoundedQueueExportPromiseHandler(options),
|
|
40
|
+
metrics: createOtlpHttpExporterMetrics(metricsComponentType, exporterMetricsHelper, options.url, meterProvider),
|
|
12
41
|
}, { timeout: options.timeoutMillis });
|
|
13
42
|
}
|
|
14
43
|
//# sourceMappingURL=otlp-http-export-delegate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-http-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-http-export-delegate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"otlp-http-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-http-export-delegate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAKlE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,sCAAsC,EAAE,MAAM,wCAAwC,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,UAAU,6BAA6B,CAC3C,oBAA4B,EAC5B,qBAAuD,EACvD,GAAuB,EACvB,aAAwC;IAExC,OAAO,IAAI,eAAe,CAAC;QACzB,aAAa,EAAE,oBAAoB;QACnC,aAAa,EAAE,qBAAqB;QACpC,GAAG;QACH,aAAa;QACb,2BAA2B,EAAE,CAAC,KAAiC,EAAE,EAAE;YACjE,IAAI,CAAC,KAAK,EAAE;gBACV,OAAO;oBACL,CAAC,8BAA8B,CAAC,EAAE,GAAG;iBACtC,CAAC;aACH;YACD,IAAI,CAAC,CAAC,KAAK,YAAY,iBAAiB,CAAC,EAAE;gBACzC,OAAO,EAAE,CAAC;aACX;YACD,OAAO;gBACL,CAAC,8BAA8B,CAAC,EAAE,KAAK,CAAC,IAAI;aAC7C,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,OAAkC,EAClC,UAA2C,EAC3C,oBAA4B,EAC5B,qBAAuD,EACvD,aAAwC;IAExC,OAAO,wBAAwB,CAC7B;QACE,SAAS,EAAE,uBAAuB,CAAC;YACjC,SAAS,EAAE,2BAA2B,CAAC,OAAO,CAAC;SAChD,CAAC;QACF,UAAU,EAAE,UAAU;QACtB,cAAc,EAAE,sCAAsC,CAAC,OAAO,CAAC;QAC/D,OAAO,EAAE,6BAA6B,CACpC,oBAAoB,EACpB,qBAAqB,EACrB,OAAO,CAAC,GAAG,EACX,aAAa,CACd;KACF,EACD,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE,CACnC,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { MeterProvider } from '@opentelemetry/api';\n\nimport type { IOtlpExportDelegate } from './otlp-export-delegate';\nimport { createOtlpExportDelegate } from './otlp-export-delegate';\nimport type {\n IExporterMetricsHelper,\n ISerializer,\n} from '@opentelemetry/otlp-transformer';\nimport { createHttpExporterTransport } from './transport/http-exporter-transport';\nimport { createBoundedQueueExportPromiseHandler } from './bounded-queue-export-promise-handler';\nimport { createRetryingTransport } from './retrying-transport';\nimport type { OtlpNodeHttpConfiguration } from './configuration/otlp-node-http-configuration';\nimport { OTLPExporterError } from './types';\nimport { ATTR_HTTP_RESPONSE_STATUS_CODE } from './semconv';\nimport { ExporterMetrics } from './ExporterMetrics';\n\nexport function createOtlpHttpExporterMetrics<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 OTLPExporterError)) {\n return {};\n }\n return {\n [ATTR_HTTP_RESPONSE_STATUS_CODE]: error.code,\n };\n },\n });\n}\n\nexport function createOtlpHttpExportDelegate<Internal, Response>(\n options: OtlpNodeHttpConfiguration,\n serializer: ISerializer<Internal, Response>,\n metricsComponentType: string,\n exporterMetricsHelper: IExporterMetricsHelper<Internal>,\n meterProvider: MeterProvider | undefined\n): IOtlpExportDelegate<Internal> {\n return createOtlpExportDelegate(\n {\n transport: createRetryingTransport({\n transport: createHttpExporterTransport(options),\n }),\n serializer: serializer,\n promiseHandler: createBoundedQueueExportPromiseHandler(options),\n metrics: createOtlpHttpExporterMetrics(\n metricsComponentType,\n exporterMetricsHelper,\n options.url,\n meterProvider\n ),\n },\n { timeout: options.timeoutMillis }\n );\n}\n"]}
|
|
@@ -2,5 +2,6 @@ import type { OtlpSharedConfiguration } from './configuration/shared-configurati
|
|
|
2
2
|
import type { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
3
3
|
import type { IExporterTransport } from './exporter-transport';
|
|
4
4
|
import type { IOtlpExportDelegate } from './otlp-export-delegate';
|
|
5
|
-
|
|
5
|
+
import { type ExporterMetrics } from './ExporterMetrics';
|
|
6
|
+
export declare function createOtlpNetworkExportDelegate<Internal, Response>(options: OtlpSharedConfiguration, serializer: ISerializer<Internal, Response>, metrics: ExporterMetrics<Internal>, transport: IExporterTransport): IOtlpExportDelegate<Internal>;
|
|
6
7
|
//# sourceMappingURL=otlp-network-export-delegate.d.ts.map
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { createBoundedQueueExportPromiseHandler } from './bounded-queue-export-promise-handler';
|
|
6
6
|
import { createOtlpExportDelegate } from './otlp-export-delegate';
|
|
7
|
-
export function createOtlpNetworkExportDelegate(options, serializer, transport) {
|
|
7
|
+
export function createOtlpNetworkExportDelegate(options, serializer, metrics, transport) {
|
|
8
8
|
return createOtlpExportDelegate({
|
|
9
9
|
transport: transport,
|
|
10
10
|
serializer,
|
|
11
11
|
promiseHandler: createBoundedQueueExportPromiseHandler(options),
|
|
12
|
+
metrics,
|
|
12
13
|
}, { timeout: options.timeoutMillis });
|
|
13
14
|
}
|
|
14
15
|
//# sourceMappingURL=otlp-network-export-delegate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-network-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-network-export-delegate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sCAAsC,EAAE,MAAM,wCAAwC,CAAC;AAKhG,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"otlp-network-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-network-export-delegate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sCAAsC,EAAE,MAAM,wCAAwC,CAAC;AAKhG,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE,MAAM,UAAU,+BAA+B,CAC7C,OAAgC,EAChC,UAA2C,EAC3C,OAAkC,EAClC,SAA6B;IAE7B,OAAO,wBAAwB,CAC7B;QACE,SAAS,EAAE,SAAS;QACpB,UAAU;QACV,cAAc,EAAE,sCAAsC,CAAC,OAAO,CAAC;QAC/D,OAAO;KACR,EACD,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE,CACnC,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { createBoundedQueueExportPromiseHandler } from './bounded-queue-export-promise-handler';\nimport type { OtlpSharedConfiguration } from './configuration/shared-configuration';\nimport type { ISerializer } from '@opentelemetry/otlp-transformer';\nimport type { IExporterTransport } from './exporter-transport';\nimport type { IOtlpExportDelegate } from './otlp-export-delegate';\nimport { createOtlpExportDelegate } from './otlp-export-delegate';\nimport { type ExporterMetrics } from './ExporterMetrics';\n\nexport function createOtlpNetworkExportDelegate<Internal, Response>(\n options: OtlpSharedConfiguration,\n serializer: ISerializer<Internal, Response>,\n metrics: ExporterMetrics<Internal>,\n transport: IExporterTransport\n): IOtlpExportDelegate<Internal> {\n return createOtlpExportDelegate(\n {\n transport: transport,\n serializer,\n promiseHandler: createBoundedQueueExportPromiseHandler(options),\n metrics,\n },\n { timeout: options.timeoutMillis }\n );\n}\n"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).
|
|
3
|
+
*
|
|
4
|
+
* @example 200
|
|
5
|
+
*/
|
|
6
|
+
export declare const ATTR_HTTP_RESPONSE_STATUS_CODE: "http.response.status_code";
|
|
7
|
+
/**
|
|
8
|
+
* A name uniquely identifying the instance of the OpenTelemetry component within its containing SDK instance.
|
|
9
|
+
*
|
|
10
|
+
* @example otlp_grpc_span_exporter/0
|
|
11
|
+
* @example custom-name
|
|
12
|
+
*
|
|
13
|
+
* @note Implementations **SHOULD** ensure a low cardinality for this attribute, even across application or SDK restarts.
|
|
14
|
+
* E.g. implementations **MUST NOT** use UUIDs as values for this attribute.
|
|
15
|
+
*
|
|
16
|
+
* Implementations **MAY** achieve these goals by following a `<otel.component.type>/<instance-counter>` pattern, e.g. `batching_span_processor/0`.
|
|
17
|
+
* Hereby `otel.component.type` refers to the corresponding attribute value of the component.
|
|
18
|
+
*
|
|
19
|
+
* The value of `instance-counter` **MAY** be automatically assigned by the component and uniqueness within the enclosing SDK instance **MUST** be guaranteed.
|
|
20
|
+
* For example, `<instance-counter>` **MAY** be implemented by using a monotonically increasing counter (starting with `0`), which is incremented every time an
|
|
21
|
+
* instance of the given component type is started.
|
|
22
|
+
*
|
|
23
|
+
* With this implementation, for example the first Batching Span Processor would have `batching_span_processor/0`
|
|
24
|
+
* as `otel.component.name`, the second one `batching_span_processor/1` and so on.
|
|
25
|
+
* These values will therefore be reused in the case of an application restart.
|
|
26
|
+
*
|
|
27
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const ATTR_OTEL_COMPONENT_NAME: "otel.component.name";
|
|
30
|
+
/**
|
|
31
|
+
* A name identifying the type of the OpenTelemetry component.
|
|
32
|
+
*
|
|
33
|
+
* @example batching_span_processor
|
|
34
|
+
* @example com.example.MySpanExporter
|
|
35
|
+
*
|
|
36
|
+
* @note If none of the standardized values apply, implementations **SHOULD** use the language-defined name of the type.
|
|
37
|
+
* E.g. for Java the fully qualified classname **SHOULD** be used in this case.
|
|
38
|
+
*
|
|
39
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
40
|
+
*/
|
|
41
|
+
export declare const ATTR_OTEL_COMPONENT_TYPE: "otel.component.type";
|
|
42
|
+
/**
|
|
43
|
+
* Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name.
|
|
44
|
+
*
|
|
45
|
+
* @example example.com
|
|
46
|
+
* @example 10.1.2.80
|
|
47
|
+
* @example /tmp/my.sock
|
|
48
|
+
*
|
|
49
|
+
* @note When observed from the client side, and when communicating through an intermediary, `server.address` **SHOULD** represent the server address behind any intermediaries, for example proxies, if it's available.
|
|
50
|
+
*/
|
|
51
|
+
export declare const ATTR_SERVER_ADDRESS: "server.address";
|
|
52
|
+
/**
|
|
53
|
+
* Server port number.
|
|
54
|
+
*
|
|
55
|
+
* @example 80
|
|
56
|
+
* @example 8080
|
|
57
|
+
* @example 443
|
|
58
|
+
*
|
|
59
|
+
* @note When observed from the client side, and when communicating through an intermediary, `server.port` **SHOULD** represent the server port behind any intermediaries, for example proxies, if it's available.
|
|
60
|
+
*/
|
|
61
|
+
export declare const ATTR_SERVER_PORT: "server.port";
|
|
62
|
+
/**
|
|
63
|
+
* Describes a class of error the operation ended with.
|
|
64
|
+
*
|
|
65
|
+
* @example timeout
|
|
66
|
+
* @example java.net.UnknownHostException
|
|
67
|
+
* @example server_certificate_invalid
|
|
68
|
+
* @example 500
|
|
69
|
+
*
|
|
70
|
+
* @note The `error.type` **SHOULD** be predictable, and **SHOULD** have low cardinality.
|
|
71
|
+
*
|
|
72
|
+
* When `error.type` is set to a type (e.g., an exception type), its
|
|
73
|
+
* canonical class name identifying the type within the artifact **SHOULD** be used.
|
|
74
|
+
*
|
|
75
|
+
* Instrumentations **SHOULD** document the list of errors they report.
|
|
76
|
+
*
|
|
77
|
+
* The cardinality of `error.type` within one instrumentation library **SHOULD** be low.
|
|
78
|
+
* Telemetry consumers that aggregate data from multiple instrumentation libraries and applications
|
|
79
|
+
* should be prepared for `error.type` to have high cardinality at query time when no
|
|
80
|
+
* additional filters are applied.
|
|
81
|
+
*
|
|
82
|
+
* If the operation has completed successfully, instrumentations **SHOULD NOT** set `error.type`.
|
|
83
|
+
*
|
|
84
|
+
* If a specific domain defines its own set of error identifiers (such as HTTP or RPC status codes),
|
|
85
|
+
* it's **RECOMMENDED** to:
|
|
86
|
+
*
|
|
87
|
+
* - Use a domain-specific attribute
|
|
88
|
+
* - Set `error.type` to capture all errors, regardless of whether they are defined within the domain-specific set or not.
|
|
89
|
+
*/
|
|
90
|
+
export declare const ATTR_ERROR_TYPE: "error.type";
|
|
91
|
+
//# sourceMappingURL=semconv.d.ts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright The OpenTelemetry Authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
* This file contains a copy of unstable semantic convention definitions
|
|
7
|
+
* used by this package.
|
|
8
|
+
* @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).
|
|
12
|
+
*
|
|
13
|
+
* @example 200
|
|
14
|
+
*/
|
|
15
|
+
export const ATTR_HTTP_RESPONSE_STATUS_CODE = 'http.response.status_code';
|
|
16
|
+
/**
|
|
17
|
+
* A name uniquely identifying the instance of the OpenTelemetry component within its containing SDK instance.
|
|
18
|
+
*
|
|
19
|
+
* @example otlp_grpc_span_exporter/0
|
|
20
|
+
* @example custom-name
|
|
21
|
+
*
|
|
22
|
+
* @note Implementations **SHOULD** ensure a low cardinality for this attribute, even across application or SDK restarts.
|
|
23
|
+
* E.g. implementations **MUST NOT** use UUIDs as values for this attribute.
|
|
24
|
+
*
|
|
25
|
+
* Implementations **MAY** achieve these goals by following a `<otel.component.type>/<instance-counter>` pattern, e.g. `batching_span_processor/0`.
|
|
26
|
+
* Hereby `otel.component.type` refers to the corresponding attribute value of the component.
|
|
27
|
+
*
|
|
28
|
+
* The value of `instance-counter` **MAY** be automatically assigned by the component and uniqueness within the enclosing SDK instance **MUST** be guaranteed.
|
|
29
|
+
* For example, `<instance-counter>` **MAY** be implemented by using a monotonically increasing counter (starting with `0`), which is incremented every time an
|
|
30
|
+
* instance of the given component type is started.
|
|
31
|
+
*
|
|
32
|
+
* With this implementation, for example the first Batching Span Processor would have `batching_span_processor/0`
|
|
33
|
+
* as `otel.component.name`, the second one `batching_span_processor/1` and so on.
|
|
34
|
+
* These values will therefore be reused in the case of an application restart.
|
|
35
|
+
*
|
|
36
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
37
|
+
*/
|
|
38
|
+
export const ATTR_OTEL_COMPONENT_NAME = 'otel.component.name';
|
|
39
|
+
/**
|
|
40
|
+
* A name identifying the type of the OpenTelemetry component.
|
|
41
|
+
*
|
|
42
|
+
* @example batching_span_processor
|
|
43
|
+
* @example com.example.MySpanExporter
|
|
44
|
+
*
|
|
45
|
+
* @note If none of the standardized values apply, implementations **SHOULD** use the language-defined name of the type.
|
|
46
|
+
* E.g. for Java the fully qualified classname **SHOULD** be used in this case.
|
|
47
|
+
*
|
|
48
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
49
|
+
*/
|
|
50
|
+
export const ATTR_OTEL_COMPONENT_TYPE = 'otel.component.type';
|
|
51
|
+
/**
|
|
52
|
+
* Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name.
|
|
53
|
+
*
|
|
54
|
+
* @example example.com
|
|
55
|
+
* @example 10.1.2.80
|
|
56
|
+
* @example /tmp/my.sock
|
|
57
|
+
*
|
|
58
|
+
* @note When observed from the client side, and when communicating through an intermediary, `server.address` **SHOULD** represent the server address behind any intermediaries, for example proxies, if it's available.
|
|
59
|
+
*/
|
|
60
|
+
export const ATTR_SERVER_ADDRESS = 'server.address';
|
|
61
|
+
/**
|
|
62
|
+
* Server port number.
|
|
63
|
+
*
|
|
64
|
+
* @example 80
|
|
65
|
+
* @example 8080
|
|
66
|
+
* @example 443
|
|
67
|
+
*
|
|
68
|
+
* @note When observed from the client side, and when communicating through an intermediary, `server.port` **SHOULD** represent the server port behind any intermediaries, for example proxies, if it's available.
|
|
69
|
+
*/
|
|
70
|
+
export const ATTR_SERVER_PORT = 'server.port';
|
|
71
|
+
/**
|
|
72
|
+
* Describes a class of error the operation ended with.
|
|
73
|
+
*
|
|
74
|
+
* @example timeout
|
|
75
|
+
* @example java.net.UnknownHostException
|
|
76
|
+
* @example server_certificate_invalid
|
|
77
|
+
* @example 500
|
|
78
|
+
*
|
|
79
|
+
* @note The `error.type` **SHOULD** be predictable, and **SHOULD** have low cardinality.
|
|
80
|
+
*
|
|
81
|
+
* When `error.type` is set to a type (e.g., an exception type), its
|
|
82
|
+
* canonical class name identifying the type within the artifact **SHOULD** be used.
|
|
83
|
+
*
|
|
84
|
+
* Instrumentations **SHOULD** document the list of errors they report.
|
|
85
|
+
*
|
|
86
|
+
* The cardinality of `error.type` within one instrumentation library **SHOULD** be low.
|
|
87
|
+
* Telemetry consumers that aggregate data from multiple instrumentation libraries and applications
|
|
88
|
+
* should be prepared for `error.type` to have high cardinality at query time when no
|
|
89
|
+
* additional filters are applied.
|
|
90
|
+
*
|
|
91
|
+
* If the operation has completed successfully, instrumentations **SHOULD NOT** set `error.type`.
|
|
92
|
+
*
|
|
93
|
+
* If a specific domain defines its own set of error identifiers (such as HTTP or RPC status codes),
|
|
94
|
+
* it's **RECOMMENDED** to:
|
|
95
|
+
*
|
|
96
|
+
* - Use a domain-specific attribute
|
|
97
|
+
* - Set `error.type` to capture all errors, regardless of whether they are defined within the domain-specific set or not.
|
|
98
|
+
*/
|
|
99
|
+
export const ATTR_ERROR_TYPE = 'error.type';
|
|
100
|
+
//# sourceMappingURL=semconv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GACzC,2BAAoC,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAA8B,CAAC;AAEvE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAA8B,CAAC;AAEvE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAyB,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAsB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,YAAqB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).\n *\n * @example 200\n */\nexport const ATTR_HTTP_RESPONSE_STATUS_CODE =\n 'http.response.status_code' as const;\n\n/**\n * A name uniquely identifying the instance of the OpenTelemetry component within its containing SDK instance.\n *\n * @example otlp_grpc_span_exporter/0\n * @example custom-name\n *\n * @note Implementations **SHOULD** ensure a low cardinality for this attribute, even across application or SDK restarts.\n * E.g. implementations **MUST NOT** use UUIDs as values for this attribute.\n *\n * Implementations **MAY** achieve these goals by following a `<otel.component.type>/<instance-counter>` pattern, e.g. `batching_span_processor/0`.\n * Hereby `otel.component.type` refers to the corresponding attribute value of the component.\n *\n * The value of `instance-counter` **MAY** be automatically assigned by the component and uniqueness within the enclosing SDK instance **MUST** be guaranteed.\n * For example, `<instance-counter>` **MAY** be implemented by using a monotonically increasing counter (starting with `0`), which is incremented every time an\n * instance of the given component type is started.\n *\n * With this implementation, for example the first Batching Span Processor would have `batching_span_processor/0`\n * as `otel.component.name`, the second one `batching_span_processor/1` and so on.\n * These values will therefore be reused in the case of an application restart.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_OTEL_COMPONENT_NAME = 'otel.component.name' as const;\n\n/**\n * A name identifying the type of the OpenTelemetry component.\n *\n * @example batching_span_processor\n * @example com.example.MySpanExporter\n *\n * @note If none of the standardized values apply, implementations **SHOULD** use the language-defined name of the type.\n * E.g. for Java the fully qualified classname **SHOULD** be used in this case.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_OTEL_COMPONENT_TYPE = 'otel.component.type' as const;\n\n/**\n * Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name.\n *\n * @example example.com\n * @example 10.1.2.80\n * @example /tmp/my.sock\n *\n * @note When observed from the client side, and when communicating through an intermediary, `server.address` **SHOULD** represent the server address behind any intermediaries, for example proxies, if it's available.\n */\nexport const ATTR_SERVER_ADDRESS = 'server.address' as const;\n\n/**\n * Server port number.\n *\n * @example 80\n * @example 8080\n * @example 443\n *\n * @note When observed from the client side, and when communicating through an intermediary, `server.port` **SHOULD** represent the server port behind any intermediaries, for example proxies, if it's available.\n */\nexport const ATTR_SERVER_PORT = 'server.port' as const;\n\n/**\n * Describes a class of error the operation ended with.\n *\n * @example timeout\n * @example java.net.UnknownHostException\n * @example server_certificate_invalid\n * @example 500\n *\n * @note The `error.type` **SHOULD** be predictable, and **SHOULD** have low cardinality.\n *\n * When `error.type` is set to a type (e.g., an exception type), its\n * canonical class name identifying the type within the artifact **SHOULD** be used.\n *\n * Instrumentations **SHOULD** document the list of errors they report.\n *\n * The cardinality of `error.type` within one instrumentation library **SHOULD** be low.\n * Telemetry consumers that aggregate data from multiple instrumentation libraries and applications\n * should be prepared for `error.type` to have high cardinality at query time when no\n * additional filters are applied.\n *\n * If the operation has completed successfully, instrumentations **SHOULD NOT** set `error.type`.\n *\n * If a specific domain defines its own set of error identifiers (such as HTTP or RPC status codes),\n * it's **RECOMMENDED** to:\n *\n * - Use a domain-specific attribute\n * - Set `error.type` to capture all errors, regardless of whether they are defined within the domain-specific set or not.\n */\nexport const ATTR_ERROR_TYPE = 'error.type' as const;\n"]}
|
package/build/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.222.0-development.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/esm/version.js
CHANGED
package/build/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,uBAAuB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.222.0-development.0';\n"]}
|
|
@@ -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,EACL,eAAe,EACf,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,W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,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAChD,OAAO,CAAC,KAAiC,EAAE,EAAE;YAC3C,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YACjD,MAAM,aAAa,GAAG,KAAK;gBACzB,CAAC,CAAC;oBACE,GAAG,IAAI,CAAC,aAAa;oBACrB,CAAC,eAAe,CAAC,EACf,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe;iBACxD;gBACH,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC;YACvB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;YAC3C,MAAM,aAAa,GAAG;gBACpB,GAAG,aAAa;gBAChB,GAAG,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC;aAC3C,CAAC;YACF,MAAM,QAAQ,GACZ,oBAAoB,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;YAClE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QAChD,CAAC,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type Attributes,\n type Counter,\n type 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
|