Skip to main content

Wide Event Logging & Observability for Google ADK Agents

Project description

🤖 adk-agentic-logging

Python Version License: MIT

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_id and span_id for 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

  1. Context Initialization: When a request starts, the middleware initializes a thread-local log context and resolves GCP/OTel metadata.
  2. Execution: As your code runs, arbitrary metadata is attached or captured automatically via ADK instrumentation.
  3. Aggregation: Content is held in a "bucket" bound to the current request.
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adk_agentic_logging-0.1.0.tar.gz (68.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adk_agentic_logging-0.1.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

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

Hashes for adk_agentic_logging-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1bbcebf586bebe20c66d108e60876041703e0f622f08f328399126fb30795fc1
MD5 838caac92cdfd11ff6c7654e3214bced
BLAKE2b-256 cdfb2a2a69fd899c0f0c301d21a57adbfb705faffff4e73f3ea0f6cfe42b0bf2

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adk_agentic_logging-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for adk_agentic_logging-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bacb95f21a45466f4e8050aec0abef57ade93ffd939651a73ec7d25f1e49bfdb
MD5 8c603fd9c86f57db2fdb3c38c3b52a26
BLAKE2b-256 acd57deab6c92a04bca5013029d52050408c24871f85d055a7dc9ffd03bc3f5f

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page