|
Viam C++ SDK current
|
RAII guard that creates a server-side OpenTelemetry span for the duration of a gRPC handler invocation. Extracts W3C trace context from the incoming gRPC request metadata and starts a child span (or a new root span if no traceparent header is present). When destroyed, ends the span and records the final gRPC status. More...
#include <span_guard.hpp>
Public Member Functions | |
| ServerSpanGuard (const GrpcServerContext *ctx, const char *method) noexcept | |
| ::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. | |
| void | record_unknown_exception () noexcept |
| Record an unknown (non-stdexception) failure. Caller rethrows. | |
| ServerSpanGuard (const ServerSpanGuard &)=delete | |
| ServerSpanGuard & | operator= (const ServerSpanGuard &)=delete |
RAII guard that creates a server-side OpenTelemetry span for the duration of a gRPC handler invocation. Extracts W3C trace context from the incoming gRPC request metadata and starts a child span (or a new root span if no traceparent header is present). When destroyed, ends the span and records the final gRPC status.
If OpenTelemetry tracing is not compiled in, or no tracer provider has been configured, uses a no-op implementation.