feat: Logfire observability adoption - config, base integration, tests#355
Draft
lpayne-dev wants to merge 2 commits into
Draft
feat: Logfire observability adoption - config, base integration, tests#355lpayne-dev wants to merge 2 commits into
lpayne-dev wants to merge 2 commits into
Conversation
|
✅ Tests passed 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
Collaborator
|
@lpayne-dev thanks for this. There was a major refactor in the base agent last week for makign the downstream agents adopt better (eg: akd-ext). This introduces the concept of session in akd and also lots of clean-ups for simplifying the downstream subclasses. So, I fear there will be lots of merge conflict with that. For now let's put this observability as a draft PR and not merge until we merge the refactored code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds optional Logfire observability to AKD.
It’s off by default, so nothing changes for local dev or tests.
If you enable it via env vars, you can trace:
agent runs
tool executions
streaming lifecycle events
in Logfire (or stdout if you’re not sending to cloud).
Details
What changed
This PR introduces a new akd.observability module that centralizes Logfire initialization and tracing helpers, including init_observability() (no-op when disabled or running under pytest), span_agent_run, span_tool_execution, and log_stream_event for streaming lifecycle tracing. All logging is redacted and truncated before sending to prevent leakage of sensitive data such as API keys or large payloads.
It adds a TelemetrySettings configuration model in akd.configs.project with env-driven controls for enabling logging, setting service and environment labels, configuring sample rate, toggling redaction behavior, and choosing whether to send data to Logfire cloud. Logfire telemetry remains disabled by default to ensure local development and tests behave exactly as before.
The .env.example file now documents the new TELEMETRY_* variables, and .gitignore excludes .logfire/ to prevent local credentials or Logfire artifacts from being committed.
Script entrypoints (demo, planner, lit-agent), dependency files (pyproject.toml, uv.lock), and relevant streaming/tool/search integrations were updated to support clean Logfire initialization and hook integration.
Finally, a new test suite under tests/observability/test_logfire.py validates redaction behavior, confirms safe initialization when disabled or under pytest, and ensures there are no import-time side effects.
Checks