Struct opentelemetry_jaeger::config::collector::CollectorPipeline
source · pub struct CollectorPipeline { /* private fields */ }
collector_client
or wasm_collector_client
only.Expand description
CollectorPipeline config and build a exporter targeting a jaeger collector using HTTP protocol.
Environment variables
-
OTEL_EXPORTER_JAEGER_ENDPOINT
: set the endpoint of the collector. Usually starts withhttp://
orhttps://
-
OTEL_EXPORTER_JAEGER_TIMEOUT
: set the timeout of the http client timeout. It only applies to build in http clients. -
OTEL_EXPORTER_JAEGER_USER
: set the username. Part of the authentication for the collector. It only applies to build in http clients. -
OTEL_EXPORTER_JAEGER_PASSWORD
: set the password. Part of the authentication for the collector. It only applies to build in http clients.
Built-in http clients
To help user setup the exporter, opentelemetry-jaeger
provides the following build in http client
implementation and relative configurations.
- hyper, requires
hyper_collector_client
feature enabled, usewith_hyper
function to setup. - surf, requires
surf_collector_client
feature enabled, usewith_surf
function to setup. - isahc, requires
isahc_collector_client
feature enabled, usewith_isahc
function to setup. - reqwest, requires
reqwest_collector_client
feature enabled, usewith_reqwest
function to setup. - reqwest blocking client, requires
reqwest_blocking_collector_client
feature enabled, usewith_reqwest_blocking
function to setup.
Additionally you can enable https
Note that the functions to setup build in http clients override each other. That means if you have a pipeline with the following setup
let tracer = opentelemetry_jaeger::new_collector_pipeline()
.with_surf()
.with_reqwest()
.install_batch(opentelemetry::runtime::Tokio)
The pipeline will use reqwest http client.
Implementations§
source§impl CollectorPipeline
impl CollectorPipeline
sourcepub fn with_timeout(self, collector_timeout: Duration) -> Self
Available on crate feature collector_client
only.
pub fn with_timeout(self, collector_timeout: Duration) -> Self
collector_client
only.Set the http client timeout.
This function only applies to build in http clients.
Default to be 10s.
sourcepub fn with_endpoint<T>(self, collector_endpoint: T) -> Selfwhere
Uri: TryFrom<T>,
<Uri as TryFrom<T>>::Error: Into<InvalidUri>,
pub fn with_endpoint<T>(self, collector_endpoint: T) -> Selfwhere Uri: TryFrom<T>, <Uri as TryFrom<T>>::Error: Into<InvalidUri>,
Set the collector endpoint.
E.g. “http://localhost:14268/api/traces”
sourcepub fn with_username<S: Into<String>>(self, collector_username: S) -> Self
pub fn with_username<S: Into<String>>(self, collector_username: S) -> Self
Set the username used in authentication to communicate with the collector.
Note that if the password is not set by calling with_password
or set OTEL_EXPORTER_JAEGER_PASSWORD
environment variables. The username will be ignored.
This function only applies to build in http clients.
sourcepub fn with_password<S: Into<String>>(self, collector_password: S) -> Self
pub fn with_password<S: Into<String>>(self, collector_password: S) -> Self
Set the password used in authentication to communicate with the collector.
Note that if the username is not set by calling with_username
or set OTEL_EXPORTER_JAEGER_USER
environment variables. The username will be ignored.
This function only applies to build in http clients.
sourcepub fn collector_username(&self) -> Option<String>
pub fn collector_username(&self) -> Option<String>
Get collector’s username set in the builder. Default to be the value of
OTEL_EXPORTER_JAEGER_USER
environment variable.
If users uses custom http client. This function can help retrieve the value of
OTEL_EXPORTER_JAEGER_USER
environment variable.
sourcepub fn collector_password(&self) -> Option<String>
pub fn collector_password(&self) -> Option<String>
Get the collector’s password set in the builder. Default to be the value of
OTEL_EXPORTER_JAEGER_PASSWORD
environment variable.
If users uses custom http client. This function can help retrieve the value of
OTEL_EXPORTER_JAEGER_PASSWORD
environment variable.
sourcepub fn with_http_client<T: HttpClient + 'static>(self, client: T) -> Self
Available on crate feature collector_client
only.
pub fn with_http_client<T: HttpClient + 'static>(self, client: T) -> Self
collector_client
only.Custom http client used to send spans.
Note that all configuration other than the endpoint
are not
applicable to custom clients.
sourcepub fn with_isahc(self) -> Self
Available on crate feature isahc_collector_client
only.
pub fn with_isahc(self) -> Self
isahc_collector_client
only.Use isahc http client in the exporter.
sourcepub fn with_surf(self) -> Self
Available on crate feature surf_collector_client
only.
pub fn with_surf(self) -> Self
surf_collector_client
only.Use surf http client in the exporter.
sourcepub fn with_reqwest(self) -> Self
Available on crate feature reqwest_collector_client
only.
pub fn with_reqwest(self) -> Self
reqwest_collector_client
only.Use reqwest http client in the exporter.
sourcepub fn with_reqwest_blocking(self) -> Self
Available on crate feature reqwest_blocking_collector_client
only.
pub fn with_reqwest_blocking(self) -> Self
reqwest_blocking_collector_client
only.Use reqwest blocking http client in the exporter.
sourcepub fn with_hyper(self) -> Self
Available on crate feature hyper_collector_client
only.
pub fn with_hyper(self) -> Self
hyper_collector_client
only.Use hyper http client in the exporter.
sourcepub fn with_service_name<T: Into<String>>(self, service_name: T) -> Self
pub fn with_service_name<T: Into<String>>(self, service_name: T) -> Self
Set the service name of the application. It generally is the name of application.
Critically, Jaeger backend depends on Span.Process.ServiceName
to identify the service
that produced the spans.
Opentelemetry allows set the service name using multiple methods. This functions takes priority over all other methods.
If the service name is not set. It will default to be unknown_service
.
Config whether to export information of instrumentation library.
It’s required to report instrumentation library as span tags. However it does have a overhead on performance, performance sensitive applications can use this function to opt out reporting instrumentation library.
Default to be true
.
sourcepub fn with_trace_config(self, config: Config) -> Self
pub fn with_trace_config(self, config: Config) -> Self
Assign the opentelemetry SDK configurations for the exporter pipeline.
For mapping between opentelemetry configurations and Jaeger spans. Please refer the spec.
Examples
Set service name via resource.
use opentelemetry::{sdk::{self, Resource}, KeyValue};
let pipeline = opentelemetry_jaeger::new_collector_pipeline()
.with_trace_config(
sdk::trace::Config::default()
.with_resource(Resource::new(vec![KeyValue::new("service.name", "my-service")]))
);
sourcepub fn with_batch_processor_config(self, config: BatchConfig) -> Self
pub fn with_batch_processor_config(self, config: BatchConfig) -> Self
Assign the batch span processor for the exporter pipeline.
Examples
Set max queue size.
use opentelemetry::sdk::trace::BatchConfig;
let pipeline = opentelemetry_jaeger::new_collector_pipeline()
.with_batch_processor_config(
BatchConfig::default().with_max_queue_size(200)
);
sourcepub fn build_batch<R: JaegerTraceRuntime>(
self,
runtime: R
) -> Result<TracerProvider, TraceError>
pub fn build_batch<R: JaegerTraceRuntime>( self, runtime: R ) -> Result<TracerProvider, TraceError>
Build a TracerProvider
using a async exporter and configurations from the pipeline.
The exporter will collect spans in a batch and send them to the agent.
It’s possible to lose spans up to a batch when the application shuts down. So users should
use shut_down_tracer_provider
to block the shut down process until
all remaining spans have been sent.
Commonly used runtime are provided via rt-tokio
, rt-tokio-current-thread
, rt-async-std
features.
sourcepub fn install_batch<R: JaegerTraceRuntime>(
self,
runtime: R
) -> Result<Tracer, TraceError>
pub fn install_batch<R: JaegerTraceRuntime>( self, runtime: R ) -> Result<Tracer, TraceError>
Similar to build_batch
but also returns a tracer from the
tracer provider.
The tracer name is opentelemetry-jaeger
. The tracer version will be the version of this crate.
sourcepub fn build_collector_exporter<R>(self) -> Result<Exporter, TraceError>where
R: JaegerTraceRuntime,
pub fn build_collector_exporter<R>(self) -> Result<Exporter, TraceError>where R: JaegerTraceRuntime,
Build an jaeger exporter targeting a jaeger collector.
Trait Implementations§
source§impl Debug for CollectorPipeline
impl Debug for CollectorPipeline
Auto Trait Implementations§
impl !RefUnwindSafe for CollectorPipeline
impl Send for CollectorPipeline
impl Sync for CollectorPipeline
impl Unpin for CollectorPipeline
impl !UnwindSafe for CollectorPipeline
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§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> 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