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

Report only known collection names in MongoClientTracer (#1625) #1662

Merged
merged 5 commits into from
Nov 20, 2020

Conversation

jyemin
Copy link
Contributor

@jyemin 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
@linux-foundation-easycla
Copy link

CLA Not Signed

@@ -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",
Copy link
Contributor Author

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")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jyemin
Copy link
Contributor Author

jyemin commented Nov 17, 2020

I signed the CLA just now, so I'm not sure why it's still saying that I'm not authorized

@trask
Copy link
Member

trask commented Nov 17, 2020

Ya, the bot doesn't update the comment, which is confusing 🙁

I can see the EasyCLA check passed tho, so u are good 👍

Copy link
Member

@trask trask left a 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"));
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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 👍

Copy link
Contributor Author

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

@jyemin
Copy link
Contributor Author

jyemin commented Nov 19, 2020

I can't tell why the build is failing.

Copy link
Member

@trask trask left a 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 🙁

@trask trask merged commit d093a56 into open-telemetry:master Nov 20, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants