Skip to main content

OpenTelemetry

Struct OpenTelemetry 

Source
pub struct OpenTelemetry<T> { /* private fields */ }
Available on crate feature opentelemetry only.
Expand description

OpenTelemetry extension

§Example

use async_graphql_extras::OpenTelemetry;

let tracer = todo!("create your OpenTelemetry tracer");

let schema = Schema::build(Query, EmptyMutation, EmptySubscription)
    .extension(OpenTelemetry::new(tracer))
    .finish();

Implementations§

Source§

impl<T> OpenTelemetry<T>

Source

pub fn new(tracer: T) -> OpenTelemetry<T>
where T: Tracer + Send + Sync + 'static, <T as Tracer>::Span: Sync + Send,

Use tracer to create an OpenTelemetry extension.

Source

pub fn with_trace_scalars(self, trace_scalars: bool) -> Self

Enable or disable tracing for scalar and enum field resolutions.

When false (the default), spans are not created for fields that return scalar or enum types. This significantly reduces the number of spans generated, preventing span explosion in queries with many scalar fields.

When true, spans are created for all field resolutions, including scalars and enums.

§Example
use async_graphql::extensions::OpenTelemetry;
use async_graphql_extras::OpenTelemetry as ExtrasOpenTelemetry;

let tracer = todo!("create your OpenTelemetry tracer");

// Trace all fields including scalars
let schema = Schema::build(Query, EmptyMutation, EmptySubscription)
    .extension(ExtrasOpenTelemetry::new(tracer).with_trace_scalars(true))
    .finish();

Trait Implementations§

Source§

impl<T> ExtensionFactory for OpenTelemetry<T>
where T: Tracer + Send + Sync + 'static, <T as Tracer>::Span: Sync + Send,

Source§

fn create(&self) -> Arc<dyn Extension>

Create an extended instance.

Auto Trait Implementations§

§

impl<T> Freeze for OpenTelemetry<T>

§

impl<T> RefUnwindSafe for OpenTelemetry<T>
where T: RefUnwindSafe,

§

impl<T> Send for OpenTelemetry<T>
where T: Sync + Send,

§

impl<T> Sync for OpenTelemetry<T>
where T: Sync + Send,

§

impl<T> Unpin for OpenTelemetry<T>

§

impl<T> UnwindSafe for OpenTelemetry<T>
where T: RefUnwindSafe,

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, 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, 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.