pub struct TonicExporterBuilder { /* private fields */ }
Expand description
Configuration for the tonic OTLP GRPC exporter.
It allows you to
- add additional metadata
- set tls config (via the
tls
feature) - specify custom channels
§Examples
use opentelemetry_sdk::metrics::reader::{
DefaultAggregationSelector, DefaultTemporalitySelector,
};
// Create a span exporter you can use to when configuring tracer providers
let span_exporter = opentelemetry_otlp::new_exporter().tonic().build_span_exporter()?;
// Create a metrics exporter you can use when configuring meter providers
let metrics_exporter = opentelemetry_otlp::new_exporter()
.tonic()
.build_metrics_exporter(
Box::new(DefaultAggregationSelector::new()),
Box::new(DefaultTemporalitySelector::new()),
)?;
// Create a log exporter you can use when configuring logger providers
let log_exporter = opentelemetry_otlp::new_exporter().tonic().build_log_exporter()?;
Implementations§
Source§impl TonicExporterBuilder
impl TonicExporterBuilder
Sourcepub fn with_metadata(self, metadata: MetadataMap) -> Self
pub fn with_metadata(self, metadata: MetadataMap) -> Self
Set custom metadata entries to send to the collector.
Sourcepub fn with_compression(self, compression: Compression) -> Self
pub fn with_compression(self, compression: Compression) -> Self
Set the compression algorithm to use when communicating with the collector.
Sourcepub fn with_channel(self, channel: Channel) -> Self
pub fn with_channel(self, channel: Channel) -> Self
Use channel
as tonic’s transport channel.
this will override tls config and should only be used
when working with non-HTTP transports.
Users MUST make sure the ExportConfig::timeout
is
the same as the channel’s timeout.
Sourcepub fn with_interceptor<I>(self, interceptor: I) -> Self
pub fn with_interceptor<I>(self, interceptor: I) -> Self
Use a custom interceptor
to modify each outbound request.
this can be used to modify the grpc metadata, for example
to inject auth tokens.
Sourcepub fn build_log_exporter(self) -> Result<LogExporter, LogError>
pub fn build_log_exporter(self) -> Result<LogExporter, LogError>
Build a new tonic log exporter
Sourcepub fn build_metrics_exporter(
self,
aggregation_selector: Box<dyn AggregationSelector>,
temporality_selector: Box<dyn TemporalitySelector>,
) -> Result<MetricsExporter>
pub fn build_metrics_exporter( self, aggregation_selector: Box<dyn AggregationSelector>, temporality_selector: Box<dyn TemporalitySelector>, ) -> Result<MetricsExporter>
Build a new tonic metrics exporter
Sourcepub fn build_span_exporter(self) -> Result<SpanExporter, TraceError>
pub fn build_span_exporter(self) -> Result<SpanExporter, TraceError>
Build a new tonic span exporter
Trait Implementations§
Source§impl Debug for TonicExporterBuilder
impl Debug for TonicExporterBuilder
Source§impl Default for TonicExporterBuilder
impl Default for TonicExporterBuilder
Source§impl From<TonicExporterBuilder> for LogExporterBuilder
impl From<TonicExporterBuilder> for LogExporterBuilder
Source§fn from(exporter: TonicExporterBuilder) -> Self
fn from(exporter: TonicExporterBuilder) -> Self
Converts to this type from the input type.
Source§impl From<TonicExporterBuilder> for MetricsExporterBuilder
impl From<TonicExporterBuilder> for MetricsExporterBuilder
Source§fn from(exporter: TonicExporterBuilder) -> Self
fn from(exporter: TonicExporterBuilder) -> Self
Converts to this type from the input type.
Source§impl From<TonicExporterBuilder> for SpanExporterBuilder
impl From<TonicExporterBuilder> for SpanExporterBuilder
Source§fn from(exporter: TonicExporterBuilder) -> Self
fn from(exporter: TonicExporterBuilder) -> Self
Converts to this type from the input type.
Source§impl HasExportConfig for TonicExporterBuilder
impl HasExportConfig for TonicExporterBuilder
Source§fn export_config(&mut self) -> &mut ExportConfig
fn export_config(&mut self) -> &mut ExportConfig
Return a mutable reference to the export config within the exporter builders.
Auto Trait Implementations§
impl Freeze for TonicExporterBuilder
impl !RefUnwindSafe for TonicExporterBuilder
impl Send for TonicExporterBuilder
impl Sync for TonicExporterBuilder
impl Unpin for TonicExporterBuilder
impl !UnwindSafe for TonicExporterBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request
Source§impl<B> WithExportConfig for Bwhere
B: HasExportConfig,
impl<B> WithExportConfig for Bwhere
B: HasExportConfig,
Source§fn with_endpoint<T>(self, endpoint: T) -> B
fn with_endpoint<T>(self, endpoint: T) -> B
Set the address of the OTLP collector. If not set or set to empty string, the default address is used.
Source§fn with_protocol(self, protocol: Protocol) -> B
fn with_protocol(self, protocol: Protocol) -> B
Set the protocol to use when communicating with the collector. Read more
Source§fn with_timeout(self, timeout: Duration) -> B
fn with_timeout(self, timeout: Duration) -> B
Set the timeout to the collector.
Source§fn with_export_config(self, exporter_config: ExportConfig) -> B
fn with_export_config(self, exporter_config: ExportConfig) -> B
Set export config. This will override all previous configuration.