tracing-google-cloud 0.1.0

A tracing-subscriber layer that outputs Google Cloud structured logs
Documentation

tracing-google-cloud

This is a tracing-subcriber Layer that implements Google Cloud's Structured Logging format. Features:

  • OpenTelemetry Trace integration (with opentelemetry feature flag)
  • Support for HTTP requests via log entry fields
  • Support for populating operation structures into log entries from the parent Span(s).

Usage

Install via:

# with tracing-opentelemetry support:
cargo add tracing-google-cloud -F opentelemetry

# but it's not required!
cargo add tracing-google-cloud # <- omits trace ids

Add to a tracing-subscriber stack after tracing-opentelemetry's layer, if you're using that:

use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;

fn main() {
    tracing_subscriber::registry()
        .with(tracing_opentelemetry::layer())
        .with(tracing_google_cloud::builder()
            .with_project_id(PROJECT_ID) // required with opentelemetry feature
            .with_writer(std::io::stdout())
            .build())
        .init();
}