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

Metered - difference between Prometheus and JSON format #39

Closed
rsvoboda opened this issue Dec 3, 2018 · 4 comments
Closed

Metered - difference between Prometheus and JSON format #39

rsvoboda opened this issue Dec 3, 2018 · 4 comments

Comments

@rsvoboda
Copy link

rsvoboda commented Dec 3, 2018

There are differences in reported results between Prometheus and JSON format.
When using the same deployment with OpenLiberty there are no differences in reported results between Prometheus and JSON format.

Code:

    @Metered(name = "itemsSold",
            unit = MetricUnits.MINUTES,
            description = "Metrics to monitor sold method - @Metered.",
            absolute = true)
    @GET
    @Path("/sold")
    public Response itemSold() {
        return Response.ok().build();
}

SmallRye Metrics via WF:

$ curl http://127.0.0.1:9990/metrics/application/itemsSold -H "Accept: application/json"
{  "itemsSold" : {
    "count": 2,
    "meanRate": 0.04008729595250973,
    "oneMinRate": 0.10268342380651845,
    "fiveMinRate": 0.1750346638085895,
    "fifteenMinRate": 0.19130574782060583
  }}

$ curl http://127.0.0.1:9990/metrics/application/itemsSold 2>/dev/null | grep -v TYPE | grep -v HELP
application:items_sold_total 120.0
application:items_sold_rate_per_second 2.394402679418024
application:items_sold_one_min_rate_per_second 6.6278656573403
application:items_sold_five_min_rate_per_second 10.526838271241285
application:items_sold_fifteen_min_rate_per_second 11.481234917949807

OpenLiberty:

curl https://localhost:9443/metrics/application/itemsSold -H "Accept: application/json" --insecure -u theUser:thePassword 2>/dev/null | jq
{
  "itemsSold": {
    "fiveMinRate": 0.1934432200964012,
    "fifteenMinRate": 0.19779007785878447,
    "meanRate": 0.12195642084943523,
    "count": 2,
    "oneMinRate": 0.16929634497812282
  }
}

$ curl https://localhost:9443/metrics/application/itemsSold --insecure -u theUser:thePassword 2>/dev/null | grep -v TYPE | grep -v HELP
application:items_sold_total 2
application:items_sold_rate_per_second 0.12012122656287032
application:items_sold_one_min_rate_per_second 0.16929634497812282
application:items_sold_five_min_rate_per_second 0.1934432200964012
application:items_sold_fifteen_min_rate_per_second 0.19779007785878447

Code: https://github.com/rsvoboda/rsvoboda-playground/blob/master/microprofile-metrics-hello-prometheus/src/main/java/com/sebastian_daschner/hello_prometheus/CoffeesResource.java#L47

@jmartisk
Copy link
Member

This should be fixed for 1.1.3 through #48
By the way, I think unit = MetricUnits.MINUTES, in your code example does not make sense, the spec says that

Meter and Timer have fixed units as described below regardless of the unit value in the Metadata.

@rsvoboda
Copy link
Author

So unit gets ignored ?

@jmartisk
Copy link
Member

Yes. Meter computes the rates always in PER_SECOND unit (and the total is dimension-less)

@jmartisk
Copy link
Member

The bug was basically that the unit was not completely ignored when it should have been, leading to nonsensical unit conversions for the output.

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

No branches or pull requests

2 participants