Struct Builder

Source
pub struct Builder { /* private fields */ }
Expand description

Builder for creating a tracing tracer, a layer or a subscriber that sends traces to Axiom via the OpenTelemetry protocol. The API token is read from the AXIOM_TOKEN environment variable. The dataset name is read from the AXIOM_DATASET environment variable. The URL defaults to Axiom Cloud whose URL is https://cloud.axiom.co but can be overridden by setting the AXIOM_URL environment variable for testing purposes

Implementations§

Source§

impl Builder

Source

pub fn with_dataset( self, dataset_name: impl Into<String>, ) -> Result<Self, Error>

Set the Axiom dataset name to use. The dataset name is the name of the persistent dataset in Axiom cloud that will store the traces and make them available for querying using APL, the Axiom SDK or the Axiom CLI.

§Errors

If the dataset name is empty.

Source

pub fn with_token(self, token: impl Into<String>) -> Result<Self, Error>

Set the Axiom API token to use.

§Errors

If the token is empty or does not start with xaat- (aka is not a api token).

Source

pub fn with_url(self, url: &str) -> Result<Self, Error>

Set the Axiom API URL to use. Defaults to Axiom Cloud. When not set Axiom Cloud is used.

§Errors

If the URL is not a valid URL.

Source

pub fn with_trace_config(self, trace_config: impl Into<TraceConfig>) -> Self

Set the trace config.

Source

pub fn with_service_name(self, service_name: impl Into<String>) -> Self

Set the service name. It will be set as a resource attribute with the name service_name.

Source

pub fn with_tags<T, K, V>(self, tags: T) -> Self
where K: Into<Key>, V: Into<Value>, T: Iterator<Item = (K, V)>,

Set the resource tags for the open telemetry tracer that publishes to Axiom. These tags will be added to all spans.

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Sets the collector timeout for the OTLP exporter. The default is 3 seconds.

Source

pub fn with_env(self) -> Result<Self, Error>

Load defaults from environment variables, if variables were set before this call they will not be replaced.

The following environment variables are used:

  • AXIOM_TOKEN
  • AXIOM_DATASET
  • AXIOM_URL
§Errors

If an environment variable is not valid UTF8, or any of their values are invalid.

Source

pub fn build<S>(self) -> Result<OpenTelemetryLayer<S, Tracer>, Error>
where S: Subscriber + for<'span> LookupSpan<'span>,

Create a layer which sends traces to Axiom that can be added to the tracing layers.

§Errors

Returns an error if any of the settings are not valid

Trait Implementations§

Source§

impl Debug for Builder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Builder

Source§

fn default() -> Builder

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, 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, 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> ErasedDestructor for T
where T: 'static,