Expand description
This is a tracing-subcriber Layer that implements Google Cloud’s Structured Logging format.
Features:
- OpenTelemetry Trace integration (with
opentelemetryfeature flag) - Support for HTTP requests via log entry fields
- Support for populating operation structures into log entries from the parent Span(s).
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();§HTTP request fields
tracing::info!(
http.request_method = "POST",
http.request_url = "/",
http.request_size = 420,
http.status = 200,
http.response_size = 1024,
http.user_agent = "Fire fox",
http.remote_ip = "127.0.0.1",
http.server_ip = "127.0.0.2",
http.referer = "127.0.0.2",
http.latency_ns = 32000000,
http.cache_lookup = false,
http.cache_hit = false,
http.cache_validated_with_origin_server = false,
http.cache_fill_bytes = 200,
http.protocol = "HTTP/4",
)§Using operations
See SpanExt::operation and Operation.
use tracing_google_cloud::{OperationInfo, SpanExt};
let span = tracing::info_span!("long_operation");
let operation = span.start_operation(
"unique-id",
Some("github.com/der-fruhling/tracing-google-cloud")
);
span.in_scope(|| {
// First log entry with an operation automatically has the "first" field set
tracing::info!("First log");
tracing::info!("Something in the middle");
// Call Operation::end() to cause the next log entry to have "last" set.
// You can also call this before the first entry if you wish.
operation.end();
tracing::info!("End of the operation");
})Structs§
- Invalid
Severity - A severity value was not one of the allowed enumerations.
- Layer
- Layer
Builder - Operation
- Represents a potentially long-running operation that can be used by Google Cloud to group log entries.
- Operation
Info
Enums§
- Severity
- Allows using any severity value supported by Cloud Logging.
Traits§
- SpanExt
- This trait extends tracing::Span with additional functionality provided by this crate.