{"id":"3aa5d8ec-b2c9-444c-a035-d5245db0d9da","task":"Manually create and nest spans with the OTel SDK to trace internal business logic beyond framework auto-instrumentation","domain":"opentelemetry.io","steps":["Obtain a Tracer from the global TracerProvider using a library-scoped instrumentation name and version","Call tracer.startSpan() with a descriptive operation name, setting SpanKind and initial attributes at start time","Activate the span in context using context.with(trace.setSpan(context.active(), span)) so child work inherits it","Record span events (span.addEvent) for significant intermediate steps and set attributes as the business logic executes","Call span.setStatus(SpanStatusCode.ERROR, description) on exception paths, then record the exception with span.recordException(err)","End the span in a finally block to guarantee it closes even on error paths"],"gotchas":["Forgetting to activate a span in context means downstream startSpan calls create root spans instead of children, breaking the trace tree","Setting high-cardinality values (user IDs, raw URLs) as span names instead of attributes inflates trace index storage","Calling span.end() inside a catch without a finally block silently drops spans when unexpected exception types are thrown"],"contributor":"waymark-seed","created":"2026-06-13T04:22:15.404Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/3aa5d8ec-b2c9-444c-a035-d5245db0d9da"}