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

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

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

{- |
 Module      :  OpenTelemetry.Resource.Telemetry
 Copyright   :  (c) Ian Duncan, 2021
 License     :  BSD-3
 Description :  Information about the telemetry SDK used to capture data recorded
 by the instrumentation libraries.
 Maintainer  :  Ian Duncan
 Stability   :  experimental
 Portability :  non-portable (GHC extensions)
-}
module OpenTelemetry.Resource.Telemetry where

import Data.Text (Text)
import OpenTelemetry.Resource


-- - id: cpp
--   value: "cpp"
-- - id: dotnet
--   value: "dotnet"
-- - id: erlang
--   value: "erlang"
-- - id: go
--   value: "go"
-- - id: java
--   value: "java"
-- - id: nodejs
--   value: "nodejs"
-- - id: php
--   value: "php"
-- - id: python
--   value: "python"
-- - id: ruby
--   value: "ruby"
-- - id: webjs
--   value: "webjs"
-- other allowed

-- | The telemetry SDK used to capture data recorded by the instrumentation libraries.
data Telemetry = Telemetry
  { Telemetry -> Text
telemetrySdkName :: Text
  -- ^ The name of the telemetry SDK as defined above.
  , Telemetry -> Maybe Text
telemetrySdkLanguage :: Maybe Text
  -- ^ The name of the telemetry SDK as defined above.
  , Telemetry -> Maybe Text
telemetrySdkVersion :: Maybe Text
  -- ^ The version string of the telemetry SDK.
  , Telemetry -> Maybe Text
telemetryAutoVersion :: Maybe Text
  --- ^ The version string of the auto instrumentation agent, if used.
  }


instance ToResource Telemetry where
  type ResourceSchema Telemetry = 'Nothing
  toResource :: Telemetry -> Resource (ResourceSchema Telemetry)
toResource Telemetry {Maybe Text
Text
telemetrySdkName :: Telemetry -> Text
telemetrySdkLanguage :: Telemetry -> Maybe Text
telemetrySdkVersion :: Telemetry -> Maybe Text
telemetryAutoVersion :: Telemetry -> Maybe Text
telemetrySdkName :: Text
telemetrySdkLanguage :: Maybe Text
telemetrySdkVersion :: Maybe Text
telemetryAutoVersion :: Maybe Text
..} =
    [Maybe (Text, Attribute)] -> Resource 'Nothing
forall (r :: Maybe Symbol). [Maybe (Text, Attribute)] -> Resource r
mkResource
      [ Text
"telemetry.sdk.name" Text -> Text -> Maybe (Text, Attribute)
forall a. ToAttribute a => Text -> a -> Maybe (Text, Attribute)
.= Text
telemetrySdkName
      , Text
"telemetry.sdk.language" Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
telemetrySdkLanguage
      , Text
"telemetry.sdk.version" Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
telemetrySdkVersion
      , Text
"telemetry.auto.version" Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
telemetryAutoVersion
      ]