buildgrid.server.decorators package
Submodules
- buildgrid.server.decorators.authorize module
- buildgrid.server.decorators.errors module
- buildgrid.server.decorators.instance module
- buildgrid.server.decorators.io module
- buildgrid.server.decorators.metadata module
- buildgrid.server.decorators.requestid module
- buildgrid.server.decorators.rpc module
- buildgrid.server.decorators.time module
Module contents
- buildgrid.server.decorators.instanced(get_instance_name: Callable[[Any], str]) Callable[[Func], Func]
- buildgrid.server.decorators.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.
- buildgrid.server.decorators.timed(metric_name: str, **tags: str) Callable[[Func], Func]
- buildgrid.server.decorators.track_request_id(f: Func) Func
Decorator to set the request ID ContextVar.
This decorator sets the
ctx_grpc_request_id
ContextVar to a UUID for the duration of the decorated function. This ContextVar is used in logging output to allow log lines for the same request to be identified.