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>,
) -> Result<Self, Error>
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.
Sourcepub fn with_token(self, token: impl Into<String>) -> Result<Self, Error>
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).
Sourcepub fn with_url(self, url: &str) -> Result<Self, Error>
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.
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.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets the collector timeout for the OTLP exporter. The default is 3 seconds.
Sourcepub fn with_env(self) -> Result<Self, Error>
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.
Sourcepub fn build<S>(self) -> Result<OpenTelemetryLayer<S, Tracer>, Error>where
S: Subscriber + for<'span> LookupSpan<'span>,
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§
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