Class StreamingEventAttributes

java.lang.Object
org.a2aproject.sdk.extras.opentelemetry.StreamingEventAttributes

public final class StreamingEventAttributes extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    apply(io.opentelemetry.api.trace.SpanBuilder builder, StreamingEventKind item)
    Applies task-specific attributes derived from the streaming event to the span builder.
    static void
    recordDuration(@Nullable io.opentelemetry.api.metrics.DoubleHistogram histogram, long startNanos, String operationName, boolean success)
    Records elapsed time to a histogram using the standard A2A operation attributes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • apply

      public static void apply(io.opentelemetry.api.trace.SpanBuilder builder, StreamingEventKind item)
      Applies task-specific attributes derived from the streaming event to the span builder. Populates task ID, task status state, and other event-kind-specific fields.
      Parameters:
      builder - the span builder to enrich with event attributes
      item - the streaming event to extract attributes from
    • recordDuration

      public static void recordDuration(@Nullable io.opentelemetry.api.metrics.DoubleHistogram histogram, long startNanos, String operationName, boolean success)
      Records elapsed time to a histogram using the standard A2A operation attributes.

      The error.type attribute is set to the fixed string "error" on failures rather than the actual exception class name. This is intentional: metrics use a low-cardinality error marker to avoid unbounded label sets, while spans carry the full class name for debugging.

      Parameters:
      histogram - the histogram to record to; no-op if null
      startNanos - the start time from System.nanoTime()
      operationName - the A2A operation name recorded as gen_ai.agent.a2a.operation.name
      success - false adds the error.type attribute