Counters...
want to resolve these 3 issues:
unexpected default for monotonic
not able to see accurate high water mark for non-monotonic counters
ParallelCounter isn't a Counter from Prometheus perspective
Background: ( https://github.com/eclipse/microprofile-metrics/issues/203 )
@Counted annotation and its behavior comes from DropWizard Metrics.
@Counted has an optional parameter, monotonic, that controls the behavior of the counter
Default is that monotonic=false. People using @Counted without setting a value for monotonic expect the monotonic=true behavior.
@Counted()
public void foo() {}
// counts the number of invocations of foo
@Counted(monotonic=true)
public void foo() {}
// counts the number of concurrent executions of bar
@Counted(monotonic=false)
public void bar() {}
How to address Counter issues?
option 1:
Introduce new @HitCounted / @ParallelCounted annotations
@HitCounted behaves like @Counted(monotonic=true)
@ParallelCounted behaves like @Counted(monotonic=false)
Introduce new HitCounter / ParallelCounter interfaces.
ParallelCounter keeps track of high/low water mark for each of last 10 minutes
Deprecate/Remove @Counted
// counts the number of invocations of foo
@HitCounted()
public void foo() {}
// counts the number of concurrent executions of bar
@ParallelCounted()
public void bar() {}
// deprecated/removed
@Counted()
public void zzz() {}
Pros:
Avoids confusion over monotonic default
Tracks high/low water marks
non-monotonic counters can be shown as Gauges in Prometheus output
Cons:
Requires people familiar with @Counted to change code to use @HitCounted / @ParallelCounted - breaks backward compatibility, but makes it very obvious where changes need to occur
Introduces 2 new metric types to MetricsRegistry
new concepts of ParallelCounter and HitCounter aren't entirely intuitive
Option 1.1: deprecate @Counted and remove later
Option 1.2: immediately remove @Counted
option 2:
Make @Counted's monotonic flag be required (instead of optional)
Introduce new ParallelCounter sub-interface of Counter to track high/low water mark for each of last 10 minutes
// counts the number of invocations of foo
@Counted(monotonic=true)
public void foo() {}
// counts the number of concurrent executions of bar
@Counted(monotonic=false)
public void bar() {}
// compile error - monotonic parameter is required
@Counted()
public void zzz() {}
Pros:
Familiar for Dropwizard Metrics developers or mpMetrics-1.1 developers
Avoids confusion over monotonic default
Tracks high/low water marks
non-monotonic counters can be shown as Gauges in Prometheus output
The only people that need to use ParallelCounter subclass are exporter developers
Cons:
Requires people familiar with @Counted to always set the monotonic flag (minor break to backward compatibility), which is noisy
Note: if the monotonic flag was not set on pre-existing code and app is deployed into a MPM2.0 environment, it may throw errors at runtime
// counts the number of invocations of foo (monotonic, never decreases)
@Counted
public void foo() {}
// gives the number of concurrent executions of bar (arbitrary number)
@ConcurrentGauge()
public void bar() {}
// deprecated
@Counted(monotonic=false)
public void zzz() {}
--
You received this message because you are subscribed to a topic in the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/microprofile/IvrBfHsq4nI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to microprofile...@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/b13c7462-285a-436a-a190-167ad7fa4aa4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/CACZTZYW0rQz4a8ks9sv4jXNtqPQrXA_uFAmUfn-_VjwmOtznvg%40mail.gmail.com.
// counts the number of invocations of foo and also computes the number of concurrent invocations
@Counted
public void foo() {}
...
@Inject @Metric
Counter fooCount;
fooCount.inc();
fooCount.dec();
fooCount.getValue(); // == 1
fooCount.getCurrent(); // == 0
...
{
"fooCount": 1, // this is the counter that is generated now
"fooCount.current": 0 // this is a new gauge with the .current suffix
}
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/961507c6-d19e-44a6-a5cc-a73b1c8d1ac1%40googlegroups.com.
Hi,I realized that some annotations already provide multiple related metrics, not just a single value. What if the @Counted annotation provided 2 metrics instead of just 1, number of total invocations and number of current concurrent invocations? If we leave the monotonic parameter as obsolete and ignored, it wouldn't require any migration steps besides configuring metrics consumers to get the number of concurrent invocations from a metric with a different name in the JSON/Prometheus output.
--
You received this message because you are subscribed to a topic in the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/microprofile/IvrBfHsq4nI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to microprofile...@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/6d4a38cc-07ae-48c4-a741-c23442f00293%40googlegroups.com.