{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE StrictData #-}
module OpenTelemetry.Internal.Metric.Types (
InstrumentKind (..),
HistogramAggregation (..),
AdvisoryParameters (..),
defaultAdvisoryParameters,
Counter (..),
UpDownCounter (..),
Histogram (..),
Gauge (..),
ObservableResult (..),
ObservableCallbackHandle (..),
ObservableCounter (..),
ObservableUpDownCounter (..),
ObservableGauge (..),
Meter (..),
MeterProvider (..),
) where
import Data.Hashable (Hashable (hashWithSalt))
import Data.Int (Int32, Int64)
import Data.Text (Text)
import Data.Vector (Vector)
import qualified Data.Vector as V
import GHC.Generics (Generic)
import OpenTelemetry.Attributes (Attributes)
import OpenTelemetry.Internal.Common.Types (FlushResult, InstrumentationLibrary, ShutdownResult)
data InstrumentKind
= KindCounter
| KindAsyncCounter
| KindUpDownCounter
| KindAsyncUpDownCounter
| KindHistogram
| KindGauge
| KindAsyncGauge
deriving stock (InstrumentKind -> InstrumentKind -> Bool
(InstrumentKind -> InstrumentKind -> Bool)
-> (InstrumentKind -> InstrumentKind -> Bool) -> Eq InstrumentKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InstrumentKind -> InstrumentKind -> Bool
== :: InstrumentKind -> InstrumentKind -> Bool
$c/= :: InstrumentKind -> InstrumentKind -> Bool
/= :: InstrumentKind -> InstrumentKind -> Bool
Eq, Int -> InstrumentKind -> ShowS
[InstrumentKind] -> ShowS
InstrumentKind -> String
(Int -> InstrumentKind -> ShowS)
-> (InstrumentKind -> String)
-> ([InstrumentKind] -> ShowS)
-> Show InstrumentKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InstrumentKind -> ShowS
showsPrec :: Int -> InstrumentKind -> ShowS
$cshow :: InstrumentKind -> String
show :: InstrumentKind -> String
$cshowList :: [InstrumentKind] -> ShowS
showList :: [InstrumentKind] -> ShowS
Show, Eq InstrumentKind
Eq InstrumentKind =>
(InstrumentKind -> InstrumentKind -> Ordering)
-> (InstrumentKind -> InstrumentKind -> Bool)
-> (InstrumentKind -> InstrumentKind -> Bool)
-> (InstrumentKind -> InstrumentKind -> Bool)
-> (InstrumentKind -> InstrumentKind -> Bool)
-> (InstrumentKind -> InstrumentKind -> InstrumentKind)
-> (InstrumentKind -> InstrumentKind -> InstrumentKind)
-> Ord InstrumentKind
InstrumentKind -> InstrumentKind -> Bool
InstrumentKind -> InstrumentKind -> Ordering
InstrumentKind -> InstrumentKind -> InstrumentKind
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
$ccompare :: InstrumentKind -> InstrumentKind -> Ordering
compare :: InstrumentKind -> InstrumentKind -> Ordering
$c< :: InstrumentKind -> InstrumentKind -> Bool
< :: InstrumentKind -> InstrumentKind -> Bool
$c<= :: InstrumentKind -> InstrumentKind -> Bool
<= :: InstrumentKind -> InstrumentKind -> Bool
$c> :: InstrumentKind -> InstrumentKind -> Bool
> :: InstrumentKind -> InstrumentKind -> Bool
$c>= :: InstrumentKind -> InstrumentKind -> Bool
>= :: InstrumentKind -> InstrumentKind -> Bool
$cmax :: InstrumentKind -> InstrumentKind -> InstrumentKind
max :: InstrumentKind -> InstrumentKind -> InstrumentKind
$cmin :: InstrumentKind -> InstrumentKind -> InstrumentKind
min :: InstrumentKind -> InstrumentKind -> InstrumentKind
Ord, (forall x. InstrumentKind -> Rep InstrumentKind x)
-> (forall x. Rep InstrumentKind x -> InstrumentKind)
-> Generic InstrumentKind
forall x. Rep InstrumentKind x -> InstrumentKind
forall x. InstrumentKind -> Rep InstrumentKind x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. InstrumentKind -> Rep InstrumentKind x
from :: forall x. InstrumentKind -> Rep InstrumentKind x
$cto :: forall x. Rep InstrumentKind x -> InstrumentKind
to :: forall x. Rep InstrumentKind x -> InstrumentKind
Generic)
deriving anyclass (Eq InstrumentKind
Eq InstrumentKind =>
(Int -> InstrumentKind -> Int)
-> (InstrumentKind -> Int) -> Hashable InstrumentKind
Int -> InstrumentKind -> Int
InstrumentKind -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> InstrumentKind -> Int
hashWithSalt :: Int -> InstrumentKind -> Int
$chash :: InstrumentKind -> Int
hash :: InstrumentKind -> Int
Hashable)
data HistogramAggregation
= HistogramAggregationExplicit !(Vector Double)
|
HistogramAggregationExponential !Int32
deriving stock (HistogramAggregation -> HistogramAggregation -> Bool
(HistogramAggregation -> HistogramAggregation -> Bool)
-> (HistogramAggregation -> HistogramAggregation -> Bool)
-> Eq HistogramAggregation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HistogramAggregation -> HistogramAggregation -> Bool
== :: HistogramAggregation -> HistogramAggregation -> Bool
$c/= :: HistogramAggregation -> HistogramAggregation -> Bool
/= :: HistogramAggregation -> HistogramAggregation -> Bool
Eq, Int -> HistogramAggregation -> ShowS
[HistogramAggregation] -> ShowS
HistogramAggregation -> String
(Int -> HistogramAggregation -> ShowS)
-> (HistogramAggregation -> String)
-> ([HistogramAggregation] -> ShowS)
-> Show HistogramAggregation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HistogramAggregation -> ShowS
showsPrec :: Int -> HistogramAggregation -> ShowS
$cshow :: HistogramAggregation -> String
show :: HistogramAggregation -> String
$cshowList :: [HistogramAggregation] -> ShowS
showList :: [HistogramAggregation] -> ShowS
Show, (forall x. HistogramAggregation -> Rep HistogramAggregation x)
-> (forall x. Rep HistogramAggregation x -> HistogramAggregation)
-> Generic HistogramAggregation
forall x. Rep HistogramAggregation x -> HistogramAggregation
forall x. HistogramAggregation -> Rep HistogramAggregation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HistogramAggregation -> Rep HistogramAggregation x
from :: forall x. HistogramAggregation -> Rep HistogramAggregation x
$cto :: forall x. Rep HistogramAggregation x -> HistogramAggregation
to :: forall x. Rep HistogramAggregation x -> HistogramAggregation
Generic)
instance Hashable HistogramAggregation where
hashWithSalt :: Int -> HistogramAggregation -> Int
hashWithSalt Int
s (HistogramAggregationExplicit Vector Double
v) =
(Int -> Double -> Int) -> Int -> Vector Double -> Int
forall a b. (a -> b -> a) -> a -> Vector b -> a
V.foldl' Int -> Double -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt (Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
0 :: Int) Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Vector Double -> Int
forall a. Vector a -> Int
V.length Vector Double
v) Vector Double
v
hashWithSalt Int
s (HistogramAggregationExponential Int32
sc) =
Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
1 :: Int) Int -> Int32 -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int32
sc
data AdvisoryParameters = AdvisoryParameters
{ AdvisoryParameters -> Maybe [Double]
advisoryExplicitBucketBoundaries :: !(Maybe [Double])
, AdvisoryParameters -> Maybe [Text]
advisoryAttributeKeys :: !(Maybe [Text])
, AdvisoryParameters -> Maybe HistogramAggregation
advisoryHistogramAggregation :: !(Maybe HistogramAggregation)
}
deriving stock (AdvisoryParameters -> AdvisoryParameters -> Bool
(AdvisoryParameters -> AdvisoryParameters -> Bool)
-> (AdvisoryParameters -> AdvisoryParameters -> Bool)
-> Eq AdvisoryParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AdvisoryParameters -> AdvisoryParameters -> Bool
== :: AdvisoryParameters -> AdvisoryParameters -> Bool
$c/= :: AdvisoryParameters -> AdvisoryParameters -> Bool
/= :: AdvisoryParameters -> AdvisoryParameters -> Bool
Eq, Int -> AdvisoryParameters -> ShowS
[AdvisoryParameters] -> ShowS
AdvisoryParameters -> String
(Int -> AdvisoryParameters -> ShowS)
-> (AdvisoryParameters -> String)
-> ([AdvisoryParameters] -> ShowS)
-> Show AdvisoryParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AdvisoryParameters -> ShowS
showsPrec :: Int -> AdvisoryParameters -> ShowS
$cshow :: AdvisoryParameters -> String
show :: AdvisoryParameters -> String
$cshowList :: [AdvisoryParameters] -> ShowS
showList :: [AdvisoryParameters] -> ShowS
Show, (forall x. AdvisoryParameters -> Rep AdvisoryParameters x)
-> (forall x. Rep AdvisoryParameters x -> AdvisoryParameters)
-> Generic AdvisoryParameters
forall x. Rep AdvisoryParameters x -> AdvisoryParameters
forall x. AdvisoryParameters -> Rep AdvisoryParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AdvisoryParameters -> Rep AdvisoryParameters x
from :: forall x. AdvisoryParameters -> Rep AdvisoryParameters x
$cto :: forall x. Rep AdvisoryParameters x -> AdvisoryParameters
to :: forall x. Rep AdvisoryParameters x -> AdvisoryParameters
Generic)
defaultAdvisoryParameters :: AdvisoryParameters
defaultAdvisoryParameters :: AdvisoryParameters
defaultAdvisoryParameters =
AdvisoryParameters
{ advisoryExplicitBucketBoundaries :: Maybe [Double]
advisoryExplicitBucketBoundaries = Maybe [Double]
forall a. Maybe a
Nothing
, advisoryAttributeKeys :: Maybe [Text]
advisoryAttributeKeys = Maybe [Text]
forall a. Maybe a
Nothing
, advisoryHistogramAggregation :: Maybe HistogramAggregation
advisoryHistogramAggregation = Maybe HistogramAggregation
forall a. Maybe a
Nothing
}
data Counter a = Counter
{ forall a. Counter a -> a -> Attributes -> IO ()
counterAdd :: !(a -> Attributes -> IO ())
, forall a. Counter a -> IO Bool
counterEnabled :: !(IO Bool)
}
data UpDownCounter a = UpDownCounter
{ forall a. UpDownCounter a -> a -> Attributes -> IO ()
upDownCounterAdd :: !(a -> Attributes -> IO ())
, forall a. UpDownCounter a -> IO Bool
upDownCounterEnabled :: !(IO Bool)
}
data Histogram = Histogram
{ Histogram -> Double -> Attributes -> IO ()
histogramRecord :: !(Double -> Attributes -> IO ())
, Histogram -> IO Bool
histogramEnabled :: !(IO Bool)
}
data Gauge a = Gauge
{ forall a. Gauge a -> a -> Attributes -> IO ()
gaugeRecord :: !(a -> Attributes -> IO ())
, forall a. Gauge a -> IO Bool
gaugeEnabled :: !(IO Bool)
}
newtype ObservableResult a = ObservableResult
{ forall a. ObservableResult a -> a -> Attributes -> IO ()
observe :: a -> Attributes -> IO ()
}
newtype ObservableCallbackHandle = ObservableCallbackHandle
{ ObservableCallbackHandle -> IO ()
unregisterObservableCallback :: IO ()
}
data ObservableCounter a = ObservableCounter
{ forall a.
ObservableCounter a
-> (ObservableResult a -> IO ()) -> IO ObservableCallbackHandle
observableCounterRegisterCallback :: !((ObservableResult a -> IO ()) -> IO ObservableCallbackHandle)
, forall a. ObservableCounter a -> InstrumentationLibrary
observableCounterInstrumentScope :: !InstrumentationLibrary
, forall a. ObservableCounter a -> Text
observableCounterInstrumentName :: !Text
, forall a. ObservableCounter a -> IO Bool
observableCounterEnabled :: !(IO Bool)
}
data ObservableUpDownCounter a = ObservableUpDownCounter
{ forall a.
ObservableUpDownCounter a
-> (ObservableResult a -> IO ()) -> IO ObservableCallbackHandle
observableUpDownCounterRegisterCallback :: !((ObservableResult a -> IO ()) -> IO ObservableCallbackHandle)
, forall a. ObservableUpDownCounter a -> InstrumentationLibrary
observableUpDownCounterInstrumentScope :: !InstrumentationLibrary
, forall a. ObservableUpDownCounter a -> Text
observableUpDownCounterInstrumentName :: !Text
, forall a. ObservableUpDownCounter a -> IO Bool
observableUpDownCounterEnabled :: !(IO Bool)
}
data ObservableGauge a = ObservableGauge
{ forall a.
ObservableGauge a
-> (ObservableResult a -> IO ()) -> IO ObservableCallbackHandle
observableGaugeRegisterCallback :: !((ObservableResult a -> IO ()) -> IO ObservableCallbackHandle)
, forall a. ObservableGauge a -> InstrumentationLibrary
observableGaugeInstrumentScope :: !InstrumentationLibrary
, forall a. ObservableGauge a -> Text
observableGaugeInstrumentName :: !Text
, forall a. ObservableGauge a -> IO Bool
observableGaugeEnabled :: !(IO Bool)
}
data Meter = Meter
{ Meter -> InstrumentationLibrary
meterInstrumentationScope :: !InstrumentationLibrary
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> IO (Counter Int64)
meterCreateCounterInt64 :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> IO (Counter Int64))
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> IO (Counter Double)
meterCreateCounterDouble :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> IO (Counter Double))
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> IO (UpDownCounter Int64)
meterCreateUpDownCounterInt64 :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> IO (UpDownCounter Int64))
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> IO (UpDownCounter Double)
meterCreateUpDownCounterDouble :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> IO (UpDownCounter Double))
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> IO Histogram
meterCreateHistogram :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> IO Histogram)
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> IO (Gauge Int64)
meterCreateGaugeInt64 :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> IO (Gauge Int64))
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> IO (Gauge Double)
meterCreateGaugeDouble :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> IO (Gauge Double))
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> [ObservableResult Int64 -> IO ()]
-> IO (ObservableCounter Int64)
meterCreateObservableCounterInt64 :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> [ObservableResult Int64 -> IO ()] -> IO (ObservableCounter Int64))
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> [ObservableResult Double -> IO ()]
-> IO (ObservableCounter Double)
meterCreateObservableCounterDouble :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> [ObservableResult Double -> IO ()] -> IO (ObservableCounter Double))
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> [ObservableResult Int64 -> IO ()]
-> IO (ObservableUpDownCounter Int64)
meterCreateObservableUpDownCounterInt64 :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> [ObservableResult Int64 -> IO ()] -> IO (ObservableUpDownCounter Int64))
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> [ObservableResult Double -> IO ()]
-> IO (ObservableUpDownCounter Double)
meterCreateObservableUpDownCounterDouble :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> [ObservableResult Double -> IO ()] -> IO (ObservableUpDownCounter Double))
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> [ObservableResult Int64 -> IO ()]
-> IO (ObservableGauge Int64)
meterCreateObservableGaugeInt64 :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> [ObservableResult Int64 -> IO ()] -> IO (ObservableGauge Int64))
, Meter
-> Text
-> Maybe Text
-> Maybe Text
-> AdvisoryParameters
-> [ObservableResult Double -> IO ()]
-> IO (ObservableGauge Double)
meterCreateObservableGaugeDouble :: !(Text -> Maybe Text -> Maybe Text -> AdvisoryParameters -> [ObservableResult Double -> IO ()] -> IO (ObservableGauge Double))
}
data MeterProvider = MeterProvider
{ MeterProvider -> InstrumentationLibrary -> IO Meter
meterProviderGetMeter :: !(InstrumentationLibrary -> IO Meter)
, MeterProvider -> Maybe Int -> IO ShutdownResult
meterProviderShutdown :: !(Maybe Int -> IO ShutdownResult)
, MeterProvider -> Maybe Int -> IO FlushResult
meterProviderForceFlush :: !(Maybe Int -> IO FlushResult)
}