structlog-gcp
A structlog set of processors to output as Google Cloud Logging format
What it is and what it does
structlog-gcp is a formatter package that bridges structlog and Google Cloud Logging. It provides processors that convert structlog output into the JSON format expected by Google Cloud Logging, with built-in support for translating Python log levels to GCP equivalents and automatic error reporting to Google Error Reporting. The package is designed for applications running on GKE, Cloud Functions, or Cloud Run—environments where logs are written to stdout and picked up by Google's logging infrastructure.
The package handles three main concerns: formatting logs as JSON, managing context variables across loggers, and detecting exceptions to report them to Error Reporting. It offers a simple configuration path via `build_processors()` for typical use cases, and a lower-level `build_gcp_processors()` for applications that need finer control over the processor chain or custom JSON serializers.
Use it for:
- Format structlog output for GKE applications so logs appear correctly in Google Cloud Logging console.
- Automatically report exceptions and CRITICAL messages to Google Error Reporting dashboard.
- Configure Cloud Run services to emit structured logs with service name and revision from environment variables.
- Integrate structlog with custom processors while maintaining Google Cloud Logging compatibility.
- Bind request-scoped context variables to logs across multiple logger calls in a single request.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Configures structlog to output logs in Google Cloud Logging JSON format, with automatic error reporting and context variable support.
Yes, if you run Python applications on Google Cloud infrastructure (GKE, Cloud Run, Cloud Functions) and use structlog for logging. The package is actively maintained, has low install friction, and solves a specific integration problem with no known vulnerabilities. Install with caution only if you are not using Google Cloud Logging or prefer a different structured logging approach.
Install
structlog-gcp on PyPI
pip
pip install structlog-gcpuv
uv add structlog-gcppoetry
poetry add structlog-gcpInstalling structlog-gcp
Before you install
Low install friction with a single runtime dependency (structlog). Actively maintained with recent releases; last commit 2026-08-11 and latest release 2026-07-07. Supports current Python versions (3.10–3.13).
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal obligations—suitable for both open-source and commercial projects.
Quickstart
pip install structlog-gcp
import structlog
import structlog_gcp
processors = structlog_gcp.build_processors()
structlog.configure(processors=processors)
logger = structlog.get_logger()
logger.info("Hello world")
Requires Python 3.10 or later; structlog must be installed as a runtime dependency.
Verify before relying
- Whether the package works with structlog versions prior to a specific release, or if there are known incompatibilities.
- Performance impact of JSON serialization and error-reporting overhead in high-volume logging scenarios.
- Whether external agents (e.g., Fluent Bit, Stackdriver agent) are required to forward logs to Google Cloud Logging.
Package facts
| License | The MIT License (MIT) Copyright (c) Jonathan Ballet and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files… (full text in the JSON record) (unclear) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — structlog |
| Maintenance | actively maintained — 38 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 414,354/month — #6,835 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: structlog_gcp-0.5.1-py3-none-any.whl
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
pytest-structlogProvides a pytest fixture for capturing and…
permissive · top 15,000 on PyPI
structlog-prettyAdds structlog processors that format log…
permissive · top 15,000 on PyPI
structlog-sentryBridges structlog and Sentry to automatically…
permissive · top 5,000 on PyPI
macwinnie-enhanced-loggingProvides a batteries-included logging setup…
unclear · top 15,000 on PyPI
django-structlogIntegrates structured logging into Django…
permissive · top 5,000 on PyPI
google-cloud-loggingWrites log entries to Google Cloud Logging and…
permissive · top 1,000 on PyPI
structlogstructlog is a structured logging library that…
permissive · top 1,000 on PyPI
opentelemetry-exporter-gcp-loggingExports OpenTelemetry logs to Google Cloud…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-structlogIntegrates structlog logging with OpenTelemetry…
permissive · top 15,000 on PyPI
exasol-error-reportingDefines and structures Exasol error messages…
permissive · top 15,000 on PyPI