zerolaunch_plugin_sdk_rust/
trace.rs1use std::future::Future;
2use tracing::Instrument;
3use zerolaunch_plugin_api::PluginContext;
4
5pub fn span_for(ctx: &PluginContext) -> tracing::Span {
7 tracing::info_span!(
8 "plugin",
9 trace_id = %ctx.trace_id,
10 plugin_id = ?ctx.plugin_id,
11 query_id = ?ctx.query_id,
12 )
13}
14
15pub fn with_trace<R>(ctx: &PluginContext, f: impl FnOnce() -> R) -> R {
17 let span = span_for(ctx);
18 let _enter = span.enter();
19 f()
20}
21
22pub fn instrument<F: Future>(ctx: &PluginContext, fut: F) -> tracing::instrument::Instrumented<F> {
24 fut.instrument(span_for(ctx))
25}