-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Migrating to mongo client 4.x #2493
Conversation
…odb.driver.pool.waitqueuesize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonatan-ivanov I added a few comments. Thx for doing this!
.../src/main/java/io/micrometer/core/instrument/binder/mongodb/MongoMetricsCommandListener.java
Show resolved
Hide resolved
...in/java/io/micrometer/core/instrument/binder/mongodb/MongoMetricsConnectionPoolListener.java
Outdated
Show resolved
Hide resolved
.../test/java/io/micrometer/core/instrument/binder/mongodb/MongoMetricsCommandListenerTest.java
Outdated
Show resolved
Hide resolved
@@ -68,7 +73,8 @@ public void clusterOpening(ClusterOpeningEvent event) { | |||
|
|||
assertThat(registry.get("mongodb.driver.pool.size").tags(tags).gauge().value()).isEqualTo(2); | |||
assertThat(registry.get("mongodb.driver.pool.checkedout").gauge().value()).isZero(); | |||
assertThat(registry.get("mongodb.driver.pool.waitqueuesize").gauge().value()).isZero(); | |||
// TODO: waitQueueEntered and waitQueueExited were removed, how can we provide mongodb.driver.pool.waitqueuesize? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Mongo driver stopped emitting these - and it was labeled as "going to be removed in future release in Mongo 3.x" I think we don't provide it. I think instead we can provide the metrics for these new events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you happen to know anything from the Mongo team we could reference in our release notes? I asked about it in #2493 (comment) before I saw your review comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not from the Mongo team per-se. However, this deprecation list (posted in 3.12) was super helpful when we migrated our apps to 4.x.
And drilling down directly into the event in question you see this loud warning:
The driver 4.0 upgrade docs coupled w/ the above info (which also references the 3.12 deprecation list) should suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. We can certainly reference that. I was hoping for any reasoning why it was deprecated and removed, but lacking that, we can use the deprecation list you linked. As a user, did you ever use the wait queue metrics? Is there removal an issue for you or do you think it might be for other users?
Edit: I should check all the updates before commenting. I see you've answered my question already in #2493 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That JIRA issue is in connection with what I found: https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#why-are-waitqueuesize-and-waitqueuemultiple-deprecated
I'm going to ask the mongo community; ConcurrentPool
has public getCount
, getInUseCount
, getAvailableCount
but its interface does not and getting a reference could also be tricky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Between the deprecated list, release notes, and this spec outlining why the waitQueue metrics are deprecated it feels like the waitQueue metrics can be omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to ask this earlier. How are docs handled in Micrometer? Do we need to open a "documentation ticket" for the removal of waitqueue metric?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on the outcome of the thread in the mongo forum, this can go to javadoc/release-notes/micrometer-docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call in posting on that forum @jonatan-ivanov - looks like we got some direction. It does sound like this will give roughly the same as waitqueue. I understand metrics are APIs and its nice to not break consumers. However, I feel like we should deprecate that metric as Mongo does not emit it anymore. What are your thoughts Jonatan and @shakuzen ?
Also, what is that process like for Micrometer metrics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think any of the metrics backends we support have a concept of a deprecated metric (though it is an interesting idea), so unfortunately we're limited by what we can do to inform users. Release notes are typically where we would call out a removal. I agree we should consider whether it is an important metric for users or not. It seems the Mongo team thinks it isn't something to be tracked, judging from their removal of it. If there are Micrometer and MongoDB users out there that find it useful, we'd like to hear about that. We could drop an ask in the release notes and remove it in the next minor version if we don't hear people are using it.
...in/java/io/micrometer/core/instrument/binder/mongodb/MongoMetricsConnectionPoolListener.java
Outdated
Show resolved
Hide resolved
@@ -79,6 +79,11 @@ public void connectionPoolClosed(ConnectionPoolClosedEvent event) { | |||
waitQueueSize.remove(serverId); | |||
} | |||
|
|||
// @Override | |||
// public void connectionPoolCleared(ConnectionPoolClearedEvent event) { | |||
// // TODO: Do we need to implement this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the ConnectionClosedEvent called for each connection when this happens? If so, perhaps we don't need to do anything with this event. The pool is still open and usable after it is cleared, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good questions @shakuzen . Seeing this plus your other comment about the other new event types I am in favor of moving these "new event support" to a follow on issue. A little bit of digging on the new events needs to be done.
This ticket is really to move from 3.x -> 4.x and this current proposal puts us in parity w/ 3.x sans "waitqueuesize".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is called when the pool is invalidated. This happens in error scenarios but nothing particular happens with the pool in this case. If the connection happens to be closed after this, as @shakuzen said a ConnectionClosedEvent
will be emitted so we seems to be ok not implementing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the connection happens to be closed
Does it get closed after? I mean, that makes sense that it would, I just did not see it when glancing through the code (I did not pull down locally though either). Either way though, I think its fine to omit it now. If someone wants it they will file an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens in error scenarios (e.g.: not able to connect) and what happens depends on when do you get the error:
- It happens before the connection checked out:
This means the connection was not in use, there is a retry, eventually there is a timeout and the connection will be closed - It happens after the connection checked out:
This means that the connection was in use, there will be a check in and then a close which is good since it takes care about the events we need
Check out the ConcurrentPool
(release
, prune
, close
) and the maintenance task in DefaultConnectionPool
they orchestrate this logic.
Resolves #2338