telemetry library
Telemetry instrumentation for Genkit.
This library is the authoring surface for pluggable telemetry providers. Use
configureInstrumentation to register one or more Instrumentation
providers before creating Genkit. Providers compose as a middleware chain,
so multiple can be active at once.
import 'package:genkit/telemetry.dart';
void main() {
configureInstrumentation(myInstrumentation());
final ai = Genkit(/* ... */);
}
By default Genkit is not instrumented. In the dev environment a built-in
provider is auto-injected only when a Genkit telemetry server is configured
(via the GENKIT_TELEMETRY_SERVER environment variable, or the CLI
reflection handshake), so the Developer UI receives traces. That built-in
runs independently of OpenTelemetry, posting Genkit's spans directly to the
server over HTTP. It also bridges package:logging records (correlated with
the active span) to the server so logs show up in the Developer UI; that
logging bridge is an implementation detail of the built-in provider, not a
behavior of Genkit core. In production, configure a provider explicitly with
configureInstrumentation.
A provider that holds resources (subscriptions, clients) can implement
DisposableInstrumentation; Genkit disposes it on Genkit.shutdown().
Classes
- DisposableInstrumentation
- Optional capability: an Instrumentation that holds resources needing release (e.g. stream subscriptions, HTTP clients).
- Instrumentation
- A pluggable telemetry instrumentation provider.
- SpanContext
- A handle to a live span, handed to the wrapped function.
- SpanMetadata
- Backend-agnostic description of a span about to be created.
Functions
-
configureInstrumentation(
Instrumentation instrumentation) → void -
Registers an
instrumentationprovider.