Copyright | (c) Ian Duncan 2021 |
---|---|
License | BSD-3 |
Maintainer | Ian Duncan |
Stability | experimental |
Portability | non-portable (GHC extensions) |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
The ability to correlate events across service boundaries is one of the principle concepts behind distributed tracing. To find these correlations, components in a distributed system need to be able to collect, store, and transfer metadata referred to as context.
A context will often have information identifying the current span and trace, and can contain arbitrary correlations as key-value pairs.
Propagation is the means by which context is bundled and transferred in and across services, often via HTTP headers.
Together, context and propagation represent the engine behind distributed tracing.
Synopsis
- data Key a
- newKey :: MonadIO m => Text -> m (Key a)
- data Context
- class HasContext s where
- empty :: Context
- lookup :: Key a -> Context -> Maybe a
- insert :: Key a -> a -> Context -> Context
- adjust :: (a -> a) -> Key a -> Context -> Context
- delete :: Key a -> Context -> Context
- union :: Context -> Context -> Context
- insertSpan :: Span -> Context -> Context
- lookupSpan :: Context -> Maybe Span
- removeSpan :: Context -> Context
- insertBaggage :: Baggage -> Context -> Context
- lookupBaggage :: Context -> Maybe Baggage
- removeBaggage :: Context -> Context
Documentation
Keys are used to allow cross-cutting concerns to control access to their local state. They are unique such that other libraries which may use the same context cannot accidentally use the same key. It is recommended that concerns mediate data access via an API, rather than provide direct public access to their keys.
A Context
is a propagation mechanism which carries execution-scoped values
across API boundaries and between logically associated execution units.
Cross-cutting concerns access their data in-process using the same shared
Context
object
removeSpan :: Context -> Context Source #
removeBaggage :: Context -> Context Source #