{-# 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.ServiceStatistics
-- 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.ServiceStatistics 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
import Amazonka.XRay.Types.ErrorStatistics
import Amazonka.XRay.Types.FaultStatistics

-- | Response statistics for a service.
--
-- /See:/ 'newServiceStatistics' smart constructor.
data ServiceStatistics = ServiceStatistics'
  { -- | Information about requests that failed with a 4xx Client Error status
    -- code.
    ServiceStatistics -> Maybe ErrorStatistics
errorStatistics :: Prelude.Maybe ErrorStatistics,
    -- | Information about requests that failed with a 5xx Server Error status
    -- code.
    ServiceStatistics -> Maybe FaultStatistics
faultStatistics :: Prelude.Maybe FaultStatistics,
    -- | The number of requests that completed with a 2xx Success status code.
    ServiceStatistics -> Maybe Integer
okCount :: Prelude.Maybe Prelude.Integer,
    -- | The total number of completed requests.
    ServiceStatistics -> Maybe Integer
totalCount :: Prelude.Maybe Prelude.Integer,
    -- | The aggregate response time of completed requests.
    ServiceStatistics -> Maybe Double
totalResponseTime :: Prelude.Maybe Prelude.Double
  }
  deriving (ServiceStatistics -> ServiceStatistics -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceStatistics -> ServiceStatistics -> Bool
$c/= :: ServiceStatistics -> ServiceStatistics -> Bool
== :: ServiceStatistics -> ServiceStatistics -> Bool
$c== :: ServiceStatistics -> ServiceStatistics -> Bool
Prelude.Eq, ReadPrec [ServiceStatistics]
ReadPrec ServiceStatistics
Int -> ReadS ServiceStatistics
ReadS [ServiceStatistics]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceStatistics]
$creadListPrec :: ReadPrec [ServiceStatistics]
readPrec :: ReadPrec ServiceStatistics
$creadPrec :: ReadPrec ServiceStatistics
readList :: ReadS [ServiceStatistics]
$creadList :: ReadS [ServiceStatistics]
readsPrec :: Int -> ReadS ServiceStatistics
$creadsPrec :: Int -> ReadS ServiceStatistics
Prelude.Read, Int -> ServiceStatistics -> ShowS
[ServiceStatistics] -> ShowS
ServiceStatistics -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceStatistics] -> ShowS
$cshowList :: [ServiceStatistics] -> ShowS
show :: ServiceStatistics -> String
$cshow :: ServiceStatistics -> String
showsPrec :: Int -> ServiceStatistics -> ShowS
$cshowsPrec :: Int -> ServiceStatistics -> ShowS
Prelude.Show, forall x. Rep ServiceStatistics x -> ServiceStatistics
forall x. ServiceStatistics -> Rep ServiceStatistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServiceStatistics x -> ServiceStatistics
$cfrom :: forall x. ServiceStatistics -> Rep ServiceStatistics x
Prelude.Generic)

-- |
-- Create a value of 'ServiceStatistics' 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:
--
-- 'errorStatistics', 'serviceStatistics_errorStatistics' - Information about requests that failed with a 4xx Client Error status
-- code.
--
-- 'faultStatistics', 'serviceStatistics_faultStatistics' - Information about requests that failed with a 5xx Server Error status
-- code.
--
-- 'okCount', 'serviceStatistics_okCount' - The number of requests that completed with a 2xx Success status code.
--
-- 'totalCount', 'serviceStatistics_totalCount' - The total number of completed requests.
--
-- 'totalResponseTime', 'serviceStatistics_totalResponseTime' - The aggregate response time of completed requests.
newServiceStatistics ::
  ServiceStatistics
newServiceStatistics :: ServiceStatistics
newServiceStatistics =
  ServiceStatistics'
    { $sel:errorStatistics:ServiceStatistics' :: Maybe ErrorStatistics
errorStatistics =
        forall a. Maybe a
Prelude.Nothing,
      $sel:faultStatistics:ServiceStatistics' :: Maybe FaultStatistics
faultStatistics = forall a. Maybe a
Prelude.Nothing,
      $sel:okCount:ServiceStatistics' :: Maybe Integer
okCount = forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:ServiceStatistics' :: Maybe Integer
totalCount = forall a. Maybe a
Prelude.Nothing,
      $sel:totalResponseTime:ServiceStatistics' :: Maybe Double
totalResponseTime = forall a. Maybe a
Prelude.Nothing
    }

-- | Information about requests that failed with a 4xx Client Error status
-- code.
serviceStatistics_errorStatistics :: Lens.Lens' ServiceStatistics (Prelude.Maybe ErrorStatistics)
serviceStatistics_errorStatistics :: Lens' ServiceStatistics (Maybe ErrorStatistics)
serviceStatistics_errorStatistics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceStatistics' {Maybe ErrorStatistics
errorStatistics :: Maybe ErrorStatistics
$sel:errorStatistics:ServiceStatistics' :: ServiceStatistics -> Maybe ErrorStatistics
errorStatistics} -> Maybe ErrorStatistics
errorStatistics) (\s :: ServiceStatistics
s@ServiceStatistics' {} Maybe ErrorStatistics
a -> ServiceStatistics
s {$sel:errorStatistics:ServiceStatistics' :: Maybe ErrorStatistics
errorStatistics = Maybe ErrorStatistics
a} :: ServiceStatistics)

-- | Information about requests that failed with a 5xx Server Error status
-- code.
serviceStatistics_faultStatistics :: Lens.Lens' ServiceStatistics (Prelude.Maybe FaultStatistics)
serviceStatistics_faultStatistics :: Lens' ServiceStatistics (Maybe FaultStatistics)
serviceStatistics_faultStatistics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceStatistics' {Maybe FaultStatistics
faultStatistics :: Maybe FaultStatistics
$sel:faultStatistics:ServiceStatistics' :: ServiceStatistics -> Maybe FaultStatistics
faultStatistics} -> Maybe FaultStatistics
faultStatistics) (\s :: ServiceStatistics
s@ServiceStatistics' {} Maybe FaultStatistics
a -> ServiceStatistics
s {$sel:faultStatistics:ServiceStatistics' :: Maybe FaultStatistics
faultStatistics = Maybe FaultStatistics
a} :: ServiceStatistics)

-- | The number of requests that completed with a 2xx Success status code.
serviceStatistics_okCount :: Lens.Lens' ServiceStatistics (Prelude.Maybe Prelude.Integer)
serviceStatistics_okCount :: Lens' ServiceStatistics (Maybe Integer)
serviceStatistics_okCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceStatistics' {Maybe Integer
okCount :: Maybe Integer
$sel:okCount:ServiceStatistics' :: ServiceStatistics -> Maybe Integer
okCount} -> Maybe Integer
okCount) (\s :: ServiceStatistics
s@ServiceStatistics' {} Maybe Integer
a -> ServiceStatistics
s {$sel:okCount:ServiceStatistics' :: Maybe Integer
okCount = Maybe Integer
a} :: ServiceStatistics)

-- | The total number of completed requests.
serviceStatistics_totalCount :: Lens.Lens' ServiceStatistics (Prelude.Maybe Prelude.Integer)
serviceStatistics_totalCount :: Lens' ServiceStatistics (Maybe Integer)
serviceStatistics_totalCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceStatistics' {Maybe Integer
totalCount :: Maybe Integer
$sel:totalCount:ServiceStatistics' :: ServiceStatistics -> Maybe Integer
totalCount} -> Maybe Integer
totalCount) (\s :: ServiceStatistics
s@ServiceStatistics' {} Maybe Integer
a -> ServiceStatistics
s {$sel:totalCount:ServiceStatistics' :: Maybe Integer
totalCount = Maybe Integer
a} :: ServiceStatistics)

-- | The aggregate response time of completed requests.
serviceStatistics_totalResponseTime :: Lens.Lens' ServiceStatistics (Prelude.Maybe Prelude.Double)
serviceStatistics_totalResponseTime :: Lens' ServiceStatistics (Maybe Double)
serviceStatistics_totalResponseTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceStatistics' {Maybe Double
totalResponseTime :: Maybe Double
$sel:totalResponseTime:ServiceStatistics' :: ServiceStatistics -> Maybe Double
totalResponseTime} -> Maybe Double
totalResponseTime) (\s :: ServiceStatistics
s@ServiceStatistics' {} Maybe Double
a -> ServiceStatistics
s {$sel:totalResponseTime:ServiceStatistics' :: Maybe Double
totalResponseTime = Maybe Double
a} :: ServiceStatistics)

instance Data.FromJSON ServiceStatistics where
  parseJSON :: Value -> Parser ServiceStatistics
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ServiceStatistics"
      ( \Object
x ->
          Maybe ErrorStatistics
-> Maybe FaultStatistics
-> Maybe Integer
-> Maybe Integer
-> Maybe Double
-> ServiceStatistics
ServiceStatistics'
            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
"ErrorStatistics")
            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
"FaultStatistics")
            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
"OkCount")
            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
"TotalCount")
            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
"TotalResponseTime")
      )

instance Prelude.Hashable ServiceStatistics where
  hashWithSalt :: Int -> ServiceStatistics -> Int
hashWithSalt Int
_salt ServiceStatistics' {Maybe Double
Maybe Integer
Maybe ErrorStatistics
Maybe FaultStatistics
totalResponseTime :: Maybe Double
totalCount :: Maybe Integer
okCount :: Maybe Integer
faultStatistics :: Maybe FaultStatistics
errorStatistics :: Maybe ErrorStatistics
$sel:totalResponseTime:ServiceStatistics' :: ServiceStatistics -> Maybe Double
$sel:totalCount:ServiceStatistics' :: ServiceStatistics -> Maybe Integer
$sel:okCount:ServiceStatistics' :: ServiceStatistics -> Maybe Integer
$sel:faultStatistics:ServiceStatistics' :: ServiceStatistics -> Maybe FaultStatistics
$sel:errorStatistics:ServiceStatistics' :: ServiceStatistics -> Maybe ErrorStatistics
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ErrorStatistics
errorStatistics
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FaultStatistics
faultStatistics
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
okCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
totalCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
totalResponseTime

instance Prelude.NFData ServiceStatistics where
  rnf :: ServiceStatistics -> ()
rnf ServiceStatistics' {Maybe Double
Maybe Integer
Maybe ErrorStatistics
Maybe FaultStatistics
totalResponseTime :: Maybe Double
totalCount :: Maybe Integer
okCount :: Maybe Integer
faultStatistics :: Maybe FaultStatistics
errorStatistics :: Maybe ErrorStatistics
$sel:totalResponseTime:ServiceStatistics' :: ServiceStatistics -> Maybe Double
$sel:totalCount:ServiceStatistics' :: ServiceStatistics -> Maybe Integer
$sel:okCount:ServiceStatistics' :: ServiceStatistics -> Maybe Integer
$sel:faultStatistics:ServiceStatistics' :: ServiceStatistics -> Maybe FaultStatistics
$sel:errorStatistics:ServiceStatistics' :: ServiceStatistics -> Maybe ErrorStatistics
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ErrorStatistics
errorStatistics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FaultStatistics
faultStatistics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
okCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
totalCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
totalResponseTime