Skip to content

Is my application leaking memory when the Trace Agent is being used?

Kelvin Jin edited this page Oct 3, 2018 · 1 revision

Spans

Each request in your Node server is represented as a trace, which are composed of one root span and zero or more child spans. The root span measures the latency of the request as a whole, while child spans measure outgoing RPCs done on behalf of a request. In other words:

  • Root spans
    • start when your server's request handler is first invoked.
    • end when you end the response stream (via res.end or similar).
  • Child spans
    • start when you call an asynchronous function.
    • end when the callback provided to that asynchronous function is invoked.

Context Propagation across Asynchronous Boundaries

A difficulty in representing spans as written above is that child spans always have a parent root span, but sometimes, when a child span is started, the parent is unknown. In other words, there is no generically applicable way for automatic instrumentation to know on behalf of which request an outgoing RPC is being performed.