Skip to content

Log warning about "function" meter re-registration #6070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jonatan-ivanov
Copy link
Member

@jonatan-ivanov jonatan-ivanov commented Mar 28, 2025

I also realized that while we added logging for gauge double registration, any of the "functional" meters are affected - FunctionCounter, FunctionTimer. That's relevant to KafkaMetrics because it only registers Gauges and FunctionCounters. /cc @jonatan-ivanov

found by @shakuzen, see: #5757 (comment)

See gh-5616
See gh-5688
See gh-5617

@jonatan-ivanov jonatan-ivanov added bug A general bug module: micrometer-core An issue that is related to our core module labels Mar 28, 2025
@jonatan-ivanov jonatan-ivanov added this to the 1.13.x milestone Mar 28, 2025
@jonatan-ivanov jonatan-ivanov changed the base branch from main to 1.13.x March 31, 2025 23:01
@jonatan-ivanov
Copy link
Member Author

I ran benchmarks with- and without the double-registration check. These tests were executed on an M4 MacBook Pro that has 10 performance + 4 efficiency cores and which ones are used for the benchmarks is not known.

CounterBenchmark tests the scenario where the logic goes through all three instanceof checks while GaugeBenchmark tests the scenario where only the first instanceof check is executed with logging. Using a TimeGauge is the same scenario as using a Gauge while FunctionCounter and FunctionTimer are in-between scenarios.

CounterBenchmark (click to expand)

CounterBenchmark

With double-registration check (should be slower)

Benchmark                            Mode      Cnt    Score    Error  Units
CounterBenchmark.baseline          sample  2180624    0.013 ±  0.001  us/op
CounterBenchmark.baseline:p0.00    sample               ≈ 0           us/op
CounterBenchmark.baseline:p0.50    sample               ≈ 0           us/op
CounterBenchmark.baseline:p0.90    sample             0.042           us/op
CounterBenchmark.baseline:p0.95    sample             0.042           us/op
CounterBenchmark.baseline:p0.99    sample             0.042           us/op
CounterBenchmark.baseline:p0.999   sample             0.042           us/op
CounterBenchmark.baseline:p0.9999  sample             0.250           us/op
CounterBenchmark.baseline:p1.00    sample           375.296           us/op
CounterBenchmark.countSum          sample  2743515    0.013 ±  0.001  us/op
CounterBenchmark.countSum:p0.00    sample               ≈ 0           us/op
CounterBenchmark.countSum:p0.50    sample               ≈ 0           us/op
CounterBenchmark.countSum:p0.90    sample             0.042           us/op
CounterBenchmark.countSum:p0.95    sample             0.042           us/op
CounterBenchmark.countSum:p0.99    sample             0.042           us/op
CounterBenchmark.countSum:p0.999   sample             0.042           us/op
CounterBenchmark.countSum:p0.9999  sample             0.152           us/op
CounterBenchmark.countSum:p1.00    sample            27.488           us/op
CounterBenchmark.retrieve          sample  2861608    0.020 ±  0.001  us/op
CounterBenchmark.retrieve:p0.00    sample               ≈ 0           us/op
CounterBenchmark.retrieve:p0.50    sample               ≈ 0           us/op
CounterBenchmark.retrieve:p0.90    sample             0.042           us/op
CounterBenchmark.retrieve:p0.95    sample             0.042           us/op
CounterBenchmark.retrieve:p0.99    sample             0.042           us/op
CounterBenchmark.retrieve:p0.999   sample             0.042           us/op
CounterBenchmark.retrieve:p0.9999  sample             0.826           us/op
CounterBenchmark.retrieve:p1.00    sample           632.832           us/op

Benchmark                            Mode      Cnt    Score    Error  Units
CounterBenchmark.baseline          sample  2153166    0.013 ±  0.001  us/op
CounterBenchmark.baseline:p0.00    sample               ≈ 0           us/op
CounterBenchmark.baseline:p0.50    sample               ≈ 0           us/op
CounterBenchmark.baseline:p0.90    sample             0.042           us/op
CounterBenchmark.baseline:p0.95    sample             0.042           us/op
CounterBenchmark.baseline:p0.99    sample             0.042           us/op
CounterBenchmark.baseline:p0.999   sample             0.042           us/op
CounterBenchmark.baseline:p0.9999  sample             0.417           us/op
CounterBenchmark.baseline:p1.00    sample           507.904           us/op
CounterBenchmark.countSum          sample  2662849    0.014 ±  0.001  us/op
CounterBenchmark.countSum:p0.00    sample               ≈ 0           us/op
CounterBenchmark.countSum:p0.50    sample               ≈ 0           us/op
CounterBenchmark.countSum:p0.90    sample             0.042           us/op
CounterBenchmark.countSum:p0.95    sample             0.042           us/op
CounterBenchmark.countSum:p0.99    sample             0.042           us/op
CounterBenchmark.countSum:p0.999   sample             0.042           us/op
CounterBenchmark.countSum:p0.9999  sample             0.250           us/op
CounterBenchmark.countSum:p1.00    sample            82.048           us/op
CounterBenchmark.retrieve          sample  2962901    0.020 ±  0.001  us/op
CounterBenchmark.retrieve:p0.00    sample               ≈ 0           us/op
CounterBenchmark.retrieve:p0.50    sample               ≈ 0           us/op
CounterBenchmark.retrieve:p0.90    sample             0.042           us/op
CounterBenchmark.retrieve:p0.95    sample             0.042           us/op
CounterBenchmark.retrieve:p0.99    sample             0.042           us/op
CounterBenchmark.retrieve:p0.999   sample             0.042           us/op
CounterBenchmark.retrieve:p0.9999  sample             0.666           us/op
CounterBenchmark.retrieve:p1.00    sample            81.152           us/op

Without double-registration check (should be faster)

Benchmark                            Mode      Cnt   Score    Error  Units
CounterBenchmark.baseline          sample  2149123   0.013 ±  0.001  us/op
CounterBenchmark.baseline:p0.00    sample              ≈ 0           us/op
CounterBenchmark.baseline:p0.50    sample              ≈ 0           us/op
CounterBenchmark.baseline:p0.90    sample            0.042           us/op
CounterBenchmark.baseline:p0.95    sample            0.042           us/op
CounterBenchmark.baseline:p0.99    sample            0.042           us/op
CounterBenchmark.baseline:p0.999   sample            0.042           us/op
CounterBenchmark.baseline:p0.9999  sample            1.420           us/op
CounterBenchmark.baseline:p1.00    sample           79.744           us/op
CounterBenchmark.countSum          sample  2552911   0.014 ±  0.001  us/op
CounterBenchmark.countSum:p0.00    sample              ≈ 0           us/op
CounterBenchmark.countSum:p0.50    sample              ≈ 0           us/op
CounterBenchmark.countSum:p0.90    sample            0.042           us/op
CounterBenchmark.countSum:p0.95    sample            0.042           us/op
CounterBenchmark.countSum:p0.99    sample            0.042           us/op
CounterBenchmark.countSum:p0.999   sample            0.042           us/op
CounterBenchmark.countSum:p0.9999  sample            0.250           us/op
CounterBenchmark.countSum:p1.00    sample           75.264           us/op
CounterBenchmark.retrieve          sample  2862835   0.019 ±  0.001  us/op
CounterBenchmark.retrieve:p0.00    sample              ≈ 0           us/op
CounterBenchmark.retrieve:p0.50    sample              ≈ 0           us/op
CounterBenchmark.retrieve:p0.90    sample            0.042           us/op
CounterBenchmark.retrieve:p0.95    sample            0.042           us/op
CounterBenchmark.retrieve:p0.99    sample            0.042           us/op
CounterBenchmark.retrieve:p0.999   sample            0.042           us/op
CounterBenchmark.retrieve:p0.9999  sample            2.042           us/op
CounterBenchmark.retrieve:p1.00    sample           95.488           us/op

Benchmark                            Mode      Cnt    Score    Error  Units
CounterBenchmark.baseline          sample  2320517    0.013 ±  0.001  us/op
CounterBenchmark.baseline:p0.00    sample               ≈ 0           us/op
CounterBenchmark.baseline:p0.50    sample               ≈ 0           us/op
CounterBenchmark.baseline:p0.90    sample             0.042           us/op
CounterBenchmark.baseline:p0.95    sample             0.042           us/op
CounterBenchmark.baseline:p0.99    sample             0.042           us/op
CounterBenchmark.baseline:p0.999   sample             0.042           us/op
CounterBenchmark.baseline:p0.9999  sample             1.496           us/op
CounterBenchmark.baseline:p1.00    sample            78.336           us/op
CounterBenchmark.countSum          sample  2533534    0.014 ±  0.001  us/op
CounterBenchmark.countSum:p0.00    sample               ≈ 0           us/op
CounterBenchmark.countSum:p0.50    sample               ≈ 0           us/op
CounterBenchmark.countSum:p0.90    sample             0.042           us/op
CounterBenchmark.countSum:p0.95    sample             0.042           us/op
CounterBenchmark.countSum:p0.99    sample             0.042           us/op
CounterBenchmark.countSum:p0.999   sample             0.042           us/op
CounterBenchmark.countSum:p0.9999  sample             0.250           us/op
CounterBenchmark.countSum:p1.00    sample            78.464           us/op
CounterBenchmark.retrieve          sample  3070706    0.021 ±  0.001  us/op
CounterBenchmark.retrieve:p0.00    sample               ≈ 0           us/op
CounterBenchmark.retrieve:p0.50    sample               ≈ 0           us/op
CounterBenchmark.retrieve:p0.90    sample             0.042           us/op
CounterBenchmark.retrieve:p0.95    sample             0.042           us/op
CounterBenchmark.retrieve:p0.99    sample             0.042           us/op
CounterBenchmark.retrieve:p0.999   sample             0.042           us/op
CounterBenchmark.retrieve:p0.9999  sample             2.832           us/op
CounterBenchmark.retrieve:p1.00    sample           599.040           us/op
GaugeBenchmark (click to expand)

GaugeBenchmark

With double-registration check (should be slower)

Benchmark                                                   Mode      Cnt    Score    Error  Units
GaugeBenchmark.baseline                                   sample  1628714    0.015 ±  0.001  us/op
GaugeBenchmark.baseline:p0.00                             sample               ≈ 0           us/op
GaugeBenchmark.baseline:p0.50                             sample               ≈ 0           us/op
GaugeBenchmark.baseline:p0.90                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.95                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.99                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.999                            sample             0.042           us/op
GaugeBenchmark.baseline:p0.9999                           sample             0.250           us/op
GaugeBenchmark.baseline:p1.00                             sample           555.008           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder             sample  1202673    0.037 ±  0.001  us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.00       sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.50       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.90       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.95       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.99       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.999      sample             0.084           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.9999     sample             2.722           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p1.00       sample            63.360           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder          sample  1615837    0.035 ±  0.001  us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.00    sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.50    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.90    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.95    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.99    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.999   sample             0.084           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.9999  sample             1.975           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p1.00    sample            96.512           us/op

Benchmark                                                   Mode      Cnt    Score    Error  Units
GaugeBenchmark.baseline                                   sample  1597634    0.015 ±  0.001  us/op
GaugeBenchmark.baseline:p0.00                             sample               ≈ 0           us/op
GaugeBenchmark.baseline:p0.50                             sample               ≈ 0           us/op
GaugeBenchmark.baseline:p0.90                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.95                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.99                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.999                            sample             0.042           us/op
GaugeBenchmark.baseline:p0.9999                           sample             0.520           us/op
GaugeBenchmark.baseline:p1.00                             sample            55.488           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder             sample  1540683    0.036 ±  0.001  us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.00       sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.50       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.90       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.95       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.99       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.999      sample             0.125           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.9999     sample             4.618           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p1.00       sample            55.168           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder          sample  1274477    0.040 ±  0.002  us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.00    sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.50    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.90    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.95    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.99    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.999   sample             0.125           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.9999  sample             6.686           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p1.00    sample           670.720           us/op

Without double-registration check (should be faster)

Benchmark                                                   Mode      Cnt    Score    Error  Units
GaugeBenchmark.baseline                                   sample  1610536    0.015 ±  0.001  us/op
GaugeBenchmark.baseline:p0.00                             sample               ≈ 0           us/op
GaugeBenchmark.baseline:p0.50                             sample               ≈ 0           us/op
GaugeBenchmark.baseline:p0.90                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.95                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.99                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.999                            sample             0.042           us/op
GaugeBenchmark.baseline:p0.9999                           sample             0.458           us/op
GaugeBenchmark.baseline:p1.00                             sample            33.856           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder             sample  1282695    0.022 ±  0.002  us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.00       sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.50       sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.90       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.95       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.99       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.999      sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.9999     sample             0.708           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p1.00       sample           538.624           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder          sample  1215342    0.022 ±  0.001  us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.00    sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.50    sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.90    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.95    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.99    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.999   sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.9999  sample             1.371           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p1.00    sample            73.344           us/op

Benchmark                                                   Mode      Cnt    Score    Error  Units
GaugeBenchmark.baseline                                   sample  1613981    0.016 ±  0.001  us/op
GaugeBenchmark.baseline:p0.00                             sample               ≈ 0           us/op
GaugeBenchmark.baseline:p0.50                             sample               ≈ 0           us/op
GaugeBenchmark.baseline:p0.90                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.95                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.99                             sample             0.042           us/op
GaugeBenchmark.baseline:p0.999                            sample             0.042           us/op
GaugeBenchmark.baseline:p0.9999                           sample             1.000           us/op
GaugeBenchmark.baseline:p1.00                             sample            61.056           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder             sample  1214053    0.022 ±  0.002  us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.00       sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.50       sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.90       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.95       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.99       sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.999      sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p0.9999     sample             4.536           us/op
GaugeBenchmark.gaugeReRegistrationWithBuilder:p1.00       sample           588.800           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder          sample  1213533    0.020 ±  0.001  us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.00    sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.50    sample               ≈ 0           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.90    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.95    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.99    sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.999   sample             0.042           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p0.9999  sample             2.400           us/op
GaugeBenchmark.gaugeReRegistrationWithoutBuilder:p1.00    sample            76.672           us/op

@jonatan-ivanov jonatan-ivanov marked this pull request as ready for review April 2, 2025 21:54
@jonatan-ivanov jonatan-ivanov modified the milestones: 1.13.x, 1.13.13 Apr 3, 2025
@shakuzen shakuzen merged commit b7a344c into micrometer-metrics:1.13.x Apr 3, 2025
8 checks passed
@jonatan-ivanov jonatan-ivanov deleted the meter-re-registration-warning branch April 3, 2025 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A general bug module: micrometer-core An issue that is related to our core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants