{-# LANGUAGE DeriveGeneric #-}
module Instana.SDK.Span.RootEntry
( RootEntry(..)
, spanId
, traceId
, addData
, addToErrorCount
, setServiceName
, setCorrelationType
, setCorrelationId
) where
import Data.Aeson (Value)
import qualified Data.Aeson.Extra.Merge as AesonExtra
import Data.Text (Text)
import GHC.Generics
import Instana.SDK.Internal.Id (Id)
data RootEntry =
RootEntry
{
RootEntry -> Id
spanAndTraceId :: Id
, RootEntry -> Text
spanName :: Text
, RootEntry -> Int
timestamp :: Int
, RootEntry -> Int
errorCount :: Int
, RootEntry -> Maybe Text
serviceName :: Maybe Text
, RootEntry -> Maybe Text
correlationType :: Maybe Text
, RootEntry -> Maybe Text
correlationId :: Maybe Text
, RootEntry -> Value
spanData :: Value
} deriving (RootEntry -> RootEntry -> Bool
(RootEntry -> RootEntry -> Bool)
-> (RootEntry -> RootEntry -> Bool) -> Eq RootEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RootEntry -> RootEntry -> Bool
$c/= :: RootEntry -> RootEntry -> Bool
== :: RootEntry -> RootEntry -> Bool
$c== :: RootEntry -> RootEntry -> Bool
Eq, (forall x. RootEntry -> Rep RootEntry x)
-> (forall x. Rep RootEntry x -> RootEntry) -> Generic RootEntry
forall x. Rep RootEntry x -> RootEntry
forall x. RootEntry -> Rep RootEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RootEntry x -> RootEntry
$cfrom :: forall x. RootEntry -> Rep RootEntry x
Generic, Int -> RootEntry -> ShowS
[RootEntry] -> ShowS
RootEntry -> String
(Int -> RootEntry -> ShowS)
-> (RootEntry -> String)
-> ([RootEntry] -> ShowS)
-> Show RootEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RootEntry] -> ShowS
$cshowList :: [RootEntry] -> ShowS
show :: RootEntry -> String
$cshow :: RootEntry -> String
showsPrec :: Int -> RootEntry -> ShowS
$cshowsPrec :: Int -> RootEntry -> ShowS
Show)
traceId :: RootEntry -> Id
traceId :: RootEntry -> Id
traceId = RootEntry -> Id
spanAndTraceId
spanId :: RootEntry -> Id
spanId :: RootEntry -> Id
spanId = RootEntry -> Id
spanAndTraceId
addToErrorCount :: Int -> RootEntry -> RootEntry
addToErrorCount :: Int -> RootEntry -> RootEntry
addToErrorCount increment :: Int
increment rootEntry :: RootEntry
rootEntry =
let
ec :: Int
ec = RootEntry -> Int
errorCount RootEntry
rootEntry
in
RootEntry
rootEntry { errorCount :: Int
errorCount = Int
ec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
increment }
setServiceName :: Text -> RootEntry -> RootEntry
setServiceName :: Text -> RootEntry -> RootEntry
setServiceName serviceName_ :: Text
serviceName_ rootEntry :: RootEntry
rootEntry =
RootEntry
rootEntry { serviceName :: Maybe Text
serviceName = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
serviceName_ }
setCorrelationType :: Text -> RootEntry -> RootEntry
setCorrelationType :: Text -> RootEntry -> RootEntry
setCorrelationType correlationType_ :: Text
correlationType_ rootEntry :: RootEntry
rootEntry =
RootEntry
rootEntry { correlationType :: Maybe Text
correlationType = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
correlationType_ }
setCorrelationId :: Text -> RootEntry -> RootEntry
setCorrelationId :: Text -> RootEntry -> RootEntry
setCorrelationId correlationId_ :: Text
correlationId_ rootEntry :: RootEntry
rootEntry =
RootEntry
rootEntry { correlationId :: Maybe Text
correlationId = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
correlationId_ }
addData :: Value -> RootEntry -> RootEntry
addData :: Value -> RootEntry -> RootEntry
addData newData :: Value
newData rootEntry :: RootEntry
rootEntry =
let
currentData :: Value
currentData = RootEntry -> Value
spanData RootEntry
rootEntry
mergedData :: Value
mergedData = Value -> Value -> Value
AesonExtra.lodashMerge Value
currentData Value
newData
in
RootEntry
rootEntry { spanData :: Value
spanData = Value
mergedData }