Skip to content

Conversation

@mattnworb
Copy link
Member

The 4.0 release of the metrics library (which changed groupId, from the
original author to the Dropwizard project) is the first that has support
for running under JDK9:

https://github.com/dropwizard/metrics/releases/tag/v4.0.0

When running semantic-metrics under JDK9+, a warning (at DEBUG level) is emitted each
time that FastForwardReporter emits metrics:

20:29:01.073 DEBUG [fast-forward-reporter-0] MetricsModule: Failed to get metrics for FileDescriptorGaugeSet
java.lang.reflect.InaccessibleObjectException: Unable to make public long com.sun.management.internal.OperatingSystemImpl.getOpenFileDescriptorCount() accessible: module jdk.management does not "opens com.sun.management.internal" to unnamed module @60438a68
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
        at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
        at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)
        at com.codahale.metrics.jvm.FileDescriptorRatioGauge.invoke(FileDescriptorRatioGauge.java:48)
        at com.codahale.metrics.jvm.FileDescriptorRatioGauge.getRatio(FileDescriptorRatioGauge.java:35)
        at com.codahale.metrics.RatioGauge.getValue(RatioGauge.java:64)
        at com.spotify.apollo.metrics.MetricsModule$1.lambda$getMetrics$0(MetricsModule.java:113)
        at com.spotify.metrics.ffwd.FastForwardReporter.reportGauge(FastForwardReporter.java:252)
        at com.spotify.metrics.ffwd.FastForwardReporter.report(FastForwardReporter.java:214)
        at com.spotify.metrics.ffwd.FastForwardReporter.report(FastForwardReporter.java:202)
        at com.spotify.metrics.ffwd.FastForwardReporter$2.run(FastForwardReporter.java:373)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)

The only downside of this exception is that the FileDescriptionGaugeSet
will report "NaN" values (as it has a fallback when exceptions are
caught).

v4.0 of the metrics library changed how FileDescriptorGaugeSet gets the
underlying data to not need reflection.

The 4.0 release of the metrics library (which changed groupId, from the
original author to the Dropwizard project) is the first that has support
for running under JDK9:

https://github.com/dropwizard/metrics/releases/tag/v4.0.0

When running semantic-metrics under JDK9+, a warning (at DEBUG level) is emitted each
time that FastForwardReporter emits metrics:

```
20:29:01.073 DEBUG [fast-forward-reporter-0] MetricsModule: Failed to get metrics for FileDescriptorGaugeSet
java.lang.reflect.InaccessibleObjectException: Unable to make public long com.sun.management.internal.OperatingSystemImpl.getOpenFileDescriptorCount() accessible: module jdk.management does not "opens com.sun.management.internal" to unnamed module @60438a68
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
        at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
        at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)
        at com.codahale.metrics.jvm.FileDescriptorRatioGauge.invoke(FileDescriptorRatioGauge.java:48)
        at com.codahale.metrics.jvm.FileDescriptorRatioGauge.getRatio(FileDescriptorRatioGauge.java:35)
        at com.codahale.metrics.RatioGauge.getValue(RatioGauge.java:64)
        at com.spotify.apollo.metrics.MetricsModule$1.lambda$getMetrics$0(MetricsModule.java:113)
        at com.spotify.metrics.ffwd.FastForwardReporter.reportGauge(FastForwardReporter.java:252)
        at com.spotify.metrics.ffwd.FastForwardReporter.report(FastForwardReporter.java:214)
        at com.spotify.metrics.ffwd.FastForwardReporter.report(FastForwardReporter.java:202)
        at com.spotify.metrics.ffwd.FastForwardReporter$2.run(FastForwardReporter.java:373)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
```

The only downside of this exception is that the FileDescriptionGaugeSet
will report "NaN" values (as it has a fallback when exceptions are
caught).

v4.0 of the metrics library changed how FileDescriptorGaugeSet gets the
underlying data to not need reflection.
@mattnworb
Copy link
Member Author

Might be smart to bump the major version of semantic metrics as a part of this change - no API changes, but I think the semantic metrics library version number has usually loosely tracked the codahale metrics version number.

@mattnworb
Copy link
Member Author

worth noting that while the maven coordinates have changed to io.dropwizard.metrics:metrics-*, the java package name is the same.

Java 7 reached end-of-life in April 2015, Java 8 itself is reaching
end-of-life in January 2019

This change is motivated by the metrics 4.x library only being built for
Java 8.
rename to avoid confusion with the existing FastForwardReporterTest. The
class being tested is FastForwardHttpReporter, not FastForwardReporter.
the current test asserts that, after the reporter is started,
`httpClient.sendBatch(..)` should be called at least twice. Since this
method is called via something scheduled with a
ScheduledExecutorService, the test can't 100% be sure how many times it
will be called within a given time window. Sometimes this test fails
because the method was called only once within the timeout, not at least
twice.

This change changes the assertion to be `atLeastOnce`, since the logic
being tested does not really depend or care about how many times
`httpClient.sendBatch(..)` is called - testing ScheduledExecutorService
is not the goal of this test.
to mark the change in metrics library version being depended on
@mattnworb mattnworb requested a review from dmichel1 October 8, 2018 19:30
@jsferrei
Copy link
Collaborator

@mattnworb FYI I am looking at these now

Copy link
Collaborator

@jsferrei jsferrei left a comment

Choose a reason for hiding this comment

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

@mattnworb some small observations (not necessarily blockers, just something I noticed):

  • memory=PS.* (i.e. memory=PS Survivor Space) is seemingly no longer published under what=jvm-memory-usage.
  • Nor is gc=PS.* under what=jvm-gc-collection-time
  • Nor is memory=Code Cache under what=jvm-memory-usage

Everything seems to run fine with these changes though! I just want to get to run by my team before approving.

@mattnworb
Copy link
Member Author

what version of Java did you test this on? G1 is the default GC since Java 9 so I wonder if you are not seeing the “PS”-related metrics simply because the collector they are related to was not active in your test.

@jsferrei
Copy link
Collaborator

I was testing on 11, so that makes sense

@jsferrei
Copy link
Collaborator

jsferrei commented Oct 11, 2018

Hey @mattnworb . I discussed with @dmichel1 . Can you make the version change to 1.0.0-SNAPSHOT and then we'll do a major release once this is merged? Reasoning behind this is that while we're not adding breaking changes to semantic-metrics itself, codahale/dropwizard is a major change and includes some incompatible changes. Because folks can depend on both libraries, we want to make it clear that they may run into issues.

Once done we are comfortable approving this (as well as #29) , adding a CHANGELOG to the library, and releasing.

@mattnworb
Copy link
Member Author

@jsferrei I bumped the <version>. I'll create a new PR to add a changelog as it would be awkward to add that across this PR and #29

@jsferrei jsferrei merged commit 69221e7 into master Oct 11, 2018
@jsferrei jsferrei deleted the mattbrown/metrics-library-v4 branch October 11, 2018 16:39
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.

3 participants