-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add structured log messages to CMAP. #1114
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
776a505
Add structured log messages to CMAP.
vbabanin 8f43213
Make Utility class final.
vbabanin faeb3fd
Add handling for observeLogMessages.
vbabanin 6a8367b
Remove unused imports.
vbabanin 44c1570
Fix checkstyle warnings.
vbabanin 2ad63a2
Remove redundant variables.
vbabanin fe94cee
Remove redundant variables.
vbabanin 38cb1ee
Move the logging message closer to where event occurs.
vbabanin 2305822
Extract lambda to a named method.
vbabanin 8282eb8
Create method for adding entries to simplify a code structure.
vbabanin 8fb29af
Fix checkstyle warnings.
vbabanin a60bcf3
Fix checkstyle warnings.
vbabanin e8c8a0e
Add reactive streams tests.
vbabanin db0b30b
Add missing variable.
vbabanin 9d0db30
Refactor logging functionality by adding interpolation to unstructure…
vbabanin d32271a
Fix checkstyle warnings.
vbabanin 57f883d
Remove redundant message variables.
vbabanin f8c6429
Fix checkstyle issues.
vbabanin adac818
Fix checkstyle issues.
vbabanin 1c9ce27
Add tests for unstructured connection pool logging.
vbabanin 902a3ae
Fix SpotBugs issue.
vbabanin bbe2023
Refactor logEventMessage to support prefix and suffix mutators.
vbabanin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
211 changes: 140 additions & 71 deletions
211
driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
driver-core/src/main/com/mongodb/internal/event/EventReasonMessageResolver.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2008-present MongoDB, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.mongodb.internal.event; | ||
|
||
import com.mongodb.event.ConnectionCheckOutFailedEvent; | ||
import com.mongodb.event.ConnectionClosedEvent; | ||
|
||
/** | ||
* <p>This class is not part of the public API and may be removed or changed at any time</p> | ||
*/ | ||
public final class EventReasonMessageResolver { | ||
private static final String MESSAGE_CONNECTION_POOL_WAS_CLOSED = "Connection pool was closed"; | ||
private static final String EMPTY_REASON = ""; | ||
|
||
public static String getMessage(final ConnectionClosedEvent.Reason reason) { | ||
switch (reason) { | ||
case STALE: | ||
return "Connection became stale because the pool was cleared"; | ||
case IDLE: | ||
return "Connection has been available but unused for longer than the configured max idle time"; | ||
case ERROR: | ||
return "An error occurred while using the connection"; | ||
case POOL_CLOSED: | ||
return MESSAGE_CONNECTION_POOL_WAS_CLOSED; | ||
default: | ||
return EMPTY_REASON; | ||
} | ||
} | ||
|
||
public static String getMessage(final ConnectionCheckOutFailedEvent.Reason reason) { | ||
switch (reason) { | ||
case TIMEOUT: | ||
return "Wait queue timeout elapsed without a connection becoming available"; | ||
case CONNECTION_ERROR: | ||
return "An error occurred while trying to establish a new connection"; | ||
case POOL_CLOSED: | ||
return MESSAGE_CONNECTION_POOL_WAS_CLOSED; | ||
default: | ||
return EMPTY_REASON; | ||
} | ||
} | ||
|
||
private EventReasonMessageResolver() { | ||
//NOP | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.