Skip to content

Commit 787b34b

Browse files
authored
Set agent name and version conditionally (#229)
* Set agent name and version conditionally * Update resource.go
1 parent 2ed56da commit 787b34b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

enrichments/internal/elastic/resource.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,19 @@ func (s *resourceEnrichmentContext) Enrich(resource pcommon.Resource, cfg config
7272
return true
7373
})
7474

75+
// agent.name and version are set by classic Elastic APM Agents - if the value is present, we take it
76+
// otherwise the setAgent[Name|Version] functions are called to derive the values
7577
if cfg.AgentName.Enabled {
76-
s.setAgentName(resource)
78+
if _, exists := resource.Attributes().Get(elasticattr.AgentName); !exists {
79+
s.setAgentName(resource)
80+
}
7781
}
7882
if cfg.AgentVersion.Enabled {
79-
s.setAgentVersion(resource)
83+
if _, exists := resource.Attributes().Get(elasticattr.AgentVersion); !exists {
84+
s.setAgentVersion(resource)
85+
}
8086
}
87+
8188
if cfg.OverrideHostName.Enabled {
8289
s.overrideHostNameWithK8sNodeName(resource)
8390
}

0 commit comments

Comments
 (0)