buildgrid.server.decorators.rpc module

buildgrid.server.decorators.rpc.log_rpc(f: Func) Func
buildgrid.server.decorators.rpc.named_rpc(f: Func) Func
buildgrid.server.decorators.rpc.rpc(*, instance_getter: ~typing.Callable[[~typing.Any], str] | None = None, request_formatter: ~typing.Callable[[~typing.Any], ~typing.Any] = <function <lambda>>) Callable[[Func], Func]

The RPC decorator provides common functionality to all buildgrid servicer methods. This decorator should be attached to all endpoints in the application.

All endpoints will produce the following metrics, with a tag “code” for grpc status values, a tag “service” for the service name of the RPC, and a tag “method” for the RPC method name. * rpc.duration.ms: The time in milliseconds spent on the method. * rpc.input_bytes.count: The number of message bytes sent from client to server. * rpc.output_bytes.count: The number of message bytes sent from server to client.

All other metrics produced during an RPC will have the tags “service” and “method” attached.

Parameters:
  • instance_getter (Callable[[Any], str]) – Determines how to fetch the instance name from the request payload. If provided, the tag “instance” will also be applied for all metrics, and the RPC will be enrolled in authentication/authorization.

  • request_formatter (Callable[[Any], str]) – Determines how to format the request payloads in logs.