22//!
33//! Defines a [LogExporter] to send logs via the OpenTelemetry Protocol (OTLP)
44
5- use async_trait:: async_trait;
65use opentelemetry:: otel_debug;
76use std:: fmt:: Debug ;
87
@@ -108,12 +107,11 @@ impl HasHttpConfig for LogExporterBuilder<HttpExporterBuilderSet> {
108107/// OTLP exporter that sends log data
109108#[ derive( Debug ) ]
110109pub struct LogExporter {
111- //client: Box<dyn opentelemetry_sdk::export::logs::LogExporter>,
112- client : LogExporterInner ,
110+ client : SupportedTransportClient ,
113111}
114112
115113#[ derive( Debug ) ]
116- enum LogExporterInner {
114+ enum SupportedTransportClient {
117115 #[ cfg( feature = "grpc-tonic" ) ]
118116 Tonic ( crate :: exporter:: tonic:: logs:: TonicLogsClient ) ,
119117 #[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
@@ -129,19 +127,18 @@ impl LogExporter {
129127 #[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
130128 pub ( crate ) fn from_http ( client : crate :: exporter:: http:: OtlpHttpClient ) -> Self {
131129 LogExporter {
132- client : LogExporterInner :: Http ( client) ,
130+ client : SupportedTransportClient :: Http ( client) ,
133131 }
134132 }
135133
136134 #[ cfg( feature = "grpc-tonic" ) ]
137135 pub ( crate ) fn from_tonic ( client : crate :: exporter:: tonic:: logs:: TonicLogsClient ) -> Self {
138136 LogExporter {
139- client : LogExporterInner :: Tonic ( client) ,
137+ client : SupportedTransportClient :: Tonic ( client) ,
140138 }
141139 }
142140}
143141
144- #[ async_trait]
145142impl opentelemetry_sdk:: export:: logs:: LogExporter for LogExporter {
146143 #[ allow( clippy:: manual_async_fn) ]
147144 fn export < ' a > (
@@ -151,19 +148,19 @@ impl opentelemetry_sdk::export::logs::LogExporter for LogExporter {
151148 async move {
152149 match & self . client {
153150 #[ cfg( feature = "grpc-tonic" ) ]
154- LogExporterInner :: Tonic ( client) => client. export ( batch) . await ,
151+ SupportedTransportClient :: Tonic ( client) => client. export ( batch) . await ,
155152 #[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
156- LogExporterInner :: Http ( client) => client. export ( batch) . await ,
153+ SupportedTransportClient :: Http ( client) => client. export ( batch) . await ,
157154 }
158155 }
159156 }
160157
161158 fn set_resource ( & mut self , resource : & opentelemetry_sdk:: Resource ) {
162159 match & mut self . client {
163160 #[ cfg( feature = "grpc-tonic" ) ]
164- LogExporterInner :: Tonic ( client) => client. set_resource ( resource) ,
161+ SupportedTransportClient :: Tonic ( client) => client. set_resource ( resource) ,
165162 #[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
166- LogExporterInner :: Http ( client) => client. set_resource ( resource) ,
163+ SupportedTransportClient :: Http ( client) => client. set_resource ( resource) ,
167164 }
168165 }
169166}
0 commit comments