Skip to content

Commit

Permalink
Pull container_image_metadata entity from attribute oci.manifest.dige…
Browse files Browse the repository at this point in the history
…st (DataDog#31307)

Co-authored-by: jackgopack4 <[email protected]>
  • Loading branch information
mackjmr and jackgopack4 authored Nov 27, 2024
1 parent 199e77a commit a159d21
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2491,6 +2491,7 @@ core,go.opentelemetry.io/collector/semconv/v1.16.0,Apache-2.0,Copyright The Open
core,go.opentelemetry.io/collector/semconv/v1.17.0,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/semconv/v1.18.0,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/semconv/v1.21.0,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/semconv/v1.22.0,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/semconv/v1.25.0,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/semconv/v1.26.0,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/semconv/v1.27.0,Apache-2.0,Copyright The OpenTelemetry Authors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ package infraattributesprocessor

import (
"fmt"
"go.uber.org/zap"
"strings"

"go.uber.org/zap"

"go.opentelemetry.io/collector/pdata/pcommon"
conventions "go.opentelemetry.io/collector/semconv/v1.21.0"
conventions22 "go.opentelemetry.io/collector/semconv/v1.22.0"

"github.com/DataDog/datadog-agent/comp/core/tagger/tags"
"github.com/DataDog/datadog-agent/comp/core/tagger/types"
Expand Down Expand Up @@ -95,8 +97,8 @@ func entityIDsFromAttributes(attrs pcommon.Map, generateID GenerateKubeMetadataE
if containerID, ok := attrs.Get(conventions.AttributeContainerID); ok {
entityIDs = append(entityIDs, types.NewEntityID(types.ContainerID, containerID.AsString()))
}
if containerImageID, ok := attrs.Get(conventions.AttributeContainerImageID); ok {
splitImageID := strings.SplitN(containerImageID.AsString(), "@sha256:", 2)
if ociManifestDigest, ok := attrs.Get(conventions22.AttributeOciManifestDigest); ok {
splitImageID := strings.SplitN(ociManifestDigest.AsString(), "@sha256:", 2)
if len(splitImageID) == 2 {
entityIDs = append(entityIDs, types.NewEntityID(types.ContainerImageMetadata, fmt.Sprintf("sha256:%v", splitImageID[1])))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/processor/processortest"
conventions "go.opentelemetry.io/collector/semconv/v1.21.0"
conventions22 "go.opentelemetry.io/collector/semconv/v1.22.0"

"github.com/DataDog/datadog-agent/comp/core/tagger/types"
)
Expand Down Expand Up @@ -185,11 +186,11 @@ func TestEntityIDsFromAttributes(t *testing.T) {
entityIDs: []string{"container_id://container_id_goes_here", "kubernetes_pod_uid://k8s_pod_uid_goes_here"},
},
{
name: "container image ID",
name: "image digest",
attrs: func() pcommon.Map {
attributes := pcommon.NewMap()
attributes.FromRaw(map[string]interface{}{
conventions.AttributeContainerImageID: "docker.io/foo@sha256:sha_goes_here",
conventions22.AttributeOciManifestDigest: "docker.io/foo@sha256:sha_goes_here",
})
return attributes
}(),
Expand Down

0 comments on commit a159d21

Please sign in to comment.