userver: ugrpc::server::middlewares::access_log Namespace Reference
Loading...
Searching...
No Matches
ugrpc::server::middlewares::access_log Namespace Reference

Detailed Description

Classes

class  Component
 gRPC server access log middleware component. Writes one TSKV log line per handled RPC in a static format. This log is intended to be collected, parsed and stored for audit or extended statistics purposes. More...
 

Functions

void SetAdditionalLogKeys (MiddlewareCallContext &context, logging::LogExtra &&log_extra)
 Adds or extends log extra fields for gRPC access logging.
 

Variables

const utils::AnyStorageDataTag< ugrpc::server::StorageContext, logging::LogExtrakLogExtraTag
 Storage to handle additional fields in access_log.
 

Function Documentation

◆ SetAdditionalLogKeys()

void ugrpc::server::middlewares::access_log::SetAdditionalLogKeys ( MiddlewareCallContext & context,
logging::LogExtra && log_extra )

Adds or extends log extra fields for gRPC access logging.

Parameters
contextMiddleware call context containing the storage
log_extraAdditional log fields to add (will be moved from)
void OnCallStart(ugrpc::server::MiddlewareCallContext& context) const override {
context,
logging::LogExtra{
std::pair<std::string, std::string>("user_id", "12345"),
std::pair<std::string, std::string>("session_id", "abc-def-ghi"),
std::pair<std::string, std::string>("request_id", "req-98765"),
std::pair<std::string, std::string>("custom_tag", "test-value"),
std::pair<std::string, std::string>("numeric_tag", "42"),
}
);
}

If log extra fields already exist in the context, extends them with new fields. Otherwise, creates new log extra storage with the provided fields.

Variable Documentation

◆ kLogExtraTag

const utils::AnyStorageDataTag<ugrpc::server::StorageContext, logging::LogExtra> ugrpc::server::middlewares::access_log::kLogExtraTag
inline

Storage to handle additional fields in access_log.

void OnCallStart(ugrpc::server::MiddlewareCallContext& context) const override {
context,
logging::LogExtra{
std::pair<std::string, std::string>("user_id", "12345"),
std::pair<std::string, std::string>("session_id", "abc-def-ghi"),
std::pair<std::string, std::string>("request_id", "req-98765"),
std::pair<std::string, std::string>("custom_tag", "test-value"),
std::pair<std::string, std::string>("numeric_tag", "42"),
}
);
}

Definition at line 19 of file component.hpp.