Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Ensure shape info is added to OTEL spans in shape requests (#2358)
Fixes electric-sql/stratovolt#299 It's a bit confusing because we use the same attirbute names elsewhere and use different values (e.g. `"shape.root_table"` is also added as a span in `Electric.Shapes.Consumer`, but there it uses the namespaced tuple instead of the request provided table). Right now they are coming in as `nil` because there is no such thing as a `:shape` key in the parameters, so I'm changing this to at least always try and include something. This populating of attributes happens both at the start of the request and at the end - I always try to use the raw query parameter value, because it should always be available and it is what we will try to correlate to request spans from proxies etc. I have the parsed parameter fallback but I'm not sure if that is even necessary or if it makes sense to be there. For example, for the `replica` parameter, if it is not present in the query string, it will still be populated with the parsed value which defaults to `"default"` - but for the purpose of this span, should we not leave it as `nil` if the requester didn't include it? Or should we include what we parsed the request as? And should priority go to the parsed version or the raw version? I've also removed the `shape.definition` attribute as it feels a bit too verbose - we can technically add it with a json safe version of the shape definition, but it feels like overkill. Unsure about these changes but figured it'd be good to at least get the basics working again - this would benefit from tests but I think we need an OTEL dependency injection to get it working, if anyone has a better idea I'd appreciate that.
- Loading branch information