geoffreyclaude commented on code in PR #14547: URL: https://github.com/apache/datafusion/pull/14547#discussion_r1976361324
########## datafusion/common-runtime/src/join_set.rs: ########## @@ -0,0 +1,207 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use std::future::Future; +use std::task::{Context, Poll}; +use tokio::runtime::Handle; +use tokio::task::JoinSet as TokioJoinSet; +use tokio::task::{AbortHandle, Id, JoinError, LocalSet}; + +#[cfg(feature = "tracing")] +mod trace_utils { + use std::future::Future; + use tracing_futures::Instrument; + + /// Instruments the provided future with the current tracing span. + pub fn trace_future<F, T>(future: F) -> impl Future<Output = T> + Send + where + F: Future<Output = T> + Send + 'static, + T: Send, + { + future.in_current_span() + } + + /// Wraps the provided blocking function to execute within the current tracing span. + pub fn trace_block<F, T>(f: F) -> impl FnOnce() -> T + Send + 'static + where + F: FnOnce() -> T + Send + 'static, + T: Send, + { + let span = tracing::Span::current(); + move || span.in_scope(f) + } +} + +/// A wrapper around Tokio's [`JoinSet`](tokio::task::JoinSet) that transparently forwards all public API calls +/// while optionally instrumenting spawned tasks and blocking closures with the current tracing span +/// when the `trace` feature is enabled. Review Comment: `trace` -> `tracing` ########## datafusion/common-runtime/src/common.rs: ########## @@ -36,6 +37,7 @@ impl<R: 'static> SpawnedTask<R> { R: Send, { let mut inner = JoinSet::new(); + inner.spawn(task); Review Comment: Remove extra line -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org