-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Please see the README on Github at
--   <a>https://github.com/ChrisCoffey/haskell-opentracing-light#readme</a>
@package servant-tracing
@version 0.1.0.2

module Tracing.Core

-- | A timed section of code with a logical name and <a>SpanContext</a>.
--   Individual spans will be reconstructed by an OpenTracing backend into
--   a single trace.
data Span
Span :: !OpName -> !SpanContext -> !POSIXTime -> !NominalDiffTime -> ![SpanRelation] -> !Map Text SpanTag -> !Map Text Text -> !Bool -> !Text -> Span
[$sel:operationName:Span] :: Span -> !OpName
[$sel:context:Span] :: Span -> !SpanContext
[$sel:timestamp:Span] :: Span -> !POSIXTime
[$sel:duration:Span] :: Span -> !NominalDiffTime
[$sel:relations:Span] :: Span -> ![SpanRelation]
[$sel:tags:Span] :: Span -> !Map Text SpanTag
[$sel:baggage:Span] :: Span -> !Map Text Text
[$sel:debug:Span] :: Span -> !Bool
[$sel:serviceName:Span] :: Span -> !Text

-- | Spans may be top level, a child, or logically follow from a given
--   span.
data SpanRelation
ChildOf :: !SpanContext -> SpanRelation
FollowsFrom :: !SpanContext -> SpanRelation

-- | Indicates the type of relation this span represents
data SpanRelationTag
Child :: SpanRelationTag
Follows :: SpanRelationTag

-- | Uniquely identifies a given <a>Span</a> &amp; points to its
--   encompasing trace
data SpanContext
SpanContext :: !TraceId -> !SpanId -> SpanContext
[$sel:traceId:SpanContext] :: SpanContext -> !TraceId
[$sel:spanId:SpanContext] :: SpanContext -> !SpanId

-- | Used to embed additional information into a Span for consumption &amp;
--   viewing in a tracing backend
data SpanTag
TagString :: !Text -> SpanTag
TagBool :: !Bool -> SpanTag
TagInt :: !Int64 -> SpanTag
TagDouble :: !Double -> SpanTag

-- | Human-readable name for the span
newtype OpName
OpName :: Text -> OpName

-- | An opaque &amp; unique identifier for a trace segment, called a Span
newtype SpanId
SpanId :: Int64 -> SpanId

-- | An opaque &amp; unique identifier for a logical operation. Traces are
--   composed of many <a>Span</a>s
newtype TraceId
TraceId :: Int64 -> TraceId

-- | Global context required for tracing. The <a>$sel:spanBuffer:Tracer</a>
--   should be manually drained by library users.
data Tracer
Tracer :: IORef [Span] -> Text -> Tracer
[$sel:spanBuffer:Tracer] :: Tracer -> IORef [Span]
[$sel:svcName:Tracer] :: Tracer -> Text

-- | Instructions that are specific to a single trace
data TracingInstructions
TracingInstructions :: !TraceId -> !SpanId -> !Maybe SpanId -> !Bool -> !Bool -> TracingInstructions
[$sel:traceId:TracingInstructions] :: TracingInstructions -> !TraceId
[$sel:spanId:TracingInstructions] :: TracingInstructions -> !SpanId
[$sel:parentSpanId:TracingInstructions] :: TracingInstructions -> !Maybe SpanId
[$sel:debug:TracingInstructions] :: TracingInstructions -> !Bool
[$sel:sample:TracingInstructions] :: TracingInstructions -> !Bool

-- | Indicates that the current monad can provide a <a>Tracer</a> and
--   related context. It assumes some form of environment. While this
--   exposes some mutable state, all of it is hidden away behind the
--   <a>recordSpan</a> api.
class Monad m => MonadTracer m
getTracer :: MonadTracer m => m Tracer
currentTrace :: MonadTracer m => m TraceId
currentSpan :: MonadTracer m => m (IORef SpanId)
isDebug :: MonadTracer m => m Bool

-- | The type in question may be converted into a <a>SpanTag</a>
class ToSpanTag a
toSpanTag :: ToSpanTag a => a -> SpanTag

-- | Allows for easily representing multiple types in a tag list
data Tag
Tag :: Text -> a -> Tag

-- | Wraps a computation &amp; writes it to the <tt>Tracer'</tt>s IORef. To
--   start a new top-level span, and therefore a new trace, call this
--   function with *spanType* == <a>Nothing</a>. Otherwise, this will
--   create a child span.
--   
--   Doesn't support parallel computations yet
recordSpan :: (MonadIO m, MonadBaseControl IO m, MonadTracer m) => Maybe SpanRelationTag -> [Tag] -> OpName -> m a -> m a

-- | Dump the details of a span. Used for debugging or logging
debugPrintSpan :: Span -> Text
instance GHC.Show.Show Tracing.Core.Span
instance GHC.Show.Show Tracing.Core.SpanTag
instance GHC.Classes.Eq Tracing.Core.SpanTag
instance GHC.Show.Show Tracing.Core.SpanRelation
instance GHC.Classes.Eq Tracing.Core.SpanRelation
instance GHC.Show.Show Tracing.Core.SpanContext
instance GHC.Classes.Eq Tracing.Core.SpanContext
instance GHC.Show.Show Tracing.Core.TracingInstructions
instance GHC.Classes.Eq Tracing.Core.TracingInstructions
instance Web.Internal.HttpApiData.FromHttpApiData Tracing.Core.TraceId
instance GHC.Show.Show Tracing.Core.TraceId
instance GHC.Classes.Ord Tracing.Core.TraceId
instance GHC.Classes.Eq Tracing.Core.TraceId
instance Web.Internal.HttpApiData.FromHttpApiData Tracing.Core.SpanId
instance GHC.Show.Show Tracing.Core.SpanId
instance GHC.Classes.Ord Tracing.Core.SpanId
instance GHC.Classes.Eq Tracing.Core.SpanId
instance Data.String.IsString Tracing.Core.OpName
instance GHC.Show.Show Tracing.Core.OpName
instance GHC.Classes.Ord Tracing.Core.OpName
instance GHC.Classes.Eq Tracing.Core.OpName
instance Tracing.Core.ToSpanTag Tracing.Core.SpanTag
instance Data.Aeson.Types.ToJSON.ToJSON a => Tracing.Core.ToSpanTag a

module Servant.Tracing

-- | Constrain the <tt>ServerT'</tt>s base monad such that it provides an
--   instance of <a>MonadTracer</a>
type ServantTracingT api m = (MonadIO m, MonadTracer m) => ServerT api m
type WithTracing = Header "uber-trace-id" TracingInstructions

-- | Instructions that are specific to a single trace
data TracingInstructions
TracingInstructions :: !TraceId -> !SpanId -> !Maybe SpanId -> !Bool -> !Bool -> TracingInstructions
[$sel:traceId:TracingInstructions] :: TracingInstructions -> !TraceId
[$sel:spanId:TracingInstructions] :: TracingInstructions -> !SpanId
[$sel:parentSpanId:TracingInstructions] :: TracingInstructions -> !Maybe SpanId
[$sel:debug:TracingInstructions] :: TracingInstructions -> !Bool
[$sel:sample:TracingInstructions] :: TracingInstructions -> !Bool

-- | Jaeger format:
--   <a>http://jaeger.readthedocs.io/en/latest/client_libraries/#propagation-format</a>
--   This allows the trace backend to reassemble downstream traces.
instructionsToHeader :: TracingInstructions -> Text

-- | In the event that there are no <a>TracingInstructions</a> for this
--   call, generate new instructions.
--   
--   This has a
getInstructions :: MonadIO m => Bool -> Maybe TracingInstructions -> m TracingInstructions
instance Web.Internal.HttpApiData.FromHttpApiData Tracing.Core.TracingInstructions

module Tracing.DataDog

-- | Publish <a>Span</a> in the <a>DataDog format</a> . No call is made on
--   an empty span list
publishDataDog :: MonadIO m => String -> Manager -> [Span] -> m (Maybe (Response Text))
newtype DataDogSpan
DataDogSpan :: Span -> DataDogSpan
instance Data.Aeson.Types.ToJSON.ToJSON Tracing.DataDog.DataDogSpan

module Tracing.Zipkin

-- | Publish <a>Span</a> in the <a>Zipkin format</a> . No call is made on
--   an empty
publishZipkin :: MonadIO m => String -> Manager -> [Span] -> m (Maybe (Response Text))
newtype ZipkinSpan
ZipkinSpan :: Span -> ZipkinSpan
instance Data.Aeson.Types.ToJSON.ToJSON Tracing.Zipkin.ZipkinSpan
