-
-
Notifications
You must be signed in to change notification settings - Fork 120
Adopt distributed tracing #645
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Moritz Lang <[email protected]>
|
@ptoffy How do you expect this to look like once database drivers like |
|
@slashmo Yes my idea is to create child spans in the underlying drivers but that might still be a while off since I'm pretty sure those are all event loop based (see https://github.com/vapor/fluent-postgres-driver). Maybe @gwynne has some insight into this. |
I'm all for following the spec. However, there isn't one for ORMs, only for db drivers. So if we'd follow the DB driver conventions here we'd have duplicate spans between Fluent and the drivers. Gorm is just one example ORM where I found built-in tracing support, and they don't follow the DB driver conventions. |
|
@slashmo what do you think about emitting driver-agnostic traces (like the ones that are in the PR now) in fluent-kit and leaving db-specific traces up to the drivers to implement? The drivers rely on fluent-kit anyway so you'll always have both. The only pain about this approach I can think of is keeping track of which ones are where, but we can just decide it upfront |
|
|
||
| func withTracing<T>(_ closure: () async throws -> T) async rethrows -> T { | ||
| if shouldTrace { | ||
| try await withSpan("db.query", context: self.serviceContext, ofKind: .client) { span in |
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.
Depending on how strict observability backends are about the semantic conventions I could see this being a problem. For example, if they look for certain required attributes that we don't supply here I could imagine it breaking their visualization of database spans. I think I'd slightly be in favor of using non-spec operation name and attributes for FluentKit spans for that reason. I also think it shouldn't be up to the Vapor DB drivers to add spans but the underlying database libraries agnostic from Vapor, like postgres-nio. This way we'd also benefit from these spans in apps not using Vapor.
This adopts tracing on
DatabaseQuery, only usingasync/awaitinterfaces.This relies on #647