@@ -225,23 +225,21 @@ pub use crate::exporter::Compression;
225225pub use crate :: exporter:: ExportConfig ;
226226#[ cfg( feature = "trace" ) ]
227227pub use crate :: span:: {
228- OtlpTracePipeline , SpanExporter , SpanExporterBuilder , OTEL_EXPORTER_OTLP_TRACES_COMPRESSION ,
228+ SpanExporter , SpanExporterBuilder , OTEL_EXPORTER_OTLP_TRACES_COMPRESSION ,
229229 OTEL_EXPORTER_OTLP_TRACES_ENDPOINT , OTEL_EXPORTER_OTLP_TRACES_HEADERS ,
230230 OTEL_EXPORTER_OTLP_TRACES_TIMEOUT ,
231231} ;
232232
233233#[ cfg( feature = "metrics" ) ]
234234pub use crate :: metric:: {
235- MetricsExporter , MetricsExporterBuilder , OtlpMetricPipeline ,
236- OTEL_EXPORTER_OTLP_METRICS_COMPRESSION , OTEL_EXPORTER_OTLP_METRICS_ENDPOINT ,
235+ MetricsExporter , OTEL_EXPORTER_OTLP_METRICS_COMPRESSION , OTEL_EXPORTER_OTLP_METRICS_ENDPOINT ,
237236 OTEL_EXPORTER_OTLP_METRICS_HEADERS , OTEL_EXPORTER_OTLP_METRICS_TIMEOUT ,
238237} ;
239238
240239#[ cfg( feature = "logs" ) ]
241240pub use crate :: logs:: {
242- LogExporter , LogExporterBuilder , OtlpLogPipeline , OTEL_EXPORTER_OTLP_LOGS_COMPRESSION ,
243- OTEL_EXPORTER_OTLP_LOGS_ENDPOINT , OTEL_EXPORTER_OTLP_LOGS_HEADERS ,
244- OTEL_EXPORTER_OTLP_LOGS_TIMEOUT ,
241+ LogExporter , OTEL_EXPORTER_OTLP_LOGS_COMPRESSION , OTEL_EXPORTER_OTLP_LOGS_ENDPOINT ,
242+ OTEL_EXPORTER_OTLP_LOGS_HEADERS , OTEL_EXPORTER_OTLP_LOGS_TIMEOUT ,
245243} ;
246244
247245pub use crate :: exporter:: {
@@ -253,6 +251,38 @@ pub use crate::exporter::{
253251
254252use opentelemetry_sdk:: export:: ExportError ;
255253
254+ /// OTLP span exporter builder.
255+ #[ derive( Debug ) ]
256+ // This enum only used during initialization stage of application. The overhead should be OK.
257+ // Users can also disable the unused features to make the overhead on object size smaller.
258+ #[ allow( clippy:: large_enum_variant) ]
259+ #[ non_exhaustive]
260+ pub enum ExporterOption {
261+ /// Tonic span exporter builder
262+ #[ cfg( feature = "grpc-tonic" ) ]
263+ Tonic ( TonicExporterBuilder ) ,
264+ /// Http span exporter builder
265+ #[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
266+ Http ( HttpExporterBuilder ) ,
267+ /// Missing exporter builder
268+ #[ doc( hidden) ]
269+ #[ cfg( not( any( feature = "http-proto" , feature = "grpc-tonic" ) ) ) ]
270+ Unconfigured ,
271+ }
272+
273+ impl Default for ExporterOption {
274+ fn default ( ) -> Self {
275+ #[ cfg( feature = "grpc-tonic" ) ]
276+ ExporterOption :: Tonic ( TonicExporterBuilder :: default ( ) )
277+ }
278+ }
279+
280+ #[ derive( Debug , Default , Clone ) ]
281+ pub struct NoExporterBuilder ;
282+
283+ #[ derive( Debug , Default ) ]
284+ pub struct ExporterBuilder ( ExporterOption ) ;
285+
256286#[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
257287pub use crate :: exporter:: http:: HttpExporterBuilder ;
258288
@@ -262,55 +292,6 @@ pub use crate::exporter::tonic::{TonicConfig, TonicExporterBuilder};
262292#[ cfg( feature = "serialize" ) ]
263293use serde:: { Deserialize , Serialize } ;
264294
265- /// General builder for both tracing and metrics.
266- #[ derive( Debug ) ]
267- pub struct OtlpPipeline ;
268-
269- /// Build a OTLP metrics or tracing exporter builder. See functions below to understand
270- /// what's currently supported.
271- #[ derive( Debug ) ]
272- pub struct OtlpExporterPipeline ;
273-
274- impl OtlpExporterPipeline {
275- /// Use tonic as grpc layer, return a `TonicExporterBuilder` to config tonic and build the exporter.
276- ///
277- /// This exporter can be used in both `tracing` and `metrics` pipeline.
278- #[ cfg( feature = "grpc-tonic" ) ]
279- pub fn tonic ( self ) -> TonicExporterBuilder {
280- TonicExporterBuilder :: default ( )
281- }
282-
283- /// Use HTTP as transport layer, return a `HttpExporterBuilder` to config the http transport
284- /// and build the exporter.
285- ///
286- /// This exporter can be used in both `tracing` and `metrics` pipeline.
287- #[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
288- pub fn http ( self ) -> HttpExporterBuilder {
289- HttpExporterBuilder :: default ( )
290- }
291- }
292-
293- /// Create a new pipeline builder with the recommended configuration.
294- ///
295- /// ## Examples
296- ///
297- /// ```no_run
298- /// fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
299- /// # #[cfg(feature = "trace")]
300- /// let tracing_builder = opentelemetry_otlp::new_pipeline().tracing();
301- ///
302- /// Ok(())
303- /// }
304- /// ```
305- pub fn new_pipeline ( ) -> OtlpPipeline {
306- OtlpPipeline
307- }
308-
309- /// Create a builder to build OTLP metrics exporter or tracing exporter.
310- pub fn new_exporter ( ) -> OtlpExporterPipeline {
311- OtlpExporterPipeline
312- }
313-
314295/// Wrap type for errors from this crate.
315296#[ derive( thiserror:: Error , Debug ) ]
316297pub enum Error {
0 commit comments