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

Update database instrumentations to follow semantic conventions #1354

Closed
wants to merge 5 commits into from

Conversation

srikanthccv
Copy link
Member

Addresses #1298

@srikanthccv srikanthccv requested review from a team, owais and toumorokoshi and removed request for a team November 4, 2020 13:47
Copy link
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

I'm approving because this looks like an improvement in and of itself, but I think there's still some reconciliation that needs to happen on the specification and the fields emitted, especially on the MongoDB side.

@@ -106,7 +108,7 @@ def succeeded(self, event: monitoring.CommandSucceededEvent):
return
if span.is_recording():
span.set_attribute(
"db.mongo.duration_micros", event.duration_micros
"db.mongodb.duration_micros", event.duration_micros
Copy link
Member

Choose a reason for hiding this comment

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

looks like this isn't present in semantic conventions. Should we add it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Spec has call level attributes for specific technologies. It is left to authors of db package to decide whether they want to add it or not. For example one would be interested in number of rows returned by query etc..

Copy link
Member

@toumorokoshi toumorokoshi Nov 5, 2020

Choose a reason for hiding this comment

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

There are also language specific attributes, and duration_micros is not one of them.

To clarify I'm not arguing against attributes for specific technologies. I'm saying I think this is adding attributes that aren't in the spec. So it seems like we should send a PR to the spec too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree. I think the rationale behind including them is that pymongo monitoring module provides handful of attributes such as operation_id, request_id, duration_micros, command_name and few others and it makes sense to include them with PymongoInstrumentor by default.

I am not really sure about sending PR to spec though.

Copy link
Member Author

Choose a reason for hiding this comment

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

@lzchen , I would appreciate your comments on this before opening PR in contrib repo.

self.assertEqual(span.attributes["db.mongo.sort"], "sort")
self.assertEqual(span.attributes["db.mongo.limit"], "limit")
self.assertEqual(span.attributes["db.mongo.pipeline"], "pipeline")
self.assertEqual(span.attributes["db.mongodb.filter"], "filter")
Copy link
Member

Choose a reason for hiding this comment

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

I don't see these in semantic conventions as well. What should these be?

Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above. If a database package adds a call level attributes to specific tech, it should be in the format of db.{DBMS}.{attr}:{val}.

Copy link
Member

Choose a reason for hiding this comment

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

MongoDB has an interesting way of building the query, relying on function calls rather than a string containing the full statement.

The specification has a convention for the statement, so if we followed the spec it may make more sense to set the raw query in the string instead, rather than put the sub-components of the statement in individual attributes.

@codeboten codeboten added the instrumentation Related to the instrumentation of third party libraries or frameworks label Nov 5, 2020
@lzchen
Copy link
Contributor

lzchen commented Nov 5, 2020

@lonewolf3739
Moving this to the contrib repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
instrumentation Related to the instrumentation of third party libraries or frameworks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants