westonpace commented on a change in pull request #12609:
URL: https://github.com/apache/arrow/pull/12609#discussion_r839799353



##########
File path: cpp/src/arrow/dataset/file_csv.cc
##########
@@ -167,9 +168,14 @@ static inline Result<csv::ReadOptions> GetReadOptions(
 static inline Future<std::shared_ptr<csv::StreamingReader>> OpenReaderAsync(
     const FileSource& source, const CsvFileFormat& format,
     const std::shared_ptr<ScanOptions>& scan_options, Executor* cpu_executor) {
+#ifdef ARROW_WITH_OPENTELEMETRY
+  auto tracer = arrow::internal::tracing::GetTracer();
+  auto span = 
tracer->StartSpan("arrow::dataset::CsvFileFormat::OpenReaderAsync");
+#endif
   ARROW_ASSIGN_OR_RAISE(auto reader_options, GetReadOptions(format, 
scan_options));
 
   ARROW_ASSIGN_OR_RAISE(auto input, source.OpenCompressed());
+  auto path = source.path();

Review comment:
       ```suggestion
     const auto& path = source.path();
   ```
   

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -88,9 +88,10 @@ Iterator<T> WrapIterator(
 
 template <typename T>
 AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped,
+                                     opentelemetry::trace::StartSpanOptions 
options,
                                      const std::string& span_name) {
   return [=]() mutable -> Future<T> {
-    auto span = GetTracer()->StartSpan(span_name);
+    auto span = GetTracer()->StartSpan(span_name, {}, options);

Review comment:
       Can we do `StartSpan(span_name, options)`?  If not, then let's do 
`StartSpan(span_name, /*attributes=*/{}, options)`

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -101,6 +102,69 @@ AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> 
wrapped,
   };
 }
 
+/// \brief Start a new span for each invocation of a generator.
+///
+/// The parent span of the new span will be the currently active span
+/// (if any) as of when WrapAsyncGenerator was itself called.
+template <typename T>
+AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped,
+                                     const std::string& span_name) {
+  opentelemetry::trace::StartSpanOptions options;
+  options.parent = GetTracer()->GetCurrentSpan()->GetContext();
+  return WrapAsyncGenerator(std::move(wrapped), std::move(options), span_name);
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(
+    AsyncGenerator<T> wrapped,
+    opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span) {
+  return [=]() mutable -> Future<T> {
+    auto scope = GetTracer()->WithActiveSpan(span);
+    return wrapped().Then(
+        [span](const T& result) -> Result<T> {
+          span->SetStatus(opentelemetry::trace::StatusCode::kOk);
+          span->End();
+          return result;
+        },
+        [span](const Status& status) -> Result<T> {
+          MarkSpan(status, span.get());
+          span->End();
+          return status;
+        });
+  };
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(AsyncGenerator<T> wrapped) {

Review comment:
       ```suggestion
   /// \brief End the given span when the given async generator ends.
   ///
   /// The span will be made the active span each time the generator is called.
   template <typename T>
   AsyncGenerator<T> TieSpanToAsyncGenerator(AsyncGenerator<T> wrapped) {
   ```
   ```suggestion
   /// \brief End the active span when the given async generator ends.
   ///
   /// The span will be made the active span each time the generator is called.
   template <typename T>
   AsyncGenerator<T> TieActiveSpanToAsyncGenerator(AsyncGenerator<T> wrapped) {
   ```
   The method rename is probably optional / minor nit but we should fix the 
comment

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -101,6 +102,69 @@ AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> 
wrapped,
   };
 }
 
+/// \brief Start a new span for each invocation of a generator.
+///
+/// The parent span of the new span will be the currently active span
+/// (if any) as of when WrapAsyncGenerator was itself called.
+template <typename T>
+AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped,
+                                     const std::string& span_name) {
+  opentelemetry::trace::StartSpanOptions options;
+  options.parent = GetTracer()->GetCurrentSpan()->GetContext();
+  return WrapAsyncGenerator(std::move(wrapped), std::move(options), span_name);
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(
+    AsyncGenerator<T> wrapped,
+    opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span) {
+  return [=]() mutable -> Future<T> {
+    auto scope = GetTracer()->WithActiveSpan(span);
+    return wrapped().Then(
+        [span](const T& result) -> Result<T> {
+          span->SetStatus(opentelemetry::trace::StatusCode::kOk);
+          span->End();
+          return result;
+        },
+        [span](const Status& status) -> Result<T> {
+          MarkSpan(status, span.get());
+          span->End();
+          return status;
+        });
+  };
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(AsyncGenerator<T> wrapped) {
+  auto span = GetTracer()->GetCurrentSpan();
+  return TieSpanToAsyncGenerator(wrapped, span);
+}
+
+/// \brief Activate the given span on each invocation of an async generator.
+template <typename T>
+AsyncGenerator<T> PropagateSpanThroughAsyncGenerator(
+    AsyncGenerator<T> wrapped,
+    opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span) {
+  return [=]() mutable -> Future<T> {
+    auto scope = GetTracer()->WithActiveSpan(span);
+    return wrapped();
+  };
+}
+
+/// \brief Activate the given span on each invocation of an async generator.
+template <typename T>
+AsyncGenerator<T> PropagateSpanThroughAsyncGenerator(AsyncGenerator<T> 
wrapped) {
+  auto span = GetTracer()->GetCurrentSpan();
+  if (!span->GetContext().IsValid()) return wrapped;
+  return PropagateSpanThroughAsyncGenerator(std::move(wrapped), 
std::move(span));
+}
+

Review comment:
       The distinction between `PropagateSpanThroughAsyncGenerator`, 
`TieSpanToAsyncGenerator`, and `WrapAsyncGenerator` are subtle.  Would it be 
possible to add a short block of prose describing "why" you pick one or the 
other?

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -88,9 +88,10 @@ Iterator<T> WrapIterator(
 
 template <typename T>
 AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped,
+                                     opentelemetry::trace::StartSpanOptions 
options,
                                      const std::string& span_name) {
   return [=]() mutable -> Future<T> {
-    auto span = GetTracer()->StartSpan(span_name);
+    auto span = GetTracer()->StartSpan(span_name, {}, options);

Review comment:
       Can we do `StartSpan(span_name, options)`?  If not, then let's do 
`StartSpan(span_name, /*attributes=*/{}, options)`

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -88,9 +88,10 @@ Iterator<T> WrapIterator(
 
 template <typename T>
 AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped,
+                                     opentelemetry::trace::StartSpanOptions 
options,
                                      const std::string& span_name) {

Review comment:
       Nit:  It's not obvious to me at a glance that I'd be bypassing the 
normal process of assigning a parent by using this overload. I'm not certain we 
want to do this but if the overload was...
   
   ```
   AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped, const 
std::string& span_name, nostd::variant<SpanContext, 
opentelemetry::context::Context> parent = SpanContext::GetInvalid())
   ```
   
   It would be more obvious to me:
   
   1. Why someone would supply options
   2. By supplying options, I am bypassing the normal process of assigning the 
parent
   
   Do we call this overload anywhere?  If not, can we get rid of it?

##########
File path: cpp/src/arrow/dataset/file_ipc.cc
##########
@@ -151,6 +171,13 @@ Result<RecordBatchGenerator> 
IpcFileFormat::ScanBatchesAsync(
       ARROW_ASSIGN_OR_RAISE(generator, reader->GetRecordBatchGenerator(
                                            /*coalesce=*/false, 
options->io_context));
     }
+#ifdef ARROW_WITH_OPENTELEMETRY
+    opentelemetry::trace::StartSpanOptions span_options;
+    span_options.parent = parent_span->GetContext();
+    generator = arrow::internal::tracing::WrapAsyncGenerator(

Review comment:
       Why do I need to manually specify the parent here?

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -88,9 +88,10 @@ Iterator<T> WrapIterator(
 
 template <typename T>
 AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped,
+                                     opentelemetry::trace::StartSpanOptions 
options,
                                      const std::string& span_name) {

Review comment:
       Nit:  It's not obvious to me at a glance that I'd be bypassing the 
normal process of assigning a parent by using this overload. I'm not certain we 
want to do this but if the overload was...
   
   ```
   AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped, const 
std::string& span_name, nostd::variant<SpanContext, 
opentelemetry::context::Context> parent = SpanContext::GetInvalid())
   ```
   
   It would be more obvious to me:
   
   1. Why someone would supply options
   2. By supplying options, I am bypassing the normal process of assigning the 
parent
   
   Do we call this overload anywhere?  If not, can we get rid of it?

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -101,6 +102,69 @@ AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> 
wrapped,
   };
 }
 
+/// \brief Start a new span for each invocation of a generator.
+///
+/// The parent span of the new span will be the currently active span
+/// (if any) as of when WrapAsyncGenerator was itself called.
+template <typename T>
+AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped,
+                                     const std::string& span_name) {
+  opentelemetry::trace::StartSpanOptions options;
+  options.parent = GetTracer()->GetCurrentSpan()->GetContext();
+  return WrapAsyncGenerator(std::move(wrapped), std::move(options), span_name);
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(
+    AsyncGenerator<T> wrapped,
+    opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span) {
+  return [=]() mutable -> Future<T> {
+    auto scope = GetTracer()->WithActiveSpan(span);
+    return wrapped().Then(
+        [span](const T& result) -> Result<T> {
+          span->SetStatus(opentelemetry::trace::StatusCode::kOk);
+          span->End();
+          return result;
+        },
+        [span](const Status& status) -> Result<T> {
+          MarkSpan(status, span.get());
+          span->End();
+          return status;
+        });
+  };
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(AsyncGenerator<T> wrapped) {

Review comment:
       ```suggestion
   /// \brief End the given span when the given async generator ends.
   ///
   /// The span will be made the active span each time the generator is called.
   template <typename T>
   AsyncGenerator<T> TieSpanToAsyncGenerator(AsyncGenerator<T> wrapped) {
   ```
   ```suggestion
   /// \brief End the active span when the given async generator ends.
   ///
   /// The span will be made the active span each time the generator is called.
   template <typename T>
   AsyncGenerator<T> TieActiveSpanToAsyncGenerator(AsyncGenerator<T> wrapped) {
   ```
   The method rename is probably optional / minor nit but we should fix the 
comment

##########
File path: cpp/src/arrow/dataset/file_ipc.cc
##########
@@ -151,6 +171,13 @@ Result<RecordBatchGenerator> 
IpcFileFormat::ScanBatchesAsync(
       ARROW_ASSIGN_OR_RAISE(generator, reader->GetRecordBatchGenerator(
                                            /*coalesce=*/false, 
options->io_context));
     }
+#ifdef ARROW_WITH_OPENTELEMETRY
+    opentelemetry::trace::StartSpanOptions span_options;
+    span_options.parent = parent_span->GetContext();
+    generator = arrow::internal::tracing::WrapAsyncGenerator(

Review comment:
       Why do I need to manually specify the parent here?  Can we add a comment 
explaining?

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -101,6 +102,69 @@ AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> 
wrapped,
   };
 }
 
+/// \brief Start a new span for each invocation of a generator.
+///
+/// The parent span of the new span will be the currently active span
+/// (if any) as of when WrapAsyncGenerator was itself called.
+template <typename T>
+AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped,
+                                     const std::string& span_name) {
+  opentelemetry::trace::StartSpanOptions options;
+  options.parent = GetTracer()->GetCurrentSpan()->GetContext();
+  return WrapAsyncGenerator(std::move(wrapped), std::move(options), span_name);
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(
+    AsyncGenerator<T> wrapped,
+    opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span) {
+  return [=]() mutable -> Future<T> {
+    auto scope = GetTracer()->WithActiveSpan(span);
+    return wrapped().Then(
+        [span](const T& result) -> Result<T> {
+          span->SetStatus(opentelemetry::trace::StatusCode::kOk);
+          span->End();
+          return result;
+        },
+        [span](const Status& status) -> Result<T> {
+          MarkSpan(status, span.get());
+          span->End();
+          return status;
+        });
+  };
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(AsyncGenerator<T> wrapped) {
+  auto span = GetTracer()->GetCurrentSpan();
+  return TieSpanToAsyncGenerator(wrapped, span);
+}
+
+/// \brief Activate the given span on each invocation of an async generator.
+template <typename T>
+AsyncGenerator<T> PropagateSpanThroughAsyncGenerator(
+    AsyncGenerator<T> wrapped,
+    opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span) {
+  return [=]() mutable -> Future<T> {
+    auto scope = GetTracer()->WithActiveSpan(span);
+    return wrapped();
+  };
+}
+
+/// \brief Activate the given span on each invocation of an async generator.
+template <typename T>
+AsyncGenerator<T> PropagateSpanThroughAsyncGenerator(AsyncGenerator<T> 
wrapped) {
+  auto span = GetTracer()->GetCurrentSpan();
+  if (!span->GetContext().IsValid()) return wrapped;
+  return PropagateSpanThroughAsyncGenerator(std::move(wrapped), 
std::move(span));
+}
+

Review comment:
       The distinction between `PropagateSpanThroughAsyncGenerator`, 
`TieSpanToAsyncGenerator`, and `WrapAsyncGenerator` are subtle.  Would it be 
possible to add a short block of comment prose above these methods describing 
"why" you pick one or the other?

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -146,6 +210,22 @@ opentelemetry::trace::StartSpanOptions 
SpanOptionsWithParent(
         return st;                                                             
   \
       })
 
+#define GET_CURRENT_SPAN(lhs) \
+  lhs = ::arrow::internal::tracing::GetTracer()->GetCurrentSpan()
+
+#define SET_SPAN_SCOPE(lhs, span) \
+  lhs = ::arrow::internal::tracing::GetTracer()->WithActiveSpan(span)
+
+#define TIE_SPAN_TO_GENERATOR(generator) \
+  generator = 
::arrow::internal::tracing::TieSpanToAsyncGenerator(std::move(generator))
+
+#define PROPAGATE_SPAN_TO_GENERATOR(generator)                                \
+  generator = ::arrow::internal::tracing::PropagateSpanThroughAsyncGenerator( \
+      std::move(generator))
+
+#define WRAP_ASYNC_GENERATOR(generator, name) \
+  generator = 
::arrow::internal::tracing::WrapAsyncGenerator(std::move(generator), name)
+

Review comment:
       What do we gain making these macros instead of static methods?  If the 
namespaces are troublesome then lets just put the methods in the `arrow` 
namespace.  That seems a better compromise than introducing a macro.
   
   ```
   namespace arrow {
     nostd::shared_ptr<Span> GetCurrentSpan() {
       return ::arrow::internal::tracing::GetTracer()->GetCurrentSpan();
     }
   }
   ```

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -101,6 +102,69 @@ AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> 
wrapped,
   };
 }
 
+/// \brief Start a new span for each invocation of a generator.
+///
+/// The parent span of the new span will be the currently active span
+/// (if any) as of when WrapAsyncGenerator was itself called.
+template <typename T>
+AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped,
+                                     const std::string& span_name) {
+  opentelemetry::trace::StartSpanOptions options;
+  options.parent = GetTracer()->GetCurrentSpan()->GetContext();
+  return WrapAsyncGenerator(std::move(wrapped), std::move(options), span_name);
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(
+    AsyncGenerator<T> wrapped,
+    opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span) {
+  return [=]() mutable -> Future<T> {
+    auto scope = GetTracer()->WithActiveSpan(span);
+    return wrapped().Then(
+        [span](const T& result) -> Result<T> {
+          span->SetStatus(opentelemetry::trace::StatusCode::kOk);
+          span->End();
+          return result;
+        },
+        [span](const Status& status) -> Result<T> {
+          MarkSpan(status, span.get());
+          span->End();
+          return status;
+        });
+  };
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(AsyncGenerator<T> wrapped) {
+  auto span = GetTracer()->GetCurrentSpan();
+  return TieSpanToAsyncGenerator(wrapped, span);
+}
+
+/// \brief Activate the given span on each invocation of an async generator.
+template <typename T>
+AsyncGenerator<T> PropagateSpanThroughAsyncGenerator(
+    AsyncGenerator<T> wrapped,
+    opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span) {
+  return [=]() mutable -> Future<T> {
+    auto scope = GetTracer()->WithActiveSpan(span);
+    return wrapped();
+  };
+}
+
+/// \brief Activate the given span on each invocation of an async generator.
+template <typename T>
+AsyncGenerator<T> PropagateSpanThroughAsyncGenerator(AsyncGenerator<T> 
wrapped) {

Review comment:
       ```suggestion
   /// \brief Activate the given span on each invocation of an async generator.
   template <typename T>
   AsyncGenerator<T> PropagateSpanThroughAsyncGenerator(AsyncGenerator<T> 
wrapped) {
   ```
   ```suggestion
   /// \brief Capture the currently active span and activate it on each 
invocation of an async generator.
   template <typename T>
   AsyncGenerator<T> PropagateActiveSpanThroughAsyncGenerator(AsyncGenerator<T> 
wrapped) {
   ```

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -101,6 +102,69 @@ AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> 
wrapped,
   };
 }
 
+/// \brief Start a new span for each invocation of a generator.
+///
+/// The parent span of the new span will be the currently active span
+/// (if any) as of when WrapAsyncGenerator was itself called.
+template <typename T>
+AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped,
+                                     const std::string& span_name) {
+  opentelemetry::trace::StartSpanOptions options;
+  options.parent = GetTracer()->GetCurrentSpan()->GetContext();
+  return WrapAsyncGenerator(std::move(wrapped), std::move(options), span_name);
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(
+    AsyncGenerator<T> wrapped,
+    opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span) {
+  return [=]() mutable -> Future<T> {
+    auto scope = GetTracer()->WithActiveSpan(span);
+    return wrapped().Then(
+        [span](const T& result) -> Result<T> {
+          span->SetStatus(opentelemetry::trace::StatusCode::kOk);
+          span->End();
+          return result;
+        },
+        [span](const Status& status) -> Result<T> {
+          MarkSpan(status, span.get());
+          span->End();
+          return status;
+        });
+  };
+}
+
+/// \brief End the given span when the given async generator ends.
+///
+/// The span will be made the active span each time the generator is called.
+template <typename T>
+AsyncGenerator<T> TieSpanToAsyncGenerator(AsyncGenerator<T> wrapped) {
+  auto span = GetTracer()->GetCurrentSpan();
+  return TieSpanToAsyncGenerator(wrapped, span);
+}
+
+/// \brief Activate the given span on each invocation of an async generator.
+template <typename T>
+AsyncGenerator<T> PropagateSpanThroughAsyncGenerator(
+    AsyncGenerator<T> wrapped,
+    opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span) {
+  return [=]() mutable -> Future<T> {
+    auto scope = GetTracer()->WithActiveSpan(span);
+    return wrapped();
+  };
+}
+
+/// \brief Activate the given span on each invocation of an async generator.
+template <typename T>
+AsyncGenerator<T> PropagateSpanThroughAsyncGenerator(AsyncGenerator<T> 
wrapped) {

Review comment:
       ```suggestion
   /// \brief Activate the given span on each invocation of an async generator.
   template <typename T>
   AsyncGenerator<T> PropagateSpanThroughAsyncGenerator(AsyncGenerator<T> 
wrapped) {
   ```
   ```suggestion
   /// \brief Capture the currently active span and activate it on each 
invocation of an async generator.
   template <typename T>
   AsyncGenerator<T> PropagateActiveSpanThroughAsyncGenerator(AsyncGenerator<T> 
wrapped) {
   ```

##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -146,6 +210,22 @@ opentelemetry::trace::StartSpanOptions 
SpanOptionsWithParent(
         return st;                                                             
   \
       })
 
+#define GET_CURRENT_SPAN(lhs) \
+  lhs = ::arrow::internal::tracing::GetTracer()->GetCurrentSpan()
+
+#define SET_SPAN_SCOPE(lhs, span) \
+  lhs = ::arrow::internal::tracing::GetTracer()->WithActiveSpan(span)
+
+#define TIE_SPAN_TO_GENERATOR(generator) \
+  generator = 
::arrow::internal::tracing::TieSpanToAsyncGenerator(std::move(generator))
+
+#define PROPAGATE_SPAN_TO_GENERATOR(generator)                                \
+  generator = ::arrow::internal::tracing::PropagateSpanThroughAsyncGenerator( \
+      std::move(generator))
+
+#define WRAP_ASYNC_GENERATOR(generator, name) \
+  generator = 
::arrow::internal::tracing::WrapAsyncGenerator(std::move(generator), name)
+

Review comment:
       What do we gain making these macros instead of static methods?  If the 
namespaces are troublesome then lets just put the methods in the `arrow` 
namespace.  That seems a better compromise than introducing a macro.
   
   ```
   namespace arrow {
     nostd::shared_ptr<Span> GetCurrentSpan() {
       return ::arrow::internal::tracing::GetTracer()->GetCurrentSpan();
     }
   }
   ```




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to