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

Metrics are improperly unregistered when application is undeployed #12

Closed
jmesnil opened this issue Oct 22, 2018 · 3 comments
Closed

Metrics are improperly unregistered when application is undeployed #12

jmesnil opened this issue Oct 22, 2018 · 3 comments

Comments

@jmesnil
Copy link
Contributor

jmesnil commented Oct 22, 2018

The code in

is problement when smallrye-metrics is used in a application server that has a longer lifecycle than application deployment.

Since MetricRegistries is @ApplicationScoped, when the application deployment is undeployed, its cleanUp method is invoked and all 3 registries are cleared (without actually unregistering the metrics inside them btw).

Imagine that an application server that support redeployment is running:

  • its base and vendor metrics are registered
  • when the deployment is deployed, its application metrics are registered
  • during redeployment (i.e. undeploy + deploy), the MetricsRegistries#cleanUp method is invoked
    => there are no longer any base and vendor metrics.

Proposed fix:

The `@ApplicationScoped' MetricRegistries should only clean up the application registry and leave the base and vendor ones untouched when it is destroyed.

In addition, I am not sure that the getBaseRegistry() and getVendorRegistry() should be @ApplicationScoped. By definition, their scope is wider than the application as they provides metrics for the whole base (JVM) and vendor (app server) whose lifecycle is longer than application deployment.

@jmesnil
Copy link
Contributor Author

jmesnil commented Oct 22, 2018

@pilhuhn Do you think that is something that can be fixed in smallrye-metrics or is it a spec concern too?

jmesnil added a commit to jmesnil/smallrye-metrics that referenced this issue Oct 23, 2018
As the MetricRegistries is @ApplicationScoped, when it is destroyed, it
must clean up only the APPLICATION MetricRegistry.

Do not flag the `getBaseRegistry` and `getVendorRegistry` as
@ApplicationScope as they can be used outside of the application scope
(e.g. it's the responsibility of the container runtime to clean up its
vendor metrics).

JIRA: smallrye#12
@mkouba
Copy link

mkouba commented Oct 29, 2018

In addition, I am not sure that the getBaseRegistry() and getVendorRegistry() should be @ApplicationScoped.

I think that the scope does not really matter here. If you removed the @ApplicationScoped then the only difference would be that getBaseRegistry()/getVendorRegistry() will be invoked for every injection point, i.e. no client proxy is created and the relevant MetricRegistry instance is not stored in app context. But since there are no disposers methods or anything it should not make any difference.

jmesnil added a commit to jmesnil/smallrye-metrics that referenced this issue Nov 5, 2018
As the MetricRegistries is @ApplicationScoped, when it is destroyed, it
must clean up only the APPLICATION MetricRegistry.

JIRA: smallrye#12
kenfinnigan added a commit that referenced this issue Nov 6, 2018
@jmesnil
Copy link
Contributor Author

jmesnil commented Nov 9, 2018

closed by #13

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