pub struct LiveMetricsSpanProcessor<R: RuntimeChannel> { /* private fields */ }
Expand description
Application Insights live metrics span processor
Enables live metrics collection: https://learn.microsoft.com/en-us/azure/azure-monitor/app/live-stream.
#[tokio::main]
async fn main() {
let exporter = opentelemetry_application_insights::Exporter::new_from_connection_string(
"connection_string",
reqwest::Client::new(),
)
.expect("valid connection string");
let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
.with_span_processor(opentelemetry_sdk::trace::span_processor_with_async_runtime::BatchSpanProcessor::builder(exporter.clone(), opentelemetry_sdk::runtime::Tokio).build())
.with_span_processor(opentelemetry_application_insights::LiveMetricsSpanProcessor::new(exporter, opentelemetry_sdk::runtime::Tokio))
.build();
opentelemetry::global::set_tracer_provider(tracer_provider.clone());
// ... send traces ...
tracer_provider.shutdown().unwrap();
}
Implementations§
Source§impl<R: RuntimeChannel> LiveMetricsSpanProcessor<R>
impl<R: RuntimeChannel> LiveMetricsSpanProcessor<R>
Sourcepub fn new<C: HttpClient + 'static>(
exporter: Exporter<C>,
runtime: R,
) -> LiveMetricsSpanProcessor<R>
pub fn new<C: HttpClient + 'static>( exporter: Exporter<C>, runtime: R, ) -> LiveMetricsSpanProcessor<R>
Create new live metrics span processor.
Trait Implementations§
Source§impl<R: RuntimeChannel> Debug for LiveMetricsSpanProcessor<R>
impl<R: RuntimeChannel> Debug for LiveMetricsSpanProcessor<R>
Source§impl<R: RuntimeChannel> Drop for LiveMetricsSpanProcessor<R>
impl<R: RuntimeChannel> Drop for LiveMetricsSpanProcessor<R>
Source§impl<R: RuntimeChannel> SpanProcessor for LiveMetricsSpanProcessor<R>
impl<R: RuntimeChannel> SpanProcessor for LiveMetricsSpanProcessor<R>
Source§fn on_start(&self, _span: &mut Span, _cx: &Context)
fn on_start(&self, _span: &mut Span, _cx: &Context)
on_start
is called when a Span
is started. This method is called
synchronously on the thread that started the span, therefore it should
not block or throw exceptions.Source§fn on_end(&self, span: SpanData)
fn on_end(&self, span: SpanData)
on_end
is called after a Span
is ended (i.e., the end timestamp is
already set). This method is called synchronously within the Span::end
API, therefore it should not block or throw an exception.
TODO - This method should take reference to SpanData
Source§fn force_flush(&self) -> OTelSdkResult
fn force_flush(&self) -> OTelSdkResult
Force the spans lying in the cache to be exported.
Source§fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult
fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult
Shuts down the processor. Called when SDK is shut down. This is an
opportunity for processors to do any cleanup required. Read more
Source§fn set_resource(&mut self, resource: &Resource)
fn set_resource(&mut self, resource: &Resource)
Set the resource for the span processor.
Auto Trait Implementations§
impl<R> Freeze for LiveMetricsSpanProcessor<R>
impl<R> RefUnwindSafe for LiveMetricsSpanProcessor<R>
impl<R> Send for LiveMetricsSpanProcessor<R>
impl<R> Sync for LiveMetricsSpanProcessor<R>
impl<R> Unpin for LiveMetricsSpanProcessor<R>
impl<R> UnwindSafe for LiveMetricsSpanProcessor<R>
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
Mutably borrows from an owned value. Read more
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more