newrelic / micrometer-registry-newrelic

ARCHIVED. TO SEND MICROMETER METRICS TO NEW RELIC, FOLLOW THE DIRECTION IN THE README.md. Micrometer registry implementation that sends data to New Relic as dimensional metrics.
Apache License 2.0
35 stars 19 forks source link

NewRelicRegistry sometimes skip publishing metrics on close #105

Closed shirolimit closed 3 years ago

shirolimit commented 3 years ago

According to MeterRegistry contract, close call on it should release all registry resources and send all unpublished meters.

NewRelicRegistry doesn't override close() method and default implementation simply calls publish(). The problem is that publish() method uses TelemetryClient that uses executor to to a scheduled send. As a result, if close() is called on application shutdown metrics aren't actually sent.

A possible solution would be to override close() method and to publish metrics synchronously in it.

shirolimit commented 3 years ago

Oh, one more option is to simply call TelemetryClient.shutdown() on NewRelicRegistry.close().

shirolimit commented 3 years ago

It seems that it has already been fixed in https://github.com/newrelic/micrometer-registry-newrelic/commit/5e42c309a238456ba3759157030d2f341e455f83 but it is not present in 0.5.0 release.

breedx-nr commented 3 years ago

Hi @shirolimit .

The commit you referenced above was part of #82, which was merged on Jun 17th. Version 0.5.0 seems to have been released in September...so what makes you believe that that change isn't present?

I've also confirmed that that change is still in place on main branch: https://github.com/newrelic/micrometer-registry-newrelic/blob/main/src/main/java/com/newrelic/telemetry/micrometer/NewRelicRegistry.java#L156

shirolimit commented 3 years ago

Hi @breedx-nr .

Two things:

As you can see ef6f14a Merge pull request #1 from paypay/issue/80-shutdonw-telemetryclient-in-close is not included in v0.5.0. For some reason the latest release was based on April's commit.

breedx-nr commented 3 years ago

Ooh, sure enough! You're right!

It looks like the tag AND release build were generated back in April, as you discovered...but the github release was backfilled to show it in September. I will look at cutting a new release build. Sorry for the confusion!

breedx-nr commented 3 years ago

@shirolimit We released v0.6.0 today that should contain these changes. Please give it a shot and let us know if this helps with buffer flushing on close. Feel free to reopen if there are additional concerns, and thanks for bringing it to our attention.