Skip to content

Commit d3f294b

Browse files
committed
Expose SpanExporterBuilder and MetricExporterBuilder
1 parent 3f29f6d commit d3f294b

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

opentelemetry-otlp/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,22 +374,25 @@ pub use crate::exporter::ExporterBuildError;
374374
#[cfg(feature = "trace")]
375375
#[cfg(any(feature = "http-proto", feature = "http-json", feature = "grpc-tonic"))]
376376
pub use crate::span::{
377-
SpanExporter, OTEL_EXPORTER_OTLP_TRACES_COMPRESSION, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
378-
OTEL_EXPORTER_OTLP_TRACES_HEADERS, OTEL_EXPORTER_OTLP_TRACES_TIMEOUT,
377+
SpanExporter, SpanExporterBuilder, OTEL_EXPORTER_OTLP_TRACES_COMPRESSION,
378+
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_HEADERS,
379+
OTEL_EXPORTER_OTLP_TRACES_TIMEOUT,
379380
};
380381

381382
#[cfg(feature = "metrics")]
382383
#[cfg(any(feature = "http-proto", feature = "http-json", feature = "grpc-tonic"))]
383384
pub use crate::metric::{
384-
MetricExporter, OTEL_EXPORTER_OTLP_METRICS_COMPRESSION, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT,
385-
OTEL_EXPORTER_OTLP_METRICS_HEADERS, OTEL_EXPORTER_OTLP_METRICS_TIMEOUT,
385+
MetricExporter, MetricExporterBuilder, OTEL_EXPORTER_OTLP_METRICS_COMPRESSION,
386+
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_HEADERS,
387+
OTEL_EXPORTER_OTLP_METRICS_TIMEOUT,
386388
};
387389

388390
#[cfg(feature = "logs")]
389391
#[cfg(any(feature = "http-proto", feature = "http-json", feature = "grpc-tonic"))]
390392
pub use crate::logs::{
391-
LogExporter, OTEL_EXPORTER_OTLP_LOGS_COMPRESSION, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT,
392-
OTEL_EXPORTER_OTLP_LOGS_HEADERS, OTEL_EXPORTER_OTLP_LOGS_TIMEOUT,
393+
LogExporter, LogExporterBuilder, OTEL_EXPORTER_OTLP_LOGS_COMPRESSION,
394+
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_HEADERS,
395+
OTEL_EXPORTER_OTLP_LOGS_TIMEOUT,
393396
};
394397

395398
#[cfg(any(feature = "http-proto", feature = "http-json"))]

opentelemetry-otlp/src/metric.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,22 @@ pub const OTEL_EXPORTER_OTLP_METRICS_COMPRESSION: &str = "OTEL_EXPORTER_OTLP_MET
3737
/// Note: this is only supported for HTTP.
3838
pub 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)]
4142
pub struct MetricExporterBuilder<C> {
4243
client: C,
4344
temporality: Temporality,
4445
}
4546

4647
impl MetricExporterBuilder<NoExporterBuilderSet> {
48+
/// Create a new [MetricExporterBuilder] with default settings.
4749
pub fn new() -> Self {
4850
MetricExporterBuilder::default()
4951
}
5052
}
5153

5254
impl<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")]
7883
impl 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"))]
8793
impl 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)

opentelemetry-otlp/src/span.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,27 @@ pub const OTEL_EXPORTER_OTLP_TRACES_COMPRESSION: &str = "OTEL_EXPORTER_OTLP_TRAC
3636
/// Note: this is only supported for HTTP.
3737
pub const OTEL_EXPORTER_OTLP_TRACES_HEADERS: &str = "OTEL_EXPORTER_OTLP_TRACES_HEADERS";
3838

39+
/// OTLP span exporter builder
3940
#[derive(Debug, Default, Clone)]
4041
pub struct SpanExporterBuilder<C> {
4142
client: C,
4243
}
4344

4445
impl SpanExporterBuilder<NoExporterBuilderSet> {
46+
/// Create a new [SpanExporterBuilder] with default settings.
4547
pub fn new() -> Self {
4648
SpanExporterBuilder::default()
4749
}
4850

51+
/// With the gRPC Tonic transport.
4952
#[cfg(feature = "grpc-tonic")]
5053
pub fn with_tonic(self) -> SpanExporterBuilder<TonicExporterBuilderSet> {
5154
SpanExporterBuilder {
5255
client: TonicExporterBuilderSet(TonicExporterBuilder::default()),
5356
}
5457
}
5558

59+
/// With the HTTP transport.
5660
#[cfg(any(feature = "http-proto", feature = "http-json"))]
5761
pub fn with_http(self) -> SpanExporterBuilder<HttpExporterBuilderSet> {
5862
SpanExporterBuilder {
@@ -63,6 +67,7 @@ impl SpanExporterBuilder<NoExporterBuilderSet> {
6367

6468
#[cfg(feature = "grpc-tonic")]
6569
impl SpanExporterBuilder<TonicExporterBuilderSet> {
70+
/// Build the [SpanExporter] with the gRPC Tonic transport.
6671
pub fn build(self) -> Result<SpanExporter, ExporterBuildError> {
6772
let span_exporter = self.client.0.build_span_exporter()?;
6873
opentelemetry::otel_debug!(name: "SpanExporterBuilt");
@@ -72,6 +77,7 @@ impl SpanExporterBuilder<TonicExporterBuilderSet> {
7277

7378
#[cfg(any(feature = "http-proto", feature = "http-json"))]
7479
impl SpanExporterBuilder<HttpExporterBuilderSet> {
80+
/// Build the [SpanExporter] with the HTTP transport.
7581
pub fn build(self) -> Result<SpanExporter, ExporterBuildError> {
7682
let span_exporter = self.client.0.build_span_exporter()?;
7783
Ok(span_exporter)

0 commit comments

Comments
 (0)