pub struct OtlpStdoutSpanExporter { /* private fields */ }Expand description
A span exporter that writes spans to stdout in OTLP format
This exporter implements the OpenTelemetry SpanExporter trait and writes spans
to stdout in OTLP format with Protobuf serialization and GZIP compression.
§Features
- Configurable GZIP compression level (0-9)
- Environment variable support for service name and headers
- Efficient batching of spans
- Base64 encoding of compressed data
§Example
use opentelemetry_sdk::runtime;
use otlp_stdout_span_exporter::OtlpStdoutSpanExporter;
// Create an exporter with maximum compression
let exporter = OtlpStdoutSpanExporter::builder()
.compression_level(9)
.build();Implementations§
Source§impl OtlpStdoutSpanExporter
impl OtlpStdoutSpanExporter
Sourcepub fn builder() -> OtlpStdoutSpanExporterBuilder
pub fn builder() -> OtlpStdoutSpanExporterBuilder
Create a new OtlpStdoutSpanExporter with default configuration.
This uses a GZIP compression level of 6 unless overridden by an environment variable.
§Output Type
The output type is determined in the following order:
- The
OTLP_STDOUT_SPAN_EXPORTER_OUTPUT_TYPEenvironment variable if set (“pipe” or “stdout”) - Constructor parameter (pipe)
- Default (stdout)
§Example
use otlp_stdout_span_exporter::OtlpStdoutSpanExporter;
let exporter = OtlpStdoutSpanExporter::default();Trait Implementations§
Source§impl Debug for OtlpStdoutSpanExporter
impl Debug for OtlpStdoutSpanExporter
Source§impl Default for OtlpStdoutSpanExporter
impl Default for OtlpStdoutSpanExporter
Source§fn default() -> OtlpStdoutSpanExporter
fn default() -> OtlpStdoutSpanExporter
Source§impl SpanExporter for OtlpStdoutSpanExporter
impl SpanExporter for OtlpStdoutSpanExporter
Source§fn export(
&self,
batch: Vec<SpanData>,
) -> impl Future<Output = Result<(), OTelSdkError>> + Send
fn export( &self, batch: Vec<SpanData>, ) -> impl Future<Output = Result<(), OTelSdkError>> + Send
Export spans to stdout in OTLP format
This function:
- Converts spans to OTLP format
- Serializes them to protobuf
- Compresses the data with GZIP
- Base64 encodes the result
- Writes a JSON object to stdout
§Arguments
batch- A vector of spans to export
§Returns
Returns a resolved future with Ok(()) if the export was successful, or a TraceError if it failed
Source§fn shutdown(&mut self) -> Result<(), OTelSdkError>
fn shutdown(&mut self) -> Result<(), OTelSdkError>
Shuts down the exporter
This is a no-op for stdout export as no cleanup is needed.
§Returns
Returns Ok(()) as there is nothing to clean up.
Source§fn force_flush(&mut self) -> Result<(), OTelSdkError>
fn force_flush(&mut self) -> Result<(), OTelSdkError>
Force flushes any pending spans
This is a no-op for stdout export as spans are written immediately.
§Returns
Returns Ok(()) as there is nothing to flush.
Source§fn set_resource(&mut self, resource: &Resource)
fn set_resource(&mut self, resource: &Resource)
Sets the resource for this exporter.
This method stores a clone of the provided resource to be used when exporting spans. The resource represents the entity producing telemetry and will be included in the exported trace data.
§Arguments
resource- The resource to associate with this exporter
Auto Trait Implementations§
impl Freeze for OtlpStdoutSpanExporter
impl !RefUnwindSafe for OtlpStdoutSpanExporter
impl Send for OtlpStdoutSpanExporter
impl Sync for OtlpStdoutSpanExporter
impl Unpin for OtlpStdoutSpanExporter
impl !UnwindSafe for OtlpStdoutSpanExporter
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
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>
T in a tonic::Request