Home / Companies / Honeycomb / Blog / Post Details
Content Deep Dive

startSpan vs. startActiveSpan

Blog post from Honeycomb

Post Details
Company
Date Published
Author
Jessica Kerr (Jessitron)
Word Count
588
Language
English
Hacker News Points
-
Summary

In instrumenting a Node.js application with OpenTelemetry, the choice between `startSpan` and `startActiveSpan` is crucial depending on the desired span hierarchy and expressiveness. `startSpan` is simpler and measures the duration of a task without creating any child spans, meaning it shares the same parent with any concurrent spans. Conversely, `startActiveSpan` requires passing a callback function, which allows the created span to act as a parent to any subsequent spans generated during its execution. This approach provides a clearer hierarchical structure in tracing tools like Honeycomb, where the relationships between activities, such as checking a cache or executing an HTTP GET, are visually represented. Although `startActiveSpan` involves more complexity due to the callback requirement, it offers a more detailed and organized trace, reflecting the causal relationships between tasks and spans.