Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions apps/landing/src/components/docs/LanguageTabs.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ interface Tab {
interface Props {
tabs: Tab[];
label?: string;
/** Storage key for the remembered pick. Groups that aren't a language choice pass their own. */
group?: string;
}

const { tabs, label = "Language" } = Astro.props;
const { tabs, label = "Language", group = "maple-docs-language" } = Astro.props;
const hasLogo = (id: string): id is LogoId => (LOGO_IDS as readonly string[]).includes(id);
---

<div class="lt" data-lang-tabs="maple-docs-language">
<div class="lt" data-lang-tabs={group}>
<div class="lt__rail" role="tablist" aria-label={label}>
{tabs.map((tab, index) => (
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ import logging
logging.getLogger(__name__).warning("Payment retry for order %s", order_id)
```

The root logger's level still applies. Python defaults it to `WARNING`, so call `logging.basicConfig(level=logging.INFO)` or set the level yourself to send `INFO` records.
The root logger's level still applies. Python defaults it to `WARNING`, so call `logging.getLogger().setLevel(logging.INFO)` to send `INFO` records. `logging.basicConfig(level=...)` does nothing once the root logger has a handler, so after `import telemetry` it no longer sets the level. See [Python logging levels](/guides/python-logging-levels) for per-module and per-handler levels.

## Verify

Expand Down
17 changes: 14 additions & 3 deletions apps/landing/src/lib/guide-highlight.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tiny highlighter for guide code blocks. The token classes match the colors a
// guide uses in its diagrams (metric name, labels, value), so a block reads the
// same way as the annotated example above it. Style the `tok-*` classes on the page.
export type GuideLang = "exposition" | "promql" | "yaml" | "python" | "typescript" | "go" | "rust" | "java" | "csharp";
export type GuideLang = "exposition" | "promql" | "yaml" | "console" | "python" | "typescript" | "go" | "rust" | "java" | "csharp";

const escape = (s: string) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
const span = (cls: string, text: string) => `<span class="tok-${cls}">${escape(text)}</span>`;
Expand Down Expand Up @@ -71,12 +71,23 @@ const python = (code: string) =>
tokenize(code, [
[/#.*/y, (m) => span("comment", m[0])],
[/"[^"\n]*"/y, (m) => span("labels", m[0])],
[/\b(?:from|import|def|with|as|return)\b/y, (m) => span("fn", m[0])],
[/\b(?:from|import|def|with|as|return|if|else|for|in|not|is|None|True|False|lambda|try|except|raise)\b/y, (m) => span("fn", m[0])],
[/\b(?:Counter|Gauge|Histogram|Summary)\b/y, (m) => span("name", m[0])],
[/\b\d+(?:\.\d+)?\b/y, (m) => span("value", m[0])],
[/[a-zA-Z_]\w*/y, (m) => escape(m[0])],
]);

// Terminal sessions: "$ command # note" lines; every other line is program output.
const consoleSession = (code: string) =>
code
.split("\n")
.map((line) => {
const cmd = /^(\$ )(.*?)(\s+#.*)?$/.exec(line);
if (!cmd) return escape(line);
return span("comment", cmd[1]) + span("fn", cmd[2]) + (cmd[3] ? span("comment", cmd[3]) : "");
})
.join("\n");

// Brace languages share one tokenizer: comments, strings, keywords, the metric
// classes (orange, like metric names), numbers.
const braces = (keywords: string) => {
Expand All @@ -99,4 +110,4 @@ const java = braces("import|public|static|final|class|void|new|try|throws");
const csharp = braces("using|var|new|await");

export const highlight = (code: string, lang: GuideLang) =>
({ exposition, promql, yaml, python, typescript, go, rust, java, csharp })[lang](code);
({ exposition, promql, yaml, console: consoleSession, python, typescript, go, rust, java, csharp })[lang](code);
7 changes: 7 additions & 0 deletions apps/landing/src/pages/guides/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ const investigationGuides = [
description: "Measure the right latency clock, isolate the slow requests, and trace a regression to the release and operation responsible.",
read: "14 min",
},
{
href: "/guides/python-logging-levels",
label: "Python",
title: "Python logging levels and how to set them",
description: "The five levels and when to use each, why info() prints nothing by default, and how to set the level with basicConfig, a --log-level flag or LOG_LEVEL.",
read: "6 min",
},
];

const fieldNotes = (await getCollection("blog") as BlogPost[])
Expand Down
623 changes: 623 additions & 0 deletions apps/landing/src/pages/guides/python-logging-levels.astro

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/landing/src/pages/llms.txt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const GET: APIRoute = ({ site }) => {
`- [What is OpenTelemetry?](${url("/opentelemetry")})`,
`- [Best open-source observability tools](${url("/best-open-source-observability-tools")})`,
`- [Dynatrace pricing, explained](${url("/guides/dynatrace-pricing")})`,
`- [Python logging levels and how to set them](${url("/guides/python-logging-levels")})`,
"",

"## Maple API",
Expand Down
Loading