#gcp #logging #tracing-subscriber #structured #fields #server #log-line

tracing-gcp

tracing subscriber for structured logging in gcp

1 unstable release

0.1.0 Dec 9, 2024

#666 in Debugging

Download history 171/week @ 2024-12-09

171 downloads per month

BSD-3-Clause

13KB
269 lines

tracing-gcp

If you're writing a webserver in rust and running it on GCP you'll likely want to use this crate.

At lockbook our production server runs in GCP and we want to fully utilize cloud monitoring's structured logging fields.

Tracing gives us the ability to attach context to each log line using Spans. Gcp's ops-agent supports a JSON formatted log lines which allow us to engage with cloud logging in a more sophisticated manner.

This crate provides an opinionated subscriber which extracts metadata from fields in spans or events in the following manner:

  • log entries are written, in json, to the specified file.
  • only events emit log entries
  • the following special fields are extracted from any parent spans or events

In the future we may provide a way to send data directly to cloud logging using a client API (reducing the need for the ops agent).

Dependencies

~2.8–4MB
~75K SLoC