@@ -37,19 +37,22 @@ pub const OTEL_EXPORTER_OTLP_METRICS_COMPRESSION: &str = "OTEL_EXPORTER_OTLP_MET
37
37
/// Note: this is only supported for HTTP.
38
38
pub const OTEL_EXPORTER_OTLP_METRICS_HEADERS : & str = "OTEL_EXPORTER_OTLP_METRICS_HEADERS" ;
39
39
40
+ /// A builder for creating a new [MetricExporter].
40
41
#[ derive( Debug , Default , Clone ) ]
41
42
pub struct MetricExporterBuilder < C > {
42
43
client : C ,
43
44
temporality : Temporality ,
44
45
}
45
46
46
47
impl MetricExporterBuilder < NoExporterBuilderSet > {
48
+ /// Create a new [MetricExporterBuilder] with default settings.
47
49
pub fn new ( ) -> Self {
48
50
MetricExporterBuilder :: default ( )
49
51
}
50
52
}
51
53
52
54
impl < C > MetricExporterBuilder < C > {
55
+ /// With the gRPC Tonic transport.
53
56
#[ cfg( feature = "grpc-tonic" ) ]
54
57
pub fn with_tonic ( self ) -> MetricExporterBuilder < TonicExporterBuilderSet > {
55
58
MetricExporterBuilder {
@@ -58,6 +61,7 @@ impl<C> MetricExporterBuilder<C> {
58
61
}
59
62
}
60
63
64
+ /// With the HTTP transport.
61
65
#[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
62
66
pub fn with_http ( self ) -> MetricExporterBuilder < HttpExporterBuilderSet > {
63
67
MetricExporterBuilder {
@@ -66,6 +70,7 @@ impl<C> MetricExporterBuilder<C> {
66
70
}
67
71
}
68
72
73
+ /// Set the temporality for the metrics.
69
74
pub fn with_temporality ( self , temporality : Temporality ) -> MetricExporterBuilder < C > {
70
75
MetricExporterBuilder {
71
76
client : self . client ,
@@ -76,6 +81,7 @@ impl<C> MetricExporterBuilder<C> {
76
81
77
82
#[ cfg( feature = "grpc-tonic" ) ]
78
83
impl MetricExporterBuilder < TonicExporterBuilderSet > {
84
+ /// Build the [MetricExporter] with the gRPC Tonic transport.
79
85
pub fn build ( self ) -> Result < MetricExporter , ExporterBuildError > {
80
86
let exporter = self . client . 0 . build_metrics_exporter ( self . temporality ) ?;
81
87
opentelemetry:: otel_debug!( name: "MetricExporterBuilt" ) ;
@@ -85,6 +91,7 @@ impl MetricExporterBuilder<TonicExporterBuilderSet> {
85
91
86
92
#[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
87
93
impl MetricExporterBuilder < HttpExporterBuilderSet > {
94
+ /// Build the [MetricExporter] with the HTTP transport.
88
95
pub fn build ( self ) -> Result < MetricExporter , ExporterBuildError > {
89
96
let exporter = self . client . 0 . build_metrics_exporter ( self . temporality ) ?;
90
97
Ok ( exporter)
0 commit comments