Tracing Patterns

Implement distributed tracing with W3C Trace Context across NodeJS and Python services.

1|Updated Sep 14, 2025
One-click install
npx skills add https://github.com/CleanExpo/DR-NRPG --skill tracing-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Tracing Patterns
Source: https://github.com/CleanExpo/DR-NRPG/tree/main/.skills/custom/tracing-patterns
Command: npx skills add https://github.com/CleanExpo/DR-NRPG --skill tracing-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the challenge of understanding and debugging complex, distributed systems by providing a robust framework for implementing end-to-end distributed tracing.

Core Features & Use Cases

  • Context Propagation: Ensures trace context is automatically passed across service boundaries (e.g., Next.js to FastAPI) and between agent orchestrator, specialists, and tools.
  • Span Hierarchy: Creates a clear, nested structure of spans representing the flow of execution, making it easy to pinpoint latency or errors.
  • Automatic Instrumentation: Integrates with frameworks like FastAPI and SQLAlchemy to automatically create spans for requests and database queries, minimizing manual code changes.
  • Use Case: Debugging a slow API request that involves multiple microservices, an agent performing several sub-tasks, and database interactions. This Skill allows you to visualize the entire request lifecycle, identify the bottleneck, and understand the root cause.

Quick Start

Apply the Tracing Patterns skill to instrument your FastAPI application by adding the TracingMiddleware as the outermost middleware.

Frequently Asked Questions about Tracing Patterns

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

FAQPage Schema
How do I implement distributed tracing across FastAPI and Next.js microservices?

Distributed tracing across FastAPI and Next.js microservices is implemented using W3C Trace Context propagation. Applying a TracingMiddleware as the outermost middleware automatically passes trace context across service boundaries and creates nested spans for execution flow visualization.

How does W3C Trace Context propagation work for debugging slow API requests?

W3C Trace Context propagation works for debugging slow API requests by passing trace context across service boundaries, creating a nested span hierarchy. This structure visualizes the entire request lifecycle across microservices, agents, and databases to pinpoint latency bottlenecks and root causes.

Can I use automatic instrumentation for SQLAlchemy database queries in Python?

Yes, you can use automatic instrumentation for SQLAlchemy database queries in Python. The tracing integration automatically creates spans for database queries and API requests, minimizing manual code changes while capturing database interactions within the distributed trace.

Does distributed tracing for NodeJS and Python applications support agent workflows?

Distributed tracing for NodeJS and Python applications fully supports agent workflows. It propagates span context seamlessly between orchestrators, specialists, and tools, ensuring the complete execution flow of agent sub-tasks is captured within the trace hierarchy.

Do I need structlog to implement span context management in my application?

Integrating structlog is required for automatic instrumentation and span context management in your application. It works alongside frameworks like FastAPI, Next.js, and SQLAlchemy to ensure trace context is automatically captured and correlated with application logs.

What is the best way to visualize the request lifecycle in complex distributed systems?

The best way to visualize the request lifecycle in complex distributed systems is by implementing a nested span hierarchy using W3C Trace Context. This approach represents the flow of execution across microservices and databases, making it easy to identify performance bottlenecks.