-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Distributed tracing -- -- https://github.com/mtth/tracing @package tracing @version 0.0.2.2 -- | This module exposes the generic MonadTrace class. module Control.Monad.Trace.Class -- | A monad capable of generating traces. -- -- There are currently two instances of this monad: -- --
-- sampledWhen b = if b then alwaysSampled else neverSampled --sampledWhen :: Bool -> Sampling -- | Returns a debug Sampling. Debug spans are always sampled. debugEnabled :: Sampling -- | The type of annotations' keys. -- -- Keys starting with double underscores are reserved and should not be -- used. type Key = Text -- | Metadata attached to a span. data Value -- | Generates a tag value from a double. tagDoubleValue :: Double -> Value -- | Generates a 64-bit integer tag value from any integer. tagInt64Value :: Integral a => a -> Value -- | Generates a Unicode text tag value. tagTextValue :: Text -> Value -- | Generates a log value with the time of writing as timestamp. Note that -- the value may be written later than it is created. For more control on -- the timestamp, use logValueAt. logValue :: ToJSON a => a -> Value -- | Generates a log value with a custom time. logValueAt :: ToJSON a => POSIXTime -> a -> Value instance GHC.Show.Show Control.Monad.Trace.Class.Builder instance (GHC.Base.Monad m, Control.Monad.Trace.Class.MonadTrace m) => Control.Monad.Trace.Class.MonadTrace (Control.Monad.Trans.Except.ExceptT e m) instance (GHC.Base.Monad m, Control.Monad.Trace.Class.MonadTrace m) => Control.Monad.Trace.Class.MonadTrace (Control.Monad.Trans.Reader.ReaderT r m) instance (GHC.Base.Monad m, Control.Monad.Trace.Class.MonadTrace m, GHC.Base.Monoid w) => Control.Monad.Trace.Class.MonadTrace (Control.Monad.Trans.RWS.Lazy.RWST r w s m) instance (GHC.Base.Monad m, Control.Monad.Trace.Class.MonadTrace m, GHC.Base.Monoid w) => Control.Monad.Trace.Class.MonadTrace (Control.Monad.Trans.RWS.Strict.RWST r w s m) instance (GHC.Base.Monad m, Control.Monad.Trace.Class.MonadTrace m) => Control.Monad.Trace.Class.MonadTrace (Control.Monad.Trans.State.Lazy.StateT s m) instance (GHC.Base.Monad m, Control.Monad.Trace.Class.MonadTrace m) => Control.Monad.Trace.Class.MonadTrace (Control.Monad.Trans.State.Strict.StateT s m) instance (GHC.Base.Monad m, Control.Monad.Trace.Class.MonadTrace m, GHC.Base.Monoid w) => Control.Monad.Trace.Class.MonadTrace (Control.Monad.Trans.Writer.Lazy.WriterT w m) instance (GHC.Base.Monad m, Control.Monad.Trace.Class.MonadTrace m, GHC.Base.Monoid w) => Control.Monad.Trace.Class.MonadTrace (Control.Monad.Trans.Writer.Strict.WriterT w m) instance Control.Monad.Trace.Class.MonadTrace Data.Functor.Identity.Identity instance Data.String.IsString Control.Monad.Trace.Class.Builder -- | This module is useful for tracing backend implementors. If you are -- only interested in adding tracing to an application, start at -- Monitor.Tracing. module Control.Monad.Trace -- | Asynchronous trace collection monad. data TraceT m a -- | Trace an action. runTraceT :: TraceT m a -> Tracer -> m a -- | A tracer collects spans emitted inside TraceT. data Tracer Tracer :: TChan (Span, Tags, Logs, Interval) -> TVar Int -> Tracer -- | Channel spans get written to when they complete. [tracerChannel] :: Tracer -> TChan (Span, Tags, Logs, Interval) -- | The number of spans currently in flight (started but not yet -- completed). [tracerPendingCount] :: Tracer -> TVar Int -- | A collection of span tags. type Tags = Map Key Value -- | A collection of span logs, sorted in chronological order. type Logs = [(POSIXTime, Key, Value)] -- | Timing information about a span. data Interval Interval :: !POSIXTime -> !NominalDiffTime -> Interval [intervalStart] :: Interval -> !POSIXTime [intervalDuration] :: Interval -> !NominalDiffTime -- | Creates a new Tracer. newTracer :: MonadIO m => m Tracer instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Trace.TraceT instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trace.TraceT m) instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trace.TraceT m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Trace.TraceT m) instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trace.TraceT m) instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (Control.Monad.Trace.TraceT m) instance Control.Monad.IO.Unlift.MonadUnliftIO m => Control.Monad.Trace.Class.MonadTrace (Control.Monad.Trace.TraceT m) instance Control.Monad.IO.Unlift.MonadUnliftIO m => Control.Monad.IO.Unlift.MonadUnliftIO (Control.Monad.Trace.TraceT m) -- | This module implements a Zipkin-powered trace publisher. You -- will almost certainly want to import it qualified. module Monitor.Tracing.Zipkin -- | Zipkin creation settings. Note that its constructor is not -- exposed to allow backwards compatible evolution; Settings -- should instead be created either via defaultSettings or its -- IsString instance. data Settings -- | Creates empty Settings. You will typically use this (or the -- IsString instance) as starting point to only fill in the fields -- you care about: -- --
-- let settings = defaultSettings { settingsPort = Just 2222 }
--
defaultSettings :: Settings
-- | The Zipkin server's hostname, defaults to localhost if unset.
settingsHostname :: Settings -> Maybe HostName
-- | The port the Zipkin server is listening on, defaults to 9411
-- if unset.
settingsPort :: Settings -> Maybe PortNumber
-- | An optional HTTP manager to use for publishing spans on the Zipkin
-- server.
settingsManager :: Settings -> Maybe Manager
-- | Local endpoint included in all published spans.
settingsEndpoint :: Settings -> Maybe Endpoint
-- | If set to a positive value, traces will be flushed in the background
-- every such period.
settingsPublishPeriod :: Settings -> Maybe NominalDiffTime
-- | Information about a hosted service, included in spans and visible in
-- the Zipkin UI.
data Endpoint
-- | An empty endpoint.
defaultEndpoint :: Endpoint
-- | The endpoint's service name.
endpointService :: Endpoint -> Maybe Text
-- | The endpoint's port, if applicable and known.
endpointPort :: Endpoint -> Maybe Int
-- | The endpoint's IPv4 address.
endpointIPv4 :: Endpoint -> Maybe IPv4
-- | The endpoint's IPv6 address.
endpointIPv6 :: Endpoint -> Maybe IPv6
-- | A Zipkin trace publisher.
data Zipkin
-- | Creates a Zipkin publisher for the input Settings.
new :: MonadIO m => Settings -> m Zipkin
-- | Runs a TraceT action, sampling spans appropriately. Note that
-- this method does not publish spans on its own; to do so, either call
-- publish manually or specify a positive
-- settingsPublishPeriod to publish in the background.
run :: TraceT m a -> Zipkin -> m a
-- | Flushes all complete spans to the Zipkin server. This method is
-- thread-safe.
publish :: MonadIO m => Zipkin -> m ()
-- | Convenience method to start a Zipkin, run an action, and
-- publish all spans before returning.
with :: MonadUnliftIO m => Settings -> (Zipkin -> m a) -> m a
-- | Exportable trace information, used for cross-process traces.
data B3
-- | Serializes the B3 to multiple headers, suitable for HTTP
-- requests. All byte-strings are UTF-8 encoded.
b3ToHeaders :: B3 -> Map (CI ByteString) ByteString
-- | Deserializes the B3 from multiple headers.
b3FromHeaders :: Map (CI ByteString) ByteString -> Maybe B3
-- | Serializes the B3 to a single UTF-8 encoded header value. It
-- will typically be set as b3 header.
b3ToHeaderValue :: B3 -> ByteString
-- | Deserializes a single header value into a B3.
b3FromHeaderValue :: ByteString -> Maybe B3
-- | Generates a child span with CLIENT kind. This function also
-- provides the corresponding B3 (or Nothing if tracing is
-- inactive) so that it can be forwarded to the server. For example, to
-- emit an HTTP request and forward the trace information in the headers:
--
--
-- clientSpan "api-call" $ \(Just b3) -> $ do
-- res <- httpLbs "http://host/api" { requestHeaders = b3ToHeaders b3 }
-- process res -- Do something with the response.
--
clientSpan :: MonadTrace m => Maybe Endpoint -> Name -> (Maybe B3 -> m a) -> m a
-- | Generates a child span with SERVER kind. The client's
-- B3 should be provided as input, for example parsed using
-- b3FromRequestHeaders.
serverSpan :: MonadTrace m => Maybe Endpoint -> B3 -> m a -> m a
-- | Generates a child span with PRODUCER kind. This function also
-- provides the corresponding B3 so that it can be forwarded to
-- the consumer.
producerSpan :: MonadTrace m => Maybe Endpoint -> Name -> (Maybe B3 -> m a) -> m a
-- | Generates a child span with CONSUMER kind. The producer's
-- B3 should be provided as input.
consumerSpan :: MonadTrace m => Maybe Endpoint -> B3 -> m a -> m a
-- | Adds a tag to the active span.
tag :: MonadTrace m => Text -> Text -> m ()
-- | Annotates the active span using the current time.
annotate :: MonadTrace m => Text -> m ()
-- | Annotates the active span at the given time.
annotateAt :: MonadTrace m => POSIXTime -> Text -> m ()
instance GHC.Show.Show Monitor.Tracing.Zipkin.Endpoint
instance GHC.Classes.Ord Monitor.Tracing.Zipkin.Endpoint
instance GHC.Classes.Eq Monitor.Tracing.Zipkin.Endpoint
instance GHC.Show.Show Monitor.Tracing.Zipkin.B3
instance GHC.Classes.Ord Monitor.Tracing.Zipkin.B3
instance GHC.Classes.Eq Monitor.Tracing.Zipkin.B3
instance Data.Aeson.Types.ToJSON.ToJSON Monitor.Tracing.Zipkin.ZipkinSpan
instance Data.Aeson.Types.ToJSON.ToJSON Monitor.Tracing.Zipkin.ZipkinAnnotation
instance Data.String.IsString Monitor.Tracing.Zipkin.Settings
instance Data.String.IsString Monitor.Tracing.Zipkin.Endpoint
instance Data.Aeson.Types.ToJSON.ToJSON Monitor.Tracing.Zipkin.Endpoint
-- | This module is where you should start if you are interested in adding
-- tracing to an application. It provides backend-agnostic utilities to
-- generate traces. Trace publication and other backend-specific features
-- are available in the modules below Monitor.Tracing (e.g.
-- Monitor.Tracing.Zipkin). The additional functionality exposed
-- under Control.Monad in this package is useful if you wish to
-- implement a new tracing backend.
module Monitor.Tracing
-- | A monad capable of generating traces.
--
-- There are currently two instances of this monad:
--
-- -- sampledWhen b = if b then alwaysSampled else neverSampled --sampledWhen :: Bool -> Sampling -- | Returns a debug Sampling. Debug spans are always sampled. debugEnabled :: Sampling -- | Starts a new trace. rootSpan :: MonadTrace m => Sampling -> Name -> m a -> m a -- | Extends a trace if it is active, otherwise do nothing. childSpan :: MonadTrace m => Name -> m a -> m a -- | A Zipkin trace publisher. data Zipkin