| 1682 | class TracingTestServer : public FlightServerBase { |
| 1683 | public: |
| 1684 | Status DoAction(const ServerCallContext& call_context, const Action&, |
| 1685 | std::unique_ptr<ResultStream>* result) override { |
| 1686 | std::vector<Result> results; |
| 1687 | auto* middleware = |
| 1688 | reinterpret_cast<TracingServerMiddleware*>(call_context.GetMiddleware("tracing")); |
| 1689 | if (!middleware) return Status::Invalid("Could not find middleware"); |
| 1690 | // When running with OTel, ASAN reports false-positives that can't be easily suppressed. |
| 1691 | // Disable OTel for ASAN. See GH-46509. |
| 1692 | #if defined(ARROW_WITH_OPENTELEMETRY) && !defined(ADDRESS_SANITIZER) |
| 1693 | // Ensure the trace context is present (but the value is random so |
| 1694 | // we cannot assert any particular value) |
| 1695 | EXPECT_FALSE(middleware->GetTraceContext().empty()); |
| 1696 | auto span = arrow::internal::tracing::GetTracer()->GetCurrentSpan(); |
| 1697 | const auto context = span->GetContext(); |
| 1698 | { |
| 1699 | const auto& span_id = context.span_id(); |
| 1700 | ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBuffer(span_id.Id().size())); |
| 1701 | std::memcpy(buffer->mutable_data(), span_id.Id().data(), span_id.Id().size()); |
| 1702 | results.push_back({std::move(buffer)}); |
| 1703 | } |
| 1704 | { |
| 1705 | const auto& trace_id = context.trace_id(); |
| 1706 | ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBuffer(trace_id.Id().size())); |
| 1707 | std::memcpy(buffer->mutable_data(), trace_id.Id().data(), trace_id.Id().size()); |
| 1708 | results.push_back({std::move(buffer)}); |
| 1709 | } |
| 1710 | #else |
| 1711 | // Ensure the trace context is not present (as OpenTelemetry is not enabled) |
| 1712 | EXPECT_TRUE(middleware->GetTraceContext().empty()); |
| 1713 | #endif |
| 1714 | *result = std::make_unique<SimpleResultStream>(std::move(results)); |
| 1715 | return Status::OK(); |
| 1716 | } |
| 1717 | }; |
| 1718 | |
| 1719 | class TestTracing : public ::testing::Test { |
nothing calls this directly
no test coverage detected