AgentInstrumentation

Port for direct instrumentation at the agent work sites (agent turn, action, LLM call, tool loop).

The core depends only on this port; the actual span creation lives in an adapter supplied by the observability module. When no module is present, com.embabel.agent.api.common.PlatformServices.instrumentation defaults to NoOpAgentInstrumentation, so the work runs un-observed and no span is ever created — structurally, not via a runtime flag, and without the core ever reading an ambient io.micrometer.observation.ObservationRegistry.

The span name is owned by the registered io.micrometer.observation.ObservationConvention in the module, so it is the Observation.Context type — not a name — that drives naming. The adapter owns the open/close (and error) lifecycle of the span around observe, guaranteeing no scope leak.

Inheritors

Functions

Link copied to clipboard
abstract fun <T> observe(context: () -> <Error class: unknown class>, work: () -> T): T

Run work inside an observation built from context. Returns exactly what work returns, including null, and propagates any exception unchanged.