add-tracing

Add OpenTelemetry tracing spans to Clojure backend code following Metabase conventions.

49.0k|6.8k|Updated Feb 2, 2015
One-click install
npx skills add https://github.com/metabase/metabase --skill add-tracing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-tracing
Source: https://github.com/metabase/metabase/tree/main/.claude/skills/add-tracing
Command: npx skills add https://github.com/metabase/metabase --skill add-tracing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Instrumenting a large Clojure codebase with OpenTelemetry tracing requires consistent span naming, attribute conventions, module boundary rules, and cyclic dependency avoidance. This Skill codifies Metabase's tracing conventions so spans are added correctly the first time.

Core Features & Use Cases

  • Span Instrumentation Guidance: Wraps meaningful I/O boundaries (database queries, external API calls, batch processing) with the tracing/with-span macro using correct groups, dot-notation span names, and namespaced keyword attributes.
  • Module Architecture Enforcement: Ensures only the public metabase.tracing.core namespace is required, prevents new tracing namespaces, and avoids cyclic load dependencies via requiring-resolve with literal quoted symbols.
  • Safe SQL Attributes: Enforces use of best-effort-sanitize-sql so HoneySQL queries appear in traces as parameterized statements without leaking data.
  • Use Case: When adding trace coverage to a new sync task, the Skill walks through checking module :uses config, adding the require, wrapping the I/O boundary, writing enabled/disabled tests, and running clj-kondo lint checks.

Quick Start

Add OpenTelemetry tracing spans to my Clojure namespace following the Metabase tracing conventions, then lint and test the changes.

Frequently Asked Questions about add-tracing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add OpenTelemetry tracing to Clojure code?

Wrap I/O-boundary code with the tracing/with-span macro, passing a group keyword, a dot-notation span name string, an attribute map, and the body. Require only metabase.tracing.core and register new groups with register-group! in tracing/core.clj.

What code should be wrapped in tracing spans?

Trace meaningful I/O boundaries: external API calls, database queries, network requests, heavy batch processing, and top-level orchestration functions. Do not trace pure computation, trivial single-row lookups, or every function in a call chain.

How do I include SQL in span attributes safely?

Always use tracing/best-effort-sanitize-sql, which converts HoneySQL maps into parameterized SQL strings with ? placeholders so no data leaks. Never put raw SQL strings or user-provided values into span attributes.

Why does requiring tracing.settings cause a cyclic dependency error?

tracing/core.clj is required by many modules, so a compile-time require of tracing.settings creates transitive load cycles. Use (requiring-resolve 'metabase.tracing.settings/tracing-enabled) with a literal quoted symbol instead.

Do Quartz jobs need a manual root span?

No. The defjob macro in metabase.task.impl automatically wraps every Quartz job with a :tasks root span. Only add child spans for I/O operations inside the job body; plain Threads need a manual root span.