-
Notifications
You must be signed in to change notification settings - Fork 888
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
feat(db.values): add db.bind.values to yaml #3092
Conversation
@joaopgrassi This is the "real" PR. I closed the other one (#3091 ) |
Also, please add a change log entry for this change under the Semantic Conventions section: |
@@ -204,6 +204,15 @@ groups: | |||
The database statement being executed. | |||
note: The value may be sanitized to exclude sensitive information. | |||
examples: ['SELECT * FROM wuser_table', 'SET mykey "WuValue"'] | |||
- id: values |
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.
What about using db.bind.values
of types string[]
and additionally db.bind.keys
of type string[]
?
Or a bit longer db.bind_params.keys
/db.bind_params.values
?
If there are no bind keys it should be omitted, if they exist the size of the two arrays must match and key[x] fits to value[x].
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.
We can discuss about naming, but I think capturing the keys also makes sense. Then the bind_values
requirement level can be Conditionally Required based if the keys are also recorded and they must match in index as you said.
What do you think @haddasbronfman?
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 guess this can also be done in a follow-up PR.
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.
Adding more attributes in a followup should be fine but I think we should avoid renames in followups. In special the decision to use a namespace (db.bind.XXX) or not not should happen now.
Or is there a specific reason to merge fast? Once merge instrumentations may use it and if we rename this creates unneeded friction.
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.
do you mean something like this? db. bind_params.keys = [name, age, city]
and db. bind_params.values = [David, 38, NY]
?
Just to make sure I understood you.
I'm not sure if this is necessary because the db.statement
attribute already gives us the keys of the query (e.g. "select * from TABLE where name=? and age=? and city=?")
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 makes sense to me to have the "db.bind" namespace and store arrays under this namespace. if I understand correctly, the suggestion is to spec "db.bind.values" now and leave the other attributes to follow-up PRs, right?
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.
Saw your comment below now. I think the idea was not to introduce a new namespace.. but maybe we should? Not sure now 🤔
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.
So I think the only thing left is to decide whether to use db.bind_values
or db.bind.values
. @joaopgrassi What do you think after what @blumamir wrote below?
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 don't have a strong opinion on it.. as long as the namespace doesn't collide later with something "standalone" and has an actual need to be the home of multiple attributes then I think it makes sense.
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 think it makes sense as it would allow us to introduce db.bind.keys
and db.bind.types
in future.
@haddasbronfman are you aware of instrumentation recording such values already? Would be interesting to know and could help us define things here. |
@haddasbronfman thanks for the links. I think this looks good. It's still experimental, so if when updating the implementations something comes up we can always tweak it. Also about the topic on recording the "bind keys" |
change db.values to db.bind_values Co-authored-by: Joao Grassi <[email protected]>
Another example supporting the const params = {
// Specify which items in the results are returned.
FilterExpression: "Subtitle = :topic AND Season = :s AND Episode = :e",
// Define the expression attribute value, which are substitutes for the values you want to compare.
ExpressionAttributeValues: {
":topic": {S: "SubTitle2"},
":s": {N: 1},
":e": {N: 2},
},
// Set the projection expression, which are the attributes that you want.
ProjectionExpression: "Season, Episode, Title, Subtitle",
TableName: "EPISODES_TABLE",
};
ddb.scan(params, function (err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data);
data.Items.forEach(function (element, index, array) {
console.log(
"printing",
element.Title.S + " (" + element.Subtitle.S + ")"
);
});
}
}); Here, for each bind value we have: "value", "key" (or name) and type. I imagine that storing those arrays into a single semantic attribute namespace could be helpful |
According to the suggestions that came up here, I changed the name to |
type: string[] | ||
requirement_level: optional | ||
brief: > | ||
An array with the values of the SQL statement bind parameters. |
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.
As discussed in this PR, the attribute can also be used for non-SQL statements. Do you think we should update the text accordingly?
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.
An array with the values of the SQL statement bind parameters. | |
An array with the values of the db statement bind parameters. |
or:
An array with the values of the SQL statement bind parameters. | |
An array with the values of the db operation bind parameters. |
?
I have a few concerns with this PR:
|
|
I support making this explicit in the current proposal (adding the text "An array with the values for a statement positional bind parameters."), or adding the
IMO, it might be confusing to have the statement in the |
I think it is better to keep db.statement as is because the overhead of changing its name can be very unexpected (although we change it only in the spec, It still appears in the SDKs, and docs... it would take a long time to rename it). |
@jsuereth Consulting with Amir we thought we should clearly write that the
|
Given the discussion/direction changed, I'm removing my approval for now
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
Fixes open-telemetry/semantic-conventions#716
Changes
Add
db.bind.values
to DB span. it contains the values that come with the query (like in pg/mysql and more)