-
Notifications
You must be signed in to change notification settings - Fork 683
Update database instrumentations to follow semantic conventions #175
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
Conversation
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.
code looks good! could you add changelog entries for each the instrumentations? and we should be good to go.
@toumorokoshi I will add the entries. General question for my reference so that I don't miss it in future, What kind of changes require a CHANGELOG entry? Is it all or is it some based on the chage? Thanks ! |
Pretty much every change that affects user behavior. Something like span attributes changing could be pretty impactful since people author queries and aggregations based on values in specific attributes. |
@@ -115,7 +115,7 @@ def wrapper(wrapped, instance, args, kwargs): | |||
@_with_tracer_wrapper | |||
def _wrap_cmd(tracer, cmd, wrapped, instance, args, kwargs): | |||
with tracer.start_as_current_span( | |||
_CMD, kind=SpanKind.INTERNAL, attributes={} | |||
_CMD, kind=SpanKind.CLIENT, attributes={} |
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 believe the span name should be a low-cardinality value representing the executed statement.
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 would also add db.name
as a span attribute to be consistent with the other instrumentations.
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.
The span name for all pymemcache commands is memcached.command
. Regarding db.name
there is db.system
which is set to here. Do you think we need db.name
set to same as well?
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.
The span name for all pymemcache commands is memcached.command
I'm not too familiar in how to use pymemcache, but does that mean there is no "command" or "statement" that is executed?
Do you think we need db.name set to same as well?
Yes, we have db.name
in other instrumentations so we should be consistent.
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 has commands. Yes we should be using them instead of hard-coded memcached.command
for span name. I don't think db.name
is applicable for memcached.
@@ -73,21 +73,23 @@ def started(self, event: monitoring.CommandStartedEvent): | |||
span = self._tracer.start_span(name, kind=SpanKind.CLIENT) |
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.
In terms of the name, I think we can remove the "DATABASE_TYPE" portion and just use the command_name
.
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.
EDIT: We can leave these in until the specs are finalized.
span.set_attribute("db.statement", statement) | ||
if event.connection_id is not None: | ||
span.set_attribute("net.peer.name", event.connection_id[0]) | ||
span.set_attribute("net.peer.port", event.connection_id[1]) | ||
|
||
# pymongo specific, not specified by spec | ||
span.set_attribute("db.mongo.operation_id", event.operation_id) | ||
span.set_attribute("db.mongo.request_id", event.request_id) | ||
span.set_attribute( |
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 would remove these attributes as they are not in the semantic conventions.
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.
@toumorokoshi also expressed the same concern on this attrs. I will remove them.
@@ -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 |
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.
And these should be removed as well.
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.
The spec doesn't have these either.
@@ -20,15 +20,14 @@ | |||
def _extract_conn_attributes(conn_kwargs): | |||
""" Transform redis conn info into dict """ | |||
attributes = { | |||
"db.type": "redis", |
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.
Span name for redis needs to be fixed too.
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 is span attribute. The span name for redis is redis.command
.
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.
Yes, I only highlighted this because Github didn't let point to the above code.
Simiarly to pymemcache for redis, is there not a concept of "statement" or "command"? The string "redis.command" doesn't really tell me much in terms of what logical operation redis is doing.
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.
The string "redis.command" doesn't really tell me much in terms of what logical operation redis is doing.
Agree.
I think there are a couple of other changes that are missing, from |
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.
Some comments.
Spec has
I would appreciate some more elaboration on this.
redis wasn't setting the connection attributes |
@lonewolf3739
I expect the name to be the "command executed" on the database. For example, commands for mongobdb. |
Hi @lzchen , I am thinking of closing this PR in favor of opening multiple small PRs as changes are becoming large. What do you suggest? |
This is becoming huge. I will be opening multiple small PRs which will be easier to work and review. |
Addresses #159