{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE StrictData #-}
module OpenTelemetry.Internal.Metric.Export (
AggregationTemporality (..),
NumberValue (..),
OptionalDouble (..),
toMaybeDouble,
MetricExemplar (..),
SumDataPoint (..),
HistogramDataPoint (..),
ExponentialHistogramDataPoint (..),
GaugeDataPoint (..),
MetricExport (..),
ScopeMetricsExport (..),
ResourceMetricsExport (..),
MetricExporter (..),
filterAttributesByKeys,
complementAttributesByKeys,
) where
import Data.ByteString (ByteString)
import qualified Data.HashMap.Strict as H
import qualified Data.HashSet as HS
import Data.Int (Int32, Int64)
import Data.Text (Text)
import Data.Vector (Vector)
import Data.Word (Word64)
import GHC.Generics (Generic)
import OpenTelemetry.Attributes (Attributes, emptyAttributes, getAttributeMap, unsafeAttributesFromMapIgnoringLimits)
import OpenTelemetry.Internal.Common.Types (ExportResult, FlushResult, InstrumentationLibrary, ShutdownResult)
import OpenTelemetry.Resource (MaterializedResources)
data AggregationTemporality
= AggregationDelta
| AggregationCumulative
deriving stock (AggregationTemporality -> AggregationTemporality -> Bool
(AggregationTemporality -> AggregationTemporality -> Bool)
-> (AggregationTemporality -> AggregationTemporality -> Bool)
-> Eq AggregationTemporality
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AggregationTemporality -> AggregationTemporality -> Bool
== :: AggregationTemporality -> AggregationTemporality -> Bool
$c/= :: AggregationTemporality -> AggregationTemporality -> Bool
/= :: AggregationTemporality -> AggregationTemporality -> Bool
Eq, Int -> AggregationTemporality -> ShowS
[AggregationTemporality] -> ShowS
AggregationTemporality -> String
(Int -> AggregationTemporality -> ShowS)
-> (AggregationTemporality -> String)
-> ([AggregationTemporality] -> ShowS)
-> Show AggregationTemporality
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AggregationTemporality -> ShowS
showsPrec :: Int -> AggregationTemporality -> ShowS
$cshow :: AggregationTemporality -> String
show :: AggregationTemporality -> String
$cshowList :: [AggregationTemporality] -> ShowS
showList :: [AggregationTemporality] -> ShowS
Show, (forall x. AggregationTemporality -> Rep AggregationTemporality x)
-> (forall x.
Rep AggregationTemporality x -> AggregationTemporality)
-> Generic AggregationTemporality
forall x. Rep AggregationTemporality x -> AggregationTemporality
forall x. AggregationTemporality -> Rep AggregationTemporality x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AggregationTemporality -> Rep AggregationTemporality x
from :: forall x. AggregationTemporality -> Rep AggregationTemporality x
$cto :: forall x. Rep AggregationTemporality x -> AggregationTemporality
to :: forall x. Rep AggregationTemporality x -> AggregationTemporality
Generic)
data NumberValue
= IntNumber {-# UNPACK #-} !Int64
| DoubleNumber {-# UNPACK #-} !Double
deriving stock (NumberValue -> NumberValue -> Bool
(NumberValue -> NumberValue -> Bool)
-> (NumberValue -> NumberValue -> Bool) -> Eq NumberValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NumberValue -> NumberValue -> Bool
== :: NumberValue -> NumberValue -> Bool
$c/= :: NumberValue -> NumberValue -> Bool
/= :: NumberValue -> NumberValue -> Bool
Eq, Int -> NumberValue -> ShowS
[NumberValue] -> ShowS
NumberValue -> String
(Int -> NumberValue -> ShowS)
-> (NumberValue -> String)
-> ([NumberValue] -> ShowS)
-> Show NumberValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NumberValue -> ShowS
showsPrec :: Int -> NumberValue -> ShowS
$cshow :: NumberValue -> String
show :: NumberValue -> String
$cshowList :: [NumberValue] -> ShowS
showList :: [NumberValue] -> ShowS
Show, (forall x. NumberValue -> Rep NumberValue x)
-> (forall x. Rep NumberValue x -> NumberValue)
-> Generic NumberValue
forall x. Rep NumberValue x -> NumberValue
forall x. NumberValue -> Rep NumberValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NumberValue -> Rep NumberValue x
from :: forall x. NumberValue -> Rep NumberValue x
$cto :: forall x. Rep NumberValue x -> NumberValue
to :: forall x. Rep NumberValue x -> NumberValue
Generic)
data OptionalDouble
= NoDouble
| SomeDouble {-# UNPACK #-} !Double
deriving stock (OptionalDouble -> OptionalDouble -> Bool
(OptionalDouble -> OptionalDouble -> Bool)
-> (OptionalDouble -> OptionalDouble -> Bool) -> Eq OptionalDouble
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OptionalDouble -> OptionalDouble -> Bool
== :: OptionalDouble -> OptionalDouble -> Bool
$c/= :: OptionalDouble -> OptionalDouble -> Bool
/= :: OptionalDouble -> OptionalDouble -> Bool
Eq, Int -> OptionalDouble -> ShowS
[OptionalDouble] -> ShowS
OptionalDouble -> String
(Int -> OptionalDouble -> ShowS)
-> (OptionalDouble -> String)
-> ([OptionalDouble] -> ShowS)
-> Show OptionalDouble
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OptionalDouble -> ShowS
showsPrec :: Int -> OptionalDouble -> ShowS
$cshow :: OptionalDouble -> String
show :: OptionalDouble -> String
$cshowList :: [OptionalDouble] -> ShowS
showList :: [OptionalDouble] -> ShowS
Show, (forall x. OptionalDouble -> Rep OptionalDouble x)
-> (forall x. Rep OptionalDouble x -> OptionalDouble)
-> Generic OptionalDouble
forall x. Rep OptionalDouble x -> OptionalDouble
forall x. OptionalDouble -> Rep OptionalDouble x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. OptionalDouble -> Rep OptionalDouble x
from :: forall x. OptionalDouble -> Rep OptionalDouble x
$cto :: forall x. Rep OptionalDouble x -> OptionalDouble
to :: forall x. Rep OptionalDouble x -> OptionalDouble
Generic)
toMaybeDouble :: OptionalDouble -> Maybe Double
toMaybeDouble :: OptionalDouble -> Maybe Double
toMaybeDouble OptionalDouble
NoDouble = Maybe Double
forall a. Maybe a
Nothing
toMaybeDouble (SomeDouble Double
d) = Double -> Maybe Double
forall a. a -> Maybe a
Just Double
d
{-# INLINE toMaybeDouble #-}
data MetricExemplar = MetricExemplar
{ MetricExemplar -> ByteString
metricExemplarTraceId :: !ByteString
, MetricExemplar -> ByteString
metricExemplarSpanId :: !ByteString
, MetricExemplar -> Word64
metricExemplarTimeUnixNano :: !Word64
, MetricExemplar -> Attributes
metricExemplarFilteredAttributes :: !Attributes
, MetricExemplar -> Maybe NumberValue
metricExemplarValue :: !(Maybe NumberValue)
}
deriving stock (MetricExemplar -> MetricExemplar -> Bool
(MetricExemplar -> MetricExemplar -> Bool)
-> (MetricExemplar -> MetricExemplar -> Bool) -> Eq MetricExemplar
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MetricExemplar -> MetricExemplar -> Bool
== :: MetricExemplar -> MetricExemplar -> Bool
$c/= :: MetricExemplar -> MetricExemplar -> Bool
/= :: MetricExemplar -> MetricExemplar -> Bool
Eq, Int -> MetricExemplar -> ShowS
[MetricExemplar] -> ShowS
MetricExemplar -> String
(Int -> MetricExemplar -> ShowS)
-> (MetricExemplar -> String)
-> ([MetricExemplar] -> ShowS)
-> Show MetricExemplar
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MetricExemplar -> ShowS
showsPrec :: Int -> MetricExemplar -> ShowS
$cshow :: MetricExemplar -> String
show :: MetricExemplar -> String
$cshowList :: [MetricExemplar] -> ShowS
showList :: [MetricExemplar] -> ShowS
Show, (forall x. MetricExemplar -> Rep MetricExemplar x)
-> (forall x. Rep MetricExemplar x -> MetricExemplar)
-> Generic MetricExemplar
forall x. Rep MetricExemplar x -> MetricExemplar
forall x. MetricExemplar -> Rep MetricExemplar x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MetricExemplar -> Rep MetricExemplar x
from :: forall x. MetricExemplar -> Rep MetricExemplar x
$cto :: forall x. Rep MetricExemplar x -> MetricExemplar
to :: forall x. Rep MetricExemplar x -> MetricExemplar
Generic)
data SumDataPoint = SumDataPoint
{ SumDataPoint -> Word64
sumDataPointStartTimeUnixNano :: !Word64
, SumDataPoint -> Word64
sumDataPointTimeUnixNano :: !Word64
, SumDataPoint -> NumberValue
sumDataPointValue :: !NumberValue
, SumDataPoint -> Attributes
sumDataPointAttributes :: !Attributes
, SumDataPoint -> Vector MetricExemplar
sumDataPointExemplars :: !(Vector MetricExemplar)
}
deriving stock (SumDataPoint -> SumDataPoint -> Bool
(SumDataPoint -> SumDataPoint -> Bool)
-> (SumDataPoint -> SumDataPoint -> Bool) -> Eq SumDataPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SumDataPoint -> SumDataPoint -> Bool
== :: SumDataPoint -> SumDataPoint -> Bool
$c/= :: SumDataPoint -> SumDataPoint -> Bool
/= :: SumDataPoint -> SumDataPoint -> Bool
Eq, Int -> SumDataPoint -> ShowS
[SumDataPoint] -> ShowS
SumDataPoint -> String
(Int -> SumDataPoint -> ShowS)
-> (SumDataPoint -> String)
-> ([SumDataPoint] -> ShowS)
-> Show SumDataPoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SumDataPoint -> ShowS
showsPrec :: Int -> SumDataPoint -> ShowS
$cshow :: SumDataPoint -> String
show :: SumDataPoint -> String
$cshowList :: [SumDataPoint] -> ShowS
showList :: [SumDataPoint] -> ShowS
Show, (forall x. SumDataPoint -> Rep SumDataPoint x)
-> (forall x. Rep SumDataPoint x -> SumDataPoint)
-> Generic SumDataPoint
forall x. Rep SumDataPoint x -> SumDataPoint
forall x. SumDataPoint -> Rep SumDataPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SumDataPoint -> Rep SumDataPoint x
from :: forall x. SumDataPoint -> Rep SumDataPoint x
$cto :: forall x. Rep SumDataPoint x -> SumDataPoint
to :: forall x. Rep SumDataPoint x -> SumDataPoint
Generic)
data HistogramDataPoint = HistogramDataPoint
{ HistogramDataPoint -> Word64
histogramDataPointStartTimeUnixNano :: !Word64
, HistogramDataPoint -> Word64
histogramDataPointTimeUnixNano :: !Word64
, HistogramDataPoint -> Word64
histogramDataPointCount :: !Word64
, HistogramDataPoint -> Double
histogramDataPointSum :: !Double
, HistogramDataPoint -> Vector Word64
histogramDataPointBucketCounts :: !(Vector Word64)
, HistogramDataPoint -> Vector Double
histogramDataPointExplicitBounds :: !(Vector Double)
, HistogramDataPoint -> Attributes
histogramDataPointAttributes :: !Attributes
, HistogramDataPoint -> Maybe Double
histogramDataPointMin :: !(Maybe Double)
, HistogramDataPoint -> Maybe Double
histogramDataPointMax :: !(Maybe Double)
, HistogramDataPoint -> Vector MetricExemplar
histogramDataPointExemplars :: !(Vector MetricExemplar)
}
deriving stock (HistogramDataPoint -> HistogramDataPoint -> Bool
(HistogramDataPoint -> HistogramDataPoint -> Bool)
-> (HistogramDataPoint -> HistogramDataPoint -> Bool)
-> Eq HistogramDataPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HistogramDataPoint -> HistogramDataPoint -> Bool
== :: HistogramDataPoint -> HistogramDataPoint -> Bool
$c/= :: HistogramDataPoint -> HistogramDataPoint -> Bool
/= :: HistogramDataPoint -> HistogramDataPoint -> Bool
Eq, Int -> HistogramDataPoint -> ShowS
[HistogramDataPoint] -> ShowS
HistogramDataPoint -> String
(Int -> HistogramDataPoint -> ShowS)
-> (HistogramDataPoint -> String)
-> ([HistogramDataPoint] -> ShowS)
-> Show HistogramDataPoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HistogramDataPoint -> ShowS
showsPrec :: Int -> HistogramDataPoint -> ShowS
$cshow :: HistogramDataPoint -> String
show :: HistogramDataPoint -> String
$cshowList :: [HistogramDataPoint] -> ShowS
showList :: [HistogramDataPoint] -> ShowS
Show, (forall x. HistogramDataPoint -> Rep HistogramDataPoint x)
-> (forall x. Rep HistogramDataPoint x -> HistogramDataPoint)
-> Generic HistogramDataPoint
forall x. Rep HistogramDataPoint x -> HistogramDataPoint
forall x. HistogramDataPoint -> Rep HistogramDataPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HistogramDataPoint -> Rep HistogramDataPoint x
from :: forall x. HistogramDataPoint -> Rep HistogramDataPoint x
$cto :: forall x. Rep HistogramDataPoint x -> HistogramDataPoint
to :: forall x. Rep HistogramDataPoint x -> HistogramDataPoint
Generic)
data ExponentialHistogramDataPoint = ExponentialHistogramDataPoint
{ ExponentialHistogramDataPoint -> Word64
exponentialHistogramDataPointStartTimeUnixNano :: !Word64
, ExponentialHistogramDataPoint -> Word64
exponentialHistogramDataPointTimeUnixNano :: !Word64
, ExponentialHistogramDataPoint -> Word64
exponentialHistogramDataPointCount :: !Word64
, ExponentialHistogramDataPoint -> Maybe Double
exponentialHistogramDataPointSum :: !(Maybe Double)
, ExponentialHistogramDataPoint -> Int32
exponentialHistogramDataPointScale :: !Int32
, ExponentialHistogramDataPoint -> Word64
exponentialHistogramDataPointZeroCount :: !Word64
, ExponentialHistogramDataPoint -> Int32
exponentialHistogramDataPointPositiveOffset :: !Int32
, ExponentialHistogramDataPoint -> Vector Word64
exponentialHistogramDataPointPositiveBucketCounts :: !(Vector Word64)
, ExponentialHistogramDataPoint -> Int32
exponentialHistogramDataPointNegativeOffset :: !Int32
, ExponentialHistogramDataPoint -> Vector Word64
exponentialHistogramDataPointNegativeBucketCounts :: !(Vector Word64)
, ExponentialHistogramDataPoint -> Attributes
exponentialHistogramDataPointAttributes :: !Attributes
, ExponentialHistogramDataPoint -> Maybe Double
exponentialHistogramDataPointMin :: !(Maybe Double)
, ExponentialHistogramDataPoint -> Maybe Double
exponentialHistogramDataPointMax :: !(Maybe Double)
, ExponentialHistogramDataPoint -> Vector MetricExemplar
exponentialHistogramDataPointExemplars :: !(Vector MetricExemplar)
, ExponentialHistogramDataPoint -> Double
exponentialHistogramDataPointZeroThreshold :: !Double
}
deriving stock (ExponentialHistogramDataPoint
-> ExponentialHistogramDataPoint -> Bool
(ExponentialHistogramDataPoint
-> ExponentialHistogramDataPoint -> Bool)
-> (ExponentialHistogramDataPoint
-> ExponentialHistogramDataPoint -> Bool)
-> Eq ExponentialHistogramDataPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExponentialHistogramDataPoint
-> ExponentialHistogramDataPoint -> Bool
== :: ExponentialHistogramDataPoint
-> ExponentialHistogramDataPoint -> Bool
$c/= :: ExponentialHistogramDataPoint
-> ExponentialHistogramDataPoint -> Bool
/= :: ExponentialHistogramDataPoint
-> ExponentialHistogramDataPoint -> Bool
Eq, Int -> ExponentialHistogramDataPoint -> ShowS
[ExponentialHistogramDataPoint] -> ShowS
ExponentialHistogramDataPoint -> String
(Int -> ExponentialHistogramDataPoint -> ShowS)
-> (ExponentialHistogramDataPoint -> String)
-> ([ExponentialHistogramDataPoint] -> ShowS)
-> Show ExponentialHistogramDataPoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExponentialHistogramDataPoint -> ShowS
showsPrec :: Int -> ExponentialHistogramDataPoint -> ShowS
$cshow :: ExponentialHistogramDataPoint -> String
show :: ExponentialHistogramDataPoint -> String
$cshowList :: [ExponentialHistogramDataPoint] -> ShowS
showList :: [ExponentialHistogramDataPoint] -> ShowS
Show, (forall x.
ExponentialHistogramDataPoint
-> Rep ExponentialHistogramDataPoint x)
-> (forall x.
Rep ExponentialHistogramDataPoint x
-> ExponentialHistogramDataPoint)
-> Generic ExponentialHistogramDataPoint
forall x.
Rep ExponentialHistogramDataPoint x
-> ExponentialHistogramDataPoint
forall x.
ExponentialHistogramDataPoint
-> Rep ExponentialHistogramDataPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
ExponentialHistogramDataPoint
-> Rep ExponentialHistogramDataPoint x
from :: forall x.
ExponentialHistogramDataPoint
-> Rep ExponentialHistogramDataPoint x
$cto :: forall x.
Rep ExponentialHistogramDataPoint x
-> ExponentialHistogramDataPoint
to :: forall x.
Rep ExponentialHistogramDataPoint x
-> ExponentialHistogramDataPoint
Generic)
data GaugeDataPoint = GaugeDataPoint
{ GaugeDataPoint -> Word64
gaugeDataPointStartTimeUnixNano :: !Word64
, GaugeDataPoint -> Word64
gaugeDataPointTimeUnixNano :: !Word64
, GaugeDataPoint -> NumberValue
gaugeDataPointValue :: !NumberValue
, GaugeDataPoint -> Attributes
gaugeDataPointAttributes :: !Attributes
, GaugeDataPoint -> Vector MetricExemplar
gaugeDataPointExemplars :: !(Vector MetricExemplar)
}
deriving stock (GaugeDataPoint -> GaugeDataPoint -> Bool
(GaugeDataPoint -> GaugeDataPoint -> Bool)
-> (GaugeDataPoint -> GaugeDataPoint -> Bool) -> Eq GaugeDataPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GaugeDataPoint -> GaugeDataPoint -> Bool
== :: GaugeDataPoint -> GaugeDataPoint -> Bool
$c/= :: GaugeDataPoint -> GaugeDataPoint -> Bool
/= :: GaugeDataPoint -> GaugeDataPoint -> Bool
Eq, Int -> GaugeDataPoint -> ShowS
[GaugeDataPoint] -> ShowS
GaugeDataPoint -> String
(Int -> GaugeDataPoint -> ShowS)
-> (GaugeDataPoint -> String)
-> ([GaugeDataPoint] -> ShowS)
-> Show GaugeDataPoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GaugeDataPoint -> ShowS
showsPrec :: Int -> GaugeDataPoint -> ShowS
$cshow :: GaugeDataPoint -> String
show :: GaugeDataPoint -> String
$cshowList :: [GaugeDataPoint] -> ShowS
showList :: [GaugeDataPoint] -> ShowS
Show, (forall x. GaugeDataPoint -> Rep GaugeDataPoint x)
-> (forall x. Rep GaugeDataPoint x -> GaugeDataPoint)
-> Generic GaugeDataPoint
forall x. Rep GaugeDataPoint x -> GaugeDataPoint
forall x. GaugeDataPoint -> Rep GaugeDataPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GaugeDataPoint -> Rep GaugeDataPoint x
from :: forall x. GaugeDataPoint -> Rep GaugeDataPoint x
$cto :: forall x. Rep GaugeDataPoint x -> GaugeDataPoint
to :: forall x. Rep GaugeDataPoint x -> GaugeDataPoint
Generic)
data MetricExport
= MetricExportSum
{ MetricExport -> Text
mesName :: !Text
, MetricExport -> Text
mesDescription :: !Text
, MetricExport -> Text
mesUnit :: !Text
, MetricExport -> InstrumentationLibrary
mesScope :: !InstrumentationLibrary
, MetricExport -> Bool
mesMonotonic :: !Bool
, MetricExport -> Bool
mesIsInt :: !Bool
, MetricExport -> AggregationTemporality
mesAggregationTemporality :: !AggregationTemporality
, MetricExport -> Vector SumDataPoint
mesSumPoints :: !(Vector SumDataPoint)
}
| MetricExportHistogram
{ MetricExport -> Text
mehName :: !Text
, MetricExport -> Text
mehDescription :: !Text
, MetricExport -> Text
mehUnit :: !Text
, MetricExport -> InstrumentationLibrary
mehScope :: !InstrumentationLibrary
, MetricExport -> AggregationTemporality
mehAggregationTemporality :: !AggregationTemporality
, MetricExport -> Vector HistogramDataPoint
mehPoints :: !(Vector HistogramDataPoint)
}
| MetricExportExponentialHistogram
{ MetricExport -> Text
meehName :: !Text
, MetricExport -> Text
meehDescription :: !Text
, MetricExport -> Text
meehUnit :: !Text
, MetricExport -> InstrumentationLibrary
meehScope :: !InstrumentationLibrary
, MetricExport -> AggregationTemporality
meehAggregationTemporality :: !AggregationTemporality
, MetricExport -> Vector ExponentialHistogramDataPoint
meehPoints :: !(Vector ExponentialHistogramDataPoint)
}
| MetricExportGauge
{ MetricExport -> Text
megName :: !Text
, MetricExport -> Text
megDescription :: !Text
, MetricExport -> Text
megUnit :: !Text
, MetricExport -> InstrumentationLibrary
megScope :: !InstrumentationLibrary
, MetricExport -> Bool
megIsInt :: !Bool
, MetricExport -> Vector GaugeDataPoint
megGaugePoints :: !(Vector GaugeDataPoint)
}
deriving stock (MetricExport -> MetricExport -> Bool
(MetricExport -> MetricExport -> Bool)
-> (MetricExport -> MetricExport -> Bool) -> Eq MetricExport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MetricExport -> MetricExport -> Bool
== :: MetricExport -> MetricExport -> Bool
$c/= :: MetricExport -> MetricExport -> Bool
/= :: MetricExport -> MetricExport -> Bool
Eq, Int -> MetricExport -> ShowS
[MetricExport] -> ShowS
MetricExport -> String
(Int -> MetricExport -> ShowS)
-> (MetricExport -> String)
-> ([MetricExport] -> ShowS)
-> Show MetricExport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MetricExport -> ShowS
showsPrec :: Int -> MetricExport -> ShowS
$cshow :: MetricExport -> String
show :: MetricExport -> String
$cshowList :: [MetricExport] -> ShowS
showList :: [MetricExport] -> ShowS
Show, (forall x. MetricExport -> Rep MetricExport x)
-> (forall x. Rep MetricExport x -> MetricExport)
-> Generic MetricExport
forall x. Rep MetricExport x -> MetricExport
forall x. MetricExport -> Rep MetricExport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MetricExport -> Rep MetricExport x
from :: forall x. MetricExport -> Rep MetricExport x
$cto :: forall x. Rep MetricExport x -> MetricExport
to :: forall x. Rep MetricExport x -> MetricExport
Generic)
data ScopeMetricsExport = ScopeMetricsExport
{ ScopeMetricsExport -> InstrumentationLibrary
scopeMetricsScope :: !InstrumentationLibrary
, ScopeMetricsExport -> Vector MetricExport
scopeMetricsExports :: !(Vector MetricExport)
}
deriving stock (ScopeMetricsExport -> ScopeMetricsExport -> Bool
(ScopeMetricsExport -> ScopeMetricsExport -> Bool)
-> (ScopeMetricsExport -> ScopeMetricsExport -> Bool)
-> Eq ScopeMetricsExport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScopeMetricsExport -> ScopeMetricsExport -> Bool
== :: ScopeMetricsExport -> ScopeMetricsExport -> Bool
$c/= :: ScopeMetricsExport -> ScopeMetricsExport -> Bool
/= :: ScopeMetricsExport -> ScopeMetricsExport -> Bool
Eq, Int -> ScopeMetricsExport -> ShowS
[ScopeMetricsExport] -> ShowS
ScopeMetricsExport -> String
(Int -> ScopeMetricsExport -> ShowS)
-> (ScopeMetricsExport -> String)
-> ([ScopeMetricsExport] -> ShowS)
-> Show ScopeMetricsExport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScopeMetricsExport -> ShowS
showsPrec :: Int -> ScopeMetricsExport -> ShowS
$cshow :: ScopeMetricsExport -> String
show :: ScopeMetricsExport -> String
$cshowList :: [ScopeMetricsExport] -> ShowS
showList :: [ScopeMetricsExport] -> ShowS
Show, (forall x. ScopeMetricsExport -> Rep ScopeMetricsExport x)
-> (forall x. Rep ScopeMetricsExport x -> ScopeMetricsExport)
-> Generic ScopeMetricsExport
forall x. Rep ScopeMetricsExport x -> ScopeMetricsExport
forall x. ScopeMetricsExport -> Rep ScopeMetricsExport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScopeMetricsExport -> Rep ScopeMetricsExport x
from :: forall x. ScopeMetricsExport -> Rep ScopeMetricsExport x
$cto :: forall x. Rep ScopeMetricsExport x -> ScopeMetricsExport
to :: forall x. Rep ScopeMetricsExport x -> ScopeMetricsExport
Generic)
data ResourceMetricsExport = ResourceMetricsExport
{ ResourceMetricsExport -> MaterializedResources
resourceMetricsResource :: !MaterializedResources
, ResourceMetricsExport -> Vector ScopeMetricsExport
resourceMetricsScopes :: !(Vector ScopeMetricsExport)
}
deriving stock (ResourceMetricsExport -> ResourceMetricsExport -> Bool
(ResourceMetricsExport -> ResourceMetricsExport -> Bool)
-> (ResourceMetricsExport -> ResourceMetricsExport -> Bool)
-> Eq ResourceMetricsExport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ResourceMetricsExport -> ResourceMetricsExport -> Bool
== :: ResourceMetricsExport -> ResourceMetricsExport -> Bool
$c/= :: ResourceMetricsExport -> ResourceMetricsExport -> Bool
/= :: ResourceMetricsExport -> ResourceMetricsExport -> Bool
Eq, Int -> ResourceMetricsExport -> ShowS
[ResourceMetricsExport] -> ShowS
ResourceMetricsExport -> String
(Int -> ResourceMetricsExport -> ShowS)
-> (ResourceMetricsExport -> String)
-> ([ResourceMetricsExport] -> ShowS)
-> Show ResourceMetricsExport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ResourceMetricsExport -> ShowS
showsPrec :: Int -> ResourceMetricsExport -> ShowS
$cshow :: ResourceMetricsExport -> String
show :: ResourceMetricsExport -> String
$cshowList :: [ResourceMetricsExport] -> ShowS
showList :: [ResourceMetricsExport] -> ShowS
Show, (forall x. ResourceMetricsExport -> Rep ResourceMetricsExport x)
-> (forall x. Rep ResourceMetricsExport x -> ResourceMetricsExport)
-> Generic ResourceMetricsExport
forall x. Rep ResourceMetricsExport x -> ResourceMetricsExport
forall x. ResourceMetricsExport -> Rep ResourceMetricsExport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ResourceMetricsExport -> Rep ResourceMetricsExport x
from :: forall x. ResourceMetricsExport -> Rep ResourceMetricsExport x
$cto :: forall x. Rep ResourceMetricsExport x -> ResourceMetricsExport
to :: forall x. Rep ResourceMetricsExport x -> ResourceMetricsExport
Generic)
data MetricExporter = MetricExporter
{ MetricExporter -> Vector ResourceMetricsExport -> IO ExportResult
metricExporterExport :: !(Vector ResourceMetricsExport -> IO ExportResult)
, MetricExporter -> IO ShutdownResult
metricExporterShutdown :: !(IO ShutdownResult)
, MetricExporter -> IO FlushResult
metricExporterForceFlush :: !(IO FlushResult)
}
filterAttributesByKeys :: Maybe (HS.HashSet Text) -> Attributes -> Attributes
filterAttributesByKeys :: Maybe (HashSet Text) -> Attributes -> Attributes
filterAttributesByKeys Maybe (HashSet Text)
Nothing Attributes
attrs = Attributes
attrs
filterAttributesByKeys (Just HashSet Text
keep) Attributes
attrs =
let m :: AttributeMap
m = Attributes -> AttributeMap
getAttributeMap Attributes
attrs
m' :: AttributeMap
m' = (Text -> Attribute -> Bool) -> AttributeMap -> AttributeMap
forall k v. (k -> v -> Bool) -> HashMap k v -> HashMap k v
H.filterWithKey (\Text
k Attribute
_ -> Text
k Text -> HashSet Text -> Bool
forall a. (Eq a, Hashable a) => a -> HashSet a -> Bool
`HS.member` HashSet Text
keep Bool -> Bool -> Bool
|| Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"otel.metric.overflow") AttributeMap
m
in AttributeMap -> Attributes
unsafeAttributesFromMapIgnoringLimits AttributeMap
m'
complementAttributesByKeys :: Maybe (HS.HashSet Text) -> Attributes -> Attributes
complementAttributesByKeys :: Maybe (HashSet Text) -> Attributes -> Attributes
complementAttributesByKeys Maybe (HashSet Text)
Nothing Attributes
_ = Attributes
emptyAttributes
complementAttributesByKeys (Just HashSet Text
keep) Attributes
attrs =
let m :: AttributeMap
m = Attributes -> AttributeMap
getAttributeMap Attributes
attrs
m' :: AttributeMap
m' = (Text -> Attribute -> Bool) -> AttributeMap -> AttributeMap
forall k v. (k -> v -> Bool) -> HashMap k v -> HashMap k v
H.filterWithKey (\Text
k Attribute
_ -> Bool -> Bool
not (Text
k Text -> HashSet Text -> Bool
forall a. (Eq a, Hashable a) => a -> HashSet a -> Bool
`HS.member` HashSet Text
keep)) AttributeMap
m
in AttributeMap -> Attributes
unsafeAttributesFromMapIgnoringLimits AttributeMap
m'