sentry-instrumentation-guide

Decide whether code instrumentation should emit errors, spans, logs, or metrics in Sentry.

Updated Apr 22, 2026
One-click install
npx skills add https://github.com/imrishuroy/algopatterns --skill sentry-instrumentation-guide-imrishuroy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sentry-instrumentation-guide
Source: https://github.com/imrishuroy/algopatterns/tree/main/.agents/skills/sentry-instrumentation-guide
Command: npx skills add https://github.com/imrishuroy/algopatterns --skill sentry-instrumentation-guide-imrishuroy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? When instrumenting code with Sentry, it is rarely obvious whether a value should become an error, a span attribute, a log, or a metric. Choosing the wrong signal leaves data technically present but useless for the workflow you need later, such as alerting, debugging a single request, or tracking an issue to resolution. ## Core Features & Use Cases - Signal Decision Framework: Maps each of the four Sentry signals (errors, traces, logs, metrics) to the question it answers and the workflow it feeds. - Overlap Tiebreakers: Resolves ambiguous cases like span attribute vs metric, log vs span, log vs metric, and error vs log with concrete rules. - Retention Guidance: Explains why traces are sampled while logs and metrics are filtered, so retention matches each signal's purpose. - Use Case: While adding observability to a recommendations endpoint, use this Skill to decide that the ranking outcome belongs as a span attribute, the decision state as a structured log, and the served rate as a metric. ## Quick Start Ask the agent to review your request handler and decide which Sentry signal each value should be emitted as.

Frequently Asked Questions about sentry-instrumentation-guide

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

FAQPage Schema
How do I choose between a Sentry log, span, and metric?

Match the signal to the question it answers: spans show where time went in a request, logs record the state and reasoning at a decision point, and metrics track rates and trends over time. The skill provides a decision table mapping common questions to the right signal.

When should I use a span attribute vs a metric in Sentry?

Use a span attribute for context about one request's flow that you read inside a trace, and a metric for a standalone value you want to chart, alert on, or slice across all requests. The same value can legitimately be emitted as both.

Should I log everything instead of using Sentry metrics?

No. Deriving a rate by counting log lines means storing every line just to compute a number a metric emits directly and cheaply. Emit the metric for the aggregate and the log when you also need to reconstruct individual requests.

Does this skill set up the Sentry SDK for my platform?

No. This skill decides what to emit, not how to configure the SDK. For setup, it hands off to the platform-specific sentry-*-sdk skills such as sentry-python-sdk or sentry-nextjs-sdk, which cover init flags and API signatures.

Why are Sentry traces sampled but logs are not?

Traces are sampled because a representative slice is enough to understand where time goes. Logs are filtered rather than sampled because their purpose is finding the one rare request that went wrong, which sampling could discard.