{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase                 #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE PatternSynonyms            #-}
{-# LANGUAGE StrictData                 #-}
{-# LANGUAGE TupleSections              #-}
{-# LANGUAGE ViewPatterns               #-}

{-# OPTIONS_GHC -fno-warn-missing-pattern-synonym-signatures #-}

module OpenTracing.Tags
    ( Tags(fromTags)
    , Tag
    , TagVal(..)
    , setTag
    , getTag
    , getTagReify

    -- * Standard span tags.
    -- | Refer to the [OpenTracing spec](https://github.com/opentracing/specification/blob/master/semantic_conventions.md#span-tags-table)
    -- for more info.
    , pattern ComponentKey
    , pattern DbInstanceKey
    , pattern DbStatementKey
    , pattern DbTypeKey
    , pattern DbUserKey
    , pattern ErrorKey
    , pattern HttpMethodKey
    , pattern HttpStatusCodeKey
    , pattern HttpUrlKey
    , pattern MessageBusDestinationKey
    , pattern PeerAddressKey
    , pattern PeerHostnameKey
    , pattern PeerIPv4Key
    , pattern PeerIPv6Key
    , pattern PeerPortKey
    , pattern PeerServiceKey
    , pattern SamplingPriorityKey
    , pattern SpanKindKey

    , pattern Component
    , pattern DbInstance
    , pattern DbStatement
    , pattern DbType
    , pattern DbUser
    , pattern Error
    , pattern HttpMethod
    , pattern HttpStatusCode
    , pattern HttpUrl
    , pattern MessageBusDestination
    , pattern PeerAddress
    , pattern PeerHostname
    , pattern PeerIPv4
    , pattern PeerIPv6
    , pattern PeerPort
    , pattern PeerService
    , pattern SamplingPriority
    , pattern SpanKind

    , _Component
    , _DbInstance
    , _DbStatement
    , _DbType
    , _DbUser
    , _Error
    , _HttpMethod
    , _HttpStatusCode
    , _HttpUrl
    , _MessageBusDestination
    , _PeerAddress
    , _PeerHostname
    , _PeerIPv4
    , _PeerIPv6
    , _PeerPort
    , _PeerService
    , _SamplingPriority
    , _SpanKind

    , SpanKinds(..)
    , spanKindLabel
    )
where

import           Control.Lens
import           Data.Aeson                  (ToJSON (..))
import           Data.Aeson.Encoding
import qualified Data.ByteString.Base64.Lazy as B64
import qualified Data.ByteString.Lazy        as Lazy
import           Data.HashMap.Strict         (HashMap)
import qualified Data.HashMap.Strict         as HashMap
import           Data.Int                    (Int64)
import           Data.Monoid                 (First)
import           Data.Text                   (Text)
import qualified Data.Text                   as Text
import           Data.Text.Encoding          (decodeUtf8, encodeUtf8)
import qualified Data.Text.Lazy.Encoding     as Lazy
import           Data.Word                   (Word8)
import           Network.HTTP.Types
import           OpenTracing.Types
import           Text.Read                   (readMaybe)

-- | Tags are structured data associated with a `OpenTracing.Span.Span`. They can give
-- a more complete picture of what a Span is doing than the operation alone. Tags
-- apply to the entire timerange of a Span. Use `OpenTracing.Log.LogField` for
-- events that refer to particular timestamp.
newtype Tags = Tags { Tags -> HashMap Text TagVal
fromTags :: HashMap Text TagVal }
    deriving (Tags -> Tags -> Bool
(Tags -> Tags -> Bool) -> (Tags -> Tags -> Bool) -> Eq Tags
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tags -> Tags -> Bool
$c/= :: Tags -> Tags -> Bool
== :: Tags -> Tags -> Bool
$c== :: Tags -> Tags -> Bool
Eq, Int -> Tags -> ShowS
[Tags] -> ShowS
Tags -> String
(Int -> Tags -> ShowS)
-> (Tags -> String) -> ([Tags] -> ShowS) -> Show Tags
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Tags] -> ShowS
$cshowList :: [Tags] -> ShowS
show :: Tags -> String
$cshow :: Tags -> String
showsPrec :: Int -> Tags -> ShowS
$cshowsPrec :: Int -> Tags -> ShowS
Show, b -> Tags -> Tags
NonEmpty Tags -> Tags
Tags -> Tags -> Tags
(Tags -> Tags -> Tags)
-> (NonEmpty Tags -> Tags)
-> (forall b. Integral b => b -> Tags -> Tags)
-> Semigroup Tags
forall b. Integral b => b -> Tags -> Tags
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: b -> Tags -> Tags
$cstimes :: forall b. Integral b => b -> Tags -> Tags
sconcat :: NonEmpty Tags -> Tags
$csconcat :: NonEmpty Tags -> Tags
<> :: Tags -> Tags -> Tags
$c<> :: Tags -> Tags -> Tags
Semigroup, Semigroup Tags
Tags
Semigroup Tags
-> Tags
-> (Tags -> Tags -> Tags)
-> ([Tags] -> Tags)
-> Monoid Tags
[Tags] -> Tags
Tags -> Tags -> Tags
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [Tags] -> Tags
$cmconcat :: [Tags] -> Tags
mappend :: Tags -> Tags -> Tags
$cmappend :: Tags -> Tags -> Tags
mempty :: Tags
$cmempty :: Tags
$cp1Monoid :: Semigroup Tags
Monoid, [Tags] -> Encoding
[Tags] -> Value
Tags -> Encoding
Tags -> Value
(Tags -> Value)
-> (Tags -> Encoding)
-> ([Tags] -> Value)
-> ([Tags] -> Encoding)
-> ToJSON Tags
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Tags] -> Encoding
$ctoEncodingList :: [Tags] -> Encoding
toJSONList :: [Tags] -> Value
$ctoJSONList :: [Tags] -> Value
toEncoding :: Tags -> Encoding
$ctoEncoding :: Tags -> Encoding
toJSON :: Tags -> Value
$ctoJSON :: Tags -> Value
ToJSON)

-- | A Tag is a key:value pair
type Tag = (Text, TagVal)

data TagVal
    = BoolT   Bool
    | StringT Text
    | IntT    Int64
    | DoubleT Double
    | BinaryT Lazy.ByteString
    deriving (TagVal -> TagVal -> Bool
(TagVal -> TagVal -> Bool)
-> (TagVal -> TagVal -> Bool) -> Eq TagVal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagVal -> TagVal -> Bool
$c/= :: TagVal -> TagVal -> Bool
== :: TagVal -> TagVal -> Bool
$c== :: TagVal -> TagVal -> Bool
Eq, Int -> TagVal -> ShowS
[TagVal] -> ShowS
TagVal -> String
(Int -> TagVal -> ShowS)
-> (TagVal -> String) -> ([TagVal] -> ShowS) -> Show TagVal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagVal] -> ShowS
$cshowList :: [TagVal] -> ShowS
show :: TagVal -> String
$cshow :: TagVal -> String
showsPrec :: Int -> TagVal -> ShowS
$cshowsPrec :: Int -> TagVal -> ShowS
Show)

instance ToJSON TagVal where
    toJSON :: TagVal -> Value
toJSON (BoolT   Bool
x) = Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
x
    toJSON (StringT Text
x) = Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
x
    toJSON (IntT    Int64
x) = Int64 -> Value
forall a. ToJSON a => a -> Value
toJSON Int64
x
    toJSON (DoubleT Double
x) = Double -> Value
forall a. ToJSON a => a -> Value
toJSON Double
x
    toJSON (BinaryT ByteString
x) = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> (ByteString -> Text) -> ByteString -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
Lazy.decodeUtf8 (ByteString -> Text)
-> (ByteString -> ByteString) -> ByteString -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
B64.encode (ByteString -> Value) -> ByteString -> Value
forall a b. (a -> b) -> a -> b
$ ByteString
x

    toEncoding :: TagVal -> Encoding
toEncoding (BoolT   Bool
x) = Bool -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding Bool
x
    toEncoding (StringT Text
x) = Text -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding Text
x
    toEncoding (IntT    Int64
x) = Int64 -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding Int64
x
    toEncoding (DoubleT Double
x) = Double -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding Double
x
    toEncoding (BinaryT ByteString
x) = Text -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding (Text -> Encoding)
-> (ByteString -> Text) -> ByteString -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
Lazy.decodeUtf8 (ByteString -> Text)
-> (ByteString -> ByteString) -> ByteString -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
B64.encode (ByteString -> Encoding) -> ByteString -> Encoding
forall a b. (a -> b) -> a -> b
$ ByteString
x

setTag :: Tag -> Tags -> Tags
setTag :: Tag -> Tags -> Tags
setTag (Text
k,TagVal
v) = HashMap Text TagVal -> Tags
Tags (HashMap Text TagVal -> Tags)
-> (Tags -> HashMap Text TagVal) -> Tags -> Tags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal -> HashMap Text TagVal -> HashMap Text TagVal
forall k v.
(Eq k, Hashable k) =>
k -> v -> HashMap k v -> HashMap k v
HashMap.insert Text
k TagVal
v (HashMap Text TagVal -> HashMap Text TagVal)
-> (Tags -> HashMap Text TagVal) -> Tags -> HashMap Text TagVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tags -> HashMap Text TagVal
fromTags

getTag :: Text -> Tags -> Maybe TagVal
getTag :: Text -> Tags -> Maybe TagVal
getTag Text
k = Text -> HashMap Text TagVal -> Maybe TagVal
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
HashMap.lookup Text
k (HashMap Text TagVal -> Maybe TagVal)
-> (Tags -> HashMap Text TagVal) -> Tags -> Maybe TagVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tags -> HashMap Text TagVal
fromTags

-- | Get a tag and attempt to convert it from a serialized format
getTagReify :: Getting (First b) Tag b -> Text -> Tags -> Maybe b
getTagReify :: Getting (First b) Tag b -> Text -> Tags -> Maybe b
getTagReify Getting (First b) Tag b
p Text
k Tags
ts = Text -> Tags -> Maybe TagVal
getTag Text
k Tags
ts Maybe TagVal -> (TagVal -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Getting (First b) Tag b -> Tag -> Maybe b
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview Getting (First b) Tag b
p (Tag -> Maybe b) -> (TagVal -> Tag) -> TagVal -> Maybe b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text
k,)


pattern $bComponentKey :: a
$mComponentKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
ComponentKey             = "component"
pattern $bDbInstanceKey :: a
$mDbInstanceKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
DbInstanceKey            = "db.instance"
pattern $bDbStatementKey :: a
$mDbStatementKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
DbStatementKey           = "db.statement"
pattern $bDbTypeKey :: a
$mDbTypeKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
DbTypeKey                = "db.type"
pattern $bDbUserKey :: a
$mDbUserKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
DbUserKey                = "db.user"
pattern $bErrorKey :: a
$mErrorKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
ErrorKey                 = "error"
pattern $bHttpMethodKey :: a
$mHttpMethodKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
HttpMethodKey            = "http.method"
pattern $bHttpStatusCodeKey :: a
$mHttpStatusCodeKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
HttpStatusCodeKey        = "http.status_code"
pattern $bHttpUrlKey :: a
$mHttpUrlKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
HttpUrlKey               = "http.url"
pattern $bMessageBusDestinationKey :: a
$mMessageBusDestinationKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
MessageBusDestinationKey = "message_bus.destination"
pattern $bPeerAddressKey :: a
$mPeerAddressKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
PeerAddressKey           = "peer.address"
pattern $bPeerHostnameKey :: a
$mPeerHostnameKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
PeerHostnameKey          = "peer.hostname"
pattern $bPeerIPv4Key :: a
$mPeerIPv4Key :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
PeerIPv4Key              = "peer.ipv4"
pattern $bPeerIPv6Key :: a
$mPeerIPv6Key :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
PeerIPv6Key              = "peer.ipv6"
pattern $bPeerPortKey :: a
$mPeerPortKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
PeerPortKey              = "peer.port"
pattern $bPeerServiceKey :: a
$mPeerServiceKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
PeerServiceKey           = "peer.service"
pattern $bSamplingPriorityKey :: a
$mSamplingPriorityKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
SamplingPriorityKey      = "sampling.priority"
pattern $bSpanKindKey :: a
$mSpanKindKey :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
SpanKindKey              = "span.kind"

_Component :: Prism' Tag Text
_Component :: p Text (f Text) -> p Tag (f Tag)
_Component = (Text -> Tag) -> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
ComponentKey,) (TagVal -> Tag) -> (Text -> TagVal) -> Text -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT) ((Tag -> Maybe Text) -> Prism Tag Tag Text Text)
-> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
v) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
ComponentKey -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
v
    Tag
_ -> Maybe Text
forall a. Maybe a
Nothing

pattern $bComponent :: Text -> Tag
$mComponent :: forall r. Tag -> (Text -> r) -> (Void# -> r) -> r
Component v <- (preview _Component -> Just v) where
    Component Text
v = AReview Tag Text -> Text -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Text
Prism Tag Tag Text Text
_Component Text
v

_DbInstance :: Prism' Tag Text
_DbInstance :: p Text (f Text) -> p Tag (f Tag)
_DbInstance = (Text -> Tag) -> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
DbInstanceKey,) (TagVal -> Tag) -> (Text -> TagVal) -> Text -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT) ((Tag -> Maybe Text) -> Prism Tag Tag Text Text)
-> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
v) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
DbInstanceKey -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
v
    Tag
_ -> Maybe Text
forall a. Maybe a
Nothing

pattern $bDbInstance :: Text -> Tag
$mDbInstance :: forall r. Tag -> (Text -> r) -> (Void# -> r) -> r
DbInstance v <- (preview _DbInstance -> Just v) where
    DbInstance Text
v = AReview Tag Text -> Text -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Text
Prism Tag Tag Text Text
_DbInstance Text
v

_DbStatement :: Prism' Tag Text
_DbStatement :: p Text (f Text) -> p Tag (f Tag)
_DbStatement = (Text -> Tag) -> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
DbStatementKey,) (TagVal -> Tag) -> (Text -> TagVal) -> Text -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT) ((Tag -> Maybe Text) -> Prism Tag Tag Text Text)
-> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
v) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
DbStatementKey -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
v
    Tag
_ -> Maybe Text
forall a. Maybe a
Nothing

pattern $bDbStatement :: Text -> Tag
$mDbStatement :: forall r. Tag -> (Text -> r) -> (Void# -> r) -> r
DbStatement v <- (preview _DbStatement -> Just v) where
    DbStatement Text
v = AReview Tag Text -> Text -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Text
Prism Tag Tag Text Text
_DbStatement Text
v

_DbType :: Prism' Tag Text
_DbType :: p Text (f Text) -> p Tag (f Tag)
_DbType = (Text -> Tag) -> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
DbTypeKey,) (TagVal -> Tag) -> (Text -> TagVal) -> Text -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT) ((Tag -> Maybe Text) -> Prism Tag Tag Text Text)
-> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
v) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
DbTypeKey -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
v
    Tag
_ -> Maybe Text
forall a. Maybe a
Nothing

pattern $bDbType :: Text -> Tag
$mDbType :: forall r. Tag -> (Text -> r) -> (Void# -> r) -> r
DbType v <- (preview _DbType -> Just v) where
    DbType Text
v = AReview Tag Text -> Text -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Text
Prism Tag Tag Text Text
_DbType Text
v

_DbUser :: Prism' Tag Text
_DbUser :: p Text (f Text) -> p Tag (f Tag)
_DbUser = (Text -> Tag) -> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
DbUserKey,) (TagVal -> Tag) -> (Text -> TagVal) -> Text -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT) ((Tag -> Maybe Text) -> Prism Tag Tag Text Text)
-> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
v) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
DbUserKey -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
v
    Tag
_ -> Maybe Text
forall a. Maybe a
Nothing

pattern $bDbUser :: Text -> Tag
$mDbUser :: forall r. Tag -> (Text -> r) -> (Void# -> r) -> r
DbUser v <- (preview _DbUser -> Just v) where
    DbUser Text
v = AReview Tag Text -> Text -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Text
Prism Tag Tag Text Text
_DbUser Text
v

_Error :: Prism' Tag Bool
_Error :: p Bool (f Bool) -> p Tag (f Tag)
_Error = (Bool -> Tag) -> (Tag -> Maybe Bool) -> Prism Tag Tag Bool Bool
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
ErrorKey,) (TagVal -> Tag) -> (Bool -> TagVal) -> Bool -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> TagVal
BoolT) ((Tag -> Maybe Bool) -> Prism Tag Tag Bool Bool)
-> (Tag -> Maybe Bool) -> Prism Tag Tag Bool Bool
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, BoolT Bool
v) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
ErrorKey -> Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
v
    Tag
_ -> Maybe Bool
forall a. Maybe a
Nothing

pattern $bError :: Bool -> Tag
$mError :: forall r. Tag -> (Bool -> r) -> (Void# -> r) -> r
Error v <- (preview _Error -> Just v) where
    Error Bool
v = AReview Tag Bool -> Bool -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Bool
Prism Tag Tag Bool Bool
_Error Bool
v

_HttpUrl :: Prism' Tag Text
_HttpUrl :: p Text (f Text) -> p Tag (f Tag)
_HttpUrl = (Text -> Tag) -> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
HttpUrlKey,) (TagVal -> Tag) -> (Text -> TagVal) -> Text -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT) ((Tag -> Maybe Text) -> Prism Tag Tag Text Text)
-> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
v) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
HttpUrlKey -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
v
    Tag
_ -> Maybe Text
forall a. Maybe a
Nothing

pattern $bHttpUrl :: Text -> Tag
$mHttpUrl :: forall r. Tag -> (Text -> r) -> (Void# -> r) -> r
HttpUrl v <- (preview _HttpUrl -> Just v) where
    HttpUrl Text
v = AReview Tag Text -> Text -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Text
Prism Tag Tag Text Text
_HttpUrl Text
v

_MessageBusDestination :: Prism' Tag Text
_MessageBusDestination :: p Text (f Text) -> p Tag (f Tag)
_MessageBusDestination = (Text -> Tag) -> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
MessageBusDestinationKey,) (TagVal -> Tag) -> (Text -> TagVal) -> Text -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT) ((Tag -> Maybe Text) -> Prism Tag Tag Text Text)
-> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
v) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
MessageBusDestinationKey -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
v
    Tag
_ -> Maybe Text
forall a. Maybe a
Nothing

pattern $bMessageBusDestination :: Text -> Tag
$mMessageBusDestination :: forall r. Tag -> (Text -> r) -> (Void# -> r) -> r
MessageBusDestination v <- (preview _MessageBusDestination -> Just v) where
    MessageBusDestination Text
v = AReview Tag Text -> Text -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Text
Prism Tag Tag Text Text
_MessageBusDestination Text
v

_PeerAddress :: Prism' Tag Text
_PeerAddress :: p Text (f Text) -> p Tag (f Tag)
_PeerAddress = (Text -> Tag) -> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
PeerAddressKey,) (TagVal -> Tag) -> (Text -> TagVal) -> Text -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT) ((Tag -> Maybe Text) -> Prism Tag Tag Text Text)
-> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
v) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
PeerAddressKey -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
v
    Tag
_ -> Maybe Text
forall a. Maybe a
Nothing

pattern $bPeerAddress :: Text -> Tag
$mPeerAddress :: forall r. Tag -> (Text -> r) -> (Void# -> r) -> r
PeerAddress v <- (preview _PeerAddress -> Just v) where
    PeerAddress Text
v = AReview Tag Text -> Text -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Text
Prism Tag Tag Text Text
_PeerAddress Text
v

_PeerHostname :: Prism' Tag Text
_PeerHostname :: p Text (f Text) -> p Tag (f Tag)
_PeerHostname = (Text -> Tag) -> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
PeerHostnameKey,) (TagVal -> Tag) -> (Text -> TagVal) -> Text -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT) ((Tag -> Maybe Text) -> Prism Tag Tag Text Text)
-> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
v) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
PeerHostnameKey -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
v
    Tag
_ -> Maybe Text
forall a. Maybe a
Nothing

pattern $bPeerHostname :: Text -> Tag
$mPeerHostname :: forall r. Tag -> (Text -> r) -> (Void# -> r) -> r
PeerHostname v <- (preview _PeerHostname -> Just v) where
    PeerHostname Text
v = AReview Tag Text -> Text -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Text
Prism Tag Tag Text Text
_PeerHostname Text
v

_PeerService :: Prism' Tag Text
_PeerService :: p Text (f Text) -> p Tag (f Tag)
_PeerService = (Text -> Tag) -> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
PeerServiceKey,) (TagVal -> Tag) -> (Text -> TagVal) -> Text -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT) ((Tag -> Maybe Text) -> Prism Tag Tag Text Text)
-> (Tag -> Maybe Text) -> Prism Tag Tag Text Text
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
v) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
PeerServiceKey -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
v
    Tag
_ -> Maybe Text
forall a. Maybe a
Nothing

pattern $bPeerService :: Text -> Tag
$mPeerService :: forall r. Tag -> (Text -> r) -> (Void# -> r) -> r
PeerService v <- (preview _PeerService -> Just v) where
    PeerService Text
v = AReview Tag Text -> Text -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Text
Prism Tag Tag Text Text
_PeerService Text
v

_HttpMethod :: Prism' Tag Method
_HttpMethod :: p Method (f Method) -> p Tag (f Tag)
_HttpMethod = (Method -> Tag)
-> (Tag -> Maybe Method) -> Prism Tag Tag Method Method
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
HttpMethodKey,) (TagVal -> Tag) -> (Method -> TagVal) -> Method -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT (Text -> TagVal) -> (Method -> Text) -> Method -> TagVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Method -> Text
decodeUtf8) ((Tag -> Maybe Method) -> Prism Tag Tag Method Method)
-> (Tag -> Maybe Method) -> Prism Tag Tag Method Method
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT (Text -> Method
encodeUtf8 -> Method
x)) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
HttpMethodKey ->
        (Method -> Maybe Method)
-> (StdMethod -> Maybe Method)
-> Either Method StdMethod
-> Maybe Method
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe Method -> Method -> Maybe Method
forall a b. a -> b -> a
const Maybe Method
forall a. Maybe a
Nothing) (Maybe Method -> StdMethod -> Maybe Method
forall a b. a -> b -> a
const (Method -> Maybe Method
forall a. a -> Maybe a
Just Method
x)) (Either Method StdMethod -> Maybe Method)
-> Either Method StdMethod -> Maybe Method
forall a b. (a -> b) -> a -> b
$ Method -> Either Method StdMethod
parseMethod Method
x
    Tag
_ -> Maybe Method
forall a. Maybe a
Nothing

pattern $bHttpMethod :: Method -> Tag
$mHttpMethod :: forall r. Tag -> (Method -> r) -> (Void# -> r) -> r
HttpMethod v <- (preview _HttpMethod -> Just v) where
    HttpMethod Method
v = AReview Tag Method -> Method -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Method
Prism Tag Tag Method Method
_HttpMethod Method
v

_HttpStatusCode :: Prism' Tag Status
_HttpStatusCode :: p Status (f Status) -> p Tag (f Tag)
_HttpStatusCode = (Status -> Tag)
-> (Tag -> Maybe Status) -> Prism Tag Tag Status Status
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
HttpStatusCodeKey,) (TagVal -> Tag) -> (Status -> TagVal) -> Status -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> TagVal
IntT (Int64 -> TagVal) -> (Status -> Int64) -> Status -> TagVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> (Status -> Int) -> Status -> Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Status -> Int
statusCode) ((Tag -> Maybe Status) -> Prism Tag Tag Status Status)
-> (Tag -> Maybe Status) -> Prism Tag Tag Status Status
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, IntT Int64
x) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
HttpStatusCodeKey -> Status -> Maybe Status
forall a. a -> Maybe a
Just (Status -> Maybe Status)
-> (Int64 -> Status) -> Int64 -> Maybe Status
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Status
forall a. Enum a => Int -> a
toEnum (Int -> Status) -> (Int64 -> Int) -> Int64 -> Status
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Maybe Status) -> Int64 -> Maybe Status
forall a b. (a -> b) -> a -> b
$ Int64
x
    Tag
_ -> Maybe Status
forall a. Maybe a
Nothing

pattern $bHttpStatusCode :: Status -> Tag
$mHttpStatusCode :: forall r. Tag -> (Status -> r) -> (Void# -> r) -> r
HttpStatusCode v <- (preview _HttpStatusCode -> Just v) where
    HttpStatusCode Status
v = AReview Tag Status -> Status -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Status
Prism Tag Tag Status Status
_HttpStatusCode Status
v

_PeerIPv4 :: Prism' Tag IPv4
_PeerIPv4 :: p IPv4 (f IPv4) -> p Tag (f Tag)
_PeerIPv4 = (IPv4 -> Tag) -> (Tag -> Maybe IPv4) -> Prism Tag Tag IPv4 IPv4
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
PeerIPv4Key,) (TagVal -> Tag) -> (IPv4 -> TagVal) -> IPv4 -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT (Text -> TagVal) -> (IPv4 -> Text) -> IPv4 -> TagVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
Text.pack (String -> Text) -> (IPv4 -> String) -> IPv4 -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IPv4 -> String
forall a. Show a => a -> String
show) ((Tag -> Maybe IPv4) -> Prism Tag Tag IPv4 IPv4)
-> (Tag -> Maybe IPv4) -> Prism Tag Tag IPv4 IPv4
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
x) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
PeerIPv4Key -> String -> Maybe IPv4
forall a. Read a => String -> Maybe a
readMaybe (Text -> String
Text.unpack Text
x)
    Tag
_ -> Maybe IPv4
forall a. Maybe a
Nothing

pattern $bPeerIPv4 :: IPv4 -> Tag
$mPeerIPv4 :: forall r. Tag -> (IPv4 -> r) -> (Void# -> r) -> r
PeerIPv4 v <- (preview _PeerIPv4 -> Just v) where
    PeerIPv4 IPv4
v = AReview Tag IPv4 -> IPv4 -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag IPv4
Prism Tag Tag IPv4 IPv4
_PeerIPv4 IPv4
v

_PeerIPv6 :: Prism' Tag IPv6
_PeerIPv6 :: p IPv6 (f IPv6) -> p Tag (f Tag)
_PeerIPv6 = (IPv6 -> Tag) -> (Tag -> Maybe IPv6) -> Prism Tag Tag IPv6 IPv6
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
PeerIPv6Key,) (TagVal -> Tag) -> (IPv6 -> TagVal) -> IPv6 -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT (Text -> TagVal) -> (IPv6 -> Text) -> IPv6 -> TagVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
Text.pack (String -> Text) -> (IPv6 -> String) -> IPv6 -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IPv6 -> String
forall a. Show a => a -> String
show) ((Tag -> Maybe IPv6) -> Prism Tag Tag IPv6 IPv6)
-> (Tag -> Maybe IPv6) -> Prism Tag Tag IPv6 IPv6
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
x) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
PeerIPv6Key -> String -> Maybe IPv6
forall a. Read a => String -> Maybe a
readMaybe (Text -> String
Text.unpack Text
x)
    Tag
_ -> Maybe IPv6
forall a. Maybe a
Nothing

pattern $bPeerIPv6 :: IPv6 -> Tag
$mPeerIPv6 :: forall r. Tag -> (IPv6 -> r) -> (Void# -> r) -> r
PeerIPv6 v <- (preview _PeerIPv6 -> Just v) where
    PeerIPv6 IPv6
v = AReview Tag IPv6 -> IPv6 -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag IPv6
Prism Tag Tag IPv6 IPv6
_PeerIPv6 IPv6
v

_PeerPort :: Prism' Tag Port
_PeerPort :: p Port (f Port) -> p Tag (f Tag)
_PeerPort = (Port -> Tag) -> (Tag -> Maybe Port) -> Prism Tag Tag Port Port
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
PeerPortKey,) (TagVal -> Tag) -> (Port -> TagVal) -> Port -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> TagVal
IntT (Int64 -> TagVal) -> (Port -> Int64) -> Port -> TagVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word16 -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word16 -> Int64) -> (Port -> Word16) -> Port -> Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Port -> Word16
fromPort) ((Tag -> Maybe Port) -> Prism Tag Tag Port Port)
-> (Tag -> Maybe Port) -> Prism Tag Tag Port Port
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, IntT Int64
x) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
PeerPortKey -> Port -> Maybe Port
forall a. a -> Maybe a
Just (Port -> Maybe Port) -> (Int64 -> Port) -> Int64 -> Maybe Port
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Port
forall a. Enum a => Int -> a
toEnum (Int -> Port) -> (Int64 -> Int) -> Int64 -> Port
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Maybe Port) -> Int64 -> Maybe Port
forall a b. (a -> b) -> a -> b
$ Int64
x
    Tag
_ -> Maybe Port
forall a. Maybe a
Nothing

pattern $bPeerPort :: Port -> Tag
$mPeerPort :: forall r. Tag -> (Port -> r) -> (Void# -> r) -> r
PeerPort v <- (preview _PeerPort -> Just v) where
    PeerPort Port
v = AReview Tag Port -> Port -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Port
Prism Tag Tag Port Port
_PeerPort Port
v

_SamplingPriority :: Prism' Tag Word8
_SamplingPriority :: p Word8 (f Word8) -> p Tag (f Tag)
_SamplingPriority = (Word8 -> Tag) -> (Tag -> Maybe Word8) -> Prism Tag Tag Word8 Word8
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
SamplingPriorityKey,) (TagVal -> Tag) -> (Word8 -> TagVal) -> Word8 -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> TagVal
IntT (Int64 -> TagVal) -> (Word8 -> Int64) -> Word8 -> TagVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral) ((Tag -> Maybe Word8) -> Prism Tag Tag Word8 Word8)
-> (Tag -> Maybe Word8) -> Prism Tag Tag Word8 Word8
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, IntT Int64
x) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
SamplingPriorityKey -> Word8 -> Maybe Word8
forall a. a -> Maybe a
Just (Word8 -> Maybe Word8) -> (Int64 -> Word8) -> Int64 -> Maybe Word8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Maybe Word8) -> Int64 -> Maybe Word8
forall a b. (a -> b) -> a -> b
$ Int64
x
    Tag
_ -> Maybe Word8
forall a. Maybe a
Nothing

pattern $bSamplingPriority :: Word8 -> Tag
$mSamplingPriority :: forall r. Tag -> (Word8 -> r) -> (Void# -> r) -> r
SamplingPriority v <- (preview _SamplingPriority -> Just v) where
    SamplingPriority Word8
v = AReview Tag Word8 -> Word8 -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag Word8
Prism Tag Tag Word8 Word8
_SamplingPriority Word8
v

_SpanKind :: Prism' Tag SpanKinds
_SpanKind :: p SpanKinds (f SpanKinds) -> p Tag (f Tag)
_SpanKind = (SpanKinds -> Tag)
-> (Tag -> Maybe SpanKinds) -> Prism Tag Tag SpanKinds SpanKinds
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text
forall a. (Eq a, IsString a) => a
SpanKindKey,) (TagVal -> Tag) -> (SpanKinds -> TagVal) -> SpanKinds -> Tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> TagVal
StringT (Text -> TagVal) -> (SpanKinds -> Text) -> SpanKinds -> TagVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SpanKinds -> Text
spanKindLabel) ((Tag -> Maybe SpanKinds) -> Prism Tag Tag SpanKinds SpanKinds)
-> (Tag -> Maybe SpanKinds) -> Prism Tag Tag SpanKinds SpanKinds
forall a b. (a -> b) -> a -> b
$ \case
    (Text
k, StringT Text
x) | Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
forall a. (Eq a, IsString a) => a
SpanKindKey -> Text -> Maybe SpanKinds
fromSpanKindLabel Text
x
    Tag
_ -> Maybe SpanKinds
forall a. Maybe a
Nothing

pattern $bSpanKind :: SpanKinds -> Tag
$mSpanKind :: forall r. Tag -> (SpanKinds -> r) -> (Void# -> r) -> r
SpanKind v <- (preview _SpanKind -> Just v) where
    SpanKind = AReview Tag SpanKinds -> SpanKinds -> Tag
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Tag SpanKinds
Prism Tag Tag SpanKinds SpanKinds
_SpanKind

data SpanKinds
    = RPCClient
    | RPCServer
    | Producer
    | Consumer
    deriving (SpanKinds -> SpanKinds -> Bool
(SpanKinds -> SpanKinds -> Bool)
-> (SpanKinds -> SpanKinds -> Bool) -> Eq SpanKinds
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SpanKinds -> SpanKinds -> Bool
$c/= :: SpanKinds -> SpanKinds -> Bool
== :: SpanKinds -> SpanKinds -> Bool
$c== :: SpanKinds -> SpanKinds -> Bool
Eq, Int -> SpanKinds -> ShowS
[SpanKinds] -> ShowS
SpanKinds -> String
(Int -> SpanKinds -> ShowS)
-> (SpanKinds -> String)
-> ([SpanKinds] -> ShowS)
-> Show SpanKinds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SpanKinds] -> ShowS
$cshowList :: [SpanKinds] -> ShowS
show :: SpanKinds -> String
$cshow :: SpanKinds -> String
showsPrec :: Int -> SpanKinds -> ShowS
$cshowsPrec :: Int -> SpanKinds -> ShowS
Show, Eq SpanKinds
Eq SpanKinds
-> (SpanKinds -> SpanKinds -> Ordering)
-> (SpanKinds -> SpanKinds -> Bool)
-> (SpanKinds -> SpanKinds -> Bool)
-> (SpanKinds -> SpanKinds -> Bool)
-> (SpanKinds -> SpanKinds -> Bool)
-> (SpanKinds -> SpanKinds -> SpanKinds)
-> (SpanKinds -> SpanKinds -> SpanKinds)
-> Ord SpanKinds
SpanKinds -> SpanKinds -> Bool
SpanKinds -> SpanKinds -> Ordering
SpanKinds -> SpanKinds -> SpanKinds
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SpanKinds -> SpanKinds -> SpanKinds
$cmin :: SpanKinds -> SpanKinds -> SpanKinds
max :: SpanKinds -> SpanKinds -> SpanKinds
$cmax :: SpanKinds -> SpanKinds -> SpanKinds
>= :: SpanKinds -> SpanKinds -> Bool
$c>= :: SpanKinds -> SpanKinds -> Bool
> :: SpanKinds -> SpanKinds -> Bool
$c> :: SpanKinds -> SpanKinds -> Bool
<= :: SpanKinds -> SpanKinds -> Bool
$c<= :: SpanKinds -> SpanKinds -> Bool
< :: SpanKinds -> SpanKinds -> Bool
$c< :: SpanKinds -> SpanKinds -> Bool
compare :: SpanKinds -> SpanKinds -> Ordering
$ccompare :: SpanKinds -> SpanKinds -> Ordering
$cp1Ord :: Eq SpanKinds
Ord)

spanKindLabel :: SpanKinds -> Text
spanKindLabel :: SpanKinds -> Text
spanKindLabel SpanKinds
RPCClient = Text
"CLIENT"
spanKindLabel SpanKinds
RPCServer = Text
"SERVER"
spanKindLabel SpanKinds
Producer  = Text
"PRODUCER"
spanKindLabel SpanKinds
Consumer  = Text
"CONSUMER"

fromSpanKindLabel :: Text -> Maybe SpanKinds
fromSpanKindLabel :: Text -> Maybe SpanKinds
fromSpanKindLabel Text
"CLIENT"   = SpanKinds -> Maybe SpanKinds
forall a. a -> Maybe a
Just SpanKinds
RPCClient
fromSpanKindLabel Text
"SERVER"   = SpanKinds -> Maybe SpanKinds
forall a. a -> Maybe a
Just SpanKinds
RPCServer
fromSpanKindLabel Text
"PRODUCER" = SpanKinds -> Maybe SpanKinds
forall a. a -> Maybe a
Just SpanKinds
Producer
fromSpanKindLabel Text
"CONSUMER" = SpanKinds -> Maybe SpanKinds
forall a. a -> Maybe a
Just SpanKinds
Consumer
fromSpanKindLabel Text
_          = Maybe SpanKinds
forall a. Maybe a
Nothing

instance ToJSON SpanKinds where
    toJSON :: SpanKinds -> Value
toJSON     = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> (SpanKinds -> Text) -> SpanKinds -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SpanKinds -> Text
spanKindLabel
    toEncoding :: SpanKinds -> Encoding
toEncoding = Text -> Encoding
forall a. Text -> Encoding' a
text   (Text -> Encoding) -> (SpanKinds -> Text) -> SpanKinds -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SpanKinds -> Text
spanKindLabel