module OpenTelemetry.Resource.Container where
import Data.Text (Text)
import OpenTelemetry.Attributes.Key (unkey)
import OpenTelemetry.Resource
import qualified OpenTelemetry.SemanticConventions as SC
data Container = Container
{ Container -> Maybe Text
containerName :: Maybe Text
, Container -> Maybe Text
containerId :: Maybe Text
, Container -> Maybe Text
containerRuntime :: Maybe Text
, Container -> Maybe Text
containerImageName :: Maybe Text
, Container -> Maybe Text
containerImageTag :: Maybe Text
, Container -> Maybe Text
containerImageId :: Maybe Text
, Container -> Maybe Text
ociManifestDigest :: Maybe Text
, Container -> Maybe [Text]
containerImageRepoDigests :: Maybe [Text]
}
instance ToResource Container where
toResource :: Container -> Resource
toResource Container {Maybe [Text]
Maybe Text
containerName :: Container -> Maybe Text
containerId :: Container -> Maybe Text
containerRuntime :: Container -> Maybe Text
containerImageName :: Container -> Maybe Text
containerImageTag :: Container -> Maybe Text
containerImageId :: Container -> Maybe Text
ociManifestDigest :: Container -> Maybe Text
containerImageRepoDigests :: Container -> Maybe [Text]
containerName :: Maybe Text
containerId :: Maybe Text
containerRuntime :: Maybe Text
containerImageName :: Maybe Text
containerImageTag :: Maybe Text
containerImageId :: Maybe Text
ociManifestDigest :: Maybe Text
containerImageRepoDigests :: 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.container_name Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
containerName
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.container_id Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
containerId
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.container_runtime_name Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
containerRuntime
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.container_runtime Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
containerRuntime
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.container_image_name Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
containerImageName
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.container_image_id Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
containerImageId
, AttributeKey [Text] -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey [Text]
SC.container_image_tags Text -> Maybe [Text] -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? ((Text -> [Text] -> [Text]
forall a. a -> [a] -> [a]
: []) (Text -> [Text]) -> Maybe Text -> Maybe [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
containerImageTag)
, AttributeKey Text -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey Text
SC.oci_manifest_digest Text -> Maybe Text -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe Text
ociManifestDigest
, AttributeKey [Text] -> Text
forall a. AttributeKey a -> Text
unkey AttributeKey [Text]
SC.container_image_repoDigests Text -> Maybe [Text] -> Maybe (Text, Attribute)
forall a.
ToAttribute a =>
Text -> Maybe a -> Maybe (Text, Attribute)
.=? Maybe [Text]
containerImageRepoDigests
]