module OpenTelemetry.Resource.Host (
Host (..),
) where
import Data.Text (Text)
import OpenTelemetry.Attributes.Key (unkey)
import OpenTelemetry.Resource (ToResource (..), mkResourceWithSchema, semConvSchemaUrl, (.=?))
import qualified OpenTelemetry.SemanticConventions as SC
data Host = Host
{ Host -> Maybe Text
hostId :: Maybe Text
, Host -> Maybe Text
hostName :: Maybe Text
, Host -> Maybe Text
hostType :: Maybe Text
, Host -> Maybe Text
hostArch :: Maybe Text
, Host -> Maybe Text
hostImageName :: Maybe Text
, Host -> Maybe Text
hostImageId :: Maybe Text
, Host -> Maybe Text
hostImageVersion :: Maybe Text
, Host -> Maybe [Text]
hostIp :: Maybe [Text]
, Host -> Maybe [Text]
hostMac :: Maybe [Text]
}
instance ToResource Host where
toResource :: Host -> Resource
toResource Host {Maybe [Text]
Maybe Text
hostId :: Host -> Maybe Text
hostName :: Host -> Maybe Text
hostType :: Host -> Maybe Text
hostArch :: Host -> Maybe Text
hostImageName :: Host -> Maybe Text
hostImageId :: Host -> Maybe Text
hostImageVersion :: Host -> Maybe Text
hostIp :: Host -> Maybe [Text]
hostMac :: Host -> Maybe [Text]
hostId :: Maybe Text
hostName :: Maybe Text
hostType :: Maybe Text
hostArch :: Maybe Text
hostImageName :: Maybe Text
hostImageId :: Maybe Text
hostImageVersion :: Maybe Text
hostIp :: Maybe [Text]
hostMac :: 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.host_id Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
hostId
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.host_name Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
hostName
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.host_type Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
hostType
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.host_arch Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
hostArch
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.host_image_name Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
hostImageName
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.host_image_id Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
hostImageId
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.host_image_version Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
hostImageVersion
, AttributeKey [Text] -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey [Text]
SC.host_ip Text -> Maybe [Text] -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe [Text]
hostIp
, AttributeKey [Text] -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey [Text]
SC.host_mac Text -> Maybe [Text] -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe [Text]
hostMac
]