uber-common / jvm-profiler

JVM Profiler Sending Metrics to Kafka, Console Output or Custom Reporter
Other
1.79k stars 342 forks source link

Avoid creation of multiple reporters #56

Open mgaido91 opened 5 years ago

mgaido91 commented 5 years ago

Due to an ambiguous semantic of the getReporter method of the Arguments class, extensions created around this project are forced to be using different reporters instances for their collectors and for the collectors in this repository. This prevents the reporter created for others' collectors to follow the proper lifecycle and hence to be correctly closed when needed, or anyway, makes them responsible to do so.

CLAassistant commented 5 years ago

CLA assistant check
All committers have signed the CLA.

mgaido91 commented 5 years ago

@boy-uber thanks for your comment. I think the point of this PR is to be able to retrieve the reporter, in order to be able to reuse it to write customized metrics. Hence just renaming the method would not do the job. We can rename it, but having it as a singleton I think would be enabling for more use cases. Thanks.

hiboyang commented 5 years ago

I see. It just looks weird that Arguments.java contains a Reporter field. If you want to reuse Reporter, I would suggest change it somewhere else. e.g. cache the reporter returned by Arguments somewhere.