Closed Kaizer303 closed 4 months ago
In 3.0, methods like find_one
return a value that implements IntoFuture
rather than the plain Future
of 2.x. Because the compiler will automatically convert it when .await
is called, in almost all cases this will be transparent. However, when working with other code that requires a Future
(like tracing's instrument
), an explicit into_future
call is needed:
collection
.find_one(doc! {})
.into_future() // <-- added
.instrument(info_span!(
"db.mongo.find_one",
db.statement = &query.to_string(),
db.system = "mongodb",
db.operation = "find_one"
))
.await
.unwrap()
To bring that method into scope, you'll need to add a use std::future::IntoFuture;
in the appropriate place as well.
Oh, Thank you very much.
Versions/Environment
Describe the bug
In driver version 3.0.0, I can't use the tracing instrument method (for working on OTEL reasons) on the collection command method, which worked in version 2.8.2.
For example:
error:
To Reproduce Steps to reproduce the behavior:
Thank you.