@@ -37,19 +37,22 @@ pub const OTEL_EXPORTER_OTLP_METRICS_COMPRESSION: &str = "OTEL_EXPORTER_OTLP_MET
3737/// Note: this is only supported for HTTP.
3838pub const OTEL_EXPORTER_OTLP_METRICS_HEADERS : & str = "OTEL_EXPORTER_OTLP_METRICS_HEADERS" ;
3939
40+ /// A builder for creating a new [MetricExporter].
4041#[ derive( Debug , Default , Clone ) ]
4142pub struct MetricExporterBuilder < C > {
4243 client : C ,
4344 temporality : Temporality ,
4445}
4546
4647impl MetricExporterBuilder < NoExporterBuilderSet > {
48+ /// Create a new [MetricExporterBuilder] with default settings.
4749 pub fn new ( ) -> Self {
4850 MetricExporterBuilder :: default ( )
4951 }
5052}
5153
5254impl < C > MetricExporterBuilder < C > {
55+ /// With the gRPC Tonic transport.
5356 #[ cfg( feature = "grpc-tonic" ) ]
5457 pub fn with_tonic ( self ) -> MetricExporterBuilder < TonicExporterBuilderSet > {
5558 MetricExporterBuilder {
@@ -58,6 +61,7 @@ impl<C> MetricExporterBuilder<C> {
5861 }
5962 }
6063
64+ /// With the HTTP transport.
6165 #[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
6266 pub fn with_http ( self ) -> MetricExporterBuilder < HttpExporterBuilderSet > {
6367 MetricExporterBuilder {
@@ -66,6 +70,7 @@ impl<C> MetricExporterBuilder<C> {
6670 }
6771 }
6872
73+ /// Set the temporality for the metrics.
6974 pub fn with_temporality ( self , temporality : Temporality ) -> MetricExporterBuilder < C > {
7075 MetricExporterBuilder {
7176 client : self . client ,
@@ -76,6 +81,7 @@ impl<C> MetricExporterBuilder<C> {
7681
7782#[ cfg( feature = "grpc-tonic" ) ]
7883impl MetricExporterBuilder < TonicExporterBuilderSet > {
84+ /// Build the [MetricExporter] with the gRPC Tonic transport.
7985 pub fn build ( self ) -> Result < MetricExporter , ExporterBuildError > {
8086 let exporter = self . client . 0 . build_metrics_exporter ( self . temporality ) ?;
8187 opentelemetry:: otel_debug!( name: "MetricExporterBuilt" ) ;
@@ -85,6 +91,7 @@ impl MetricExporterBuilder<TonicExporterBuilderSet> {
8591
8692#[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
8793impl MetricExporterBuilder < HttpExporterBuilderSet > {
94+ /// Build the [MetricExporter] with the HTTP transport.
8895 pub fn build ( self ) -> Result < MetricExporter , ExporterBuildError > {
8996 let exporter = self . client . 0 . build_metrics_exporter ( self . temporality ) ?;
9097 Ok ( exporter)
0 commit comments