[service/otelconftelemetry] incorrect null behavior in service.telemetry.resource.attributes modern format
Component(s)
service
What happened?
Describe the bug
When configuring static resource attributes for internal telemetry, the modern "array of maps with name and value keys" format does not behave the same as the legacy "inline map" format when using null values.
Consider the following legacy "inline map" configuration format:
service:
telemetry:
resource:
service.instance.id: null
service.name: nullThis format will correctly REMOVE the specified default resource attributes from the telemetry, as documented here: https://github.com/open-telemetry/opentelemetry-collector/blob/78b98e74fdfd6cf55ee7ce7e1ebd842e8389bb51/service/telemetry/otelconftelemetry/config.go#L19-L26
However, when using the (supposedly) equivalent modern "array of maps" configuration format:
service:
telemetry:
resource:
attributes:
- name: service.name
value: null
- name: service.instance.id
value: nullThe default attributes are NOT removed, but set to null instead. Breaking the documented behavior.
The bug seems to be in the createInitialResourceConfig function. In this function, the appendng of default resource attributes is conditioned only on the cfg.LegacyAttributes field, ignoring the modern cfg.Attributes field altogether:
for name, value := range defaults {
if _, ok := cfg.LegacyAttributes[name]; ok {
continue
}
sdkCfg.Attributes = append(sdkCfg.Attributes, otelconf.AttributeNameValue{
Name: name,
Value: value,
})
}Steps to reproduce
- Create a simple collector configuration with
service.telemetry.resourceoverriding any of the default resource attributes (see previous section for a concrete example) using the legacy "inline map" format. - Scrape the default Prometheus endpoint of the collector and observe the abscence of the overriden default attribute (for example
service.instance.id) in thetarget_infometric:target_info{service_name="observiq-otel-collector",service_version="v1.109.0"} 1 - Replace the legacy "inline map" format with the equivalent modern "array of maps" format (see previous section for a concrete example).
- Scrape the default Prometheus endpoint of the collector again and observe the presence of the overriden default attribute with a
nullvalue in thetarget_infometric (as opposed to being absent):target_info{service_instance_id="<nil>",service_name="observiq-otel-collector",service_version="v1.109.0"} 1 - Alternatively, this difference can be also observed in the collector console logs:
{"level":"info","ts":"2026-09-30T21:23:56.360+0100","caller":"[email protected]/service.go:233","msg":"Starting observiq-otel-collector...","resource":{"service.name":"observiq-otel-collector","service.version":"v1.109.0"},"Version":"v1.109.0","NumCPU":4}{"level":"info","ts":"2026-09-30T22:09:27.420+0100","caller":"[email protected]/service.go:233","msg":"Starting observiq-otel-collector...","resource":{"service.instance.id":"<nil>","service.name":"observiq-otel-collector","service.version":"v1.109.0"},"Version":"v1.109.0","NumCPU":4}
What did you expect to see? Both the legacy "inline map" and modern "array of maps" resource attribute formats to behave the same (as documented) when nullifying default resource attributes (for the purpose of removing them).
What did you see instead? Only the legacy "inline map" format adheres to the documented behaviour, not the modern "array of maps" format.
Collector version
master
Environment information
Environment
OS: Linux
Using Bindplane Distro for OpenTelemetry (BDOT) collector version v1.109.0.
Tip
React with to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Source: open-telemetry/opentelemetry-collector