Skip to content

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Oct 10, 2025

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.

Copy link
Contributor Author

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);
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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(),
Copy link
Contributor Author

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;
Copy link
Contributor Author

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>>
Copy link
Contributor Author

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:
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant