You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/01 16:15:41 UTC

[GitHub] [arrow] lidavidm commented on a change in pull request #12609: ARROW-15067: [C++] Add tracing spans to the scanner

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



##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -101,6 +86,33 @@ AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T> wrapped,
   };
 }
 
+/// \brief Propagate the given span to 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 Propagate the currently active span to 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));
+}
+
+/*
+ * PropagateSpanThroughAsyncGenerator - only makes sure the trace context is propagated,
+ * so that spans created when running generator instances asynchronously do not
+ * end up in a separate, disconnected trace.
+ * WrapAsyncGenerator - Connect the current span to the generator. When the generator
+ * finishes, it will stop the span. Optionally, create child spans at each invocation.

Review comment:
       These could probably be folded into the docstrings themselves?

##########
File path: cpp/src/arrow/dataset/file_ipc.cc
##########
@@ -121,6 +137,10 @@ Result<std::shared_ptr<Schema>> IpcFileFormat::Inspect(const FileSource& source)
 Result<RecordBatchGenerator> IpcFileFormat::ScanBatchesAsync(
     const std::shared_ptr<ScanOptions>& options,
     const std::shared_ptr<FileFragment>& file) const {
+#ifdef ARROW_WITH_OPENTELEMETRY
+  auto tracer = arrow::internal::tracing::GetTracer();
+  auto parent_span = tracer->GetCurrentSpan();
+#endif

Review comment:
       Does this actually have an effect anymore?




-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org