Output format·Analytics & Monitoring

Python Observability

Python observability patterns including structured logging, metrics, and distributed tracing.

You say
Buy it · $19 Read it before you buy $19 Written by wshobson · unverified publisher
Context cost
3k tokensestimated from the bundle, loaded when it triggers
Bundle
2 files · 12.1 kBtext throughout, nothing executable
Licence
MITpaid listing
Last change
no release on file
Servers it uses
Noneruns standalone

What it does

Python observability patterns including structured logging, metrics, and distributed tracing. Use when adding logging, implementing metrics collection, setting up tracing, or debugging production systems.

Installed, it changes the agent in these ways.

What this skill changes about the agent is not written down here yet. The listing was collected from its source, and the description is in its own SKILL.md.

Output format

Produces one artefact, exactly shaped.

analyticspythonloggingobservability

The skill itself

This is the whole product. A skill is instructions the model reads, so there is nothing behind the listing you cannot see first — the front matter loads with every session, and the body below it loads when the skill triggers.

SKILL.md7.1 kB · 230 lines
--- name: python-observability description: Python observability patterns including structured logging, metrics, and distributed tracing. Use when adding logging, implementing metrics collection, setting up tracing, or debugging production systems. ---
6# Python Observability
7
8Instrument Python applications with structured logs, metrics, and traces. When something breaks in production, you need to answer "what, where, and why" without deploying new code.
9
10## When to Use This Skill
11
12- Adding structured logging to applications
13- Implementing metrics collection with Prometheus
14- Setting up distributed tracing across services
15- Propagating correlation IDs through request chains
16- Debugging production issues
17- Building observability dashboards
18
19## Core Concepts
20
21### 1. Structured Logging
22
23Emit logs as JSON with consistent fields for production environments. Machine-readable logs enable powerful queries and alerts. For local development, consider human-readable formats.
24
25### 2. The Four Golden Signals
26
27Track latency, traffic, errors, and saturation for every service boundary.
28
29### 3. Correlation IDs
30
31Thread a unique ID through all logs and spans for a single request, enabling end-to-end tracing.
32
33### 4. Bounded Cardinality
34
35Keep metric label values bounded. Unbounded labels (like user IDs) explode storage costs.
36
37## Quick Start
38
39```python
40import structlog
41
42structlog.configure(
43 processors=[
44 structlog.processors.TimeStamper(fmt="iso"),
45 structlog.processors.JSONRenderer(),
46 ],
47)
48
49logger = structlog.get_logger()
50logger.info("Request processed", user_id="123", duration_ms=45)
51```
52
53## Fundamental Patterns
54
55### Pattern 1: Structured Logging with Structlog
56
57Configure structlog for JSON output with consistent fields.
58
59```python
60import logging
61import structlog
62
63def configure_logging(log_level: str = "INFO") -> None:
64 """Configure structured logging for the application."""
65 structlog.configure(
66 processors=[
67 structlog.contextvars.merge_contextvars,
68 structlog.processors.add_log_level,
69 structlog.processors.TimeStamper(fmt="iso"),
70 structlog.processors.StackInfoRenderer(),
71 structlog.processors.format_exc_info,
72 structlog.processors.JSONRenderer(),
73 ],
74 wrapper_class=structlog.make_filtering_bound_logger(
75 getattr(logging, log_level.upper())
76 ),
77 context_class=dict,
78 logger_factory=structlog.PrintLoggerFactory(),
79 cache_logger_on_first_use=True,
80 )
81
82# Initialize at application startup
83configure_logging("INFO")
84logger = structlog.get_logger()
85```
86
87### Pattern 2: Consistent Log Fields
88
89Every log entry should include standard fields for filtering and correlation.
90
91```python
92import structlog
93from contextvars import ContextVar
94
95# Store correlation ID in context
96correlation_id: ContextVar[str] = ContextVar("correlation_id", default="")
97
98logger = structlog.get_logger()
99
100def process_request(request: Request) -> Response:
101 """Process request with structured logging."""
102 logger.info(
103 "Request received",
104 correlation_id=correlation_id.get(),
105 method=request.method,
106 path=request.path,
107 user_id=request.user_id,
108 )
109
110 try:
111 result = handle_request(request)
112 logger.info(
113 "Request completed",
114 correlation_id=correlation_id.get(),
115 status_code=200,
116 duration_ms=elapsed,
117 )
118 return result
119 except Exception as e:
120 logger.error(
121 "Request failed",
122 correlation_id=correlation_id.get(),
123 error_type=type(e).__name__,
124 error_message=str(e),
125 )
126 raise
127```
128
129### Pattern 3: Semantic Log Levels
130
131Use log levels consistently across the application.
132
133| Level | Purpose | Examples |
134|-------|---------|----------|
135| DEBUG | Development diagnostics | Variable values, internal state |
136| INFO | Request lifecycle, operations | Request start/end, job completion |
137| WARNING | Recoverable anomalies | Retry attempts, fallback used |
138| ERROR | Failures needing attention | Exceptions, service unavailable |
139
140```python
141# DEBUG: Detailed internal information
142logger.debug("Cache lookup", key=cache_key, hit=cache_hit)
143
144# INFO: Normal operational events
145logger.info("Order created", order_id=order.id, total=order.total)
146
147# WARNING: Abnormal but handled situations
148logger.warning(
149 "Rate limit approaching",
150 current_rate=950,
151 limit=1000,
152 reset_seconds=30,
153)
154
155# ERROR: Failures requiring investigation
156logger.error(
157 "Payment processing failed",
158 order_id=order.id,
159 error=str(e),
160 payment_provider="stripe",
161)
162```
163
164Never log expected behavior at ERROR. A user entering a wrong password is INFO, not ERROR.
165
166### Pattern 4: Correlation ID Propagation
167
168Generate a unique ID at ingress and thread it through all operations.
169
170```python
171from contextvars import ContextVar
172import uuid
173import structlog
174
175correlation_id: ContextVar[str] = ContextVar("correlation_id", default="")
176
177def set_correlation_id(cid: str | None = None) -> str:
178 """Set correlation ID for current context."""
179 cid = cid or str(uuid.uuid4())
180 correlation_id.set(cid)
181 structlog.contextvars.bind_contextvars(correlation_id=cid)
182 return cid
183
184# FastAPI middleware example
185from fastapi import Request
186
187async def correlation_middleware(request: Request, call_next):
188 """Middleware to set and propagate correlation ID."""
189 # Use incoming header or generate new
190 cid = request.headers.get("X-Correlation-ID") or str(uuid.uuid4())
191 set_correlation_id(cid)
192
193 response = await call_next(request)
194 response.headers["X-Correlation-ID"] = cid
195 return response
196```
197
198Propagate to outbound requests:
199
200```python
201import httpx
202
203async def call_downstream_service(endpoint: str, data: dict) -> dict:
204 """Call downstream service with correlation ID."""
205 async with httpx.AsyncClient() as client:
206 response = await client.post(
207 endpoint,
208 json=data,
209 headers={"X-Correlation-ID": correlation_id.get()},
210 )
211 return response.json()
212```
213
214## Detailed worked examples and patterns
215
216Detailed sections (starting with ## Advanced Patterns) live in references/details.md. Read that file when the navigation summary above is insufficient.
217
218## Best Practices Summary
219
2201. **Use structured logging** - JSON logs with consistent fields
2212. **Propagate correlation IDs** - Thread through all requests and logs
2223. **Track the four golden signals** - Latency, traffic, errors, saturation
2234. **Bound label cardinality** - Never use unbounded values as metric labels
2245. **Log at appropriate levels** - Don't cry wolf with ERROR
2256. **Include context** - User ID, request ID, operation name in logs
2267. **Use context managers** - Consistent timing and error handling
2278. **Separate concerns** - Observability code shouldn't pollute business logic
2289. **Test your observability** - Verify logs and metrics in integration tests
22910. **Set up alerts** - Metrics are useless without alerting
230
In the file
SKILL.md751 words
Files2
LicenceMIT
Why you can read it

Nothing in a skill executes. The client loads the text and the model follows it, so a skill can be audited the way a runbook is — by reading it.

What it costs in context

Skills are not billed by the call. They are paid for in context: every token the instructions occupy is a token your code, your diff and your conversation cannot use. Here is what this one takes and when it takes it.

≈60
always loaded
The name and description, so the model knows the skill exists and when to reach for it.
2,965
on trigger
The instruction body and 1 supporting file, read only when the skill fires.
1.5%
of a 200k window
Ten skills this size would take about 15% of the window before you open a file.
050k100k150k200k context window

3k tokens, estimated from the bundle at four bytes to the token, held for the rest of the session once it triggers. Middling. Fine to keep on in a project where you use it weekly, worth unloading in one where you never do.

Servers bill, skills cost

A server charges by the month. A skill charges once per session, in context, and then keeps charging it for as long as the session lives.

Before and after

The same question, put to the same model twice: once as it comes, and once with these instructions loaded.

No worked example has been published for this skill yet.

Adoption
Installsnone yet
Ratingno reviews yet

The procedure it runs

The procedure has not been published here. It is in the skill’s own SKILL.md, which its author has not sent to the marketplace yet.

Prose, not code

These steps are written for a model to follow, not executed by a runtime. It can still be told to skip one, and it will say so when it does.

Servers it uses

None. This skill calls no MCP servers at all.

Everything it needs is in the instructions, so it works in a project with nothing connected — the model reads the file and changes how it works with what it can already reach.

It writes no files and reaches no network. All it changes is how the model reasons and writes.

What it asks for
Writes filesno
Network accessno

Read from the allowed-tools line of this skill’s own SKILL.md. A skill grants no permissions of its own — it can only ask for tools your client already has.

What it will not do

Every skill is narrow, and the useful ones say where they stop. These are the jobs this one is the wrong tool for.

What this skill is not for has not been published here. Nothing is implied by that: it is a section the author has not filled in.

What is in the bundle

2 files, 12.1 kB on disk. A bundle is text throughout: the instructions the model reads, plus the templates it fills in.

  • SKILL.md7.1 kB
  • references/details.md5.0 kB
What is not in it

No dependencies and nothing executable: a skill is text the agent reads, so the bundle is 2 files you can review in full before installing. The MIT licence covers the templates and examples as well as the instructions.

Install

Installing copies the bundle into your project. Nothing runs at install time — the files sit on disk until the model reads them.

$19 once
Python Observability · MIT · wshobson
one-time
Price$19 once
LicenceMIT — the author’s, unchanged by this purchase
Paid throughStripe, once, on the card you add at the checkout
Keeps workingfor good — the files are yours once they are on disk
Updatesevery update its author ships, delivered through this account

You can read the whole bundle before paying — the SKILL.md above is the product, not a preview of it. What the money buys is the delivery: the folder packaged and handed to your machine by key, every update its author ships, and our support if it does not do what this listing says. The terms of use are MIT, set by the author and unchanged by buying it here.

Payment runs through Stripe, on a page like this one rather than a redirect. Once there is an account it joins the same mcprush invoice as everything else you run, so there is never a second card to enter.

Which clients pick it up on their own

A skill is a folder of text. A client with a skills folder reads it without being told; everywhere else the same text works, it is just handed to the model rather than found.

Claude Code.claude/skills/
Claude Desktop
ChatGPT
Cursor.cursor/skills/
VS Code.github/skills/
Codex CLI.agents/skills/
Gemini CLI.gemini/skills/
Grok.grok/skills/
Zed.agents/skills/
Windsurf.windsurf/skills/
Agent SDK.claude/skills/
HTTP / API
This release
Versionnot versioned
Publishedno release date on file
Price$19
Referencewshobson/python-observability

Versions

Its author publishes no version number, so there is nothing here to pin to: what you install is the folder as it stands today. Instructions change more often than APIs do — a skill can be rewritten entirely without anything it depends on moving.

v
  • No earlier releases have been published to the marketplace.
Pinning

Nothing to pin to: this skill carries no version number of its own. What you install is what the folder holds on the day you install it.

Reviews

no reviews yet · no installs yet

Nobody has reviewed this skill yet. The rating is the mean of the reviews written here, so there is none until somebody writes the first.

Who can post

Only accounts that have had the skill installed for fourteen days, so a review is written after living with it rather than after reading it. Publishers may reply once.

Publisher
Servers0