lidavidm commented on a change in pull request #12100:
URL: https://github.com/apache/arrow/pull/12100#discussion_r784008528
##########
File path: cpp/src/arrow/util/tracing_internal.h
##########
@@ -97,6 +100,63 @@ AsyncGenerator<T> WrapAsyncGenerator(AsyncGenerator<T>
wrapped,
return fut;
};
}
+
+class SpanImpl {
+ public:
+ opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span;
+};
+
+opentelemetry::trace::StartSpanOptions SpanOptionsWithParent(
+ const util::tracing::Span& parent_span);
+
+#define START_SPAN(target_span, ...)
\
+ auto opentelemetry_scope##__LINE__ =
\
+ ::arrow::internal::tracing::GetTracer()->WithActiveSpan(
\
+ target_span
\
+ .Set(::arrow::util::tracing::Span::Impl{
\
+
::arrow::internal::tracing::GetTracer()->StartSpan(__VA_ARGS__)}) \
+ .span)
+
+#define START_SPAN_WITH_PARENT(target_span, parent_span, ...)
\
+ auto opentelemetry_scope##__LINE__ =
\
+ ::arrow::internal::tracing::GetTracer()->WithActiveSpan(
\
+ target_span
\
+ .Set(::arrow::util::tracing::Span::Impl{
\
+ ::arrow::internal::tracing::GetTracer()->StartSpan(
\
+ __VA_ARGS__,
\
+
::arrow::internal::tracing::SpanOptionsWithParent(parent_span))}) \
+ .span)
+
+#define EVENT(target_span, ...) target_span.Get().span->AddEvent(__VA_ARGS__)
+
+#define MARK_SPAN(target_span, status) \
+ ::arrow::internal::tracing::MarkSpan(status, target_span.Get().span.get())
+
+#define END_SPAN(target_span) target_span.Get().span->End()
+
+#define END_SPAN_ON_FUTURE_COMPLETION(target_span, target_future,
target_capture) \
+ target_future = target_future.Then(
\
+ [target_capture]() {
\
+ MARK_SPAN(target_span, Status::OK());
\
+ END_SPAN(target_span);
\
+ },
\
+ [target_capture](const Status& st) {
\
+ MARK_SPAN(target_span, st);
\
+ END_SPAN(target_span);
\
+ return st;
\
+ })
Review comment:
This macro really makes me think we should consider just adding Span as
a part of Future (and see how it impacts performance). That can be done later,
though, I think we can get this in first and continue refining how we use
OpenTelemetry.
--
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]