{-# 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.ElasticBeanstalk.Types.Latency
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ElasticBeanstalk.Types.Latency where

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

-- | Represents the average latency for the slowest X percent of requests
-- over the last 10 seconds.
--
-- /See:/ 'newLatency' smart constructor.
data Latency = Latency'
  { -- | The average latency for the slowest 25 percent of requests over the last
    -- 10 seconds.
    Latency -> Maybe Double
p75 :: Prelude.Maybe Prelude.Double,
    -- | The average latency for the slowest 50 percent of requests over the last
    -- 10 seconds.
    Latency -> Maybe Double
p50 :: Prelude.Maybe Prelude.Double,
    -- | The average latency for the slowest 15 percent of requests over the last
    -- 10 seconds.
    Latency -> Maybe Double
p85 :: Prelude.Maybe Prelude.Double,
    -- | The average latency for the slowest 0.1 percent of requests over the
    -- last 10 seconds.
    Latency -> Maybe Double
p999 :: Prelude.Maybe Prelude.Double,
    -- | The average latency for the slowest 10 percent of requests over the last
    -- 10 seconds.
    Latency -> Maybe Double
p90 :: Prelude.Maybe Prelude.Double,
    -- | The average latency for the slowest 5 percent of requests over the last
    -- 10 seconds.
    Latency -> Maybe Double
p95 :: Prelude.Maybe Prelude.Double,
    -- | The average latency for the slowest 1 percent of requests over the last
    -- 10 seconds.
    Latency -> Maybe Double
p99 :: Prelude.Maybe Prelude.Double,
    -- | The average latency for the slowest 90 percent of requests over the last
    -- 10 seconds.
    Latency -> Maybe Double
p10 :: Prelude.Maybe Prelude.Double
  }
  deriving (Latency -> Latency -> Bool
(Latency -> Latency -> Bool)
-> (Latency -> Latency -> Bool) -> Eq Latency
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Latency -> Latency -> Bool
$c/= :: Latency -> Latency -> Bool
== :: Latency -> Latency -> Bool
$c== :: Latency -> Latency -> Bool
Prelude.Eq, ReadPrec [Latency]
ReadPrec Latency
Int -> ReadS Latency
ReadS [Latency]
(Int -> ReadS Latency)
-> ReadS [Latency]
-> ReadPrec Latency
-> ReadPrec [Latency]
-> Read Latency
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Latency]
$creadListPrec :: ReadPrec [Latency]
readPrec :: ReadPrec Latency
$creadPrec :: ReadPrec Latency
readList :: ReadS [Latency]
$creadList :: ReadS [Latency]
readsPrec :: Int -> ReadS Latency
$creadsPrec :: Int -> ReadS Latency
Prelude.Read, Int -> Latency -> ShowS
[Latency] -> ShowS
Latency -> String
(Int -> Latency -> ShowS)
-> (Latency -> String) -> ([Latency] -> ShowS) -> Show Latency
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Latency] -> ShowS
$cshowList :: [Latency] -> ShowS
show :: Latency -> String
$cshow :: Latency -> String
showsPrec :: Int -> Latency -> ShowS
$cshowsPrec :: Int -> Latency -> ShowS
Prelude.Show, (forall x. Latency -> Rep Latency x)
-> (forall x. Rep Latency x -> Latency) -> Generic Latency
forall x. Rep Latency x -> Latency
forall x. Latency -> Rep Latency x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Latency x -> Latency
$cfrom :: forall x. Latency -> Rep Latency x
Prelude.Generic)

-- |
-- Create a value of 'Latency' 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:
--
-- 'p75', 'latency_p75' - The average latency for the slowest 25 percent of requests over the last
-- 10 seconds.
--
-- 'p50', 'latency_p50' - The average latency for the slowest 50 percent of requests over the last
-- 10 seconds.
--
-- 'p85', 'latency_p85' - The average latency for the slowest 15 percent of requests over the last
-- 10 seconds.
--
-- 'p999', 'latency_p999' - The average latency for the slowest 0.1 percent of requests over the
-- last 10 seconds.
--
-- 'p90', 'latency_p90' - The average latency for the slowest 10 percent of requests over the last
-- 10 seconds.
--
-- 'p95', 'latency_p95' - The average latency for the slowest 5 percent of requests over the last
-- 10 seconds.
--
-- 'p99', 'latency_p99' - The average latency for the slowest 1 percent of requests over the last
-- 10 seconds.
--
-- 'p10', 'latency_p10' - The average latency for the slowest 90 percent of requests over the last
-- 10 seconds.
newLatency ::
  Latency
newLatency :: Latency
newLatency =
  Latency' :: Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Latency
Latency'
    { $sel:p75:Latency' :: Maybe Double
p75 = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:p50:Latency' :: Maybe Double
p50 = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:p85:Latency' :: Maybe Double
p85 = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:p999:Latency' :: Maybe Double
p999 = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:p90:Latency' :: Maybe Double
p90 = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:p95:Latency' :: Maybe Double
p95 = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:p99:Latency' :: Maybe Double
p99 = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:p10:Latency' :: Maybe Double
p10 = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The average latency for the slowest 25 percent of requests over the last
-- 10 seconds.
latency_p75 :: Lens.Lens' Latency (Prelude.Maybe Prelude.Double)
latency_p75 :: (Maybe Double -> f (Maybe Double)) -> Latency -> f Latency
latency_p75 = (Latency -> Maybe Double)
-> (Latency -> Maybe Double -> Latency)
-> Lens Latency Latency (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Latency' {Maybe Double
p75 :: Maybe Double
$sel:p75:Latency' :: Latency -> Maybe Double
p75} -> Maybe Double
p75) (\s :: Latency
s@Latency' {} Maybe Double
a -> Latency
s {$sel:p75:Latency' :: Maybe Double
p75 = Maybe Double
a} :: Latency)

-- | The average latency for the slowest 50 percent of requests over the last
-- 10 seconds.
latency_p50 :: Lens.Lens' Latency (Prelude.Maybe Prelude.Double)
latency_p50 :: (Maybe Double -> f (Maybe Double)) -> Latency -> f Latency
latency_p50 = (Latency -> Maybe Double)
-> (Latency -> Maybe Double -> Latency)
-> Lens Latency Latency (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Latency' {Maybe Double
p50 :: Maybe Double
$sel:p50:Latency' :: Latency -> Maybe Double
p50} -> Maybe Double
p50) (\s :: Latency
s@Latency' {} Maybe Double
a -> Latency
s {$sel:p50:Latency' :: Maybe Double
p50 = Maybe Double
a} :: Latency)

-- | The average latency for the slowest 15 percent of requests over the last
-- 10 seconds.
latency_p85 :: Lens.Lens' Latency (Prelude.Maybe Prelude.Double)
latency_p85 :: (Maybe Double -> f (Maybe Double)) -> Latency -> f Latency
latency_p85 = (Latency -> Maybe Double)
-> (Latency -> Maybe Double -> Latency)
-> Lens Latency Latency (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Latency' {Maybe Double
p85 :: Maybe Double
$sel:p85:Latency' :: Latency -> Maybe Double
p85} -> Maybe Double
p85) (\s :: Latency
s@Latency' {} Maybe Double
a -> Latency
s {$sel:p85:Latency' :: Maybe Double
p85 = Maybe Double
a} :: Latency)

-- | The average latency for the slowest 0.1 percent of requests over the
-- last 10 seconds.
latency_p999 :: Lens.Lens' Latency (Prelude.Maybe Prelude.Double)
latency_p999 :: (Maybe Double -> f (Maybe Double)) -> Latency -> f Latency
latency_p999 = (Latency -> Maybe Double)
-> (Latency -> Maybe Double -> Latency)
-> Lens Latency Latency (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Latency' {Maybe Double
p999 :: Maybe Double
$sel:p999:Latency' :: Latency -> Maybe Double
p999} -> Maybe Double
p999) (\s :: Latency
s@Latency' {} Maybe Double
a -> Latency
s {$sel:p999:Latency' :: Maybe Double
p999 = Maybe Double
a} :: Latency)

-- | The average latency for the slowest 10 percent of requests over the last
-- 10 seconds.
latency_p90 :: Lens.Lens' Latency (Prelude.Maybe Prelude.Double)
latency_p90 :: (Maybe Double -> f (Maybe Double)) -> Latency -> f Latency
latency_p90 = (Latency -> Maybe Double)
-> (Latency -> Maybe Double -> Latency)
-> Lens Latency Latency (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Latency' {Maybe Double
p90 :: Maybe Double
$sel:p90:Latency' :: Latency -> Maybe Double
p90} -> Maybe Double
p90) (\s :: Latency
s@Latency' {} Maybe Double
a -> Latency
s {$sel:p90:Latency' :: Maybe Double
p90 = Maybe Double
a} :: Latency)

-- | The average latency for the slowest 5 percent of requests over the last
-- 10 seconds.
latency_p95 :: Lens.Lens' Latency (Prelude.Maybe Prelude.Double)
latency_p95 :: (Maybe Double -> f (Maybe Double)) -> Latency -> f Latency
latency_p95 = (Latency -> Maybe Double)
-> (Latency -> Maybe Double -> Latency)
-> Lens Latency Latency (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Latency' {Maybe Double
p95 :: Maybe Double
$sel:p95:Latency' :: Latency -> Maybe Double
p95} -> Maybe Double
p95) (\s :: Latency
s@Latency' {} Maybe Double
a -> Latency
s {$sel:p95:Latency' :: Maybe Double
p95 = Maybe Double
a} :: Latency)

-- | The average latency for the slowest 1 percent of requests over the last
-- 10 seconds.
latency_p99 :: Lens.Lens' Latency (Prelude.Maybe Prelude.Double)
latency_p99 :: (Maybe Double -> f (Maybe Double)) -> Latency -> f Latency
latency_p99 = (Latency -> Maybe Double)
-> (Latency -> Maybe Double -> Latency)
-> Lens Latency Latency (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Latency' {Maybe Double
p99 :: Maybe Double
$sel:p99:Latency' :: Latency -> Maybe Double
p99} -> Maybe Double
p99) (\s :: Latency
s@Latency' {} Maybe Double
a -> Latency
s {$sel:p99:Latency' :: Maybe Double
p99 = Maybe Double
a} :: Latency)

-- | The average latency for the slowest 90 percent of requests over the last
-- 10 seconds.
latency_p10 :: Lens.Lens' Latency (Prelude.Maybe Prelude.Double)
latency_p10 :: (Maybe Double -> f (Maybe Double)) -> Latency -> f Latency
latency_p10 = (Latency -> Maybe Double)
-> (Latency -> Maybe Double -> Latency)
-> Lens Latency Latency (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Latency' {Maybe Double
p10 :: Maybe Double
$sel:p10:Latency' :: Latency -> Maybe Double
p10} -> Maybe Double
p10) (\s :: Latency
s@Latency' {} Maybe Double
a -> Latency
s {$sel:p10:Latency' :: Maybe Double
p10 = Maybe Double
a} :: Latency)

instance Core.FromXML Latency where
  parseXML :: [Node] -> Either String Latency
parseXML [Node]
x =
    Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Latency
Latency'
      (Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Latency)
-> Either String (Maybe Double)
-> Either
     String
     (Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Latency)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"P75")
      Either
  String
  (Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Latency)
-> Either String (Maybe Double)
-> Either
     String
     (Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Latency)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"P50")
      Either
  String
  (Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Latency)
-> Either String (Maybe Double)
-> Either
     String
     (Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Latency)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"P85")
      Either
  String
  (Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Latency)
-> Either String (Maybe Double)
-> Either
     String
     (Maybe Double
      -> Maybe Double -> Maybe Double -> Maybe Double -> Latency)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"P999")
      Either
  String
  (Maybe Double
   -> Maybe Double -> Maybe Double -> Maybe Double -> Latency)
-> Either String (Maybe Double)
-> Either
     String (Maybe Double -> Maybe Double -> Maybe Double -> Latency)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"P90")
      Either
  String (Maybe Double -> Maybe Double -> Maybe Double -> Latency)
-> Either String (Maybe Double)
-> Either String (Maybe Double -> Maybe Double -> Latency)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"P95")
      Either String (Maybe Double -> Maybe Double -> Latency)
-> Either String (Maybe Double)
-> Either String (Maybe Double -> Latency)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"P99")
      Either String (Maybe Double -> Latency)
-> Either String (Maybe Double) -> Either String Latency
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"P10")

instance Prelude.Hashable Latency

instance Prelude.NFData Latency