-
Notifications
You must be signed in to change notification settings - Fork 791
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
Report only known collection names in MongoClientTracer (#1625) #1662
Conversation
jyemin
commented
Nov 17, 2020
- Use allow-list of commands that are known to use collection name as the value of the command
- Special-case getMore command, which uses a different field for the collection name
…ry#1625) * Use allow-list of commands that are known to use collection name as the value of the command * Special-case getMore command, which uses a different field for the collection name
|
@@ -130,10 +133,24 @@ private static BsonValue scrub(BsonValue origin) { | |||
return scrubbed; | |||
} | |||
|
|||
private static final Set<String> COMMANDS_WITH_COLLECTION_NAME_AS_VALUE = | |||
new HashSet<>(asList( | |||
"aggregate", "count", "distinct", "mapReduce", "geoSearch", "delete", "find", "killCursors", |
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.
While a n allow-list is in some ways not future proof, in practice I think it's safe as the trend in MongoDB has been to use new initiating stages in aggregation pipelines to add new functionality (e.g. the $changeStream
stage.
if (collectionValue != null && collectionValue.isString()) { | ||
return collectionValue.asString().getValue(); | ||
if (event.getCommandName().equals("getMore")) { | ||
if (event.getCommand().containsKey("collection")) { |
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 signed the CLA just now, so I'm not sure why it's still saying that I'm not authorized |
Ya, the bot doesn't update the comment, which is confusing 🙁 I can see the EasyCLA check passed tho, so u are good 👍 |
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.
thanks @jyemin!
"findAndModify", | ||
"insert", | ||
"update", | ||
"listIndexes")); |
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.
does it make sense to include create
in this list?
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 considered it. It doesn't do any harm, but I left it out because in MongoDB AFAIK it's not so common to create collections explicitly, as MongoDB will create them implicitly on first insert.
But happy to add it (and drop
as well, I guess) if there's support.
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.
sure, let's include them both 👍
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.
Added create
, drop
, and createIndexes
…on name as their values
I can't tell why the build is failing. |
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.
thx @jyemin! btw, ignore the build failures, we are having infra issues 🙁