spandex-project / spandex

A platform agnostic tracing library
MIT License
333 stars 53 forks source link

Support distributed trace sampling #142

Open reachfh opened 2 years ago

reachfh commented 2 years ago

This PR makes changes to priority to support distributed tracing and sampling.

In distributed tracing, an upstream process may set an HTTP header indicating that the current request should be sampled. We need to determine if that header was present, and optionally make a decision about whether to sample the request if it is not already set. The application code may also need to increase priority for the trace later, e.g. if there is an error in the request.

This PR sets the default priority as nil instead of 1, allowing code to identify if it has been set already. The application can make a sampling decision if it is the first application in the trace, otherwise the current value will be maintained. This PR adds functions to get and set the current trace priority.

Most of the details are specific to the back end library, and are handled by spandex_datadog in this PR: https://github.com/spandex-project/spandex_datadog/pull/52

Features:

Breaking Changes:

Potentially Breaking Changes:

Bug Fixes:

zachdaniel commented 1 year ago

Its been a while, but @reachfh have you tried this in production? Does it have the intended effect?