5#include <grpcpp/support/status.h>
7#include <viam/sdk/common/grpc_fwd.hpp>
9#ifdef VIAMCPPSDK_OPENTELEMETRY_TRACING
10#include <opentelemetry/trace/scope.h>
11#include <opentelemetry/trace/span.h>
29 explicit ServerSpanGuard(
const GrpcServerContext* ctx,
const char* method)
noexcept;
33 ::grpc::Status
commit(::grpc::Status status)
noexcept;
44#ifdef VIAMCPPSDK_OPENTELEMETRY_TRACING
47 static opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> start_span_(
48 const GrpcServerContext* ctx,
const char* method)
noexcept;
50 opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span_;
51 opentelemetry::trace::Scope scope_;
52 bool committed_ =
false;
62void inject_trace_context(GrpcClientContext* ctx)
noexcept;
64#ifdef VIAMCPPSDK_OPENTELEMETRY_TRACING
66void record_exception(opentelemetry::trace::Span* span,
const std::exception& xcp)
noexcept;
70void record_unknown_exception(opentelemetry::trace::Span* span)
noexcept;
RAII guard that creates a server-side OpenTelemetry span for the duration of a gRPC handler invocatio...
Definition span_guard.hpp:27
void record_unknown_exception() noexcept
Record an unknown (non-std::exception) failure. Caller rethrows.
::grpc::Status commit(::grpc::Status status) noexcept
Record the final gRPC status before destruction and return it unchanged.
void record_exception(const std::exception &xcp) noexcept
Record xcp as an "exception" event and set span status to Error. Caller rethrows.