pub struct BindingSpan(/* private fields */);Expand description
One inbound call on a binding outside this crate: the SERVER span it
runs in, and its rpc.server.call.duration, exactly as the bindings in
this crate record theirs.
The span is named lf.a2a.v1.A2AService/{Method} and carries the A2A
attributes; the handler’s
InboundTracePolicy decides whether a
traceparent among the call’s headers becomes its parent; the duration
goes to the handler’s Metrics, failed calls with the
binding’s own status. Open it after the request has decoded, and run the
RequestHandler call inside it:
const MY_BINDING: CustomBinding =
CustomBinding::new("mybinding", |e: &ServerError| {
Cow::Owned(e.to_a2a_error().code.as_i32().to_string())
});
let task = BindingSpan::open(handler, MY_BINDING, "GetTask", Some(&headers))
.run(handler.on_get_task(params, Some(&headers)))
.await;Implementations§
Source§impl BindingSpan
impl BindingSpan
Sourcepub fn open(
handler: &RequestHandler,
binding: CustomBinding,
method: &str,
headers: Option<&HashMap<String, String>>,
) -> BindingSpan
pub fn open( handler: &RequestHandler, binding: CustomBinding, method: &str, headers: Option<&HashMap<String, String>>, ) -> BindingSpan
Opens the span for one call of method — the A2A method as the gRPC
service spells it ("GetTask"); one this crate does not know is
recorded as _OTHER, so a peer’s string never becomes a span name or
a metric attribute.
Sourcepub fn run<T, F>(self, fut: F) -> impl Future<Output = Result<T, ServerError>>
pub fn run<T, F>(self, fut: F) -> impl Future<Output = Result<T, ServerError>>
Runs fut inside the span, then records the call: its duration and,
for an Err, the binding’s status for it. A call whose future is
dropped first is recorded as failed with error.type cancelled.
Sourcepub fn run_with<T, F, R>(
self,
fut: F,
then: impl FnOnce(Result<T, ServerError>) -> R,
) -> impl Future<Output = R>
pub fn run_with<T, F, R>( self, fut: F, then: impl FnOnce(Result<T, ServerError>) -> R, ) -> impl Future<Output = R>
run, then then on the outcome, inside the call: for
a call that answers with a stream. A stream then sets up claims the
call with StreamEnd::claim; a successful
call is then recorded when the stream ends, with the
StreamOutcome passed to
StreamEnd::end — or as cancelled if the
claim is dropped first — so its span and duration cover the stream,
as the semantic conventions ask of a streaming call.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for BindingSpan
impl !UnwindSafe for BindingSpan
impl Forget for BindingSpan
impl Freeze for BindingSpan
impl Move for BindingSpan
impl Send for BindingSpan
impl Sync for BindingSpan
impl Unpin for BindingSpan
impl UnsafeUnpin for BindingSpan
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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> ⓘ
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> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].