code coverage fixes

Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
This commit is contained in:
Pratik Mankawde
2026-06-03 14:23:24 +01:00
parent d6fefe2468
commit bdd7dea4b4
5 changed files with 17 additions and 10 deletions

View File

@@ -217,12 +217,14 @@ SpanGuard::linkedSpan(std::string_view name) const
rootCtx = rootCtx.SetValue(otel_trace::kIsRootSpanKey, true);
opts.parent = rootCtx;
// LCOV_EXCL_START
return SpanGuard(
std::make_unique<Impl>(tracer->StartSpan(
std::string(name),
{},
{{spanCtx, {{std::string(attr::linkType), std::string(attr_val::followsFrom)}}}},
opts)));
// LCOV_EXCL_STOP
}
SpanGuard
@@ -248,6 +250,7 @@ SpanGuard::linkedSpan(std::string_view name, SpanContext const& linkCtx)
rootCtx = rootCtx.SetValue(otel_trace::kIsRootSpanKey, true);
opts.parent = rootCtx;
// LCOV_EXCL_START
return SpanGuard(
std::make_unique<Impl>(tracer->StartSpan(
std::string(name),
@@ -255,6 +258,7 @@ SpanGuard::linkedSpan(std::string_view name, SpanContext const& linkCtx)
{{linkSpan->GetContext(),
{{std::string(attr::linkType), std::string(attr_val::followsFrom)}}}},
opts)));
// LCOV_EXCL_STOP
}
// ===== Context capture =====================================================

View File

@@ -296,8 +296,9 @@ public:
{opentelemetry::semconv::service::kServiceName, setup_.serviceName},
{opentelemetry::semconv::service::kServiceVersion, setup_.serviceVersion},
{opentelemetry::semconv::service::kServiceInstanceId, setup_.serviceInstanceId},
{std::string(attr::networkId), static_cast<int64_t>(setup_.networkId)},
{std::string(attr::networkType), setup_.networkType},
{std::string(attr::networkId),
static_cast<int64_t>(setup_.networkId)}, // LCOV_EXCL_LINE
{std::string(attr::networkType), setup_.networkType}, // LCOV_EXCL_LINE
});
// Configure sampler

View File

@@ -178,8 +178,9 @@ GRPCServerImpl::CallData<Request, Response>::process(std::shared_ptr<JobQueue::C
bool const isUnlimited = clientIsUnlimited();
if (!isUnlimited && usage.disconnect(app_.getJournal("gRPCServer")))
{
span.setAttribute(grpc_span::attr::grpcStatus, grpc_span::val::error);
span.setError(grpc_span::val::resourceExhausted);
span.setAttribute(
grpc_span::attr::grpcStatus, grpc_span::val::error); // LCOV_EXCL_LINE
span.setError(grpc_span::val::resourceExhausted); // LCOV_EXCL_LINE
grpc::Status const status{
grpc::StatusCode::RESOURCE_EXHAUSTED, "usage balance exceeds threshold"};
responder_.FinishWithError(status, this);
@@ -230,8 +231,9 @@ GRPCServerImpl::CallData<Request, Response>::process(std::shared_ptr<JobQueue::C
if (conditionMetRes != RpcSuccess)
{
RPC::ErrorInfo const errorInfo = RPC::getErrorInfo(conditionMetRes);
span.setAttribute(grpc_span::attr::grpcStatus, grpc_span::val::error);
span.setError(errorInfo.token.cStr());
span.setAttribute(
grpc_span::attr::grpcStatus, grpc_span::val::error); // LCOV_EXCL_LINE
span.setError(errorInfo.token.cStr()); // LCOV_EXCL_LINE
grpc::Status const status{
grpc::StatusCode::FAILED_PRECONDITION, errorInfo.message.cStr()};
responder_.FinishWithError(status, this);
@@ -248,8 +250,8 @@ GRPCServerImpl::CallData<Request, Response>::process(std::shared_ptr<JobQueue::C
}
catch (std::exception const& ex)
{
span.setAttribute(grpc_span::attr::grpcStatus, grpc_span::val::error);
span.recordException(ex);
span.setAttribute(grpc_span::attr::grpcStatus, grpc_span::val::error); // LCOV_EXCL_LINE
span.recordException(ex); // LCOV_EXCL_LINE
grpc::Status const status{grpc::StatusCode::INTERNAL, ex.what()};
responder_.FinishWithError(status, this);
}

View File

@@ -229,7 +229,7 @@ doCommand(RPC::JsonContext& context, json::Value& result)
}
else
{
cmdName = "unknown";
cmdName = "unknown"; // LCOV_EXCL_LINE
}
// Use the resolved command name as the span suffix so dashboards
// can break out per-command error rates (e.g. rpc.command.submit

View File

@@ -238,7 +238,7 @@ ServerHandler::onHandoff(
}
catch (std::exception const& e)
{
span.recordException(e);
span.recordException(e); // LCOV_EXCL_LINE
JLOG(journal_.error()) << "Exception upgrading websocket: " << e.what() << "\n";
return statusRequestResponse(request, http::status::internal_server_error);
}