trace-analysis
Skill4 starsChanged 2 months agoMITView on GitHub
Use when debugging issues with Grafana Tempo traces, analyzing request flows, finding slow operations, or investigating errors. Use this skill for any production debugging that requires trace analysis, span inspection, or performance investigation.
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 4 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 136
Check error details in span attributes:
- Distinctive: line 141
Look at input that caused the error:
- Distinctive: line 151
Check call hierarchy in trace view:
- Very specific: line 163
Check component order: router → middleware → controller → service → repository
- Very specific: line 164
Verify data transformation via method.input.json and method.output.json
- Distinctive: line 200
Look for: error status codes, long durations between spans, gaps in the trace, and unexpected span attributes.
- Very specific: line 203
Read span attributes (input, output, error.message) to understand what went wrong.
- Very specific: line 226
Check OTEL_COLLECTOR_TRACE_URL in Config
- Very specific: line 227
Verify startTelemetry() called at startup
- Very specific: line 228
Check if class is resolved via DI container (auto-traced via autoTrace)
- Very specific: line 234
Check method.result.keys for object structure
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Trace Analysis
Analyze distributed traces in Grafana Tempo using span attributes from packages/api/typescript/src/shared/utils/Tracing.ts.
When to Use
- Debugging production errors or unexpected behavior
- Investigating slow API responses
- Analyzing request flows across services
- Finding error patterns in specific endpoints
When NOT to Use
- Local development debugging (use console logs or debugger)
- Investigating frontend-only issues
- Database performance issues (use Grafana dashboards instead)
Available Span Attributes
Class/Component
| Attribute | Type | Description |
class.name | string | Class name (e.g., CreateUserUseCase) |
class.component | string | Component type: router, middleware, controller, service, repository, handler, factory, event, mediator |
class.module | string | Context/module name (e.g., user, appointment) |
Method
| Attribute | Type | Description |
method.name | string | Method name (e.g., execute, save) |
method.type | string | async or sync |
method.args.count | number | Number of arguments passed |
method.input.json | string | JSON stringified input arguments |
method.output.json | string | JSON stringified return value |
method.duration.ms | number | Execution time in milliseconds |
method.timestamp.start | number | Unix timestamp when method started |
method.timestamp.end | number | Unix timestamp when method ended |
Result
| Attribute | Type | Description |
method.result.type | string | typeof result (object, string, etc.) |
method.result.has_value | boolean | Whether method returned a value |
method.result.constructor | string | Result object's constructor name |
method.result.keys | string | Comma-separated object keys |
Error
| Attribute | Type | Description |
method.error.type | string | Error constructor name (e.g., BaseError) |
method.error.message | string | Error message |
method.error.stack | string | Full stack trace |
TraceQL Queries
Find Errors
// All errors in a module
{ class.module = "appointment" && status = error }
// Specific error type
{ method.error.type = "ValidationError" }
// Errors containing message
{ method.error.message =~ ".*not found.*" }Performance Analysis
// Slow operations (>1000ms)
{ method.duration.ms > 1000 }
// Slow repository calls
{ class.component = "repository" && method.duration.ms > 500 }
// Slow use cases in specific module
{ class.component = "usecase" && class.module = "user" && method.duration.ms > 2000 }Filter by Component Layer
// All controller calls
{ class.component = "controller" }
// Repository operations for a module
{ class.component = "repository" && class.module = "appointment" }
// Event handlers
{ class.component = "handler" }Find Specific Operations
// Specific class and method
{ class.name = "CreateUserUseCase" && method.name = "execute" }
// All save operations
{ method.name = "save" }
// Search by input content
{ method.input.json =~ ".*email@example.com.*" }Trace Flow Analysis
// Full request trace for a module
{ class.module = "appointment" } | select(class.name, method.name, method.duration.ms)
// Compare async vs sync methods
{ method.type = "async" && class.component = "service" }Debugging Workflows
Investigating a Failed Request
- Find the error span:
{ status = error && class.module = "<module>" } - Check error details in span attributes:
method.error.type- What error classmethod.error.message- Error descriptionmethod.error.stack- Stack trace
- Look at input that caused the error:
method.input.json- Arguments passed
Performance Investigation
- Find slow operations:
{ method.duration.ms > 1000 } - Check call hierarchy in trace view:
- Which component is slowest?
- Which method within that component?
- Analyze pattern:
{ class.name = "SlowClass" } | rate() by (method.name)
Request Flow Analysis
- Get full trace for a request
- Check component order:
router→middleware→controller→service→repository - Verify data transformation via
method.input.jsonandmethod.output.json
Grafana Dashboard Queries
Error Rate by Module
sum(rate(traces_spanmetrics_calls_total{status="STATUS_CODE_ERROR"}[5m])) by (class_module)P95 Latency by Component
histogram_quantile(0.95, sum(rate(traces_spanmetrics_latency_bucket[5m])) by (le, class_component))Throughput by Use Case
sum(rate(traces_spanmetrics_calls_total{class_component="usecase"}[5m])) by (class_name)Debugging Process
Step 1: Identify the Symptom
Determine what you're investigating: error responses (5xx), slow requests, missing data, or unexpected behavior.
Step 2: Choose Query Strategy
| Symptom | Strategy |
| Known request | Search by traceId |
| Error on endpoint | Filter by http.route + status = error |
| Slow responses | Filter by duration > 1s + http.route |
| Missing data | Search by entity ID in span attributes |
Step 3: Analyze Spans
Look for: error status codes, long durations between spans, gaps in the trace, and unexpected span attributes.
Step 4: Identify Root Cause
Read span attributes (input, output, error.message) to understand what went wrong.
Complete Debugging Example
Problem: API returns 500 on POST /appointments
// Step 1: Search error spans
{ resource.service.name = "template-api" } && status = error && span.http.route = "POST /appointments"
// Step 2: Found error span with attributes:
// error.message: "DOCTOR_NOT_AVAILABLE"
// input: { doctorId: "abc-123", date: "2024-03-15" }
// module: "service"
// Step 3: Root cause — doctor availability not checked before scheduling
// Fix: Add availability validation in CreateAppointment use caseCommon Issues
Missing Traces
- Check
OTEL_COLLECTOR_TRACE_URLin Config - Verify
startTelemetry()called at startup - Check if class is resolved via DI container (auto-traced via
autoTrace)
Truncated Data
method.input.jsonandmethod.output.jsonare truncated at 10000 characters- Shows
[truncated]suffix when exceeded - Check
method.result.keysfor object structure
Unserializable Data
- Shows
[unserializable]for circular references or special objects - Common with streams, Buffers, complex class instances
References
packages/api/typescript/src/shared/utils/Tracing.ts- Tracing implementationpackages/api/typescript/src/shared/utils/Config.ts- OTEL configuration
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- ai-analyst-lab/ai-analyst★ 304same name
- rejot-dev/fragno★ 63same name
- itsmuskanagarwal/effective-agents-lab★ 0same name
- zl3311/alpha-mining★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository45 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- agentSkill
- bounded-contextSkill
- clean-branchSkill
- commitSkill
- componentSkill
- controllerSkill
- db-modellingSkill
- ddd-modelingSkill
- ddd-specSkill
- design-systemSkill
- desktop-shellSkill
- e2eSkill
- entitySkill
- enumSkill
- errorsSkill
- eventSkill
- formSkill
- grill-with-docsSkill
- handlerSkill
- handoffSkill
- middlewareSkill
- migrateSkill
- prdSkill
- primitiveSkill
- projectionSkill
- projectorSkill
- querySkill
- repositorySkill
- reviewSkill
- routeSkill
- saas-researchSkill
- schedulerSkill
- schemaSkill
- sdkSkill
- serviceSkill
- spec-reviewSkill
- storeSkill
- storybookSkill
- task-breakdownSkill
- testSkill
- ui-compositionSkill
- usecaseSkill
- user-storiesSkill
- value-objectSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

