{- |
 Module      :  OpenTelemetry.Resource.Webengine
 Copyright   :  (c) Ian Duncan, 2021-2026
 License     :  BSD-3
 Description :  Resource describing the web engine running the application
 Maintainer  :  Ian Duncan
 Stability   :  experimental
 Portability :  non-portable (GHC extensions)

 Resource describing the packaged software running the application code.
 Web engines are typically executed using @process.runtime@.
-}
module OpenTelemetry.Resource.Webengine where

import Data.Text (Text)
import OpenTelemetry.Attributes.Key (unkey)
import OpenTelemetry.Resource
import qualified OpenTelemetry.SemanticConventions as SC


{- | A web engine instance.

@since 1.0.0.0
-}
data Webengine = Webengine
  { Webengine -> Text
webengineName :: Text
  -- ^ The name of the web engine. Required.
  , Webengine -> Maybe Text
webengineVersion :: Maybe Text
  -- ^ The version of the web engine.
  , Webengine -> Maybe Text
webengineDescription :: Maybe Text
  -- ^ Additional description of the web engine.
  }


instance ToResource Webengine where
  toResource :: Webengine -> Resource
toResource Webengine {Maybe Text
Text
webengineName :: Webengine -> Text
webengineVersion :: Webengine -> Maybe Text
webengineDescription :: Webengine -> Maybe Text
webengineName :: Text
webengineVersion :: Maybe Text
webengineDescription :: Maybe Text
..} =
    Maybe Text -> [Maybe (Text, Attribute)] -> Resource
mkResourceWithSchema
      (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
semConvSchemaUrl)
      [ AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.webengine_name Text -> Text -> Maybe (Text, Attribute)
forall a. ToAttribute a => Text -> a -> Maybe (Text, Attribute)
.= Text
webengineName
      , AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.webengine_version Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
webengineVersion
      , AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.webengine_description Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
webengineDescription
      ]