Repository navigation
ref(attributes): Use JSON for aws.s3.delete & document multi-collection db.collection.name - #711
pabloDeputter wants to merge 2 commits into
Conversation
…ion `db.collection/name`
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
| }, | ||
| "is_in_otel": true, | ||
| "example": "users", | ||
| "examples": ["users", ",customers,orders,"], |
There was a problem hiding this comment.
I looked at documentation in OTel how they treat multiple collections but it doesn't seem like they specify anything regarding multiple collections. Looking at their database span spec, it seems like they only want this attribute to be set, when the db operation is done on one collection.
I think this is free to interpretation but I would assume that when you have something like SELECT * FROM users JOIN orders ON ..., db.collection.name should only hold users.
This is a string attribute, so I'd prefer we avoid joining multiple values into one string.
Are we doing the comma-joined list already somewhere? If so, why the leading ,? 😅
There was a problem hiding this comment.
Yup, I noticed that as well. So for a JOIN OTel will probably omit both users and orders. However db.collection.name is already set to this joined form by Relay; I sent a few queries through the python-SQLAlchemy integration (which never sets db.collection.name): https://sentry-sdks.sentry.io/explore/traces/trace/a4c29d7664f047bfac9ba507460c7ed1/?mode=samples&node=span-a7290e2aed0619ab&project=4511733153660928&source=traces&statsPeriod=1h&table=trace×tamp=1791970030.188
- join on 2 tables:
SELECT * FROM users JOIN orders ON ...=>,orders,users, - multiple queries:
SELECT * FROM "acme-shop-customers" …; SELECT * FROM "acme-shop-orders" …=>,acme-shop-customers,acme-shop-orders, - single table:
SELECT * FROM "Users" WHERE ...=>,users,
So pretty sure Relay sets db.collection.name (when not provided by the SDK) based off query.text; sorts and lower-cases it as well.
So that's why I added the new example to it, I probably should have been a bit more specific on why I changed this.
There was a problem hiding this comment.
sql_tables_from_query() implements this extraction, sorting and lower-casing: https://github.com/getsentry/relay/blob/4e69c4221c841ec7f0c6e43b252bffeb1b3e7dde/relay-event-normalization/src/normalize/span/tag_extraction.rs#L1396-L1431
There was a problem hiding this comment.
So I looked at this again and OTel ([1] remark at https://opentelemetry.io/docs/specs/semconv/registry/attributes/db/#db-collection-name) states that it should not be extracted from db.query.text when the db system supports queries over multiple collections (which basically covers any SQL db), and recommends no case normalization. sql_tables_from_query() does both of these things when db.collection.name isn't set by the SDK (Users => ,users,, users JOIN orders => ,orders,users,).
The commas are inherited from v1 span.domain which was (I think) so a contains-search can differentiate ,users, from ,users_postfix, (getsentry/relay#5399)
| example: '{"Objects":[{"Key":"someFile.yml","VersionId":"3HL4kqtJlcpXroDTDmJ"}],"Quiet":false}', | ||
| examples: ['{"Objects":[{"Key":"someFile.yml","VersionId":"3HL4kqtJlcpXroDTDmJ"}],"Quiet":false}'], |
There was a problem hiding this comment.
examples takes precedence, so no need to have both keys
| example: '{"Objects":[{"Key":"someFile.yml","VersionId":"3HL4kqtJlcpXroDTDmJ"}],"Quiet":false}', | |
| examples: ['{"Objects":[{"Key":"someFile.yml","VersionId":"3HL4kqtJlcpXroDTDmJ"}],"Quiet":false}'], | |
| examples: ['{"Objects":[{"Key":"someFile.yml","VersionId":"3HL4kqtJlcpXroDTDmJ"}],"Quiet":false}'], |
| }, | ||
| 'aws.s3.delete': { | ||
| brief: 'The delete request container that specifies the objects to be deleted.', | ||
| brief: 'The JSON-serialized value of Delete request field, which specifies the objects to be deleted.', |
There was a problem hiding this comment.
Do you know which SDKs set this attribute and if they all use the JSON-serialized version?
There was a problem hiding this comment.
actually, this is the more important question: #711 (comment)
There was a problem hiding this comment.
In sentry-python (for the next major, so not yet released), boto3 passes it as a dict, so we serialize it as a JSON (https://github.com/getsentry/sentry-python/blob/major/3.0/sentry_sdk/integrations/boto3/_services/s3.py#L70-L79)
| }, | ||
| 'aws.s3.delete': { | ||
| brief: 'The delete request container that specifies the objects to be deleted.', | ||
| brief: 'The JSON-serialized value of Delete request field, which specifies the objects to be deleted.', |
There was a problem hiding this comment.
I looked up the OTel definition and the current format is what OTel specifies. Why should we diverge here?
There was a problem hiding this comment.
I'm pretty sure that the Objects[{key=string, ... format is just copied from the AWS CLI docs which is one way of providing it to the CLI, next to JSON.
In the SDK we get the Deletestructure itself, e.g. boto3 passes it as a dict, so we serialize it to a JSON: https://github.com/getsentry/sentry-python/blob/major/3.0/sentry_sdk/integrations/boto3/_services/s3.py#L70-L79 (for the next major, not relased yet)
Other OTel attributes, e.g. aws.dynamodb.* also use JSON-serialized values; so just trying to make it consistent across the aws.* attributes.
Description
Update
aws.s3.deleteanddb.collection.namedescriptions and examples.