Skip to content

Conversation

@codyde
Copy link
Contributor

@codyde codyde commented Oct 27, 2025

Overview

Updates the span metrics instrumentation examples page with comprehensive, real-world use cases demonstrating how to instrument both frontend and backend code for distributed tracing.

What's New

Four Complete Examples with Sample Repositories

  1. E-Commerce Checkout Flow (Crash Commerce)

    • Frontend: React checkout button instrumentation with ui.action spans
    • Backend: Order processing and payment provider spans
    • Demonstrates: Cart metrics, payment provider tracking, end-to-end checkout flow
    • Metrics to monitor: p95 duration by cart size, error rates by payment provider
  2. Media Upload with Background Processing (SnapTrace)

    • Frontend: Upload experience tracking with file.upload spans
    • Backend: Validation spans and async media processing
    • Demonstrates: User-perceived upload time, async background jobs, trace continuity
    • Metrics to monitor: p95 by file size, processing success rates, storage optimization
  3. Search Autocomplete (NullFlix)

    • Frontend: Debounced search with abort handling
    • Backend: Search performance with query categorization
    • Demonstrates: Cancellable requests, slow query detection, performance patterns
    • Metrics to monitor: p95 by query length, cancellation rates, empty result rates
  4. Manual LLM Instrumentation (Customer Service Bot)

    • Frontend: AI chat interface with agent spans
    • Backend: Custom LLM integration with tool execution
    • Demonstrates: AI agent conventions, token tracking, tool call monitoring
    • Metrics to monitor: Token usage, tool performance, agent effectiveness

Key Improvements

  • Practical, production-ready examples - Each example shows real-world monitoring scenarios
  • End-to-end tracing - Demonstrates how frontend and backend spans work together in a distributed trace
  • Best practices - Shows proper span naming, attribute usage, and error handling
  • Actionable metrics - Each example includes specific span metrics queries to monitor
  • Sample repos - Links to working example repositories with Arcade demos
  • Implementation guidance - Clear notes on where to place instrumentation code

Content Structure

Each example includes:

  • Challenge statement - The monitoring problem to solve
  • Solution approach - How to instrument with spans and attributes
  • Code examples - Frontend and backend instrumentation
  • Implementation notes - Where to add code in your app
  • Trace flow explanation - How the spans connect in a distributed trace
  • Monitoring guidance - Specific span metrics queries to use

@vercel
Copy link

vercel bot commented Oct 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
develop-docs Ready Ready Preview Comment Oct 31, 2025 8:33am
sentry-docs Ready Ready Preview Comment Oct 31, 2025 8:33am

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@codyde codyde requested review from Lms24, chargome and s1gr1d October 27, 2025 09:24
@codecov
Copy link

codecov bot commented Oct 27, 2025

Bundle Report

Changes will increase total bundle size by 293.61kB (1.27%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-client-array-push 10.16MB -6 bytes (-0.0%) ⬇️
sentry-docs-server-cjs 12.84MB 293.61kB (2.34%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.74MB -0.0%
../instrumentation.js -3 bytes 1.07MB -0.0%
9523.js -3 bytes 1.04MB -0.0%
../app/[[...path]]/page.js.nft.json 97.87kB 847.23kB 13.06% ⚠️
../app/platform-redirect/page.js.nft.json 97.87kB 847.15kB 13.06% ⚠️
../app/sitemap.xml/route.js.nft.json 97.87kB 844.38kB 13.11% ⚠️
view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 882.71kB -0.0%
static/chunks/8321-*.js -3 bytes 425.87kB -0.0%
static/k3XKDfmu226boiH80XZgb/_buildManifest.js (New) 684 bytes 684 bytes 100.0% 🚀
static/k3XKDfmu226boiH80XZgb/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/tsnKZj96qpetzf3TqAAMr/_buildManifest.js (Deleted) -684 bytes 0 bytes -100.0% 🗑️
static/tsnKZj96qpetzf3TqAAMr/_ssgManifest.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️

cursor[bot]

This comment was marked as outdated.

- Add four comprehensive real-world examples with sample repositories
- E-Commerce Checkout Flow (Crash Commerce)
- Media Upload with Background Processing (SnapTrace)
- Search Autocomplete (NullFlix)
- Manual LLM Instrumentation (Customer Service Bot)
- Fix high-cardinality span name in payment processing
- Add missing gen_ai.response.model attribute to AI agent span
- Include implementation guidance and monitoring recommendations
- Fix duplicate finalResponse declaration (line 719)
- Fix undefined uploadId reference, use uploadData.jobId instead (line 224)
- Fix function name mismatch, call searchKnowledgeBase instead of executeKnowledgeBaseSearch (line 708)
- Serialize processing.operations array with JSON.stringify()
- Ensures proper attribute serialization in Sentry spans
- Follows Sentry conventions for non-primitive span attributes
File Upload Example:
- Use proper queue operations (queue.publish/queue.process)
- Add queue instrumentation attributes (messaging.*)
- Implement trace continuation with continueTrace()
- Link to Queues Module documentation
- Align span names with queue docs pattern (queue_producer/queue_consumer)

Search Autocomplete Example:
- Change manual span from http.client to function op
- Let SDK auto-instrument fetch requests
- Don't re-throw AbortError to avoid sending to Sentry
- Return empty results on abort instead

LLM Example:
- Add link to AI Agents Module documentation
- Reference gen_ai attribute specifications

All changes follow Sentry's documented conventions and patterns.
Remove ✨ and ❌ emoji characters from code examples that were causing
'InvalidCharacterError: Failed to execute atob' errors in docs.

The atob function only supports Latin1 (ISO-8859-1) characters, and
emojis are outside that range, causing encoding issues during page
rendering.
Replace em dashes (—) with hyphens (-) and arrows (→) with (->)
These Unicode characters were causing 'atob' encoding errors:
'InvalidCharacterError: Failed to execute atob on Window'

The atob function only supports Latin1 (ISO-8859-1) characters.
All special Unicode characters have been replaced with ASCII equivalents.
The high-cardinality fix was reverted during rebase.
Changed back from template literal to static name:
- name: 'Charge Payment Provider' (not `Charge ${requestedProvider}`)
This attribute was lost during the rebase and needs to be present
in the frontend invoke_agent span for proper AI monitoring.
Replace 'Coming soon' with link to actual example repository:
https://github.com/getsentry/llm-manual-agent-monitoring-example

This repo demonstrates custom AI agent instrumentation with tool calls,
token tracking, and conversation monitoring.
@semgrep-code-getsentry
Copy link

Semgrep found 1 ssc-6e8d64d7-d1a9-4807-b6e7-8a16a1a2085c finding:

Risk: Affected versions of next are vulnerable to Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling'). A vulnerability in Next.js can enable an attacker to poison the cache. Under certain conditions, a HTTP 204 response may be cached for static pages, causing all subsequent requests to receive an empty response and effectively leading to a Denial of Service condition.

Manual Review Advice: A vulnerability from this advisory is reachable if you are using ISR with cache revalidation (in next start or standalone mode), and route using SSR, and you are not hosting on Vercel

Fix: Upgrade this library to at least version 15.1.8 at sentry-docs/pnpm-lock.yaml:6643.

Reference(s): GHSA-67rr-84xm-4c7r, CVE-2025-49826

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants