Wide Event Logging & Observability for Google ADK Agents
Project description
🤖 adk-agentic-logging
adk-agentic-logging transforms the observability of AI agents from a fragmented stream of text into a structured, queryable dataset.
Its core philosophy is the "Wide Event" model: capturing the entire lifecycle of an agentic interaction—including HTTP context, OpenTelemetry trace headers, and deep ADK internal state—into a single, high-cardinality JSON artifact per request.
By seamlessly bridging web frameworks with Google Cloud’s ecosystem, it enforces a "zero-config" standard that eliminates scattered debug prints, turning complex AI behavior into transparent insights from day one.
✨ Features
- 🚀 One Request = One Log Line: Aggregates all context into a single JSON object emitted at the end of the request.
- 🧠 Deep ADK Observability: Automatically captures token usage, tool calls, and session metadata.
- ☁️ Zero-Config GCP: Automatic detection of project ID and environment metadata.
- 🔍 Trace-Aware: Injects OpenTelemetry
trace_idandspan_idfor seamless Cloud Trace linking. - 🔌 Framework Agnostic: First-class support for FastAPI, Flask, and Django.
📦 Installation
uv pip install adk-agentic-logging
🚀 Quick Start
1. Integrate with your Web Framework
FastAPI
from fastapi import FastAPI
from adk_agentic_logging.integrations.fastapi import AgenticLoggingMiddleware
app = FastAPI()
app.add_middleware(AgenticLoggingMiddleware)
Flask
from flask import Flask
from adk_agentic_logging.integrations.flask import AgenticLogging
app = Flask(__name__)
agentic_logging = AgenticLogging(app)
Django
Add to your MIDDLEWARE in settings.py:
MIDDLEWARE = [
...,
"adk_agentic_logging.integrations.django.AgenticLoggingMiddleware",
...,
]
2. Instrument your ADK Agent
Use @instrument_runner to automatically capture internal state from your ADK runners.
from adk_agentic_logging.adk.instrumentation import instrument_runner
class MyAgentRunner:
@instrument_runner
def run(self, runner_input, **kwargs):
# Your ADK agent logic
return result
3. Enrich with Agent Context
You can explicitly enrich the wide event with any context, such as the user's question and the agent's response, using log_ctx.
from adk_agentic_logging import log_ctx
# In your agent logic or route handler
log_ctx.enrich(
question="What is the weather in Paris?",
response="The weather in Paris is sunny with 22°C."
)
Adding these fields makes your logs easily queryable for specific interactions.
🛠️ How It Works
- Context Initialization: When a request starts, the middleware initializes a thread-local log context and resolves GCP/OTel metadata.
- Execution: As your code runs, arbitrary metadata is attached or captured automatically via ADK instrumentation.
- Aggregation: Content is held in a "bucket" bound to the current request.
- Emission: On request completion, a single structured JSON blob (HTTP info, performance metrics, ADK stats, errors) is emitted to stdout.
📄 License
This project is licensed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adk_agentic_logging-0.1.0.tar.gz.
File metadata
- Download URL: adk_agentic_logging-0.1.0.tar.gz
- Upload date:
- Size: 68.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bbcebf586bebe20c66d108e60876041703e0f622f08f328399126fb30795fc1
|
|
| MD5 |
838caac92cdfd11ff6c7654e3214bced
|
|
| BLAKE2b-256 |
cdfb2a2a69fd899c0f0c301d21a57adbfb705faffff4e73f3ea0f6cfe42b0bf2
|
Provenance
The following attestation bundles were made for adk_agentic_logging-0.1.0.tar.gz:
Publisher:
publish.yaml on scauchet-google/adk-agentic-logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adk_agentic_logging-0.1.0.tar.gz -
Subject digest:
1bbcebf586bebe20c66d108e60876041703e0f622f08f328399126fb30795fc1 - Sigstore transparency entry: 829237786
- Sigstore integration time:
-
Permalink:
scauchet-google/adk-agentic-logging@003659f8cffe7840aeb7a6c0a37cb6ccb0786095 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/scauchet-google
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@003659f8cffe7840aeb7a6c0a37cb6ccb0786095 -
Trigger Event:
release
-
Statement type:
File details
Details for the file adk_agentic_logging-0.1.0-py3-none-any.whl.
File metadata
- Download URL: adk_agentic_logging-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bacb95f21a45466f4e8050aec0abef57ade93ffd939651a73ec7d25f1e49bfdb
|
|
| MD5 |
8c603fd9c86f57db2fdb3c38c3b52a26
|
|
| BLAKE2b-256 |
acd57deab6c92a04bca5013029d52050408c24871f85d055a7dc9ffd03bc3f5f
|
Provenance
The following attestation bundles were made for adk_agentic_logging-0.1.0-py3-none-any.whl:
Publisher:
publish.yaml on scauchet-google/adk-agentic-logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adk_agentic_logging-0.1.0-py3-none-any.whl -
Subject digest:
bacb95f21a45466f4e8050aec0abef57ade93ffd939651a73ec7d25f1e49bfdb - Sigstore transparency entry: 829237789
- Sigstore integration time:
-
Permalink:
scauchet-google/adk-agentic-logging@003659f8cffe7840aeb7a6c0a37cb6ccb0786095 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/scauchet-google
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@003659f8cffe7840aeb7a6c0a37cb6ccb0786095 -
Trigger Event:
release
-
Statement type: