From 8b115131e0d5ef9d3726d95336a539a5653decc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B2=92=E7=B2=92=E6=A9=99?= Date: Wed, 8 Mar 2023 05:02:00 +0000 Subject: [PATCH] feat(otel-grpc-exporter-base): support LogsService --- .../otlp-grpc-exporter-base/src/types.ts | 5 ++- .../otlp-grpc-exporter-base/src/util.ts | 39 ++++++++++++------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/experimental/packages/otlp-grpc-exporter-base/src/types.ts b/experimental/packages/otlp-grpc-exporter-base/src/types.ts index fa3fea4ab17..af671888463 100644 --- a/experimental/packages/otlp-grpc-exporter-base/src/types.ts +++ b/experimental/packages/otlp-grpc-exporter-base/src/types.ts @@ -22,7 +22,7 @@ import { } from '@opentelemetry/otlp-exporter-base'; /** - * Queue item to be used to save temporary spans/metrics in case the GRPC service + * Queue item to be used to save temporary spans/metrics/logs in case the GRPC service * hasn't been fully initialized yet */ export interface GRPCQueueItem { @@ -32,7 +32,7 @@ export interface GRPCQueueItem { } /** - * Service Client for sending spans or metrics + * Service Client for sending spans/metrics/logs */ export interface ServiceClient extends grpc.Client { export: ( @@ -55,4 +55,5 @@ export interface OTLPGRPCExporterConfigNode extends OTLPExporterConfigBase { export enum ServiceClientType { SPANS, METRICS, + LOGS, } diff --git a/experimental/packages/otlp-grpc-exporter-base/src/util.ts b/experimental/packages/otlp-grpc-exporter-base/src/util.ts index 9a423271670..f4dc8af8a90 100644 --- a/experimental/packages/otlp-grpc-exporter-base/src/util.ts +++ b/experimental/packages/otlp-grpc-exporter-base/src/util.ts @@ -64,20 +64,31 @@ export function onInit( 'grpc.default_compression_algorithm': collector.compression, }; - if (collector.getServiceClientType() === ServiceClientType.SPANS) { - collector.serviceClient = - new packageObject.opentelemetry.proto.collector.trace.v1.TraceService( - collector.url, - credentials, - options - ); - } else { - collector.serviceClient = - new packageObject.opentelemetry.proto.collector.metrics.v1.MetricsService( - collector.url, - credentials, - options - ); + switch (collector.getServiceClientType()) { + case ServiceClientType.SPANS: + collector.serviceClient = + new packageObject.opentelemetry.proto.collector.trace.v1.TraceService( + collector.url, + credentials, + options + ); + break; + case ServiceClientType.METRICS: + collector.serviceClient = + new packageObject.opentelemetry.proto.collector.metrics.v1.MetricsService( + collector.url, + credentials, + options + ); + break; + case ServiceClientType.LOGS: + collector.serviceClient = + new packageObject.opentelemetry.proto.collector.logs.v1.LogsService( + collector.url, + credentials, + options + ); + break; } if (collector.grpcQueue.length > 0) {