Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ func ec2Hostname(m pcommon.Map) (string, bool, error) {
return strField(m, string(conventions.HostNameKey))
}

// getCCRID gets Canonical Cloud Resource ID from a resource attribute map.
// It returns:
// - The CCRID if available
// - Whether CCRID was found
// - Any errors found retrieving the ID
func getCCRID(m pcommon.Map) (string, bool, error) {
return strField(m, "datadog.ccrid")
}

// Set a hardcoded host metadata payload.
func (m *HostMap) Set(md payload.HostMetadata) error {
m.mu.Lock()
Expand Down Expand Up @@ -249,6 +258,16 @@ func (m *HostMap) Update(host string, res pcommon.Resource) (changed bool, md pa
md.Meta.EC2Hostname = ec2Host
}

//Get CCRID (Canonical Cloud Resource ID: AWS=ARN, Azure=Resource ID, GCP=CAI, OCI=OCID)
if ccrid, ok, err2 := getCCRID(res.Attributes()); err2 != nil {
err = errors.Join(err, err2)
} else if ok {
if ccrid != md.Meta.CanonicalCloudResourceID {
md.Meta.CanonicalCloudResourceID = ccrid
changed = true
}
}

// Gohai - Platform
md.Platform()["hostname"] = host
for field, attribute := range platformAttributesMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ type Meta struct {

// HostAliases are other available host names
HostAliases []string `json:"host_aliases,omitempty"`

// CCRID
CanonicalCloudResourceID string `json:"ccrid,omitempty"`
}

// NewEmpty creates a new HostMetadata with empty fields.
Expand Down
Loading