Skip to content

Duplicate meter binding when context contains multiple registries, none are primary, and one or more is a composite #42396

@wilkinsona

Description

@wilkinsona

See #42310 for discussion and background.

When there are multiple MeterRegistry beans and none of them is marked @Primary, auto-configuration creates a @Primary composite meter registry that contains every MeterRegistry bean. In such a situation, MeterRegistryPostProcessor will bind and MeterBinder beans to every CompositeMeterRegistry in the context. This works as intended when the auto-configured composite is the only CompositeMeterRegistry. However, when there's a user-defined composite as well as the auto-configured composite, it results in meters being bound twice to the user-defined composite: once directly when the user-defined composite is post-processed and once when the auto-configured composite cascades the binding down to the meter registries that it contains.

When the context contains an auto-configured composite, we should ignore every meter registry other than the auto-configured composite.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions