{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DefaultSignatures #-}
module OpenTelemetry.Trace.Monad
( inSpan
, inSpan'
, OpenTelemetry.Trace.Monad.inSpan''
, MonadTracer(..)
) where
import Data.Text (Text)
import OpenTelemetry.Trace.Core
( Tracer
, Span
, SpanArguments(..)
, inSpan''
)
import Control.Monad.IO.Unlift
import GHC.Stack
class Monad m => MonadTracer m where
getTracer :: m Tracer
inSpan
:: (MonadUnliftIO m, MonadTracer m, HasCallStack)
=> Text
-> SpanArguments
-> m a
-> m a
inSpan :: Text -> SpanArguments -> m a -> m a
inSpan Text
n SpanArguments
args m a
m = CallStack -> Text -> SpanArguments -> (Span -> m a) -> m a
forall (m :: * -> *) a.
(MonadUnliftIO m, MonadTracer m, HasCallStack) =>
CallStack -> Text -> SpanArguments -> (Span -> m a) -> m a
OpenTelemetry.Trace.Monad.inSpan'' CallStack
HasCallStack => CallStack
callStack Text
n SpanArguments
args (m a -> Span -> m a
forall a b. a -> b -> a
const m a
m)
inSpan'
:: (MonadUnliftIO m, MonadTracer m, HasCallStack)
=> Text
-> SpanArguments
-> (Span -> m a)
-> m a
inSpan' :: Text -> SpanArguments -> (Span -> m a) -> m a
inSpan' = CallStack -> Text -> SpanArguments -> (Span -> m a) -> m a
forall (m :: * -> *) a.
(MonadUnliftIO m, MonadTracer m, HasCallStack) =>
CallStack -> Text -> SpanArguments -> (Span -> m a) -> m a
OpenTelemetry.Trace.Monad.inSpan'' CallStack
HasCallStack => CallStack
callStack
inSpan''
:: (MonadUnliftIO m, MonadTracer m, HasCallStack)
=> CallStack
-> Text
-> SpanArguments
-> (Span -> m a)
-> m a
inSpan'' :: CallStack -> Text -> SpanArguments -> (Span -> m a) -> m a
inSpan'' CallStack
cs Text
n SpanArguments
args Span -> m a
f = do
Tracer
t <- m Tracer
forall (m :: * -> *). MonadTracer m => m Tracer
getTracer
Tracer
-> CallStack -> Text -> SpanArguments -> (Span -> m a) -> m a
forall (m :: * -> *) a.
(MonadUnliftIO m, HasCallStack) =>
Tracer
-> CallStack -> Text -> SpanArguments -> (Span -> m a) -> m a
OpenTelemetry.Trace.Core.inSpan'' Tracer
t CallStack
cs Text
n SpanArguments
args Span -> m a
f