From 1c5de7ac2fde765286f8884bcd97a24eba6e40fa Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Fri, 3 May 2024 18:25:37 +0200 Subject: [PATCH] feat!: use serializers in browser exporters (#4581) * feat!: use serializer in browser exporters * feat!: remove unused convert * fixup! feat!: use serializer in browser exporters * chore: update changleog --- experimental/CHANGELOG.md | 6 + .../src/OTLPLogExporter.ts | 2 - .../src/platform/browser/OTLPLogExporter.ts | 25 +-- .../src/platform/node/OTLPLogExporter.ts | 11 +- .../exporter-logs-otlp-proto/package.json | 1 - .../src/platform/browser/OTLPLogExporter.ts | 23 +- .../src/platform/node/OTLPLogExporter.ts | 12 +- .../test/node/OTLPLogExporter.test.ts | 29 +-- .../tsconfig.esm.json | 3 - .../tsconfig.esnext.json | 3 - .../exporter-logs-otlp-proto/tsconfig.json | 3 - .../src/OTLPTraceExporter.ts | 7 +- .../src/platform/browser/OTLPTraceExporter.ts | 14 +- .../src/platform/node/OTLPTraceExporter.ts | 11 +- .../browser/CollectorTraceExporter.test.ts | 5 +- .../exporter-trace-otlp-proto/package.json | 1 - .../src/platform/browser/OTLPTraceExporter.ts | 20 +- .../src/platform/node/OTLPTraceExporter.ts | 12 +- .../test/node/OTLPTraceExporter.test.ts | 31 +-- .../tsconfig.esm.json | 3 - .../tsconfig.esnext.json | 3 - .../exporter-trace-otlp-proto/tsconfig.json | 3 - .../src/OTLPMetricExporter.ts | 2 - .../src/OTLPMetricExporterBase.ts | 7 +- .../platform/browser/OTLPMetricExporter.ts | 12 +- .../src/platform/node/OTLPMetricExporter.ts | 2 - .../browser/CollectorMetricExporter.test.ts | 5 +- .../common/CollectorMetricExporter.test.ts | 8 +- .../package.json | 1 - .../src/OTLPMetricExporter.ts | 7 - .../test/OTLPMetricExporter.test.ts | 26 ++- .../tsconfig.esm.json | 3 - .../tsconfig.esnext.json | 3 - .../tsconfig.json | 3 - .../src/OTLPExporterBase.ts | 2 - .../browser/OTLPExporterBrowserBase.ts | 27 ++- .../src/platform/browser/util.ts | 4 +- .../src/platform/node/OTLPExporterNodeBase.ts | 12 +- .../src/platform/node/util.ts | 4 +- .../test/browser/util.test.ts | 2 +- .../test/common/CollectorExporter.test.ts | 11 +- .../otlp-exporter-base/test/node/util.test.ts | 2 +- .../src/OTLPGRPCExporterNodeBase.ts | 12 +- .../test/OTLPGRPCExporterNodeBase.test.ts | 1 - .../otlp-proto-exporter-base/.eslintignore | 2 - .../otlp-proto-exporter-base/.eslintrc.js | 8 - .../otlp-proto-exporter-base/.gitignore | 2 - .../otlp-proto-exporter-base/.npmignore | 4 - .../packages/otlp-proto-exporter-base/LICENSE | 201 ------------------ .../otlp-proto-exporter-base/README.md | 33 --- .../otlp-proto-exporter-base/package.json | 89 -------- .../packages/otlp-proto-exporter-base/protos | 1 - .../src/generated/.gitkeep | 0 .../otlp-proto-exporter-base/src/index.ts | 16 -- .../browser/OTLPProtoExporterBrowserBase.ts | 77 ------- .../src/platform/browser/index.ts | 17 -- .../src/platform/index.ts | 19 -- .../src/platform/types.ts | 21 -- .../src/platform/util.ts | 40 ---- .../tsconfig.esm.json | 24 --- .../tsconfig.esnext.json | 24 --- .../otlp-proto-exporter-base/tsconfig.json | 24 --- tsconfig.esm.json | 3 - tsconfig.esnext.json | 3 - tsconfig.json | 4 - 65 files changed, 135 insertions(+), 861 deletions(-) delete mode 100644 experimental/packages/otlp-proto-exporter-base/.eslintignore delete mode 100644 experimental/packages/otlp-proto-exporter-base/.eslintrc.js delete mode 100644 experimental/packages/otlp-proto-exporter-base/.gitignore delete mode 100644 experimental/packages/otlp-proto-exporter-base/.npmignore delete mode 100644 experimental/packages/otlp-proto-exporter-base/LICENSE delete mode 100644 experimental/packages/otlp-proto-exporter-base/README.md delete mode 100644 experimental/packages/otlp-proto-exporter-base/package.json delete mode 160000 experimental/packages/otlp-proto-exporter-base/protos delete mode 100644 experimental/packages/otlp-proto-exporter-base/src/generated/.gitkeep delete mode 100644 experimental/packages/otlp-proto-exporter-base/src/index.ts delete mode 100644 experimental/packages/otlp-proto-exporter-base/src/platform/browser/OTLPProtoExporterBrowserBase.ts delete mode 100644 experimental/packages/otlp-proto-exporter-base/src/platform/browser/index.ts delete mode 100644 experimental/packages/otlp-proto-exporter-base/src/platform/index.ts delete mode 100644 experimental/packages/otlp-proto-exporter-base/src/platform/types.ts delete mode 100644 experimental/packages/otlp-proto-exporter-base/src/platform/util.ts delete mode 100644 experimental/packages/otlp-proto-exporter-base/tsconfig.esm.json delete mode 100644 experimental/packages/otlp-proto-exporter-base/tsconfig.esnext.json delete mode 100644 experimental/packages/otlp-proto-exporter-base/tsconfig.json diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 6ee96219a9..f336cb0de9 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -11,6 +11,12 @@ All notable changes to experimental packages in this project will be documented * (user-facing) `convert()` now returns an empty object and will be removed in a follow-up * (internal) OTLPExporterNodeBase now has additional constructor parameters that are required * (internal) OTLPExporterNodeBase now has an additional `ResponseType` type parameter +* feat(exporter-*-otlp-*)!: move serialization for Node.js exporters to `@opentelemetry/otlp-transformer` [#4581](https://github.com/open-telemetry/opentelemetry-js/pull/4581) @pichlermarc + * Breaking changes: + * (user-facing) `convert()` has been removed from all exporters + * (internal) OTLPExporterBrowserBase: `RequestType` has been replaced by a `ResponseType` type-argument + * (internal) OTLPExporterNodeBase: `ServiceRequest` has been replaced by a `ServiceResponse` type-argument + * (internal) the `@opentelemetry/otlp-exporter-proto-base` package has been removed, and will from now on be deprecated in `npm` ### :rocket: (Enhancement) diff --git a/experimental/packages/exporter-logs-otlp-grpc/src/OTLPLogExporter.ts b/experimental/packages/exporter-logs-otlp-grpc/src/OTLPLogExporter.ts index 600f6626b0..1172126cbd 100644 --- a/experimental/packages/exporter-logs-otlp-grpc/src/OTLPLogExporter.ts +++ b/experimental/packages/exporter-logs-otlp-grpc/src/OTLPLogExporter.ts @@ -23,7 +23,6 @@ import { DEFAULT_COLLECTOR_URL, } from '@opentelemetry/otlp-grpc-exporter-base'; import { - IExportLogsServiceRequest, IExportLogsServiceResponse, ProtobufLogsSerializer, } from '@opentelemetry/otlp-transformer'; @@ -39,7 +38,6 @@ const USER_AGENT = { export class OTLPLogExporter extends OTLPGRPCExporterNodeBase< ReadableLogRecord, - IExportLogsServiceRequest, IExportLogsServiceResponse > implements LogRecordExporter diff --git a/experimental/packages/exporter-logs-otlp-http/src/platform/browser/OTLPLogExporter.ts b/experimental/packages/exporter-logs-otlp-http/src/platform/browser/OTLPLogExporter.ts index d65ff9aeb8..a4f5f2ddd5 100644 --- a/experimental/packages/exporter-logs-otlp-http/src/platform/browser/OTLPLogExporter.ts +++ b/experimental/packages/exporter-logs-otlp-http/src/platform/browser/OTLPLogExporter.ts @@ -19,10 +19,10 @@ import type { LogRecordExporter, } from '@opentelemetry/sdk-logs'; import type { OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base'; -import type { IExportLogsServiceRequest } from '@opentelemetry/otlp-transformer'; +import type { IExportLogsServiceResponse } from '@opentelemetry/otlp-transformer'; import { OTLPExporterBrowserBase } from '@opentelemetry/otlp-exporter-base'; import { baggageUtils, getEnv } from '@opentelemetry/core'; -import { createExportLogsServiceRequest } from '@opentelemetry/otlp-transformer'; +import { JsonLogsSerializer } from '@opentelemetry/otlp-transformer'; import { getDefaultUrl } from '../config'; @@ -30,15 +30,19 @@ import { getDefaultUrl } from '../config'; * Collector Logs Exporter for Web */ export class OTLPLogExporter - extends OTLPExporterBrowserBase + extends OTLPExporterBrowserBase implements LogRecordExporter { constructor(config: OTLPExporterConfigBase = {}) { // load OTEL_EXPORTER_OTLP_LOGS_TIMEOUT env var - super({ - timeoutMillis: getEnv().OTEL_EXPORTER_OTLP_LOGS_TIMEOUT, - ...config, - }); + super( + { + timeoutMillis: getEnv().OTEL_EXPORTER_OTLP_LOGS_TIMEOUT, + ...config, + }, + JsonLogsSerializer, + 'application/json' + ); this._headers = { ...this._headers, ...baggageUtils.parseKeyPairsIntoRecord( @@ -47,13 +51,6 @@ export class OTLPLogExporter }; } - convert(logRecords: ReadableLogRecord[]): IExportLogsServiceRequest { - return createExportLogsServiceRequest(logRecords, { - useHex: true, - useLongBits: false, - }); - } - getDefaultUrl(config: OTLPExporterConfigBase): string { return getDefaultUrl(config); } diff --git a/experimental/packages/exporter-logs-otlp-http/src/platform/node/OTLPLogExporter.ts b/experimental/packages/exporter-logs-otlp-http/src/platform/node/OTLPLogExporter.ts index e422f1c551..093061424b 100644 --- a/experimental/packages/exporter-logs-otlp-http/src/platform/node/OTLPLogExporter.ts +++ b/experimental/packages/exporter-logs-otlp-http/src/platform/node/OTLPLogExporter.ts @@ -19,10 +19,7 @@ import type { LogRecordExporter, } from '@opentelemetry/sdk-logs'; import type { OTLPExporterNodeConfigBase } from '@opentelemetry/otlp-exporter-base'; -import type { - IExportLogsServiceRequest, - IExportLogsServiceResponse, -} from '@opentelemetry/otlp-transformer'; +import type { IExportLogsServiceResponse } from '@opentelemetry/otlp-transformer'; import { getEnv, baggageUtils } from '@opentelemetry/core'; import { OTLPExporterNodeBase, @@ -41,11 +38,7 @@ const USER_AGENT = { * Collector Logs Exporter for Node */ export class OTLPLogExporter - extends OTLPExporterNodeBase< - ReadableLogRecord, - IExportLogsServiceRequest, - IExportLogsServiceResponse - > + extends OTLPExporterNodeBase implements LogRecordExporter { constructor(config: OTLPExporterNodeConfigBase = {}) { diff --git a/experimental/packages/exporter-logs-otlp-proto/package.json b/experimental/packages/exporter-logs-otlp-proto/package.json index 8dd711e1e6..2f21220484 100644 --- a/experimental/packages/exporter-logs-otlp-proto/package.json +++ b/experimental/packages/exporter-logs-otlp-proto/package.json @@ -97,7 +97,6 @@ "@opentelemetry/api-logs": "0.51.0", "@opentelemetry/core": "1.24.0", "@opentelemetry/otlp-exporter-base": "0.51.0", - "@opentelemetry/otlp-proto-exporter-base": "0.51.0", "@opentelemetry/otlp-transformer": "0.51.0", "@opentelemetry/resources": "1.24.0", "@opentelemetry/sdk-logs": "0.51.0", diff --git a/experimental/packages/exporter-logs-otlp-proto/src/platform/browser/OTLPLogExporter.ts b/experimental/packages/exporter-logs-otlp-proto/src/platform/browser/OTLPLogExporter.ts index fff28d4e77..a1ed000d66 100644 --- a/experimental/packages/exporter-logs-otlp-proto/src/platform/browser/OTLPLogExporter.ts +++ b/experimental/packages/exporter-logs-otlp-proto/src/platform/browser/OTLPLogExporter.ts @@ -19,14 +19,11 @@ import { OTLPExporterConfigBase, appendResourcePathToUrl, appendRootPathToUrlIfNeeded, + OTLPExporterBrowserBase, } from '@opentelemetry/otlp-exporter-base'; import { - OTLPProtoExporterBrowserBase, - ServiceClientType, -} from '@opentelemetry/otlp-proto-exporter-base'; -import { - createExportLogsServiceRequest, - IExportLogsServiceRequest, + IExportLogsServiceResponse, + ProtobufLogsSerializer, } from '@opentelemetry/otlp-transformer'; import { ReadableLogRecord, LogRecordExporter } from '@opentelemetry/sdk-logs'; @@ -38,14 +35,11 @@ const DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURC * Collector Trace Exporter for Web */ export class OTLPLogExporter - extends OTLPProtoExporterBrowserBase< - ReadableLogRecord, - IExportLogsServiceRequest - > + extends OTLPExporterBrowserBase implements LogRecordExporter { constructor(config: OTLPExporterConfigBase = {}) { - super(config); + super(config, ProtobufLogsSerializer, 'application/x-protobuf'); this._headers = Object.assign( this._headers, baggageUtils.parseKeyPairsIntoRecord( @@ -53,9 +47,6 @@ export class OTLPLogExporter ) ); } - convert(logs: ReadableLogRecord[]): IExportLogsServiceRequest { - return createExportLogsServiceRequest(logs); - } getDefaultUrl(config: OTLPExporterConfigBase): string { return typeof config.url === 'string' @@ -69,8 +60,4 @@ export class OTLPLogExporter ) : DEFAULT_COLLECTOR_URL; } - - getServiceClientType() { - return ServiceClientType.LOGS; - } } diff --git a/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts b/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts index 9fc7ad479c..989d5e237a 100644 --- a/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts +++ b/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts @@ -22,9 +22,7 @@ import { OTLPExporterNodeBase, parseHeaders, } from '@opentelemetry/otlp-exporter-base'; -import { ServiceClientType } from '@opentelemetry/otlp-proto-exporter-base'; import { - IExportLogsServiceRequest, IExportLogsServiceResponse, ProtobufLogsSerializer, } from '@opentelemetry/otlp-transformer'; @@ -43,11 +41,7 @@ const DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURC * Collector Trace Exporter for Node */ export class OTLPLogExporter - extends OTLPExporterNodeBase< - ReadableLogRecord, - IExportLogsServiceRequest, - IExportLogsServiceResponse - > + extends OTLPExporterNodeBase implements LogRecordExporter { constructor(config: OTLPExporterConfigBase = {}) { @@ -74,8 +68,4 @@ export class OTLPLogExporter ) : DEFAULT_COLLECTOR_URL; } - - getServiceClientType() { - return ServiceClientType.LOGS; - } } diff --git a/experimental/packages/exporter-logs-otlp-proto/test/node/OTLPLogExporter.test.ts b/experimental/packages/exporter-logs-otlp-proto/test/node/OTLPLogExporter.test.ts index 8bf1436206..71a88635b9 100644 --- a/experimental/packages/exporter-logs-otlp-proto/test/node/OTLPLogExporter.test.ts +++ b/experimental/packages/exporter-logs-otlp-proto/test/node/OTLPLogExporter.test.ts @@ -33,16 +33,27 @@ import { OTLPExporterNodeConfigBase, OTLPExporterError, } from '@opentelemetry/otlp-exporter-base'; -import { - getExportRequestProto, - ServiceClientType, -} from '@opentelemetry/otlp-proto-exporter-base'; import { IExportLogsServiceRequest } from '@opentelemetry/otlp-transformer'; import { ReadableLogRecord } from '@opentelemetry/sdk-logs'; import { VERSION } from '../../src/version'; +import { Root } from 'protobufjs'; +import * as path from 'path'; let fakeRequest: PassThrough; +const dir = path.resolve(__dirname, '../../../otlp-transformer/protos'); +const root = new Root(); +root.resolvePath = function (origin, target) { + return `${dir}/${target}`; +}; +const proto = root.loadSync([ + 'opentelemetry/proto/common/v1/common.proto', + 'opentelemetry/proto/resource/v1/resource.proto', + 'opentelemetry/proto/logs/v1/logs.proto', + 'opentelemetry/proto/collector/logs/v1/logs_service.proto', +]); +const exportRequestServiceProto = proto?.lookupType('ExportLogsServiceRequest'); + describe('OTLPLogExporter - node with proto over http', () => { let collectorExporter: OTLPLogExporter; let collectorExporterConfig: OTLPExporterNodeConfigBase; @@ -240,10 +251,7 @@ describe('OTLPLogExporter - node with proto over http', () => { let buff = Buffer.from(''); fakeRequest.on('end', () => { - const ExportLogsServiceRequestProto = getExportRequestProto( - ServiceClientType.LOGS - ); - const data = ExportLogsServiceRequestProto.decode(buff); + const data = exportRequestServiceProto.decode(buff); const json = data?.toJSON() as IExportLogsServiceRequest; const log1 = json.resourceLogs?.[0].scopeLogs?.[0].logRecords?.[0]; assert.ok(typeof log1 !== 'undefined', "log doesn't exist"); @@ -328,10 +336,7 @@ describe('OTLPLogExporter - node with proto over http', () => { let buff = Buffer.from(''); fakeRequest.on('end', () => { const unzippedBuff = zlib.gunzipSync(buff); - const ExportLogsServiceRequestProto = getExportRequestProto( - ServiceClientType.LOGS - ); - const data = ExportLogsServiceRequestProto.decode(unzippedBuff); + const data = exportRequestServiceProto.decode(unzippedBuff); const json = data?.toJSON() as IExportLogsServiceRequest; const log1 = json.resourceLogs?.[0].scopeLogs?.[0].logRecords?.[0]; assert.ok(typeof log1 !== 'undefined', "log doesn't exist"); diff --git a/experimental/packages/exporter-logs-otlp-proto/tsconfig.esm.json b/experimental/packages/exporter-logs-otlp-proto/tsconfig.esm.json index 5eba4694be..051fcfd62c 100644 --- a/experimental/packages/exporter-logs-otlp-proto/tsconfig.esm.json +++ b/experimental/packages/exporter-logs-otlp-proto/tsconfig.esm.json @@ -27,9 +27,6 @@ { "path": "../otlp-exporter-base" }, - { - "path": "../otlp-proto-exporter-base" - }, { "path": "../otlp-transformer" }, diff --git a/experimental/packages/exporter-logs-otlp-proto/tsconfig.esnext.json b/experimental/packages/exporter-logs-otlp-proto/tsconfig.esnext.json index b37520a70f..2bf55f532b 100644 --- a/experimental/packages/exporter-logs-otlp-proto/tsconfig.esnext.json +++ b/experimental/packages/exporter-logs-otlp-proto/tsconfig.esnext.json @@ -27,9 +27,6 @@ { "path": "../otlp-exporter-base" }, - { - "path": "../otlp-proto-exporter-base" - }, { "path": "../otlp-transformer" }, diff --git a/experimental/packages/exporter-logs-otlp-proto/tsconfig.json b/experimental/packages/exporter-logs-otlp-proto/tsconfig.json index 2349f8706c..00f0fe83cb 100644 --- a/experimental/packages/exporter-logs-otlp-proto/tsconfig.json +++ b/experimental/packages/exporter-logs-otlp-proto/tsconfig.json @@ -27,9 +27,6 @@ { "path": "../otlp-exporter-base" }, - { - "path": "../otlp-proto-exporter-base" - }, { "path": "../otlp-transformer" }, diff --git a/experimental/packages/exporter-trace-otlp-grpc/src/OTLPTraceExporter.ts b/experimental/packages/exporter-trace-otlp-grpc/src/OTLPTraceExporter.ts index 82bdaa3da2..cffa9b0749 100644 --- a/experimental/packages/exporter-trace-otlp-grpc/src/OTLPTraceExporter.ts +++ b/experimental/packages/exporter-trace-otlp-grpc/src/OTLPTraceExporter.ts @@ -23,7 +23,6 @@ import { DEFAULT_COLLECTOR_URL, } from '@opentelemetry/otlp-grpc-exporter-base'; import { - IExportTraceServiceRequest, IExportTraceServiceResponse, ProtobufTraceSerializer, } from '@opentelemetry/otlp-transformer'; @@ -37,11 +36,7 @@ const USER_AGENT = { * OTLP Trace Exporter for Node */ export class OTLPTraceExporter - extends OTLPGRPCExporterNodeBase< - ReadableSpan, - IExportTraceServiceRequest, - IExportTraceServiceResponse - > + extends OTLPGRPCExporterNodeBase implements SpanExporter { constructor(config: OTLPGRPCExporterConfigNode = {}) { diff --git a/experimental/packages/exporter-trace-otlp-http/src/platform/browser/OTLPTraceExporter.ts b/experimental/packages/exporter-trace-otlp-http/src/platform/browser/OTLPTraceExporter.ts index fa164f65cf..594054cf49 100644 --- a/experimental/packages/exporter-trace-otlp-http/src/platform/browser/OTLPTraceExporter.ts +++ b/experimental/packages/exporter-trace-otlp-http/src/platform/browser/OTLPTraceExporter.ts @@ -23,8 +23,8 @@ import { OTLPExporterBrowserBase, } from '@opentelemetry/otlp-exporter-base'; import { - createExportTraceServiceRequest, - IExportTraceServiceRequest, + IExportTraceServiceResponse, + JsonTraceSerializer, } from '@opentelemetry/otlp-transformer'; const DEFAULT_COLLECTOR_RESOURCE_PATH = 'v1/traces'; @@ -34,11 +34,11 @@ const DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURC * Collector Trace Exporter for Web */ export class OTLPTraceExporter - extends OTLPExporterBrowserBase + extends OTLPExporterBrowserBase implements SpanExporter { constructor(config: OTLPExporterConfigBase = {}) { - super(config); + super(config, JsonTraceSerializer, 'application/json'); this._headers = Object.assign( this._headers, baggageUtils.parseKeyPairsIntoRecord( @@ -46,12 +46,6 @@ export class OTLPTraceExporter ) ); } - convert(spans: ReadableSpan[]): IExportTraceServiceRequest { - return createExportTraceServiceRequest(spans, { - useHex: true, - useLongBits: false, - }); - } getDefaultUrl(config: OTLPExporterConfigBase): string { return typeof config.url === 'string' diff --git a/experimental/packages/exporter-trace-otlp-http/src/platform/node/OTLPTraceExporter.ts b/experimental/packages/exporter-trace-otlp-http/src/platform/node/OTLPTraceExporter.ts index 54180a9a2b..e8e77831fb 100644 --- a/experimental/packages/exporter-trace-otlp-http/src/platform/node/OTLPTraceExporter.ts +++ b/experimental/packages/exporter-trace-otlp-http/src/platform/node/OTLPTraceExporter.ts @@ -25,10 +25,7 @@ import { appendResourcePathToUrl, appendRootPathToUrlIfNeeded, } from '@opentelemetry/otlp-exporter-base'; -import { - IExportTraceServiceRequest, - IExportTraceServiceResponse, -} from '@opentelemetry/otlp-transformer'; +import { IExportTraceServiceResponse } from '@opentelemetry/otlp-transformer'; import { VERSION } from '../../version'; import { JsonTraceSerializer } from '@opentelemetry/otlp-transformer'; @@ -42,11 +39,7 @@ const USER_AGENT = { * Collector Trace Exporter for Node */ export class OTLPTraceExporter - extends OTLPExporterNodeBase< - ReadableSpan, - IExportTraceServiceRequest, - IExportTraceServiceResponse - > + extends OTLPExporterNodeBase implements SpanExporter { constructor(config: OTLPExporterNodeConfigBase = {}) { diff --git a/experimental/packages/exporter-trace-otlp-http/test/browser/CollectorTraceExporter.test.ts b/experimental/packages/exporter-trace-otlp-http/test/browser/CollectorTraceExporter.test.ts index 4e8bc1d6e1..56efeb8092 100644 --- a/experimental/packages/exporter-trace-otlp-http/test/browser/CollectorTraceExporter.test.ts +++ b/experimental/packages/exporter-trace-otlp-http/test/browser/CollectorTraceExporter.test.ts @@ -195,7 +195,10 @@ describe('OTLPTraceExporter - web', () => { assert.strictEqual(request.url, 'http://foo.bar.com'); const body = request.requestBody; - const json = JSON.parse(body) as IExportTraceServiceRequest; + const decoder = new TextDecoder(); + const json = JSON.parse( + decoder.decode(body) + ) as IExportTraceServiceRequest; const span1 = json.resourceSpans?.[0].scopeSpans?.[0].spans?.[0]; assert.ok(typeof span1 !== 'undefined', "span doesn't exist"); diff --git a/experimental/packages/exporter-trace-otlp-proto/package.json b/experimental/packages/exporter-trace-otlp-proto/package.json index d486ec482e..ef84aea77d 100644 --- a/experimental/packages/exporter-trace-otlp-proto/package.json +++ b/experimental/packages/exporter-trace-otlp-proto/package.json @@ -95,7 +95,6 @@ "dependencies": { "@opentelemetry/core": "1.24.0", "@opentelemetry/otlp-exporter-base": "0.51.0", - "@opentelemetry/otlp-proto-exporter-base": "0.51.0", "@opentelemetry/otlp-transformer": "0.51.0", "@opentelemetry/resources": "1.24.0", "@opentelemetry/sdk-trace-base": "1.24.0" diff --git a/experimental/packages/exporter-trace-otlp-proto/src/platform/browser/OTLPTraceExporter.ts b/experimental/packages/exporter-trace-otlp-proto/src/platform/browser/OTLPTraceExporter.ts index 890268333f..0de8a9a962 100644 --- a/experimental/packages/exporter-trace-otlp-proto/src/platform/browser/OTLPTraceExporter.ts +++ b/experimental/packages/exporter-trace-otlp-proto/src/platform/browser/OTLPTraceExporter.ts @@ -20,14 +20,11 @@ import { OTLPExporterConfigBase, appendResourcePathToUrl, appendRootPathToUrlIfNeeded, + OTLPExporterBrowserBase, } from '@opentelemetry/otlp-exporter-base'; import { - OTLPProtoExporterBrowserBase, - ServiceClientType, -} from '@opentelemetry/otlp-proto-exporter-base'; -import { - createExportTraceServiceRequest, - IExportTraceServiceRequest, + IExportTraceServiceResponse, + ProtobufTraceSerializer, } from '@opentelemetry/otlp-transformer'; const DEFAULT_COLLECTOR_RESOURCE_PATH = 'v1/traces'; @@ -37,11 +34,11 @@ const DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURC * Collector Trace Exporter for Web */ export class OTLPTraceExporter - extends OTLPProtoExporterBrowserBase + extends OTLPExporterBrowserBase implements SpanExporter { constructor(config: OTLPExporterConfigBase = {}) { - super(config); + super(config, ProtobufTraceSerializer, 'application/x-protobuf'); this._headers = Object.assign( this._headers, baggageUtils.parseKeyPairsIntoRecord( @@ -49,9 +46,6 @@ export class OTLPTraceExporter ) ); } - convert(spans: ReadableSpan[]): IExportTraceServiceRequest { - return createExportTraceServiceRequest(spans); - } getDefaultUrl(config: OTLPExporterConfigBase): string { return typeof config.url === 'string' @@ -65,8 +59,4 @@ export class OTLPTraceExporter ) : DEFAULT_COLLECTOR_URL; } - - getServiceClientType() { - return ServiceClientType.SPANS; - } } diff --git a/experimental/packages/exporter-trace-otlp-proto/src/platform/node/OTLPTraceExporter.ts b/experimental/packages/exporter-trace-otlp-proto/src/platform/node/OTLPTraceExporter.ts index 8bcb35fd36..bb3c916dbb 100644 --- a/experimental/packages/exporter-trace-otlp-proto/src/platform/node/OTLPTraceExporter.ts +++ b/experimental/packages/exporter-trace-otlp-proto/src/platform/node/OTLPTraceExporter.ts @@ -23,9 +23,7 @@ import { OTLPExporterNodeBase, parseHeaders, } from '@opentelemetry/otlp-exporter-base'; -import { ServiceClientType } from '@opentelemetry/otlp-proto-exporter-base'; import { - IExportTraceServiceRequest, IExportTraceServiceResponse, ProtobufTraceSerializer, } from '@opentelemetry/otlp-transformer'; @@ -41,11 +39,7 @@ const USER_AGENT = { * Collector Trace Exporter for Node with protobuf */ export class OTLPTraceExporter - extends OTLPExporterNodeBase< - ReadableSpan, - IExportTraceServiceRequest, - IExportTraceServiceResponse - > + extends OTLPExporterNodeBase implements SpanExporter { constructor(config: OTLPExporterNodeConfigBase = {}) { @@ -72,8 +66,4 @@ export class OTLPTraceExporter ) : DEFAULT_COLLECTOR_URL; } - - getServiceClientType() { - return ServiceClientType.SPANS; - } } diff --git a/experimental/packages/exporter-trace-otlp-proto/test/node/OTLPTraceExporter.test.ts b/experimental/packages/exporter-trace-otlp-proto/test/node/OTLPTraceExporter.test.ts index 7dfbb101fe..90c212e8aa 100644 --- a/experimental/packages/exporter-trace-otlp-proto/test/node/OTLPTraceExporter.test.ts +++ b/experimental/packages/exporter-trace-otlp-proto/test/node/OTLPTraceExporter.test.ts @@ -34,12 +34,25 @@ import { OTLPExporterNodeConfigBase, OTLPExporterError, } from '@opentelemetry/otlp-exporter-base'; -import { - getExportRequestProto, - ServiceClientType, -} from '@opentelemetry/otlp-proto-exporter-base'; import { IExportTraceServiceRequest } from '@opentelemetry/otlp-transformer'; +import { Root } from 'protobufjs'; import { VERSION } from '../../src/version'; +import * as path from 'path'; + +const dir = path.resolve(__dirname, '../../../otlp-transformer/protos'); +const root = new Root(); +root.resolvePath = function (origin, target) { + return `${dir}/${target}`; +}; +const proto = root.loadSync([ + 'opentelemetry/proto/common/v1/common.proto', + 'opentelemetry/proto/resource/v1/resource.proto', + 'opentelemetry/proto/trace/v1/trace.proto', + 'opentelemetry/proto/collector/trace/v1/trace_service.proto', +]); +const exportRequestServiceProto = proto?.lookupType( + 'ExportTraceServiceRequest' +); let fakeRequest: PassThrough; @@ -247,10 +260,7 @@ describe('OTLPTraceExporter - node with proto over http', () => { let buff = Buffer.from(''); fakeRequest.on('end', () => { - const ExportTraceServiceRequestProto = getExportRequestProto( - ServiceClientType.SPANS - ); - const data = ExportTraceServiceRequestProto.decode(buff); + const data = exportRequestServiceProto.decode(buff); const json = data?.toJSON() as IExportTraceServiceRequest; const span1 = json.resourceSpans?.[0].scopeSpans?.[0].spans?.[0]; assert.ok(typeof span1 !== 'undefined', "span doesn't exist"); @@ -335,10 +345,7 @@ describe('OTLPTraceExporter - node with proto over http', () => { let buff = Buffer.from(''); fakeRequest.on('end', () => { const unzippedBuff = zlib.gunzipSync(buff); - const ExportTraceServiceRequestProto = getExportRequestProto( - ServiceClientType.SPANS - ); - const data = ExportTraceServiceRequestProto.decode(unzippedBuff); + const data = exportRequestServiceProto.decode(unzippedBuff); const json = data?.toJSON() as IExportTraceServiceRequest; const span1 = json.resourceSpans?.[0].scopeSpans?.[0].spans?.[0]; assert.ok(typeof span1 !== 'undefined', "span doesn't exist"); diff --git a/experimental/packages/exporter-trace-otlp-proto/tsconfig.esm.json b/experimental/packages/exporter-trace-otlp-proto/tsconfig.esm.json index 22887f7b0a..8647f6ec56 100644 --- a/experimental/packages/exporter-trace-otlp-proto/tsconfig.esm.json +++ b/experimental/packages/exporter-trace-otlp-proto/tsconfig.esm.json @@ -24,9 +24,6 @@ { "path": "../otlp-exporter-base" }, - { - "path": "../otlp-proto-exporter-base" - }, { "path": "../otlp-transformer" } diff --git a/experimental/packages/exporter-trace-otlp-proto/tsconfig.esnext.json b/experimental/packages/exporter-trace-otlp-proto/tsconfig.esnext.json index 199ea3b325..b85acc27df 100644 --- a/experimental/packages/exporter-trace-otlp-proto/tsconfig.esnext.json +++ b/experimental/packages/exporter-trace-otlp-proto/tsconfig.esnext.json @@ -24,9 +24,6 @@ { "path": "../otlp-exporter-base" }, - { - "path": "../otlp-proto-exporter-base" - }, { "path": "../otlp-transformer" } diff --git a/experimental/packages/exporter-trace-otlp-proto/tsconfig.json b/experimental/packages/exporter-trace-otlp-proto/tsconfig.json index cf9d8d1ec7..417e1ad468 100644 --- a/experimental/packages/exporter-trace-otlp-proto/tsconfig.json +++ b/experimental/packages/exporter-trace-otlp-proto/tsconfig.json @@ -24,9 +24,6 @@ { "path": "../otlp-exporter-base" }, - { - "path": "../otlp-proto-exporter-base" - }, { "path": "../otlp-transformer" } diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/src/OTLPMetricExporter.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/src/OTLPMetricExporter.ts index 864f0f7c32..d7d3c1eea3 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/src/OTLPMetricExporter.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/src/OTLPMetricExporter.ts @@ -27,7 +27,6 @@ import { } from '@opentelemetry/otlp-grpc-exporter-base'; import { baggageUtils, getEnv } from '@opentelemetry/core'; import { - IExportMetricsServiceRequest, IExportMetricsServiceResponse, ProtobufMetricsSerializer, } from '@opentelemetry/otlp-transformer'; @@ -40,7 +39,6 @@ const USER_AGENT = { class OTLPMetricExporterProxy extends OTLPGRPCExporterNodeBase< ResourceMetrics, - IExportMetricsServiceRequest, IExportMetricsServiceResponse > { constructor(config?: OTLPGRPCExporterConfigNode & OTLPMetricExporterOptions) { diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/OTLPMetricExporterBase.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/OTLPMetricExporterBase.ts index 91aaf67977..76b7f74dfd 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/OTLPMetricExporterBase.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/OTLPMetricExporterBase.ts @@ -29,7 +29,6 @@ import { OTLPMetricExporterOptions, } from './OTLPMetricExporterOptions'; import { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base'; -import { IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer'; import { diag } from '@opentelemetry/api'; export const CumulativeTemporalitySelector: AggregationTemporalitySelector = @@ -119,11 +118,7 @@ function chooseAggregationSelector( } export class OTLPMetricExporterBase< - T extends OTLPExporterBase< - OTLPMetricExporterOptions, - ResourceMetrics, - IExportMetricsServiceRequest - >, + T extends OTLPExporterBase, > implements PushMetricExporter { public _otlpExporter: T; diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/platform/browser/OTLPMetricExporter.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/platform/browser/OTLPMetricExporter.ts index cff7a6ec00..890f1e9deb 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/platform/browser/OTLPMetricExporter.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/platform/browser/OTLPMetricExporter.ts @@ -25,8 +25,8 @@ import { appendRootPathToUrlIfNeeded, } from '@opentelemetry/otlp-exporter-base'; import { - createExportMetricsServiceRequest, - IExportMetricsServiceRequest, + IExportMetricsServiceResponse, + JsonMetricsSerializer, } from '@opentelemetry/otlp-transformer'; const DEFAULT_COLLECTOR_RESOURCE_PATH = 'v1/metrics'; @@ -34,10 +34,10 @@ const DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURC class OTLPExporterBrowserProxy extends OTLPExporterBrowserBase< ResourceMetrics, - IExportMetricsServiceRequest + IExportMetricsServiceResponse > { constructor(config?: OTLPMetricExporterOptions & OTLPExporterConfigBase) { - super(config); + super(config, JsonMetricsSerializer, 'application/json'); this._headers = Object.assign( this._headers, baggageUtils.parseKeyPairsIntoRecord( @@ -60,10 +60,6 @@ class OTLPExporterBrowserProxy extends OTLPExporterBrowserBase< ) : DEFAULT_COLLECTOR_URL; } - - convert(metrics: ResourceMetrics[]): IExportMetricsServiceRequest { - return createExportMetricsServiceRequest(metrics, { useLongBits: false }); - } } /** diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/platform/node/OTLPMetricExporter.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/platform/node/OTLPMetricExporter.ts index d76249b316..d812c37b26 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/platform/node/OTLPMetricExporter.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/platform/node/OTLPMetricExporter.ts @@ -26,7 +26,6 @@ import { parseHeaders, } from '@opentelemetry/otlp-exporter-base'; import { - IExportMetricsServiceRequest, IExportMetricsServiceResponse, JsonMetricsSerializer, } from '@opentelemetry/otlp-transformer'; @@ -40,7 +39,6 @@ const USER_AGENT = { class OTLPExporterNodeProxy extends OTLPExporterNodeBase< ResourceMetrics, - IExportMetricsServiceRequest, IExportMetricsServiceResponse > { constructor(config?: OTLPExporterNodeConfigBase & OTLPMetricExporterOptions) { diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/browser/CollectorMetricExporter.test.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/browser/CollectorMetricExporter.test.ts index cc112a9b55..1cdccbdbd8 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/browser/CollectorMetricExporter.test.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/browser/CollectorMetricExporter.test.ts @@ -238,7 +238,10 @@ describe('OTLPMetricExporter - web', () => { assert.strictEqual(request.url, 'http://foo.bar.com'); const body = request.requestBody; - const json = JSON.parse(body) as IExportMetricsServiceRequest; + const decoder = new TextDecoder(); + const json = JSON.parse( + decoder.decode(body) + ) as IExportMetricsServiceRequest; // The order of the metrics is not guaranteed. const counterIndex = metrics.scopeMetrics[0].metrics.findIndex( it => it.descriptor.name === 'int-counter' diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/CollectorMetricExporter.test.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/CollectorMetricExporter.test.ts index 963328da75..e4ae9f3926 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/CollectorMetricExporter.test.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/CollectorMetricExporter.test.ts @@ -29,14 +29,12 @@ import { OTLPExporterBase, OTLPExporterConfigBase, } from '@opentelemetry/otlp-exporter-base'; -import { IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer'; type CollectorExporterConfig = OTLPExporterConfigBase; class OTLPMetricExporter extends OTLPExporterBase< CollectorExporterConfig, - ResourceMetrics, - IExportMetricsServiceRequest + ResourceMetrics > { onInit() {} @@ -47,10 +45,6 @@ class OTLPMetricExporter extends OTLPExporterBase< getDefaultUrl(config: CollectorExporterConfig) { return config.url || ''; } - - convert(metrics: ResourceMetrics[]): IExportMetricsServiceRequest { - return { resourceMetrics: [] }; - } } describe('OTLPMetricExporter - common', () => { diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json index 07819c010d..d25bbd05f8 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json @@ -77,7 +77,6 @@ "@opentelemetry/core": "1.24.0", "@opentelemetry/exporter-metrics-otlp-http": "0.51.0", "@opentelemetry/otlp-exporter-base": "0.51.0", - "@opentelemetry/otlp-proto-exporter-base": "0.51.0", "@opentelemetry/otlp-transformer": "0.51.0", "@opentelemetry/resources": "1.24.0", "@opentelemetry/sdk-metrics": "1.24.0" diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/src/OTLPMetricExporter.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/src/OTLPMetricExporter.ts index 598b49806c..150181db01 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/src/OTLPMetricExporter.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/src/OTLPMetricExporter.ts @@ -15,7 +15,6 @@ */ import { OTLPMetricExporterOptions } from '@opentelemetry/exporter-metrics-otlp-http'; -import { ServiceClientType } from '@opentelemetry/otlp-proto-exporter-base'; import { getEnv, baggageUtils } from '@opentelemetry/core'; import { ResourceMetrics } from '@opentelemetry/sdk-metrics'; import { OTLPMetricExporterBase } from '@opentelemetry/exporter-metrics-otlp-http'; @@ -27,7 +26,6 @@ import { OTLPExporterNodeBase, } from '@opentelemetry/otlp-exporter-base'; import { - IExportMetricsServiceRequest, IExportMetricsServiceResponse, ProtobufMetricsSerializer, } from '@opentelemetry/otlp-transformer'; @@ -41,7 +39,6 @@ const USER_AGENT = { class OTLPMetricExporterNodeProxy extends OTLPExporterNodeBase< ResourceMetrics, - IExportMetricsServiceRequest, IExportMetricsServiceResponse > { constructor(config?: OTLPExporterNodeConfigBase & OTLPMetricExporterOptions) { @@ -70,10 +67,6 @@ class OTLPMetricExporterNodeProxy extends OTLPExporterNodeBase< ) : DEFAULT_COLLECTOR_URL; } - - getServiceClientType() { - return ServiceClientType.METRICS; - } } export class OTLPMetricExporter extends OTLPMetricExporterBase { diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/test/OTLPMetricExporter.test.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/test/OTLPMetricExporter.test.ts index 8398b2a3f7..969f433458 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/test/OTLPMetricExporter.test.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/test/OTLPMetricExporter.test.ts @@ -16,10 +16,6 @@ import { diag } from '@opentelemetry/api'; import { ExportResultCode } from '@opentelemetry/core'; -import { - getExportRequestProto, - ServiceClientType, -} from '@opentelemetry/otlp-proto-exporter-base'; import * as assert from 'assert'; import * as http from 'http'; import * as sinon from 'sinon'; @@ -46,9 +42,26 @@ import { import { Stream, PassThrough } from 'stream'; import { OTLPExporterNodeConfigBase } from '@opentelemetry/otlp-exporter-base'; import { VERSION } from '../src/version'; +import { Root } from 'protobufjs'; +import * as path from 'path'; let fakeRequest: PassThrough; +const dir = path.resolve(__dirname, '../../otlp-transformer/protos'); +const root = new Root(); +root.resolvePath = function (origin, target) { + return `${dir}/${target}`; +}; +const proto = root.loadSync([ + 'opentelemetry/proto/common/v1/common.proto', + 'opentelemetry/proto/resource/v1/resource.proto', + 'opentelemetry/proto/metrics/v1/metrics.proto', + 'opentelemetry/proto/collector/metrics/v1/metrics_service.proto', +]); +const exportRequestServiceProto = proto?.lookupType( + 'ExportMetricsServiceRequest' +); + describe('OTLPMetricExporter - node with proto over http', () => { let collectorExporter: OTLPMetricExporter; let collectorExporterConfig: OTLPExporterNodeConfigBase & @@ -281,10 +294,7 @@ describe('OTLPMetricExporter - node with proto over http', () => { let buff = Buffer.from(''); fakeRequest.on('end', () => { - const ExportTraceServiceRequestProto = getExportRequestProto( - ServiceClientType.METRICS - ); - const data = ExportTraceServiceRequestProto.decode(buff); + const data = exportRequestServiceProto.decode(buff); const json = data?.toJSON() as any; // The order of the metrics is not guaranteed. diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.esm.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.esm.json index b657f54211..4fb587ea8d 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.esm.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.esm.json @@ -27,9 +27,6 @@ { "path": "../otlp-exporter-base" }, - { - "path": "../otlp-proto-exporter-base" - }, { "path": "../otlp-transformer" } diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.esnext.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.esnext.json index 31e46faeda..8f77308fbd 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.esnext.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.esnext.json @@ -27,9 +27,6 @@ { "path": "../otlp-exporter-base" }, - { - "path": "../otlp-proto-exporter-base" - }, { "path": "../otlp-transformer" } diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json index d3497ee2dd..185c670198 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json @@ -27,9 +27,6 @@ { "path": "../otlp-exporter-base" }, - { - "path": "../otlp-proto-exporter-base" - }, { "path": "../otlp-transformer" } diff --git a/experimental/packages/otlp-exporter-base/src/OTLPExporterBase.ts b/experimental/packages/otlp-exporter-base/src/OTLPExporterBase.ts index 8a008dacb9..6581e2cf22 100644 --- a/experimental/packages/otlp-exporter-base/src/OTLPExporterBase.ts +++ b/experimental/packages/otlp-exporter-base/src/OTLPExporterBase.ts @@ -33,7 +33,6 @@ import { configureExporterTimeout } from './util'; export abstract class OTLPExporterBase< T extends OTLPExporterConfigBase, ExportItem, - ServiceRequest, > { public readonly url: string; public readonly hostname: string | undefined; @@ -143,5 +142,4 @@ export abstract class OTLPExporterBase< onError: (error: OTLPExporterError) => void ): void; abstract getDefaultUrl(config: T): string; - abstract convert(objects: ExportItem[]): ServiceRequest; } diff --git a/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts b/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts index 1c3715055a..2eed5d3e56 100644 --- a/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts +++ b/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts @@ -21,22 +21,33 @@ import { parseHeaders } from '../../util'; import { sendWithBeacon, sendWithXhr } from './util'; import { diag } from '@opentelemetry/api'; import { getEnv, baggageUtils } from '@opentelemetry/core'; +import { ISerializer } from '@opentelemetry/otlp-transformer'; /** * Collector Metric Exporter abstract base class */ export abstract class OTLPExporterBrowserBase< ExportItem, - ServiceRequest, -> extends OTLPExporterBase { + ServiceResponse, +> extends OTLPExporterBase { protected _headers: Record; private _useXHR: boolean = false; + private _contentType: string; + private _serializer: ISerializer; /** * @param config + * @param serializer + * @param contentType */ - constructor(config: OTLPExporterConfigBase = {}) { + constructor( + config: OTLPExporterConfigBase = {}, + serializer: ISerializer, + contentType: string + ) { super(config); + this._serializer = serializer; + this._contentType = contentType; this._useXHR = !!config.headers || typeof navigator.sendBeacon !== 'function'; if (this._useXHR) { @@ -65,15 +76,17 @@ export abstract class OTLPExporterBrowserBase< diag.debug('Shutdown already started. Cannot send objects'); return; } - const serviceRequest = this.convert(items); - const body = JSON.stringify(serviceRequest); + const body = this._serializer.serializeRequest(items) ?? new Uint8Array(); const promise = new Promise((resolve, reject) => { if (this._useXHR) { sendWithXhr( body, this.url, - this._headers, + { + ...this._headers, + 'Content-Type': this._contentType, + }, this.timeoutMillis, resolve, reject @@ -82,7 +95,7 @@ export abstract class OTLPExporterBrowserBase< sendWithBeacon( body, this.url, - { type: 'application/json' }, + { type: this._contentType }, resolve, reject ); diff --git a/experimental/packages/otlp-exporter-base/src/platform/browser/util.ts b/experimental/packages/otlp-exporter-base/src/platform/browser/util.ts index fade4afa88..d82688b97c 100644 --- a/experimental/packages/otlp-exporter-base/src/platform/browser/util.ts +++ b/experimental/packages/otlp-exporter-base/src/platform/browser/util.ts @@ -33,7 +33,7 @@ import { * @param onError */ export function sendWithBeacon( - body: string, + body: Uint8Array, url: string, blobPropertyBag: BlobPropertyBag, onSuccess: () => void, @@ -58,7 +58,7 @@ export function sendWithBeacon( * @param onError */ export function sendWithXhr( - body: string | Blob, + body: Uint8Array, url: string, headers: Record, exporterTimeout: number, diff --git a/experimental/packages/otlp-exporter-base/src/platform/node/OTLPExporterNodeBase.ts b/experimental/packages/otlp-exporter-base/src/platform/node/OTLPExporterNodeBase.ts index c4b13e8218..5d39153831 100644 --- a/experimental/packages/otlp-exporter-base/src/platform/node/OTLPExporterNodeBase.ts +++ b/experimental/packages/otlp-exporter-base/src/platform/node/OTLPExporterNodeBase.ts @@ -31,13 +31,8 @@ import { ISerializer } from '@opentelemetry/otlp-transformer'; */ export abstract class OTLPExporterNodeBase< ExportItem, - ServiceRequest, ServiceResponse, -> extends OTLPExporterBase< - OTLPExporterNodeConfigBase, - ExportItem, - ServiceRequest -> { +> extends OTLPExporterBase { DEFAULT_HEADERS: Record = {}; headers: Record; agent: http.Agent | https.Agent | undefined; @@ -68,11 +63,6 @@ export abstract class OTLPExporterNodeBase< onInit(_config: OTLPExporterNodeConfigBase): void {} - override convert(_objects: ExportItem[]): ServiceRequest { - // TODO(pichlermarc): needs to be removed from base in a follow-up - return {} as ServiceRequest; - } - send( objects: ExportItem[], onSuccess: () => void, diff --git a/experimental/packages/otlp-exporter-base/src/platform/node/util.ts b/experimental/packages/otlp-exporter-base/src/platform/node/util.ts index a42c95b110..d9bca47088 100644 --- a/experimental/packages/otlp-exporter-base/src/platform/node/util.ts +++ b/experimental/packages/otlp-exporter-base/src/platform/node/util.ts @@ -41,8 +41,8 @@ import { * @param onSuccess * @param onError */ -export function sendWithHttp( - collector: OTLPExporterNodeBase, +export function sendWithHttp( + collector: OTLPExporterNodeBase, data: string | Uint8Array, contentType: string, onSuccess: () => void, diff --git a/experimental/packages/otlp-exporter-base/test/browser/util.test.ts b/experimental/packages/otlp-exporter-base/test/browser/util.test.ts index 1dd3b77d58..367c51a2f1 100644 --- a/experimental/packages/otlp-exporter-base/test/browser/util.test.ts +++ b/experimental/packages/otlp-exporter-base/test/browser/util.test.ts @@ -21,7 +21,7 @@ import { ensureHeadersContain } from '../testHelper'; describe('util - browser', () => { let server: any; - const body = ''; + const body = new Uint8Array(); const url = ''; let onSuccessStub: sinon.SinonStub; diff --git a/experimental/packages/otlp-exporter-base/test/common/CollectorExporter.test.ts b/experimental/packages/otlp-exporter-base/test/common/CollectorExporter.test.ts index e3b36e704d..c6be6965e6 100644 --- a/experimental/packages/otlp-exporter-base/test/common/CollectorExporter.test.ts +++ b/experimental/packages/otlp-exporter-base/test/common/CollectorExporter.test.ts @@ -22,15 +22,10 @@ import { OTLPExporterConfigBase } from '../../src/types'; import { ComplexTestObject, mockedComplexTestObject } from '../testHelper'; import * as otlpTypes from '../../src/types'; -interface ExportRequest { - resourceSpans: object[]; -} - type CollectorExporterConfig = OTLPExporterConfigBase; class OTLPTraceExporter extends OTLPExporterBase< CollectorExporterConfig, - ComplexTestObject, - ExportRequest + ComplexTestObject > { onInit() {} onShutdown() {} @@ -49,10 +44,6 @@ class OTLPTraceExporter extends OTLPExporterBase< getDefaultUrl(config: CollectorExporterConfig): string { return config.url || ''; } - - convert(spans: ComplexTestObject[]): ExportRequest { - return { resourceSpans: [] }; - } } describe('OTLPTraceExporter - common', () => { diff --git a/experimental/packages/otlp-exporter-base/test/node/util.test.ts b/experimental/packages/otlp-exporter-base/test/node/util.test.ts index 39c2321349..0d3891cae6 100644 --- a/experimental/packages/otlp-exporter-base/test/node/util.test.ts +++ b/experimental/packages/otlp-exporter-base/test/node/util.test.ts @@ -51,7 +51,7 @@ class HttpRequest extends PassThrough { // Barebones exporter for use by sendWithHttp type ExporterConfig = OTLPExporterNodeConfigBase; -class Exporter extends OTLPExporterNodeBase { +class Exporter extends OTLPExporterNodeBase { getDefaultUrl(config: ExporterConfig): string { return config.url || ''; } diff --git a/experimental/packages/otlp-grpc-exporter-base/src/OTLPGRPCExporterNodeBase.ts b/experimental/packages/otlp-grpc-exporter-base/src/OTLPGRPCExporterNodeBase.ts index fb75bcf19c..8ffc1458b2 100644 --- a/experimental/packages/otlp-grpc-exporter-base/src/OTLPGRPCExporterNodeBase.ts +++ b/experimental/packages/otlp-grpc-exporter-base/src/OTLPGRPCExporterNodeBase.ts @@ -35,13 +35,8 @@ import { IExporterTransport } from './exporter-transport'; */ export abstract class OTLPGRPCExporterNodeBase< ExportItem, - ServiceRequest, ServiceResponse, -> extends OTLPExporterBase< - OTLPGRPCExporterConfigNode, - ExportItem, - ServiceRequest -> { +> extends OTLPExporterBase { grpcQueue: GRPCQueueItem[] = []; compression: CompressionAlgorithm; private _transport: IExporterTransport; @@ -114,11 +109,6 @@ export abstract class OTLPGRPCExporterNodeBase< this._transport.shutdown(); } - override convert(_objects: ExportItem[]): ServiceRequest { - // Not used, nothing to do. - return {} as ServiceRequest; - } - send( objects: ExportItem[], onSuccess: () => void, diff --git a/experimental/packages/otlp-grpc-exporter-base/test/OTLPGRPCExporterNodeBase.test.ts b/experimental/packages/otlp-grpc-exporter-base/test/OTLPGRPCExporterNodeBase.test.ts index cca5434c9c..d1fe77f962 100644 --- a/experimental/packages/otlp-grpc-exporter-base/test/OTLPGRPCExporterNodeBase.test.ts +++ b/experimental/packages/otlp-grpc-exporter-base/test/OTLPGRPCExporterNodeBase.test.ts @@ -26,7 +26,6 @@ import sinon = require('sinon'); class MockCollectorExporter extends OTLPGRPCExporterNodeBase< ReadableSpan, - ReadableSpan[], any > { getDefaultUrl(config: OTLPGRPCExporterConfigNode): string { diff --git a/experimental/packages/otlp-proto-exporter-base/.eslintignore b/experimental/packages/otlp-proto-exporter-base/.eslintignore deleted file mode 100644 index 345f1a599e..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -build -src/generated diff --git a/experimental/packages/otlp-proto-exporter-base/.eslintrc.js b/experimental/packages/otlp-proto-exporter-base/.eslintrc.js deleted file mode 100644 index 9cfb3fd423..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/.eslintrc.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - "env": { - "mocha": true, - "commonjs": true, - "node": true, - }, - ...require('../../../eslint.base.js') -} diff --git a/experimental/packages/otlp-proto-exporter-base/.gitignore b/experimental/packages/otlp-proto-exporter-base/.gitignore deleted file mode 100644 index c82683cbd7..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -src/generated/* -!src/generated/.gitkeep diff --git a/experimental/packages/otlp-proto-exporter-base/.npmignore b/experimental/packages/otlp-proto-exporter-base/.npmignore deleted file mode 100644 index 9505ba9450..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -/bin -/coverage -/doc -/test diff --git a/experimental/packages/otlp-proto-exporter-base/LICENSE b/experimental/packages/otlp-proto-exporter-base/LICENSE deleted file mode 100644 index 261eeb9e9f..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/experimental/packages/otlp-proto-exporter-base/README.md b/experimental/packages/otlp-proto-exporter-base/README.md deleted file mode 100644 index fa4cd9032d..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# OpenTelemetry Collector Exporter for node with protobuf - -[![NPM Published Version][npm-img]][npm-url] -[![Apache License][license-image]][license-image] - -**Note: This package is intended for internal use only.** - -**Note: This is an experimental package under active development. New releases may include breaking changes.** - -This module provides a OTLP-http/protobuf exporter base for Node.js (browsers not supported) to be used with [opentelemetry-collector][opentelemetry-collector-url]. - -## Installation - -```bash -npm install --save @opentelemetry/otlp-proto-exporter-base -``` - -## Useful links - -- For more information on OpenTelemetry, visit: -- For more about OpenTelemetry JavaScript: -- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] - -## License - -Apache 2.0 - See [LICENSE][license-url] for more information. - -[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions -[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE -[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat -[npm-url]: https://www.npmjs.com/package/@opentelemetry/otlp-proto-exporter-base -[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fotlp-proto-exporter-base.svg -[opentelemetry-collector-url]: https://github.com/open-telemetry/opentelemetry-collector diff --git a/experimental/packages/otlp-proto-exporter-base/package.json b/experimental/packages/otlp-proto-exporter-base/package.json deleted file mode 100644 index 66834e68ee..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/package.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "name": "@opentelemetry/otlp-proto-exporter-base", - "version": "0.51.0", - "description": "OpenTelemetry OTLP-HTTP-protobuf Exporter base (for internal use only)", - "main": "build/src/index.js", - "module": "build/esm/index.js", - "esnext": "build/esnext/index.js", - "types": "build/src/index.d.ts", - "repository": "open-telemetry/opentelemetry-js", - "browser": { - "./src/platform/index.ts": "./src/platform/browser/index.ts", - "./build/esm/platform/index.js": "./build/esm/platform/browser/index.js", - "./build/esnext/platform/index.js": "./build/esnext/platform/browser/index.js", - "./build/src/platform/index.js": "./build/src/platform/browser/index.js" - }, - "scripts": { - "prepublishOnly": "npm run compile", - "compile": "npm run protos && tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json", - "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json", - "lint": "eslint . --ext .ts", - "lint:fix": "eslint . --ext .ts --fix", - "protos": "npm run submodule && npm run protos:generate", - "protos:generate": "node ../../../scripts/generate-protos.js", - "submodule": "git submodule sync --recursive && git submodule update --init --recursive", - "version": "node ../../../scripts/version-update.js", - "watch": "npm run protos && tsc -w tsconfig.json tsconfig.esm.json tsconfig.esnext.json", - "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", - "prewatch": "npm run precompile" - }, - "keywords": [ - "opentelemetry", - "nodejs", - "protobuf", - "tracing", - "profiling", - "metrics", - "stats" - ], - "author": "OpenTelemetry Authors", - "license": "Apache-2.0", - "engines": { - "node": ">=14" - }, - "files": [ - "build/esm/**/*.js", - "build/esm/**/*.js.map", - "build/esm/**/*.d.ts", - "build/esnext/**/*.js", - "build/esnext/**/*.js.map", - "build/esnext/**/*.d.ts", - "build/src/**/*.js", - "build/src/**/*.js.map", - "build/src/**/*.d.ts", - "doc", - "LICENSE", - "README.md" - ], - "publishConfig": { - "access": "public" - }, - "devDependencies": { - "@babel/core": "7.23.6", - "@babel/preset-env": "7.22.20", - "@opentelemetry/api": "1.8.0", - "@types/mocha": "10.0.6", - "@types/node": "18.6.5", - "@types/sinon": "10.0.20", - "codecov": "3.8.3", - "cross-var": "1.1.0", - "lerna": "6.6.2", - "mocha": "10.2.0", - "nyc": "15.1.0", - "protobufjs-cli": "1.1.2", - "sinon": "15.1.2", - "ts-loader": "8.4.0", - "ts-mocha": "10.0.0", - "typescript": "4.4.4" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.0.0" - }, - "dependencies": { - "@opentelemetry/core": "1.24.0", - "@opentelemetry/otlp-exporter-base": "0.51.0", - "protobufjs": "^7.2.3" - }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/otlp-proto-exporter-base", - "sideEffects": false -} diff --git a/experimental/packages/otlp-proto-exporter-base/protos b/experimental/packages/otlp-proto-exporter-base/protos deleted file mode 160000 index 1608f92cf0..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/protos +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1608f92cf08119f9aec237c910b200d1317ec696 diff --git a/experimental/packages/otlp-proto-exporter-base/src/generated/.gitkeep b/experimental/packages/otlp-proto-exporter-base/src/generated/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/experimental/packages/otlp-proto-exporter-base/src/index.ts b/experimental/packages/otlp-proto-exporter-base/src/index.ts deleted file mode 100644 index e76b3a3593..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/src/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export * from './platform'; diff --git a/experimental/packages/otlp-proto-exporter-base/src/platform/browser/OTLPProtoExporterBrowserBase.ts b/experimental/packages/otlp-proto-exporter-base/src/platform/browser/OTLPProtoExporterBrowserBase.ts deleted file mode 100644 index 4bc9e5c70a..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/src/platform/browser/OTLPProtoExporterBrowserBase.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { diag } from '@opentelemetry/api'; -import { ServiceClientType } from '../types'; -import { - OTLPExporterBrowserBase as OTLPExporterBaseMain, - OTLPExporterError, - OTLPExporterConfigBase, - sendWithXhr, -} from '@opentelemetry/otlp-exporter-base'; - -import { getExportRequestProto } from '../util'; - -/** - * Collector Exporter abstract base class - */ -export abstract class OTLPProtoExporterBrowserBase< - ExportItem, - ServiceRequest, -> extends OTLPExporterBaseMain { - constructor(config: OTLPExporterConfigBase = {}) { - super(config); - } - - override send( - objects: ExportItem[], - onSuccess: () => void, - onError: (error: OTLPExporterError) => void - ): void { - if (this._shutdownOnce.isCalled) { - diag.debug('Shutdown already started. Cannot send objects'); - return; - } - - const serviceRequest = this.convert(objects); - const exportRequestType = getExportRequestProto( - this.getServiceClientType() - ); - const message = exportRequestType.create(serviceRequest); - - if (message) { - const body = exportRequestType.encode(message).finish(); - if (body) { - sendWithXhr( - new Blob([body], { type: 'application/x-protobuf' }), - this.url, - { - ...this._headers, - 'Content-Type': 'application/x-protobuf', - Accept: 'application/x-protobuf', - }, - this.timeoutMillis, - onSuccess, - onError - ); - } - } else { - onError(new OTLPExporterError('No proto')); - } - } - - abstract getServiceClientType(): ServiceClientType; -} diff --git a/experimental/packages/otlp-proto-exporter-base/src/platform/browser/index.ts b/experimental/packages/otlp-proto-exporter-base/src/platform/browser/index.ts deleted file mode 100644 index 26765ea51f..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/src/platform/browser/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export { OTLPProtoExporterBrowserBase } from './OTLPProtoExporterBrowserBase'; -export { ServiceClientType } from '../types'; diff --git a/experimental/packages/otlp-proto-exporter-base/src/platform/index.ts b/experimental/packages/otlp-proto-exporter-base/src/platform/index.ts deleted file mode 100644 index f6ead82b84..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/src/platform/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { OTLPProtoExporterBrowserBase } from './browser'; -export { ServiceClientType } from './types'; -export { ExportRequestType, getExportRequestProto } from './util'; diff --git a/experimental/packages/otlp-proto-exporter-base/src/platform/types.ts b/experimental/packages/otlp-proto-exporter-base/src/platform/types.ts deleted file mode 100644 index b15ad36abc..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/src/platform/types.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export enum ServiceClientType { - SPANS, - METRICS, - LOGS, -} diff --git a/experimental/packages/otlp-proto-exporter-base/src/platform/util.ts b/experimental/packages/otlp-proto-exporter-base/src/platform/util.ts deleted file mode 100644 index 2fe428b432..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/src/platform/util.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as root from '../generated/root'; -import { ServiceClientType } from './types'; -import type * as protobuf from 'protobufjs'; - -export interface ExportRequestType unknown }> { - create(properties?: T): R; - encode(message: T, writer?: protobuf.Writer): protobuf.Writer; - decode(reader: protobuf.Reader | Uint8Array, length?: number): R; -} - -export function getExportRequestProto( - clientType: ServiceClientType -): ExportRequestType { - if (clientType === ServiceClientType.SPANS) { - return root.opentelemetry.proto.collector.trace.v1 - .ExportTraceServiceRequest as unknown as ExportRequestType; - } else if (clientType === ServiceClientType.LOGS) { - return root.opentelemetry.proto.collector.logs.v1 - .ExportLogsServiceRequest as unknown as ExportRequestType; - } else { - return root.opentelemetry.proto.collector.metrics.v1 - .ExportMetricsServiceRequest as unknown as ExportRequestType; - } -} diff --git a/experimental/packages/otlp-proto-exporter-base/tsconfig.esm.json b/experimental/packages/otlp-proto-exporter-base/tsconfig.esm.json deleted file mode 100644 index d5c055a849..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/tsconfig.esm.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "extends": "../../../tsconfig.base.esm.json", - "compilerOptions": { - "allowJs": true, - "outDir": "build/esm", - "rootDir": "src", - "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" - }, - "include": [ - "src/**/*.ts", - "src/generated/*.js" - ], - "references": [ - { - "path": "../../../api" - }, - { - "path": "../../../packages/opentelemetry-core" - }, - { - "path": "../otlp-exporter-base" - } - ] -} diff --git a/experimental/packages/otlp-proto-exporter-base/tsconfig.esnext.json b/experimental/packages/otlp-proto-exporter-base/tsconfig.esnext.json deleted file mode 100644 index 2eeda32b24..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/tsconfig.esnext.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "extends": "../../../tsconfig.base.esnext.json", - "compilerOptions": { - "allowJs": true, - "outDir": "build/esnext", - "rootDir": "src", - "tsBuildInfoFile": "build/esnext/tsconfig.esnext.tsbuildinfo" - }, - "include": [ - "src/**/*.ts", - "src/generated/*.js" - ], - "references": [ - { - "path": "../../../api" - }, - { - "path": "../../../packages/opentelemetry-core" - }, - { - "path": "../otlp-exporter-base" - } - ] -} diff --git a/experimental/packages/otlp-proto-exporter-base/tsconfig.json b/experimental/packages/otlp-proto-exporter-base/tsconfig.json deleted file mode 100644 index 442b34dd38..0000000000 --- a/experimental/packages/otlp-proto-exporter-base/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "extends": "../../../tsconfig.base.json", - "compilerOptions": { - "allowJs": true, - "outDir": "build", - "rootDir": "." - }, - "include": [ - "src/**/*.ts", - "src/generated/*.js", - "test/**/*.ts" - ], - "references": [ - { - "path": "../../../api" - }, - { - "path": "../../../packages/opentelemetry-core" - }, - { - "path": "../otlp-exporter-base" - } - ] -} diff --git a/tsconfig.esm.json b/tsconfig.esm.json index 5b61f9698c..90bbae757d 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -44,9 +44,6 @@ { "path": "experimental/packages/otlp-exporter-base/tsconfig.esm.json" }, - { - "path": "experimental/packages/otlp-proto-exporter-base/tsconfig.esm.json" - }, { "path": "experimental/packages/otlp-transformer/tsconfig.esm.json" }, diff --git a/tsconfig.esnext.json b/tsconfig.esnext.json index a8540bd071..71835edb45 100644 --- a/tsconfig.esnext.json +++ b/tsconfig.esnext.json @@ -44,9 +44,6 @@ { "path": "experimental/packages/otlp-exporter-base/tsconfig.esnext.json" }, - { - "path": "experimental/packages/otlp-proto-exporter-base/tsconfig.esnext.json" - }, { "path": "experimental/packages/otlp-transformer/tsconfig.esnext.json" }, diff --git a/tsconfig.json b/tsconfig.json index a513edfe84..f493455c0c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,7 +26,6 @@ "experimental/packages/opentelemetry-sdk-node", "experimental/packages/otlp-exporter-base", "experimental/packages/otlp-grpc-exporter-base", - "experimental/packages/otlp-proto-exporter-base", "experimental/packages/otlp-transformer", "experimental/packages/propagator-aws-xray-lambda", "experimental/packages/sdk-logs", @@ -125,9 +124,6 @@ { "path": "experimental/packages/otlp-grpc-exporter-base" }, - { - "path": "experimental/packages/otlp-proto-exporter-base" - }, { "path": "experimental/packages/otlp-transformer" },