<#10058 feat(core): Add Google Cloud Logging JSON ...
# meltano-repo-activity
g
#10058 feat(core): Add Google Cloud Logging JSON formatter Pull request opened by DRACULA1729 Description Meltano's
json_formatter
emits log lines using the structlog keys
event
,
level
, and
timestamp
. Google Cloud Logging (formerly Stackdriver) recognizes a JSON line as a structured entry only when it contains the special fields
severity
,
message
, and
timestamp
. As a result, logs produced by
json_formatter
were ingested as plain text at
INFO
severity, and severity-based filtering and alerting were unavailable. This is the behavior reported in #9420. This PR adds
google_cloud_logging_formatter
, which: • renames
event
to
message
and
level
to
severity
(upper-cased, so it matches the Google Cloud Logging severities), and • emits a
<http://logging.googleapis.com/sourceLocation|logging.googleapis.com/sourceLocation>
field (file, line, function) when
callsite_parameters
is enabled. With this formatter, logs are ingested as structured entries with the correct severity, without requiring a downstream agent (e.g. the Ops Agent) to remap fields. Example output: {"timestamp": "2025-07-29T092519Z", "severity": "WARNING", "message": "There was an error in the application.", "logging.googleapis.com/sourceLocation": {"file": "/app/run.py", "line": "42", "function": "main"}} Changes: • `src/meltano/core/logging/formatters.py`: add
google_cloud_logging_formatter
and its processor. • `src/meltano/core/logging/__init__.py`: export the new formatter. • `tests/meltano/core/logging/test_formatters.py`: unit tests for severity/message mapping, all severity levels, source location, and exceptions. • `docs/docs/guide/logging.md`: update the Google Cloud logging section to use the new formatter. Checklist • I have read the contribution guide Was generative AI tooling used to co-author this PR? • Yes (Claude Code) Generated-by: Claude Code following the agentic coding guidelines Related Issues • Closes #9420 Summary by Sourcery Add a Google Cloud Logging–compatible JSON formatter and document its usage for structured logging on GCP. New Features: • Introduce google_cloud_logging_formatter to emit JSON logs using Google Cloud Logging special fields for severity, message, and timestamp. Enhancements: • Populate Google Cloud Logging sourceLocation metadata from callsite parameters when enabled. Documentation: • Update logging guide to describe Google Cloud Logging behavior and show configuration examples using google_cloud_logging_formatter. Tests: • Add unit tests covering Google Cloud Logging formatter severity mapping, source location emission, and exception handling. meltano/meltano