Struct tracing_axiom::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
impl Builder
sourcepub fn with_dataset(self, dataset_name: impl Into<String>) -> Self
pub fn with_dataset(self, dataset_name: impl Into<String>) -> Self
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.
sourcepub fn with_token(self, token: impl Into<String>) -> Self
pub fn with_token(self, token: impl Into<String>) -> Self
Set the Axiom API token to use.
sourcepub fn with_url(self, url: impl Into<String>) -> Self
pub fn with_url(self, url: impl Into<String>) -> Self
Set the Axiom API URL to use. Defaults to Axiom Cloud.
sourcepub fn with_trace_config(self, trace_config: impl Into<TraceConfig>) -> Self
pub fn with_trace_config(self, trace_config: impl Into<TraceConfig>) -> Self
Set the trace config.
sourcepub fn with_service_name(self, service_name: impl Into<String>) -> Self
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
.
Set the resource tags for the open telemetry tracer that publishes to Axiom. These tags will be added to all spans.
§Errors
Returns an error if a key is invalid.
sourcepub fn init(self) -> Result<(), Error>
pub fn init(self) -> Result<(), Error>
Initialize the global subscriber. This panics if the initialization was
unsuccessful, likely because a global subscriber was already installed or
AXIOM_TOKEN
is not set or invalid.
§Errors
Returns an error if the initialization was unsuccessful, likely because
a global subscriber was already installed or AXIOM_TOKEN
is not set or
invalid.
sourcepub fn layer<S>(
self
) -> Result<Layered<OpenTelemetryLayer<S, Tracer>, AxiomOpenTelemetryLayer<S>, S>, Error>where
S: Subscriber + for<'span> LookupSpan<'span>,
pub fn layer<S>(
self
) -> Result<Layered<OpenTelemetryLayer<S, Tracer>, AxiomOpenTelemetryLayer<S>, S>, Error>where
S: Subscriber + for<'span> LookupSpan<'span>,
Create a layer which sends traces to Axiom and a Guard which will shut down the tracer provider on drop.
§Errors
Returns an error if the initialization was unsuccessful, likely because
a global subscriber was already installed or AXIOM_TOKEN
is not set or
invalid.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl !RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
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