diff --git a/experimental/packages/exporter-logs-otlp-proto/README.md b/experimental/packages/exporter-logs-otlp-proto/README.md index 4b98c103775..be603d873e7 100644 --- a/experimental/packages/exporter-logs-otlp-proto/README.md +++ b/experimental/packages/exporter-logs-otlp-proto/README.md @@ -1,4 +1,4 @@ -# OpenTelemetry Collector Exporter for node with protobuf +# An OTLP exporter to send logs using protobuf over HTTP [![NPM Published Version][npm-img]][npm-url] [![Apache License][license-image]][license-image] @@ -42,7 +42,6 @@ const logger = logProvider.getLogger('test_log_instrumentation'); logger.emit({ //log data to emit }) - ``` ## Exporter Timeout Configuration diff --git a/experimental/packages/exporter-logs-otlp-proto/package.json b/experimental/packages/exporter-logs-otlp-proto/package.json index cbea2d1c9ed..6dcdab76a07 100644 --- a/experimental/packages/exporter-logs-otlp-proto/package.json +++ b/experimental/packages/exporter-logs-otlp-proto/package.json @@ -1,7 +1,7 @@ { "name": "@opentelemetry/exporter-logs-otlp-proto", "version": "0.38.0", - "description": "OpenTelemetry Collector Exporter allows user to send collected logs to the OpenTelemetry Collector using json over Protobuf", + "description": "An OTLP exporter to send logs using protobuf over HTTP", "main": "build/src/index.js", "module": "build/esm/index.js", "esnext": "build/esnext/index.js", 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 index 5d8165fb19d..41e0c6859eb 100644 --- a/experimental/packages/otlp-proto-exporter-base/src/platform/browser/OTLPProtoExporterBrowserBase.ts +++ b/experimental/packages/otlp-proto-exporter-base/src/platform/browser/OTLPProtoExporterBrowserBase.ts @@ -23,7 +23,7 @@ import { sendWithXhr, } from '@opentelemetry/otlp-exporter-base'; -import { getExportRequestProto } from '../node'; +import { getExportRequestProto } from '../util'; interface ExportRequestType unknown }> { create(properties?: T): R; diff --git a/experimental/packages/otlp-proto-exporter-base/src/platform/index.ts b/experimental/packages/otlp-proto-exporter-base/src/platform/index.ts index 22efeb03093..fc344756ea5 100644 --- a/experimental/packages/otlp-proto-exporter-base/src/platform/index.ts +++ b/experimental/packages/otlp-proto-exporter-base/src/platform/index.ts @@ -14,11 +14,7 @@ * limitations under the License. */ -export { - OTLPProtoExporterNodeBase, - ExportRequestType, - getExportRequestProto, - send, -} from './node'; +export { OTLPProtoExporterNodeBase, send } from './node'; export { OTLPProtoExporterBrowserBase } from './browser'; export { ServiceClientType } from './types'; +export { ExportRequestType, getExportRequestProto } from './util'; diff --git a/experimental/packages/otlp-proto-exporter-base/src/platform/node/index.ts b/experimental/packages/otlp-proto-exporter-base/src/platform/node/index.ts index c9c84bdac3f..08016fec935 100644 --- a/experimental/packages/otlp-proto-exporter-base/src/platform/node/index.ts +++ b/experimental/packages/otlp-proto-exporter-base/src/platform/node/index.ts @@ -15,4 +15,4 @@ */ export { OTLPProtoExporterNodeBase } from './OTLPProtoExporterNodeBase'; -export { ExportRequestType, getExportRequestProto, send } from './util'; +export { send } from './util'; diff --git a/experimental/packages/otlp-proto-exporter-base/src/platform/node/util.ts b/experimental/packages/otlp-proto-exporter-base/src/platform/node/util.ts index cdee89bd85e..36fe866d678 100644 --- a/experimental/packages/otlp-proto-exporter-base/src/platform/node/util.ts +++ b/experimental/packages/otlp-proto-exporter-base/src/platform/node/util.ts @@ -14,36 +14,14 @@ * limitations under the License. */ -import { ServiceClientType } from '../types'; import { OTLPProtoExporterNodeBase } from './OTLPProtoExporterNodeBase'; import { CompressionAlgorithm, OTLPExporterError, sendWithHttp, } from '@opentelemetry/otlp-exporter-base'; -import type * as protobuf from 'protobufjs'; -import * as root from '../../generated/root'; -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; - } -} +import { getExportRequestProto } from '../util'; export function send( collector: OTLPProtoExporterNodeBase, diff --git a/experimental/packages/otlp-proto-exporter-base/src/platform/util.ts b/experimental/packages/otlp-proto-exporter-base/src/platform/util.ts new file mode 100644 index 00000000000..c6e1272816f --- /dev/null +++ b/experimental/packages/otlp-proto-exporter-base/src/platform/util.ts @@ -0,0 +1,39 @@ +/* + * 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'; + +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/sdk-logs/test/common/utils.ts b/experimental/packages/sdk-logs/test/common/utils.ts index 62b5e23f261..80dc84e0c74 100644 --- a/experimental/packages/sdk-logs/test/common/utils.ts +++ b/experimental/packages/sdk-logs/test/common/utils.ts @@ -21,11 +21,12 @@ export const validAttributes = { 'array': ['str1', 'str2'], 'array': [1, 2], 'array': [true, false], + object: { bar: 'foo' }, }; export const invalidAttributes = { - // invalid attribute type object - // object: { foo: 'bar' }, + // invalid attribute empty object + object: {}, // invalid attribute inhomogeneous array 'non-homogeneous-array': [0, ''], // This empty length attribute should not be set