daklib.rpc_log

Logging middleware for the DAK RPC server.

Classes

LoggingInterceptor()

gRPC interceptor for request logging and error sanitization.

RequestContextFilter([name])

Logging filter that injects request_id and auth_sub from context vars.

class daklib.rpc_log.LoggingInterceptor[source]

gRPC interceptor for request logging and error sanitization.

_abc_impl = <_abc._abc_data object>
intercept_service(continuation: Callable[[grpc.HandlerCallDetails], grpc.RpcMethodHandler[Any, Any] | None], handler_call_details: HandlerCallDetails) grpc.RpcMethodHandler[Any, Any] | None[source]

Intercepts incoming RPCs before handing them over to a handler.

Args:
continuation: A function that takes a HandlerCallDetails and

proceeds to invoke the next interceptor in the chain, if any, or the RPC handler lookup logic, with the call details passed as an argument, and returns an RpcMethodHandler instance if the RPC is considered serviced, or None otherwise.

handler_call_details: A HandlerCallDetails describing the RPC.

Returns:

An RpcMethodHandler with which the RPC may be serviced if the interceptor chooses to service this RPC, or None otherwise.

class daklib.rpc_log.RequestContextFilter(name='')[source]

Logging filter that injects request_id and auth_sub from context vars.

filter(record: LogRecord) bool[source]

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.