Repository navigation
feat(landing): Python logging levels guide - #1574
JeremyFunk wants to merge 6 commits into
Conversation
Maple review🟢 Confidence 8/10 · likely safe to merge Adds an English landing guide on Python logging levels, wires it into the guides index and llms.txt, and corrects the Python instrumentation doc's level advice. Safe to merge once the sibling Loguru page it links to exists.
Before merge
Findings🟠 Warning · F1 · Link to
|
| <p class="guide-kicker">Python logs in Maple</p> | ||
| <h3>Search by severity, then jump to the trace</h3> | ||
| <p> | ||
| Once the handler is attached, the Logs page charts volume by severity, filters by service and environment, and opens the trace behind any line logged inside a span. Using Loguru instead? See the <a href="/guides/loguru">Loguru guide</a>. |
There was a problem hiding this comment.
Warning
Link to /guides/loguru has no page in this repository
F1 · Warning · correctness
/guides/loguru resolves to no page: apps/landing/src/pages/guides/ holds only api-latency, index, python-logging-levels, uptime-monitoring, what-is-apdex and what-is-apm, on this head and on main. Every other internal guide link points at an existing page, so this one sends readers to the 404 page unless the parallel Loguru PR lands first.
Hold this sentence until `apps/landing/src/pages/guides/loguru.astro` exists, or point it at `/docs/guides/instrumentation-python#logging` until then.
🤖 Prompt to fix with an AI agent
In `apps/landing/src/pages/guides/python-logging-levels.astro:541`: Link to `/guides/loguru` has no page in this repository.
`/guides/loguru` resolves to no page: `apps/landing/src/pages/guides/` holds only api-latency, index, python-logging-levels, uptime-monitoring, what-is-apdex and what-is-apm, on this head and on `main`. Every other internal guide link points at an existing page, so this one sends readers to the 404 page unless the parallel Loguru PR lands first.
Suggested fix: Hold this sentence until `apps/landing/src/pages/guides/loguru.astro` exists, or point it at `/docs/guides/instrumentation-python#logging` until then.
Verify the problem exists at that location before changing it, and keep the fix to those lines.
There was a problem hiding this comment.
Intentional: /guides/loguru is being added in a parallel PR. Merge that one first (or together) so the link resolves.
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| console.setFormatter(logging.Formatter("%(levelname)-8s %(name)s: %(message)s")) | ||
| root.addHandler(console) | ||
|
|
||
| root.addHandler(LoggingHandler(level=logging.INFO, logger_provider=logger_provider)) |
There was a problem hiding this comment.
🔴 Debug logs leak and exports duplicate
When added after the Python telemetry setup, otelCode exports DEBUG records to Maple and exports INFO records twice. The existing root LoggingHandler remains at NOTSET alongside the new INFO-only handler.
Learn more
The Python instrumentation setup already attaches a LoggingHandler to the root logger at NOTSET in telemetry.py. This example is labeled as code to run after that setup creates logger_provider. Raising the root logger to DEBUG lets its existing handler receive DEBUG records. Appending a second handler at INFO leaves the first intact, so INFO and higher records go to Maple twice.
Example: After importing telemetry, run this snippet and emit log.debug("cart has 3 items") followed by log.info("order 1042 placed"). Maple receives one DEBUG record and two INFO records instead of zero DEBUG and one INFO.
Recommended fix: Replace or reconfigure the existing telemetry LoggingHandler rather than appending another one. For example, keep a reference to the existing handler in telemetry.py and set its level to INFO before raising the root level, then add only the console handler.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Fixed: the snippet now replaces the line in telemetry.py that adds the LoggingHandler, so the root logger has a single OpenTelemetry handler at INFO.
Maple review🟢 Confidence 8/10 · likely safe to merge Adds a
Before merge
Still open from earlier reviews
What was checked
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 3 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
275d763 to
ee07df5
Compare
Maple review🟢 Confidence 8/10 · likely safe to merge Adds a
Before merge
Findings🟠 Warning · F2 · Guide embeds two screenshots that do not exist in
|
| File | Calls/day | Busiest operations |
|---|---|---|
apps/landing/src/pages/guides/python-logging-levels.astro |
105k | maple 105k/day, 91.1% err |
Ingest cost of new log lines
apps/landing/src/pages/guides/python-logging-levels.astro:91: If this logs once per call, about 853 MB/month: the file's operations run 105k times a day.apps/landing/src/pages/guides/python-logging-levels.astro:102: If this logs once per call, about 853 MB/month: the file's operations run 105k times a day.apps/landing/src/pages/guides/python-logging-levels.astro:121: If this logs once per call, about 853 MB/month: the file's operations run 105k times a day.apps/landing/src/pages/guides/python-logging-levels.astro:122: If this logs once per call, about 853 MB/month: the file's operations run 105k times a day.apps/landing/src/pages/guides/python-logging-levels.astro:145: If this logs once per call, about 853 MB/month: the file's operations run 105k times a day.apps/landing/src/pages/guides/python-logging-levels.astro:146: If this logs once per call, about 853 MB/month: the file's operations run 105k times a day.apps/landing/src/pages/guides/python-logging-levels.astro:236: If this logs once per call, about 853 MB/month: the file's operations run 105k times a day.apps/landing/src/pages/guides/python-logging-levels.astro:484: If this logs once per call, about 853 MB/month: the file's operations run 105k times a day.apps/landing/src/pages/guides/python-logging-levels.astro:567: If this logs once per call, about 853 MB/month: the file's operations run 105k times a day.
What was checked
otelCodereplaces the rootLoggingHandlerline andtelemetry.pyhas no console handler, so no duplicate outputconsoleSessionregex only splits$-prefixed lines and escapes each part; no markup reachesset:htmlunescaped- Every
tocslug andsectionNavanchor matches a heading id in the page
ee07df5 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.
Maple review🟢 Confidence 8/10 · likely safe to merge Adds the two referenced Logs-page screenshots and corrects their alt text and intrinsic dimensions. The screenshot gap is fixed; the guide still links to
Before merge
Still open from earlier reviews
Production impactProduction traffic of the changed files (last 7 days)
Ingest cost of new log lines
What was checked
|
Covers the standard levels, logger vs handler levels and propagation, setting the level from argparse, LOG_LEVEL and dictConfig, per-module levels, custom levels and getLevelNamesMapping, and how levels interact with the OpenTelemetry LoggingHandler. Fixes the Python instrumentation doc, which suggested basicConfig after the handler is attached, where it is a no-op.
Short H1, five grouped sections, a diagram of how a record passes the logger level, propagates and meets each handler's level, level colors shared with Maple's severity palette, and highlighted code throughout. The ways to set the level sit in tabs; the OpenTelemetry section uses the LoggingHandler from opentelemetry-instrumentation-logging. LanguageTabs takes an optional storage group so non-language tabs don't overwrite the remembered language. The guide highlighter gains a console mode and more Python keywords.
Lead with what a level is, the five levels with an example each and how basicConfig sets one. Drop the numeric values, dictConfig, the -v flag, runtime switching and the propagation diagram; keep handler levels as one short section before OpenTelemetry.
87bd710 to
16961c2
Compare
Maple review🟢 Confidence 8/10 · likely safe to merge Adds the Python logging levels guide and its two screenshots, lists it in the guides index and llms.txt, and corrects the Python instrumentation doc's
Before merge
Still open from earlier reviews
Fixed since the last review
Production impactProduction traffic of the changed files (last 7 days)
Ingest cost of new log lines
What was checked
|
…ng levels guide The OpenTelemetry section now installs, configures and runs a complete logs-only telemetry.py for any OTLP backend, with Maple as the example. Drop the severity mapping, shorten the basicConfig callout and add copy buttons to every code block.
Maple review🟢 Confidence 8/10 · likely safe to merge Adds a self-contained Python logging-levels guide page, with a language-tab storage group and a console highlighter so the snippets don't fight other pages' remembered language. Mergeable once the
Before merge
Still open from earlier reviews
Production impactProduction traffic of the changed files (last 7 days)
Ingest cost of new log lines
What was checked
|
Adds
/guides/python-logging-levels, a beginner-first explainer and how-to for the levels in Python's standardloggingmodule.Covers
basicConfigandsetLevel, whylog.info()prints nothing by default (WARNING), and a question list for choosing a level. Levels use the named constants only, no numeric values.--log-levelflag or aLOG_LEVELvariable (tabs), thebasicConfigruns-once callout (one sentence plus thesetLevelfix), and quieting noisy libraries with per-logger levels.telemetry.py(endpoint, auth header, service name, a terminal handler for every level and aLoggingHandlerat INFO on the root logger), how to run it with real output, and what you see on Maple's Logs page (two screenshots). Maple is the example backend; a local OpenTelemetry Collector endpoint is given as the alternative.Level colors use the
--severity-*tokens that Maple's Logs page uses, in the badges, tables and code. Every code block has a copy button (bindCopyButtonsfromsrc/lib/copy-to-clipboard.ts, as in the Loguru guide); output blocks don't.Shared code (additive)
LanguageTabstakes an optionalgroupstorage key, so this page's tabs don't overwrite the language a reader picked elsewhere on the site.guide-highlight.ts: aconsolemode for terminal sessions and more Python keywords.Also fixes
content/docs/guides/instrumentation-python.md. Oncetelemetry.pyhas attached its handler,basicConfig(level=...)does nothing, so the docs now say to calllogging.getLogger().setLevel(...)and link to this guide.Search intent: what the Python logging levels are, the default level, and how to set the level in code, from the command line or from an environment variable.
Maple docs linked:
/docs/explore/logs, and/docs/guides/instrumentation-pythonfrom the closing card only (for traces and metrics).Verification: every Python snippet on the page was run on Python 3.14.5 and the sample outputs are from those runs. The
telemetry.pyandapp.pypair was run with opentelemetry-sdk 1.45.1, opentelemetry-exporter-otlp-proto-http 1.45.1 and opentelemetry-instrumentation-logging 0.66b1 against a local OTLP/HTTP receiver: the terminal shows all three lines, the receiver gets the INFO and WARNING records with the service name and auth header, and without the urllib3 line the exporter's DEBUG request logs print.bun run --cwd apps/landing buildpasses; the page was reviewed in Playwright at desktop and mobile widths.Sources: Python docs (logging, Logging HOWTO), the OTLP specification and PyPI opentelemetry-instrumentation-logging.
Summary by CodeRabbit
New Features
Documentation