# Class ApiServerSpanExporter

java.lang.Object
com.google.adk.web.service.ApiServerSpanExporter

All Implemented Interfaces:
  `io.opentelemetry.sdk.trace.export.SpanExporter, Closeable, AutoCloseable`

public class ApiServerSpanExporter extends Object implements io.opentelemetry.sdk.trace.export.SpanExporter
A custom SpanExporter that stores relevant span data. It handles two types of trace data storage: 1. Event-ID based: Stores attributes of specific spans (call_llm, send_data, tool_response) keyed by `gcp.vertex.agent.event_id`. This is used for debugging individual events. 2. Session-ID based: Stores all exported spans and maintains a mapping from `session_id` (extracted from `call_llm` spans) to a list of `trace_id`s. This is used for retrieving all spans related to a session.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ApiServerSpanExporter()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `io.opentelemetry.sdk.common.CompletableResultCode`
  `export(Collection<io.opentelemetry.sdk.trace.data.SpanData> spans)`
  `io.opentelemetry.sdk.common.CompletableResultCode`
  `flush()`
  `List<io.opentelemetry.sdk.trace.data.SpanData>`
  `getAllExportedSpans()`
  `Map<String,Object>`
  `getEventTraceAttributes(String eventId)`
  `Map<String, List<String>>`
  `getSessionToTraceIdsMap()`
  `io.opentelemetry.sdk.common.CompletableResultCode`
  `shutdown()`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface io.opentelemetry.sdk.trace.export.SpanExporter

  `close`

- ## Constructor Details

  - ### ApiServerSpanExporter

    public ApiServerSpanExporter()

- ## Method Details

  - ### getEventTraceAttributes

    public Map<String,Object> getEventTraceAttributes(String eventId)

  - ### getSessionToTraceIdsMap

    public Map<String, List<String>> getSessionToTraceIdsMap()

  - ### getAllExportedSpans

    public List<io.opentelemetry.sdk.trace.data.SpanData> getAllExportedSpans()

  - ### export

    public io.opentelemetry.sdk.common.CompletableResultCode export(Collection<io.opentelemetry.sdk.trace.data.SpanData> spans)
    Specified by:
      `export` in interface `io.opentelemetry.sdk.trace.export.SpanExporter`

  - ### flush

    public io.opentelemetry.sdk.common.CompletableResultCode flush()
    Specified by:
      `flush` in interface `io.opentelemetry.sdk.trace.export.SpanExporter`

  - ### shutdown

    public io.opentelemetry.sdk.common.CompletableResultCode shutdown()
    Specified by:
      `shutdown` in interface `io.opentelemetry.sdk.trace.export.SpanExporter`