{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}

-----------------------------------------------------------------------------

-----------------------------------------------------------------------------

{- |
 Module      :  OpenTelemetry.Resource.DeploymentEnvironment
 Copyright   :  (c) Ian Duncan, 2021
 License     :  BSD-3
 Description :  Name of the deployment environment (aka deployment tier)
 Maintainer  :  Ian Duncan
 Stability   :  experimental
 Portability :  non-portable (GHC extensions)
-}
module OpenTelemetry.Resource.DeploymentEnvironment where

import Data.Text (Text)
import OpenTelemetry.Resource


{- | The software deployment.

 This resource doesn't have a an automatic detector because
 deployment environments tend to have very different detection
 mechanisms for differing projects.
-}
newtype DeploymentEnvironment = DeploymentEnvironment
  { DeploymentEnvironment -> Maybe Text
deploymentEnvironment :: Maybe Text
  -- ^ Name of the deployment environment (aka deployment tier).
  --
  -- Examples: @staging@, @production@
  }


instance ToResource DeploymentEnvironment where
  type ResourceSchema DeploymentEnvironment = 'Nothing
  toResource :: DeploymentEnvironment
-> Resource (ResourceSchema DeploymentEnvironment)
toResource DeploymentEnvironment {Maybe Text
deploymentEnvironment :: DeploymentEnvironment -> Maybe Text
deploymentEnvironment :: Maybe Text
..} =
    [Maybe (Text, Attribute)] -> Resource 'Nothing
forall (r :: Maybe Symbol). [Maybe (Text, Attribute)] -> Resource r
mkResource
      [ Text
"deployment.environment" Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
deploymentEnvironment
      ]