Skip to content

Conversation

@olavloite
Copy link
Collaborator

The default MetricsRegistry used by OpenCensus is a singleton that does not allow the same metrics to be registered multiple times. The session pool metrics gathering did not take this into account, and when multiple session pools were created within the same class loader, it would throw
an InvalidArgumentException for the second session pool.

Fixes #106.

The default MetricsRegistry used by OpenCensus is a singleton that does
not allow the same metrics to be registered multiple times. The session
pool metrics gathering did not take this into account, and when multiple
session pools were created within the same class loader, it would throw
an InvalidArgumentException for the second session pool.

Fixes #106.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 15, 2020
@mayurkale22
Copy link
Member

Although this fix looks good to me, I have implemented fix in OpenCensus (census-instrumentation/opencensus-java#2017) to allow users to register the same metrics multiple times without exception. I am planning to release a cut either on Monday or Tuesday. What do you think about my fix?

@olavloite
Copy link
Collaborator Author

olavloite commented Mar 15, 2020

Although this fix looks good to me, I have implemented fix in OpenCensus (census-instrumentation/opencensus-java#2017) to allow users to register the same metrics multiple times without exception. I am planning to release a cut either on Monday or Tuesday. What do you think about my fix?

@mayurkale22 Could you elaborate a little on how your fix will work when the same metric is registered multiple times both with the same label values and different label values? In the current implementation in the Spanner client the metrics are given label values to identify the database. The following situations are however possible:

  1. Multiple database clients for the same database are created, but with different SessionPoolOptions. This will create multiple instances of a SessionPool, and each SessionPool register the same metric multiple times with the same label value. The measurements will however be different.
  2. Multiple database clients for different databases are created. This will also lead to multiple instances of SessionPool being created, but this time with different label values. Will the metrics of each SessionPool be visible as a separate metric with a different label value in the monitoring?

See also this question: https://github.com/census-instrumentation/opencensus-java/pull/2017/files#r392709160

@olavloite
Copy link
Collaborator Author

Closing in favor of census-instrumentation/opencensus-java#2017

@olavloite olavloite closed this Mar 16, 2020
rajatbhatta pushed a commit to rajatbhatta/java-spanner that referenced this pull request Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session pool metrics registered multiple times

3 participants