use orcher_sdk_core::interceptor::{InterceptorContext, InterceptorHook};
pub struct TracingInterceptor {
_private: (),
}
impl TracingInterceptor {
pub fn new() -> Self {
Self { _private: () }
}
}
impl Default for TracingInterceptor {
fn default() -> Self {
Self::new()
}
}
impl InterceptorHook for TracingInterceptor {
fn name(&self) -> &str {
"tracing"
}
fn before_execution(&self, ctx: &InterceptorContext) {
tracing::debug_span!(
"orcher.execution",
otel.name = %ctx.operation_name,
operation = %ctx.operation_type,
id = %ctx.operation_id,
name = %ctx.operation_name,
attempt = ctx.attempt,
task_queue = %ctx.task_queue,
namespace = %ctx.namespace,
)
.in_scope(|| {
tracing::debug!("Execution span created");
});
}
fn after_execution(&self, ctx: &InterceptorContext, duration_ms: u64) {
tracing::debug!(
operation = %ctx.operation_type,
id = %ctx.operation_id,
duration_ms = duration_ms,
"Execution span completed"
);
}
fn on_error(&self, ctx: &InterceptorContext, error: &str, duration_ms: u64) {
tracing::debug!(
operation = %ctx.operation_type,
id = %ctx.operation_id,
duration_ms = duration_ms,
error = %error,
"Execution span errored"
);
}
}