-
Notifications
You must be signed in to change notification settings - Fork 185
RUST-2138 Add optional support for OpenTelemetry #1495
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
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 utility functions here just got moved out of tracing
since they're needed for otel as well.
let cmd_name = cmd.name.clone(); | ||
let target_db = cmd.target_db.clone(); | ||
#[cfg(feature = "opentelemetry")] | ||
let cmd_attrs = crate::otel::CommandAttributes::new(&cmd); |
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.
otel::CommandAttributes
exists because the opentelemetry trace needs values from both the Command
struct and the Message
struct, and constructing the latter consumes the former so they can't just both be passed in directly.
self.drop_span(); | ||
} | ||
|
||
pub(crate) fn drop_span(&mut self) { |
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'm annoyed that this is needed but commit
/ abort
are called before the relevant operation is executed and that op needs to be included in the span.
self.transaction.start( | ||
options, | ||
#[cfg(feature = "opentelemetry")] | ||
self.client.start_transaction_span(), |
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 was hoping to keep span construction internal to Transaction
but it doesn't have access to the Client
(specifically, the client's tracer
) so it has to happen here and get passed in.
#[cfg(feature = "opentelemetry")] | ||
pub mod otel; | ||
#[cfg(not(feature = "opentelemetry"))] | ||
mod otel_stub; |
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 of the executor opentelemetry stuff (future method chaining mostly) would be really awkward and noisy to keep behind #[cfg(feature = "opentelemetry")]
; the otel_stub
module exists to sidestep that.
#[derive_where(skip)] | ||
#[builder( | ||
setter( | ||
fn transform<S, T, P>(provider: P) -> Option<Arc<dyn ObjectSafeTracerProvider + Send + Sync>> |
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 what necessitated the bump on typed_builder
- older versions don't support setters with constraints.
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn run_unified_operation() { | ||
// TODO: |
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.
These and the skip reasons are going to turn into a follow-up PR for the driver otel spec&tests.
RUST-2138
The bulk of the added code is in the new
crate::otel
submodule; beyond that it's mostly some additional tracking in the executor and new fields for operations.