Struct AgentPipeline

Source
pub struct AgentPipeline { /* private fields */ }
๐Ÿ‘ŽDeprecated since 0.21.0: Please migrate to opentelemetry-otlp exporter.
Expand description

Deprecation Notice: Ingestion of OTLP is now supported in Jaeger please check crates.io for more details.

AgentPipeline config and build a exporter targeting a jaeger agent using UDP as transport layer protocol.

ยงUDP packet max length

The exporter uses UDP to communicate with the agent. UDP requests may be rejected if itโ€™s too long. See UDP packet size for details.

Users can utilise with_max_packet_size and with_auto_split_batch to avoid spans loss or UDP requests failure.

The default max_packet_size is 65000(why 65000?). If your platform has a smaller limit on UDP packet. You will need to adjust the max_packet_size accordingly.

Set auto_split_batch to true will config the exporter to split the batch based on max_packet_size automatically. Note that it has a performance overhead as every batch could require multiple requests to export.

For example, OSX UDP packet limit is 9216 by default. You can configure the pipeline as following to avoid UDP packet breaches the limit.

    let tracer = opentelemetry_jaeger::new_agent_pipeline()
        .with_endpoint("localhost:6831")
        .with_service_name("my_app")
        .with_max_packet_size(9_216)
        .with_auto_split_batch(true)
        .install_batch(Tokio).unwrap();

ยงEnvironment variables

The following environment variables are available to configure the agent exporter.

  • OTEL_EXPORTER_JAEGER_AGENT_HOST, set the host of the agent. If the OTEL_EXPORTER_JAEGER_AGENT_HOST is not set, the value will be ignored.
  • OTEL_EXPORTER_JAEGER_AGENT_PORT, set the port of the agent. If the OTEL_EXPORTER_JAEGER_AGENT_HOST is not set, the exporter will use 127.0.0.1 as the host.

Implementationsยง

Sourceยง

impl AgentPipeline

Source

pub fn with_endpoint<T: Into<String>>(self, agent_endpoint: T) -> Self

set the endpoint of the agent.

It usually composed by host ip and the port number. Any valid socket address can be used.

Default to be 127.0.0.1:6831.

Source

pub fn with_max_packet_size(self, max_packet_size: usize) -> Self

Assign the max packet size in bytes.

It should be consistent with the limit of platforms. Otherwise, UDP requests maybe reject with error like thrift agent failed with transport error or thrift agent failed with message too long.

The exporter will cut off spans if the batch is long. To avoid this, set auto_split_batch to true to split a batch into multiple UDP packets.

Default to be 65000.

Source

pub fn with_auto_split_batch(self, should_auto_split: bool) -> Self

Config whether to auto split batches.

When auto split is set to true, the exporter will try to split the batch into smaller ones so that there will be minimal data loss. It will impact the performance.

Note that if the length of one serialized span is longer than the max_packet_size. The exporter will return an error as it cannot export the span. Use jaeger collector instead of jaeger agent may be help in this case as the exporter will use HTTP to communicate with jaeger collector.

Default to be false.

Source

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.

Source

pub fn with_instrumentation_library_tags(self, should_export: bool) -> Self

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.

Source

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::KeyValue;
use opentelemetry_sdk::{Resource, trace::Config};

let pipeline = opentelemetry_jaeger::new_agent_pipeline()
                .with_trace_config(
                      Config::default()
                        .with_resource(Resource::new(vec![KeyValue::new("service.name", "my-service")]))
                );
Source

pub fn with_batch_processor_config(self, config: BatchConfig) -> Self

Assign the batch span processor for the exporter pipeline.

If a simple span processor is used by install_simple or build_simple, then this config will not be ignored.

ยงExamples

Set max queue size.

use opentelemetry_sdk::trace::BatchConfigBuilder;

let pipeline = opentelemetry_jaeger::new_agent_pipeline()
                .with_batch_processor_config(
                      BatchConfigBuilder::default()
                        .with_max_queue_size(200)
                        .build()
                );
Source

pub fn build_simple(self) -> Result<TracerProvider, TraceError>

Build a TracerProvider using a blocking exporter and configurations from the pipeline.

The exporter will send each span to the agent upon the span ends.

Source

pub fn build_batch<R>(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.

Source

pub fn install_simple(self) -> Result<Tracer, TraceError>

Similar to build_simple 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.

Source

pub fn install_batch<R>(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.

Source

pub fn build_async_agent_exporter<R>( self, runtime: R, ) -> Result<Exporter, TraceError>

Build an jaeger exporter targeting a jaeger agent and running on the async runtime.

Source

pub fn build_sync_agent_exporter(self) -> Result<Exporter, TraceError>

Build an jaeger exporter targeting a jaeger agent and running on the sync runtime.

Trait Implementationsยง

Sourceยง

impl Debug for AgentPipeline

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Sourceยง

impl Default for AgentPipeline

Sourceยง

fn default() -> Self

Returns the โ€œdefault valueโ€ for a type. Read more

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> FutureExt for T

Sourceยง

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Sourceยง

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Sourceยง

impl<T> Instrument for T

Sourceยง

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Sourceยง

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Sourceยง

impl<T> Instrument for T

Sourceยง

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Sourceยง

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> IntoRequest<T> for T

Sourceยง

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Sourceยง

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Sourceยง

fn vzip(self) -> V

Sourceยง

impl<T> WithSubscriber for T

Sourceยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

impl<T> WithSubscriber for T

Sourceยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

impl<T> ErasedDestructor for T
where T: 'static,

Sourceยง

impl<T> MaybeSendSync for T