Skip to content

globalAttributeSupplier doesn't get installed as expected #1094

@LeadAssimilator

Description

@LeadAssimilator

If a global attribute supplier is provided, but returns an empty list, the supplier does not get installed. This makes it difficult to dynamically add attributes later. As it stands, a dummy attribute has to be returned just to get the supplier installed which is just a dumb gross hack. The easiest way to fix this is to just remove the nonsensical isEmpty check and change the default to null.

if (config.hasGlobalAttributes()) {
// Add span processor that appends global attributes.
GlobalAttributesSpanAppender appender =
new GlobalAttributesSpanAppender(config.getGlobalAttributesSupplier());
addTracerProviderCustomizer(
(tracerProviderBuilder, app) ->
tracerProviderBuilder.addSpanProcessor(appender));
}

public boolean hasGlobalAttributes() {
Attributes attributes = globalAttributesSupplier.get();
return attributes != null && !attributes.isEmpty();
}

private Supplier<Attributes> globalAttributesSupplier = Attributes::empty;

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions