Skip to content
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

Ensure prometheus metrics with the same name are serialized as a group. #4386

Merged
merged 2 commits into from
Apr 18, 2022

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Apr 15, 2022

This doesn't stop us from exporting two identical time series, filed open-telemetry/opentelemetry-specification#2493 for spec on working on that. This should still help in many cases.

Fixes #4382

@anuraaga anuraaga requested a review from a user April 15, 2022 03:47
@anuraaga anuraaga requested a review from Oberon00 as a code owner April 15, 2022 03:47
1633947011000000000L, 1633950672000000000L, KP_VP_ATTR, 5))));
1633947011000000000L,
1633950672000000000L,
Attributes.of(TYPE, "mcds"),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before all the metrics had the same name, meter, attributes, which is not representative of anything the SDK could actually output. So added this attribute to make a bit more realistic

@@ -14,7 +14,9 @@ class JpmsTest {
@Test
void noLinkageErrors() {
SdkMeterProvider meterProvider =
SdkMeterProvider.builder().registerMetricReader(PrometheusHttpServer.create()).build();
SdkMeterProvider.builder()
.registerMetricReader(PrometheusHttpServer.builder().setPort(0).build())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test flaked on this PR so added the fix in

@codecov
Copy link

codecov bot commented Apr 15, 2022

Codecov Report

Merging #4386 (d7674eb) into main (45e278a) will increase coverage by 0.00%.
The diff coverage is 96.00%.

@@            Coverage Diff            @@
##               main    #4386   +/-   ##
=========================================
  Coverage     89.95%   89.96%           
- Complexity     4897     4901    +4     
=========================================
  Files           567      567           
  Lines         15167    15180   +13     
  Branches       1462     1462           
=========================================
+ Hits          13643    13656   +13     
  Misses         1052     1052           
  Partials        472      472           
Impacted Files Coverage Δ
.../opentelemetry/exporter/prometheus/Serializer.java 86.44% <96.00%> (+1.23%) ⬆️
...etry/exporter/prometheus/PrometheusHttpServer.java 73.73% <0.00%> (-1.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 45e278a...d7674eb. Read the comment docs.

+ "instrument_name_bucket{kp=\"vp\",le=\"+Inf\"} 2.0 1633950672.000 # {span_id=\"0000000000000002\",trace_id=\"00000000000000000000000000000001\"} 4.0 0.001\n"
+ "# TYPE instrument_name gauge\n"
+ "# HELP instrument_name description\n"
+ "instrument_name_total{type=\"mcds\"} 5.0 1633950672.000\n"
Copy link
Member

@jack-berg jack-berg Apr 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this specific PR, but the spec requires that unit be appended to the metric name as a suffix. We don't do that anywhere today. I believe that would represent a breaking behavior change for prometheus users as their metric names would change when unit is present.

Still, would be good to do that soon to minimize the impact.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing this - filed open-telemetry/opentelemetry-specification#2497

@jack-berg jack-berg merged commit e628013 into open-telemetry:main Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metric queueSize twice in Prometheus output
4 participants