libbmq 2f89e4a12c66e1eef53d27df596a2d59742f6a67
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bmqpi_dtcontext.h File Reference

Provide an interface for a context with a notion of a current span. More...

#include <bmqpi_dtspan.h>
#include <bsl_memory.h>
#include <bslma_managedptr.h>

Go to the source code of this file.

Classes

class  BloombergLP::bmqpi::DTContext
 A pure interface for a context with a notion of a current span. More...
 

Namespaces

namespace  BloombergLP
 
namespace  BloombergLP::bmqpi
 

Detailed Description

bmqpi::DTContext is a pure interface representing a context which defines a "current" bmqpi::DTSpan for the calling thread. Implementations may return different spans for each thread, or return a single span shared by all calling threads.

Many distributed trace libraries provide a well-defined thread-local storage slot for the span currently under execution, which allows a function to obtain a reference to its caller across library boundaries, without changes to its API to facilitate dependency injection. This storage slot is set by instantiating an RAII "Span Guard" that writes a span to the TLS at construction, and reverts its state on destruction (emulating the semantics of a call-stack). The API of bmqpi::DTContext aims to make it easy to wrap these common patterns in a library-agnostic manner, while also facilitating test double implementations.