Fix multiple registration of Jaeger-related gauges #6013
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #5811
The Helidon Jaeger tracing integration registers metrics on behalf of Jaeger by acting as a Jaeger
MetricsFactory
. In doing so, Helidon defines the metrics metadata to be reusable so if multiple components and/or the developer's own app use Jaeger tracing we don't define duplicate metrics.But, Helidon gauges (consistent with MicroProfile metrics) are never reusable, regardless of what the metadata says. Jaeger requests the creation of gauges, and with multiple traceable components present the second attempt to register the same gauge fails, as reported in the issue.
This fix explicitly checks for the existence of a gauge (metric name and tags) before registering it to avoid this problem.
Because of the Jaeger SPI we implement, we need to be able to find the Jaeger-typed
Gauge
which corresponds to each HelidonGauge
so the PR adds a map. (The way we implement gauges internally does not allow us to simply store a reference to the Jaeger gauge in our own gauge and then retrieve the Jaeger gauge from it; hence the need for the map.)Signed-off-by: [email protected] [email protected]