pub struct OpenTelemetryPlugin { /* private fields */ }Expand description
OpenTelemetry tracing plugin.
Sets up OTLP trace export via tracing-opentelemetry. All tracing
spans in the application are exported as OpenTelemetry traces.
Depends on TracingPlugin which owns the subscriber.
§Lifecycle
build()— builds the OTLP exporter and tracer, and pushes theOTellayer intoTracingLayersApi.cleanup()— shuts down the tracer provider, flushing pending spans.
§Example
use polaris_core_plugins::OpenTelemetryPlugin;
OpenTelemetryPlugin::new("http://localhost:4318/v1/traces")
.with_service_name("my-agent")
.with_env_filter("polaris=debug,hyper=warn")
.with_resource_attribute("deployment.environment.name", "production")
.with_export_header("x-api-key", api_key);Implementations§
Source§impl OpenTelemetryPlugin
impl OpenTelemetryPlugin
Sourcepub fn new(endpoint: impl Into<String>) -> OpenTelemetryPlugin
pub fn new(endpoint: impl Into<String>) -> OpenTelemetryPlugin
Creates a new plugin targeting the given OTLP HTTP endpoint.
§Arguments
endpoint- OTLP HTTP endpoint
Sourcepub fn with_service_name(self, name: impl Into<String>) -> OpenTelemetryPlugin
pub fn with_service_name(self, name: impl Into<String>) -> OpenTelemetryPlugin
Sets the service name reported in traces.
Sourcepub fn with_env_filter(self, filter: impl Into<String>) -> OpenTelemetryPlugin
pub fn with_env_filter(self, filter: impl Into<String>) -> OpenTelemetryPlugin
Sets a custom environment filter for OTel span export.
Format: target=level,target=level,...
Sourcepub fn with_resource_attribute(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> OpenTelemetryPlugin
pub fn with_resource_attribute( self, key: impl Into<String>, value: impl Into<String>, ) -> OpenTelemetryPlugin
Adds an OTel resource attribute to the trace provider.
Resource attributes identify the entity producing telemetry (e.g., deployment environment, service version, host).
use polaris_core_plugins::OpenTelemetryPlugin;
OpenTelemetryPlugin::new("http://localhost:4318/v1/traces")
.with_resource_attribute("deployment.environment.name", "production")
.with_resource_attribute("service.version", "1.2.0");Sourcepub fn with_export_header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> OpenTelemetryPlugin
pub fn with_export_header( self, key: impl Into<String>, value: impl Into<String>, ) -> OpenTelemetryPlugin
Adds an HTTP header to OTLP export requests.
use polaris_core_plugins::OpenTelemetryPlugin;
OpenTelemetryPlugin::new("https://api.honeycomb.io/v1/traces")
.with_export_header("x-api-key", api_key);Trait Implementations§
Source§impl Plugin for OpenTelemetryPlugin
impl Plugin for OpenTelemetryPlugin
Source§fn build(&self, server: &mut Server)
fn build(&self, server: &mut Server)
Configures the server. Called once when the plugin is added. Read more
Source§async fn ready(&self, _server: &mut Server)
async fn ready(&self, _server: &mut Server)
Called after all plugins have been built and the server is ready to run. Read more
Source§async fn cleanup(&self, _server: &mut Server)
async fn cleanup(&self, _server: &mut Server)
Called when the server is shutting down. Read more
Source§fn dependencies(&self) -> Vec<PluginId>
fn dependencies(&self) -> Vec<PluginId>
Declares plugins that must be added before this one. Read more
Source§fn update(&self, _server: &mut Server, _schedule: ScheduleId)
fn update(&self, _server: &mut Server, _schedule: ScheduleId)
Called when a schedule this plugin registered for is triggered. Read more
Source§fn tick_schedules(&self) -> Vec<ScheduleId>
fn tick_schedules(&self) -> Vec<ScheduleId>
Declares which schedules this plugin wants to receive updates on. Read more
Auto Trait Implementations§
impl !Freeze for OpenTelemetryPlugin
impl !RefUnwindSafe for OpenTelemetryPlugin
impl Send for OpenTelemetryPlugin
impl Sync for OpenTelemetryPlugin
impl Unpin for OpenTelemetryPlugin
impl UnsafeUnpin for OpenTelemetryPlugin
impl !UnwindSafe for OpenTelemetryPlugin
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 moreCreates a shared type from an unshared type.
Source§impl<P> Plugins for Pwhere
P: Plugin,
impl<P> Plugins for Pwhere
P: Plugin,
Source§fn add_to_server(self, server: &mut Server)
fn add_to_server(self, server: &mut Server)
Adds these plugins to the server.
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn propagate_header(self, header: HeaderName) -> PropagateHeader<Self>where
Self: Sized,
fn propagate_header(self, header: HeaderName) -> PropagateHeader<Self>where
Self: Sized,
Available on crate feature
propagate-header only.Propagate a header from the request to the response. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Available on crate feature
trace only.High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Available on crate feature
trace only.High level tracing that classifies responses using gRPC headers. Read more
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Available on crate feature
follow-redirect only.Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Available on crate feature
request-id only.Add request id header and extension. Read more
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Available on crate feature
request-id only.Add request id header and extension, using
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Available on crate feature
request-id only.Propgate request ids from requests to responses. Read more
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
Available on crate feature
request-id only.Propgate request ids from requests to responses, using
x-request-id as the header name. Read more