Skip to main content
Genkit provides built-in observability through automatic tracing, a local Developer UI, and production monitoring integrations with OpenTelemetry.

Why Observability Matters for AI

AI applications are inherently non-deterministic and complex:
  • Multi-step workflows: Model calls, tool invocations, data retrieval
  • Non-deterministic: Same input can produce different outputs
  • Expensive: Token costs, latency, rate limits
  • Hard to debug: What went wrong in a 10-step agentic workflow?
Genkit’s observability features help you:
  • Debug failures: See exactly which step failed and why
  • Optimize performance: Identify slow model calls or bottlenecks
  • Monitor costs: Track token usage across models
  • Improve quality: Analyze outputs and refine prompts

Automatic Tracing

Every action in Genkit is automatically traced:
Every span captures:
  • Timing: Start time, duration
  • Input/Output: Request and response data
  • Metadata: Model name, token usage, cost
  • Errors: Stack traces and error messages
  • Hierarchy: Parent-child relationships

Developer UI

The Developer UI provides a local dashboard for testing and debugging:

Starting the Dev UI

Then open http://localhost:4000

Features

1. Action Browser
  • Browse all flows, models, prompts, tools
  • See input/output schemas
  • Read descriptions and metadata
2. Flow Runner
  • Run flows with test inputs
  • See results in real-time
  • Test streaming responses
  • Try different configurations
3. Trace Inspector
  • View execution traces
  • Expand/collapse spans
  • See timing breakdowns
  • Inspect input/output at each step
  • Filter by flow, model, or time range
4. Prompt Editor
  • Edit .prompt files
  • Test with sample inputs
  • See rendered output
  • Compare variants
5. Model Tester
  • Test models directly
  • Compare different models
  • Adjust temperature, topK, etc.
  • See token usage and cost

OpenTelemetry Integration

Genkit uses OpenTelemetry for all tracing, making it compatible with any observability platform.

How It Works

Genkit automatically:
  1. Creates OpenTelemetry spans for every action
  2. Exports spans to configured backends
  3. Includes Genkit-specific attributes (tokens, model, cost)

Production Monitoring

Google Cloud Trace

Integrate with Google Cloud for production tracing:
Features:
  • Cloud Trace: Distributed tracing across services
  • Cloud Logging: Structured logs with trace correlation
  • Metrics: Token usage, latency, error rates
  • Alerts: Set up alerts on errors or slow requests

Firebase

For Firebase projects:
Provides:
  • Cloud Trace integration
  • Cloud Logging
  • Firebase Console integration

Third-Party Observability

Support for popular platforms:
Supported platforms:
  • Sentry: Error tracking and performance monitoring
  • Datadog: APM, logs, metrics
  • Honeycomb: Distributed tracing and observability
  • New Relic: Application performance monitoring
  • Jaeger: Open-source distributed tracing
  • Zipkin: Distributed tracing system

Custom Telemetry

Add custom attributes to traces:

Metrics and Token Tracking

Genkit automatically tracks: Token Usage
  • Input tokens per request
  • Output tokens per request
  • Total tokens per flow
  • Tokens by model
Latency
  • Model call duration
  • Tool execution time
  • End-to-end flow time
  • Time to first token (TTFT)
Costs (when supported by model)
  • Cost per request
  • Cost per model
  • Daily/monthly spend
Error Rates
  • Failed requests
  • Timeout errors
  • Rate limit errors
  • Model-specific errors
Access in traces:

Trace Export Formats

Genkit supports multiple trace export formats: JSON
OpenTelemetry Protocol (OTLP)
Zipkin
Jaeger

Best Practices

1. Use Meaningful Step Names

Name your steps clearly:

2. Add Custom Metadata

Enrich traces with business context:

3. Monitor Token Usage

Set up alerts for unexpected token usage:

4. Sample in Production

For high-traffic apps, sample traces:

5. Use Dev UI for Debugging

Before deploying:
  1. Run flows in Dev UI with test data
  2. Inspect traces for unexpected behavior
  3. Verify token usage and latency
  4. Test error handling

Debugging Common Issues

High Latency

Check trace for:
  • Slow model calls → Try faster model
  • Multiple sequential tool calls → Can any run in parallel?
  • Large prompts → Reduce context size
  • Network delays → Check model endpoint

High Token Usage

Check trace for:
  • Long conversation history → Summarize or truncate
  • Verbose prompts → Simplify instructions
  • Unnecessary tool calls → Refine tool descriptions
  • Large tool responses → Return only needed data

Errors

Check trace for:
  • Stack trace and error message
  • Which step failed
  • Input that caused the error
  • Model-specific error codes (rate limits, etc.)

Example: Monitoring Dashboard

Query traces programmatically:

Next Steps

  • Learn about Flows - building traceable workflows
  • Explore Architecture - how tracing works internally
  • See Plugins - telemetry plugin options