{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.XRay.Types.SamplingStatisticSummary
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.XRay.Types.SamplingStatisticSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Aggregated request sampling data for a sampling rule across all services
-- for a 10-second window.
--
-- /See:/ 'newSamplingStatisticSummary' smart constructor.
data SamplingStatisticSummary = SamplingStatisticSummary'
  { -- | The number of requests recorded with borrowed reservoir quota.
    SamplingStatisticSummary -> Maybe Int
borrowCount :: Prelude.Maybe Prelude.Int,
    -- | The number of requests that matched the rule.
    SamplingStatisticSummary -> Maybe Int
requestCount :: Prelude.Maybe Prelude.Int,
    -- | The name of the sampling rule.
    SamplingStatisticSummary -> Maybe Text
ruleName :: Prelude.Maybe Prelude.Text,
    -- | The number of requests recorded.
    SamplingStatisticSummary -> Maybe Int
sampledCount :: Prelude.Maybe Prelude.Int,
    -- | The start time of the reporting window.
    SamplingStatisticSummary -> Maybe POSIX
timestamp :: Prelude.Maybe Data.POSIX
  }
  deriving (SamplingStatisticSummary -> SamplingStatisticSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SamplingStatisticSummary -> SamplingStatisticSummary -> Bool
$c/= :: SamplingStatisticSummary -> SamplingStatisticSummary -> Bool
== :: SamplingStatisticSummary -> SamplingStatisticSummary -> Bool
$c== :: SamplingStatisticSummary -> SamplingStatisticSummary -> Bool
Prelude.Eq, ReadPrec [SamplingStatisticSummary]
ReadPrec SamplingStatisticSummary
Int -> ReadS SamplingStatisticSummary
ReadS [SamplingStatisticSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SamplingStatisticSummary]
$creadListPrec :: ReadPrec [SamplingStatisticSummary]
readPrec :: ReadPrec SamplingStatisticSummary
$creadPrec :: ReadPrec SamplingStatisticSummary
readList :: ReadS [SamplingStatisticSummary]
$creadList :: ReadS [SamplingStatisticSummary]
readsPrec :: Int -> ReadS SamplingStatisticSummary
$creadsPrec :: Int -> ReadS SamplingStatisticSummary
Prelude.Read, Int -> SamplingStatisticSummary -> ShowS
[SamplingStatisticSummary] -> ShowS
SamplingStatisticSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SamplingStatisticSummary] -> ShowS
$cshowList :: [SamplingStatisticSummary] -> ShowS
show :: SamplingStatisticSummary -> String
$cshow :: SamplingStatisticSummary -> String
showsPrec :: Int -> SamplingStatisticSummary -> ShowS
$cshowsPrec :: Int -> SamplingStatisticSummary -> ShowS
Prelude.Show, forall x.
Rep SamplingStatisticSummary x -> SamplingStatisticSummary
forall x.
SamplingStatisticSummary -> Rep SamplingStatisticSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SamplingStatisticSummary x -> SamplingStatisticSummary
$cfrom :: forall x.
SamplingStatisticSummary -> Rep SamplingStatisticSummary x
Prelude.Generic)

-- |
-- Create a value of 'SamplingStatisticSummary' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'borrowCount', 'samplingStatisticSummary_borrowCount' - The number of requests recorded with borrowed reservoir quota.
--
-- 'requestCount', 'samplingStatisticSummary_requestCount' - The number of requests that matched the rule.
--
-- 'ruleName', 'samplingStatisticSummary_ruleName' - The name of the sampling rule.
--
-- 'sampledCount', 'samplingStatisticSummary_sampledCount' - The number of requests recorded.
--
-- 'timestamp', 'samplingStatisticSummary_timestamp' - The start time of the reporting window.
newSamplingStatisticSummary ::
  SamplingStatisticSummary
newSamplingStatisticSummary :: SamplingStatisticSummary
newSamplingStatisticSummary =
  SamplingStatisticSummary'
    { $sel:borrowCount:SamplingStatisticSummary' :: Maybe Int
borrowCount =
        forall a. Maybe a
Prelude.Nothing,
      $sel:requestCount:SamplingStatisticSummary' :: Maybe Int
requestCount = forall a. Maybe a
Prelude.Nothing,
      $sel:ruleName:SamplingStatisticSummary' :: Maybe Text
ruleName = forall a. Maybe a
Prelude.Nothing,
      $sel:sampledCount:SamplingStatisticSummary' :: Maybe Int
sampledCount = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:SamplingStatisticSummary' :: Maybe POSIX
timestamp = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of requests recorded with borrowed reservoir quota.
samplingStatisticSummary_borrowCount :: Lens.Lens' SamplingStatisticSummary (Prelude.Maybe Prelude.Int)
samplingStatisticSummary_borrowCount :: Lens' SamplingStatisticSummary (Maybe Int)
samplingStatisticSummary_borrowCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticSummary' {Maybe Int
borrowCount :: Maybe Int
$sel:borrowCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
borrowCount} -> Maybe Int
borrowCount) (\s :: SamplingStatisticSummary
s@SamplingStatisticSummary' {} Maybe Int
a -> SamplingStatisticSummary
s {$sel:borrowCount:SamplingStatisticSummary' :: Maybe Int
borrowCount = Maybe Int
a} :: SamplingStatisticSummary)

-- | The number of requests that matched the rule.
samplingStatisticSummary_requestCount :: Lens.Lens' SamplingStatisticSummary (Prelude.Maybe Prelude.Int)
samplingStatisticSummary_requestCount :: Lens' SamplingStatisticSummary (Maybe Int)
samplingStatisticSummary_requestCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticSummary' {Maybe Int
requestCount :: Maybe Int
$sel:requestCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
requestCount} -> Maybe Int
requestCount) (\s :: SamplingStatisticSummary
s@SamplingStatisticSummary' {} Maybe Int
a -> SamplingStatisticSummary
s {$sel:requestCount:SamplingStatisticSummary' :: Maybe Int
requestCount = Maybe Int
a} :: SamplingStatisticSummary)

-- | The name of the sampling rule.
samplingStatisticSummary_ruleName :: Lens.Lens' SamplingStatisticSummary (Prelude.Maybe Prelude.Text)
samplingStatisticSummary_ruleName :: Lens' SamplingStatisticSummary (Maybe Text)
samplingStatisticSummary_ruleName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticSummary' {Maybe Text
ruleName :: Maybe Text
$sel:ruleName:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Text
ruleName} -> Maybe Text
ruleName) (\s :: SamplingStatisticSummary
s@SamplingStatisticSummary' {} Maybe Text
a -> SamplingStatisticSummary
s {$sel:ruleName:SamplingStatisticSummary' :: Maybe Text
ruleName = Maybe Text
a} :: SamplingStatisticSummary)

-- | The number of requests recorded.
samplingStatisticSummary_sampledCount :: Lens.Lens' SamplingStatisticSummary (Prelude.Maybe Prelude.Int)
samplingStatisticSummary_sampledCount :: Lens' SamplingStatisticSummary (Maybe Int)
samplingStatisticSummary_sampledCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticSummary' {Maybe Int
sampledCount :: Maybe Int
$sel:sampledCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
sampledCount} -> Maybe Int
sampledCount) (\s :: SamplingStatisticSummary
s@SamplingStatisticSummary' {} Maybe Int
a -> SamplingStatisticSummary
s {$sel:sampledCount:SamplingStatisticSummary' :: Maybe Int
sampledCount = Maybe Int
a} :: SamplingStatisticSummary)

-- | The start time of the reporting window.
samplingStatisticSummary_timestamp :: Lens.Lens' SamplingStatisticSummary (Prelude.Maybe Prelude.UTCTime)
samplingStatisticSummary_timestamp :: Lens' SamplingStatisticSummary (Maybe UTCTime)
samplingStatisticSummary_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticSummary' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: SamplingStatisticSummary
s@SamplingStatisticSummary' {} Maybe POSIX
a -> SamplingStatisticSummary
s {$sel:timestamp:SamplingStatisticSummary' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: SamplingStatisticSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON SamplingStatisticSummary where
  parseJSON :: Value -> Parser SamplingStatisticSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SamplingStatisticSummary"
      ( \Object
x ->
          Maybe Int
-> Maybe Int
-> Maybe Text
-> Maybe Int
-> Maybe POSIX
-> SamplingStatisticSummary
SamplingStatisticSummary'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"BorrowCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RequestCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RuleName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SampledCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Timestamp")
      )

instance Prelude.Hashable SamplingStatisticSummary where
  hashWithSalt :: Int -> SamplingStatisticSummary -> Int
hashWithSalt Int
_salt SamplingStatisticSummary' {Maybe Int
Maybe Text
Maybe POSIX
timestamp :: Maybe POSIX
sampledCount :: Maybe Int
ruleName :: Maybe Text
requestCount :: Maybe Int
borrowCount :: Maybe Int
$sel:timestamp:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe POSIX
$sel:sampledCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
$sel:ruleName:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Text
$sel:requestCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
$sel:borrowCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
borrowCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
requestCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ruleName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
sampledCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
timestamp

instance Prelude.NFData SamplingStatisticSummary where
  rnf :: SamplingStatisticSummary -> ()
rnf SamplingStatisticSummary' {Maybe Int
Maybe Text
Maybe POSIX
timestamp :: Maybe POSIX
sampledCount :: Maybe Int
ruleName :: Maybe Text
requestCount :: Maybe Int
borrowCount :: Maybe Int
$sel:timestamp:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe POSIX
$sel:sampledCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
$sel:ruleName:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Text
$sel:requestCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
$sel:borrowCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
borrowCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
requestCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ruleName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
sampledCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
timestamp