Skip to content

Commit

Permalink
feat(otel-grpc-exporter-base): support LogsService
Browse files Browse the repository at this point in the history
  • Loading branch information
llc1123 committed Apr 13, 2023
1 parent c0186cc commit e6214a6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
5 changes: 3 additions & 2 deletions experimental/packages/otlp-grpc-exporter-base/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExportedItem> {
Expand All @@ -32,7 +32,7 @@ export interface GRPCQueueItem<ExportedItem> {
}

/**
* Service Client for sending spans or metrics
* Service Client for sending spans/metrics/logs
*/
export interface ServiceClient extends grpc.Client {
export: (
Expand All @@ -55,4 +55,5 @@ export interface OTLPGRPCExporterConfigNode extends OTLPExporterConfigBase {
export enum ServiceClientType {
SPANS,
METRICS,
LOGS,
}
39 changes: 25 additions & 14 deletions experimental/packages/otlp-grpc-exporter-base/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,31 @@ export function onInit<ExportItem, ServiceRequest>(
'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) {
Expand Down

0 comments on commit e6214a6

Please sign in to comment.