Skip to content

Commit

Permalink
reporter: pass down container metadata in addTraceLabels
Browse files Browse the repository at this point in the history
appease gocritic linter on copied struct size
  • Loading branch information
Gandem committed Nov 19, 2024
1 parent 3b9c620 commit 2a9defc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions reporter/datadog_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ func (r *DatadogReporter) getPprofProfile() (profile *pprofile.Profile,
if r.timeline {
timestamps = traceInfo.timestamps
}
addTraceLabels(sample.Label, traceKey, processMeta, baseExec, timestamps)
addTraceLabels(sample.Label, traceKey, processMeta.containerMetadata, baseExec, timestamps)

count := int64(len(traceInfo.timestamps))
sample.Value = append(sample.Value, count, count*samplingPeriod)
Expand Down Expand Up @@ -620,22 +620,22 @@ func createPprofFunctionEntry(funcMap map[funcInfo]*pprofile.Function,
return function
}

func addTraceLabels(labels map[string][]string, i traceAndMetaKey, processMeta processMetadata,
func addTraceLabels(labels map[string][]string, i traceAndMetaKey, containerMetadata containermetadata.ContainerMetadata,
baseExec string, timestamps []uint64) {
if i.comm != "" {
labels["thread_name"] = append(labels["thread_name"], i.comm)
}

if processMeta.containerMetadata.PodName != "" {
labels["pod_name"] = append(labels["pod_name"], processMeta.containerMetadata.PodName)
if containerMetadata.PodName != "" {
labels["pod_name"] = append(labels["pod_name"], containerMetadata.PodName)
}

if processMeta.containerMetadata.ContainerID != "" {
labels["container_id"] = append(labels["container_id"], processMeta.containerMetadata.ContainerID)
if containerMetadata.ContainerID != "" {
labels["container_id"] = append(labels["container_id"], containerMetadata.ContainerID)
}

if processMeta.containerMetadata.ContainerName != "" {
labels["container_name"] = append(labels["container_name"], processMeta.containerMetadata.ContainerName)
if containerMetadata.ContainerName != "" {
labels["container_name"] = append(labels["container_name"], containerMetadata.ContainerName)
}

if i.apmServiceName != "" {
Expand Down

0 comments on commit 2a9defc

Please sign in to comment.