port-span-names

Ports Sentry span ops to low-cardinality span names gated on span streaming.

8.7k|1.8k|Updated Feb 1, 2012
One-click install
npx skills add https://github.com/getsentry/sentry-javascript --skill port-span-names
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: port-span-names
Source: https://github.com/getsentry/sentry-javascript/tree/main/.agents/skills/port-span-names
Command: npx skills add https://github.com/getsentry/sentry-javascript --skill port-span-names

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Raw URLs, IDs, and query strings leaking into Sentry span names create high-cardinality telemetry that breaks grouping and analysis. This Skill guides the systematic porting of a span op (e.g. navigation, db.query, http.client) to low-cardinality names in the sentry-javascript monorepo, applied only when span streaming is enabled.

Core Features & Use Cases

  • Convention-driven naming: Looks up the Sentry span name conventions, adds a static fallback constant to packages/core/src/tracing/spans/spanNames.ts, and applies it via inline ternaries gated on hasSpanStreamingEnabled(client).
  • Exhaustive site discovery: Provides grep patterns to find every span start site, name update site, and reader that compares span names against URLs or routes.
  • Safety guards: Ensures fallback names never reach scope.setTransactionName, keeps sentry.segment.name consistent with the segment span, and preserves attributes like sentry.source and url.template unchanged.
  • Use Case: When asked to "port navigation spans to low cardinality names", the Skill walks through finding all naming sites, applying the fallback, fixing readers, guarding the scope transaction name, running tests, and documenting the change in MIGRATION.md.

Quick Start

Ask the AI to port the navigation span op to low-cardinality span names following the Sentry span name conventions.

Frequently Asked Questions about port-span-names

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

FAQPage Schema
How do I make Sentry span names low cardinality?

Look up the op in the Sentry span name conventions, add a static fallback constant to packages/core/src/tracing/spans/spanNames.ts, and apply it at each naming site with an inline ternary gated on hasSpanStreamingEnabled(client). Never rewrite names retroactively at capture or serialization time.

How do I find every site that names a span with a given op?

Grep for SEMANTIC_ATTRIBUTE_SENTRY_OP with the op value across packages/*/src, plus .updateName( and updateSpanName( for later writes, and spanToJSON(...).name for readers that compare names against URLs. Missing a site leaves a raw URL in production.

Does the low-cardinality fallback apply when span streaming is disabled?

No. With traceLifecycle: 'static', every span name must stay byte-identical to before. The fallback only applies when hasSpanStreamingEnabled(client) returns true, checked inline at each naming site.

Why must the fallback name never reach setTransactionName?

The scope's transaction name is what error events are grouped by, so it must keep the raw URL or parameterized route. Passing a fallback like Navigation would break error grouping, so guard those call sites and pin the behavior with a test.

What are the limitations of this span naming approach?

It forbids shared helper functions, attribute-derived name resolution, and retroactive name rewriting in captureSpan or spanToJSON. Each site uses an inline ternary, and only the name changes while attributes like sentry.source and url.template stay untouched.