haonguyen1915/flex-kit/python-observability
Claude Code and agent skill by haonguyen1915/flex-kit
- community
Checking that the SKILL.md file is still in the repository.
Making a running Python app observable - per-module loggers, structured logging configured once at the entry point (never in libraries), log levels, exception logging, and emitting metrics. Use when adding logging/metrics, diagnosing a production issue, or reviewing diagnostic output. Not for build/test tool config (see python-project) or exception design (see python-error-handling).
Install
npx vskill@latest install haonguyen1915/flex-kit/python-observabilitySKILL.md
The same SKILL.md was published earlier as haonguyen1915/flex-kit/python-observability.
Python Observability
Logging and metrics are how you understand a running system. The core rule: libraries emit, the application configures - a reusable module never dictates where logs go.
Per-module loggers
Get a logger named after the module; never log on the root logger or print. The __name__ hierarchy lets the app tune verbosity per package (logging.getLogger("shop.db")).
A library/package adds only a NullHandler so it stays silent until an app configures logging - it must not add stream/file handlers or call basicConfig:
Configure once, at the entry point
Handlers, formatters, and levels are set one time in the application's composition root (main()/bootstrap), driven by runtime config (env/settings) - this is a runtime concern, distinct from build-time tool config in pyproject.
For production, attach a JSON/structured formatter so logs are queryable by field (python-json-logger or a custom Formatter); pass context via extra={...}, not f-string concatenation - structured fields survive log aggregation, interpolated strings don't.
Levels - mean them
DEBUGdeveloper detail;INFOnormal lifecycle events;WARNINGsomething off but
handled; ERROR an operation failed; CRITICAL the app can't continue.
- Use lazy
%-args, not f-strings:logger.info("user %s", uid)- the format is skipped
if the level is disabled.
- In an
except, uselogger.exception("...")(ERROR + traceback); log it once, at the
boundary that handles it (see python-error-handling), not at every layer.
Metrics
Emit counters/histograms for rates and latency (prometheus_client, OpenTelemetry, or StatsD) at the same boundaries you log. Name them consistently, keep label cardinality low (no user-ids as labels), and measure the things you'd page on: request rate, error rate, latency. Don't reinvent a metrics store - export to the platform's collector.
Review checklist
- [ ]
logger = logging.getLogger(__name__)per module; noprintfor diagnostics - [ ] libraries add only
NullHandler; no handler/basicConfigoutside the app entry - [ ] logging configured once at the composition root from runtime config
- [ ] context passed via
extra={...}/ structured fields, not string-concatenated - [ ] levels used meaningfully;
logger.exceptionin handlers; logged once at the edge - [ ] metrics at the same boundaries; low label cardinality; exported, not home-grown
Red Flags
print()(orlogging.infoon the root) used as application logging- a library calling
basicConfig/adding aStreamHandler(hijacks the app's config) logger.info(f"user {uid} did {action}")- unstructured, eager, unqueryable- the same error logged and re-logged at every layer it passes through
- a metric label with unbounded cardinality (user id, request id, raw URL)
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingflex_kit/packs/languages/python/skills/craft/python-observability/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/haonguyen1915/flex-kit/python-observability)