add-tracing
БесплатноБез исполняемых скриптовНе проверенAdd OpenTelemetry tracing spans to Clojure code following Metabase tracing conventions. Use when instrumenting backend code with trace coverage.
от metabase★ 50 742 звезды на GitHubОб этом скилле
Add Tracing Spans to Clojure Code
This skill helps you add OpenTelemetry (OTel) tracing spans to the Metabase backend codebase using the custom tracing/with-span macro.
Reference Files
src/metabase/tracing/core.clj-with-spanmacro, group registry, SDK lifecycle,best-effort-sanitize-sql, Pyroscope integrationsrc/metabase/task/impl.clj-defjobmacro that wraps Quartz jobs with root spans.clj-kondo/config/modules/config.edn- Module boundary configuration
Module Architecture
The tracing module has a deliberately minimal API surface. Only 2 namespaces are public (listed in :api in the module config):
| Namespace | Role | Status |
|---|---|---|
tracing.core |
Primary API: with-span, groups, SDK lifecycle, Pyroscope, MDC, best-effort-sanitize-sql |
Public API |
tracing.init |
Side-effect loader for quartz and settings |
Public API (init convention) |
tracing.attributes |
best-effort-sanitize-sql implementation (re-exported via tracing.core) |
Internal |
tracing.settings |
Setting definitions (MB_TRACING_* env vars) |
Internal |
tracing.quartz |
Quartz JDBC proxy + JobListener | Internal |
Rules:
- Only require
[metabase.tracing.core :as tracing]from outside the module.tracing/best-effort-sanitize-sqland all other public functions are available from this single namespace. - Do not add new API namespaces. Add new public functions to
tracing.coreinstead. - Do not require internal namespaces (
tracing.attributes,tracing.settings,tracing.quartz) from outside the module. :uses :anyon thecoremodule does NOT bypass the target module's:apicheck — internal namespaces are still enforced.
Cyclic Dependency Avoidance
tracing/core.clj is required by many modules across the codebase. It must NOT compile-time require tracing.settings, as this creates transitive cyclic load dependencies (e.g., settings/core -> tracing/settings -> tracing/core -> events/impl -> events/core).
Instead, tracing/core.clj uses requiring-resolve for settings access:
;; CORRECT — lazy runtime resolution, no compile-time dependency
((requiring-resolve 'metabase.tracing.settings/tracing-enabled))
;; WRONG — creates cyclic load dependency
(require '[metabase.tracing.settings :as settings])
(settings/tracing-enabled)
External library namespaces (clj-otel API, SDK, exporters) are safe to require normally — they don't participate in Metabase namespace cycles.
Important: requiring-resolve must use literal quoted symbols. Kondo hooks validate that required-namespaces are all simple symbols, so dynamic construction fails:
;; CORRECT — literal quoted symbol
(requiring-resolve 'metabase.tracing.settings/tracing-endpoint)
;; WRONG — kondo hook rejects this: "Assert failed: (every? simple-symbol? required-namespaces)"
(requiring-resolve (symbol "metabase.tracing.settings" "tracing-endpoint"))
Quick Checklist
When adding tracing spans:
- Module has
tracingin its:usesset in.clj-kondo/config/modules/config.edn - Added
[metabase.tracing.core :as tracing]to ns requires (alphabetically sorted) - Span wraps a meaningful I/O boundary (not pure computation)
- Group matches the domain (check
src/metabase/tracing/core.cljfor registered groups; add a new one if none fit) - Span name follows dot-notation convention (
"domain.subsystem.operation") - Attributes use namespaced keywords (
:search/query-length,:db/id) - No sensitive data in attributes (use
best-effort-sanitize-sqlfor HoneySQL, never raw SQL) - No new tracing namespaces created (add to
tracing.coreinstead) - No
DO_NOT_ADD_NEW_FILES_HERE.txtviolations in the target directory - Run
clj-kondo --lint <files>to verify 0 errors, 0 warnings - Add or update tests in the corresponding
test/path (see Testing section below) - Run tests:
clojure -X:dev:test :only <test-ns>
The with-span Macro
(tracing/with-span group span-name attrs & body)
- group - A keyword selecting which trace group this span belongs to (e.g.,
:tasks,:sync) - span-name - A string identifying the span in traces (e.g.,
"search.execute") - attrs - A map of span attributes (e.g.,
{:db/id 42}) - body - The code to execute inside the span
When disabled: zero overhead -- single atom deref + boolean check, body runs directly.
When enabled: creates OTel span AND injects trace_id/span_id into Log4j2 MDC for log-to-trace correlation.
Trace Groups
Groups are registered in src/metabase/tracing/core.clj. Check that file for the current list. The general rule: match the group to the domain, not the call site. If code runs inside a Quartz job but is logically search work, use :search, not :tasks.
To add a new group:
;; In src/metabase/tracing/core.clj
(register-group! :my-domain "Description of what this cove
Установить add-tracing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл add-tracing?
Add OpenTelemetry tracing spans to Clojure code following Metabase tracing conventions. Use when instrumenting backend code with trace coverage.
Как установить скилл add-tracing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл add-tracing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic