Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

feature/Gcp-log-sink · L-260916-9f1908 — cloud logging client, extra (#1209)

Louis Choquel1758ddf5e749
diff --git a/.drift/acks/config-docs.toml b/.drift/acks/config-docs.toml
index 6ec091d1d..84083e0c2 100644
--- a/.drift/acks/config-docs.toml
+++ b/.drift/acks/config-docs.toml
@@ -1,13 +1,13 @@
contract = "config-docs"
-digest = "sha256:c92f24eeb4684a4bcfb92ea177fd96943be6bd045c04881bee14fafb6388166b"
+digest = "sha256:882e711271ff0716aefa3315cc794c70ac30667f386bca3436d260df3ec1f0c7"
reviewed_by = "Louis Choquel"
-reviewed_at = "2026-09-17T13:32:03Z"
-rationale = "The only trigger change is the extra_patterns validator, which now also refuses a regular expression matching the empty string: x* where x+ was meant matches at every position and replaces the whole of every log line the process writes, for the life of the process, so it is named where the pattern is still in front of whoever typed it. It narrows the accepted domain and no fingerprint can see it, which is what this contract asks about, and it takes no migration ledger entry: the shipped default is an empty list, a file already holding such a pattern was already having every line destroyed by it, and no migration can guess what pattern was meant. No field was added, renamed or removed and no other validator moved; check-migration-schemas reports the surfaces accounted for. The review targets were read: docs/configuration/config-practical/logging-config.md now says the refusal beside the one for a pattern re refuses, and names what each shipped family actually reads, since the families were rewritten in the same change; configs.py and config_cogt.py are untouched by it."
+reviewed_at = "2026-09-25T14:40:46Z"
+rationale = "Merge of dev, which now carries the redaction member, into the gcp sink branch. Each side was acked on its own; the merge only combines them: log_config.py holds both GcpLogSinkConfig and LogRedactionConfig with LogConfig carrying both the redaction and gcp sections, and pipelex.toml ships both [runtime.log.gcp] and [runtime.log.redaction]. logging-config.md already documents both sections and both appear in its example configuration; both are additions with shipped defaults, so no migration ledger entry is owed, and the defaults@5 golden carries both tables."
[trigger_files]
"pipelex/cogt/config_cogt.py" = "blob:02f71cb4a6b01aebda59c2e31f262ef9c865e17b"
"pipelex/cogt/img_gen/img_gen_job_components.py" = "blob:084985080413fd8d6c3b1b9b0747020cb0161858"
-"pipelex/pipelex.toml" = "blob:6140d1296b800011b423e75f421ec4a951efda89"
+"pipelex/pipelex.toml" = "blob:8d5b60c54ea342992546918b718563a02629d31f"
"pipelex/system/configuration/__init__.py" = "blob:8b137891791fe96927ad78e64b0aad7bded08bdc"
"pipelex/system/configuration/config_check.py" = "blob:88e15a92b186088a5ea1c7c4ebcedac830707d3a"
"pipelex/system/configuration/config_loader.py" = "blob:ac384ce993933656682999c26afffb4c9f9b1975"
@@ -18,4 +18,4 @@ rationale = "The only trigger change is the extra_patterns validator, which now
"pipelex/system/configuration/pipe_func_config.py" = "blob:dc8890e914fbcdb611147e42eaa0cd87b32288a5"
"pipelex/system/telemetry/telemetry_config.py" = "blob:7070951a6d3e4c10cb7d59822ce168c6590c53be"
"pipelex/tools/aws/aws_config.py" = "blob:c1aeafeae08d3921464db33795f11a29ff3892ba"
-"pipelex/tools/log/log_config.py" = "blob:d42123b1bbd64383447e35414a8c4bcbf073b890"
+"pipelex/tools/log/log_config.py" = "blob:5b98b3ebe7090fa306cd5253c96812605f0d3dbc"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c86d2d9f4..3052eee24 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
- **Named fields and a run-scoped context on the log calls**: the seven `log.*` methods take a keyword-only `fields={...}`, carried as attributes of the stdlib `LogRecord` and never rendered into the message, and `with log.context(request_id=..., pipeline_run_id=..., pipe_run_id=...)` stamps the run's identifiers onto every record emitted in scope, nested bindings merging and an absent identifier staying absent rather than reading `None`. `PipeRun.run` binds the request and pipeline identifiers from the job's metadata for a direct-mode run, and every pipe binds its own `pipe_run_id` around the whole of its run, its announcement and its failure included. A `dict` or `list` content is carried as the record's `data` attribute beside its console rendering, a JSON-ready snapshot of the call rather than the caller's live object, and an entry named like an attribute the record already owns, a record factory's included, or like one of the names set after the fields are attached — the formatter's, and the internal marker that tells a sink a record reached it already — is carried under a `field_` prefix instead of raising or steering delivery, whatever the order the names arrive in — a field spelling `data` beside structured content included, so the content keeps the name a sink reads it under and the field keeps its value beside it, as [Logging](tools/logging.md) describes.
- **Log sinks are a plugin capability selected by `[runtime.log] sink` (Breaking)**: where the records go is a registered sink token, `console` (the Rich handler, the default so the CLI keeps its rendering), `json` (one JSON object per line carrying `time`, `severity`, `logger`, `message`, the fields, the context identifiers and the exception, with no ANSI ever, for a server behind a log agent) or `otlp` (the OpenTelemetry logs signal, configured under `[runtime.log.otlp]`, so a collector receives the logs beside the spans), each of the two reserving the keys it writes itself so that a field named like one of them rides under a `field_` prefix rather than overwriting it, or a token an installed plugin registers through `add_log_sink`, and a token nobody provides stops the boot naming the registered ones, while `pipelex doctor` reports it in a row of its own and carries on through the console sink. `log_mode`, `poor_loggers`, `generic_poor_logger` and `is_console_logging_enabled` are gone with the rich-or-poor mode, and `set_log_mode`, `set_poor_log_formatter` and `LevelAndEmojiLogFormatter` with them, so a server that wants plain output selects `json` and a host that wants Pipelex silent sets `pipelex = "OFF"` under `[runtime.log.package_log_levels]`. **Migration:** run `pipelex migrate`; ledger entry `pipelex-config@5` deletes the four retired keys from `~/.pipelex/` and every project `.pipelex/` file, after which the defaults supply `sink = "console"`. A file that had `log_mode = "poor"` or `is_console_logging_enabled = false` chose a behaviour that deletion undoes and no migration may write back, so such a file sets `sink = "json"` or `pipelex = "OFF"` under `[runtime.log.package_log_levels]` by hand, as the entry's title says. [Log Sink Plugins](under-the-hood/log-sink-plugins.md) documents the seam.
+- **A `gcp` log sink writing to Google Cloud Logging**: `sink = "gcp"` sends each record to Cloud Logging through the `google-cloud-logging` client library, which the new `gcp-logging` extra installs; selecting it without the extra stops the boot with the install hint and the `json` alternative named. Each record becomes one struct entry — the level mapped onto the Cloud Logging severity scale, the message, the logger, the exception and the fields as the JSON payload, the run-scoped identifiers as the entry's labels, which is what Cloud Logging indexes, and the run's own OpenTelemetry trace id, project-qualified, in the entry's `trace` field, so a line and the spans of its run are filed together. The entries leave through the library's background-thread transport, so no record costs an API round trip on the thread that logged it, with the export path rejected before the handler's lock so a refused batch is reported on stderr, rate-limited, rather than through the pipeline that refused it, and the teardown's flush carrying a deadline the library's own flush does not. `[runtime.log.gcp]` carries the log name, the project when it is not the ambient one, and a service-account credentials path for a process that should not use Application Default Credentials. **Most processes on Google Cloud want `json` instead**: Cloud Run, GKE and any platform running a logging agent over the container's stdout ingest what that sink writes and need no client at all, which [Logging Configuration](configuration/config-practical/logging-config.md) spells out.
- **Secrets are scrubbed and field values made injection-safe before any sink sees a record**: one processor, configured under `[runtime.log.redaction]` and on by default, replaces an `Authorization` header's credential whichever scheme carries it, an api-key or signature header value, an OAuth `code` parameter read through the delimiter that ends it so a percent-encoded code goes whole, a cookie header's every crumb, a secret entry written as a serialised entry or plainly as `name=value`, and an `sk_` / `plx_sk_` / `pk_` / `bl_` key spelled with a dash as with an underscore, with `[REDACTED]`, in the message, in the exception's rendered text and in every string a field carries. Each family reads the shape a secret is actually written in rather than running to the end of the line, so a sentence that merely says "cookie:" keeps its words and an identifier like `pk_customer_reference_index` is left alone, and the key family keeps the prefix that named the secret as every other family keeps its carrier. A field of the record, or a mapping entry at any depth, whose own name is a secret's (`authorization`, `password`, `api_key`, `access_token` and the like, read in any case and with a dash as an underscore) loses its value whatever it holds, judged by the name the call used so a field carried under the `field_` collision prefix is covered too, and a structured content is redacted by name before it is rendered, so the message says exactly what `data` holds even where the secret sat in a nested object or in a number, content JSON refuses and falls back to its `repr` included; a pydantic model or any other object is rendered before the walk exactly as the wire sinks would have rendered it after, and one that refuses to render becomes an `[UNRENDERABLE: …]` marker costing that value alone. Each control character in a field's string values becomes its printable escape so a caller-supplied string cannot forge a line, a field separator or a colour on a terminal; the message and the `data` attribute keep theirs, being the runtime's own rendering, and `data` is the runtime's name alone, a call that passes a field of that name having it carried as `field_data` and escaped like any other. It is installed by `log.install_sink` in front of whatever the sink appended, so every sink is behind it, and it edits the record the root logger shares rather than a copy, so a handler ordered after the sink is behind it too, and a boot that dies before its sink arrives runs it over the records held since `log.configure` before they reach the stdlib's last resort on stderr; `extra_patterns` adds the secret shapes only a deployment knows, and a pattern the `re` module refuses is a configuration error named at load, as is one that matches the empty string, which would replace every line the process writes. The `otlp` sink emits `exception.type` and `exception.stacktrace` and no `exception.message`, so what it exports is the scrubbed text, an exception carrying no traceback rendering as its own last line. A sink processor that raises is now reported on stderr by its type and its name, never by its text, instead of raising out of the log call or going to the stdlib's `handleError`, which prints the exception and the record's raw arguments; a record whose arguments do not fit its format string keeps the scrubbed format string and an `[ARGUMENTS WITHHELD: …]` notice for the same reason, and the redaction processor fails closed, stripping the record to a `[REDACTION FAILED: …]` notice before it reports and dropping the record outright where even that stripping could not complete, as [Logging](tools/logging.md#redaction) describes.
### Changed
diff --git a/docs/configuration/config-practical/logging-config.md b/docs/configuration/config-practical/logging-config.md
index 87914ab2f..826606241 100644
--- a/docs/configuration/config-practical/logging-config.md
+++ b/docs/configuration/config-practical/logging-config.md
@@ -1,5 +1,5 @@
---
-description: "Select where Pipelex log records go with the sink key, and fine-tune logging levels, the console rendering, the JSON and OTLP sinks and message formatting through TOML configuration settings in pipelex.toml."
+description: "Select where Pipelex log records go with the sink key, and fine-tune logging levels, the console rendering, the JSON, OTLP and Google Cloud Logging sinks and message formatting through TOML configuration settings in pipelex.toml."
---
# Logging Configuration
@@ -47,6 +47,7 @@ sink = "console"
- `"console"`: the Rich handler, for a terminal. The default, so the CLI keeps its rendering
- `"json"`: one JSON object per line, for a server behind a log agent
- `"otlp"`: the OpenTelemetry logs signal, for a collector
+- `"gcp"`: Google Cloud Logging through the client library, for a process that must write to it directly
- Any other token an installed plugin registers; a token nobody provides stops the boot naming the registered ones
- The sink is a plugin capability: how it is discovered, selected and written is in [Log Sink Plugins](../../under-the-hood/log-sink-plugins.md)
@@ -219,6 +220,39 @@ headers = { Authorization = "Bearer ..." }
- The semantic-convention keys the sink writes itself — the source location `code.file.path`, `code.function.name` and `code.line.number`, and the `exception.*` keys — are reserved on every record whether or not it carries an exception, exactly as the `json` sink reserves its own keys: a field named like one of them is carried under the same `field_` prefix, so nothing is overwritten and a field keeps one wire name whichever sink is selected
- The sink never exports its own export path: a record the SDK or the transport emits while an export is in flight is rejected before the handler's lock is taken, so an unreachable collector costs a warning on the export thread and never a loop or a hang at exit. A flush at teardown is bounded by the exporter's own timeout, `OTEL_EXPORTER_OTLP_TIMEOUT`, and whatever the sink raises while it flushes or closes is said on stderr rather than left to interrupt the teardown
+## The `gcp` Sink
+
+Configuration section: `[runtime.log.gcp]`, read only when `sink = "gcp"`. The sink writes to Google Cloud Logging through the `google-cloud-logging` client library, which the `gcp-logging` extra installs: `uv pip install "pipelex[gcp-logging]"`. Selecting the sink without the extra stops the boot with the install hint and the `json` alternative named.
+
+### Which of the two to pick
+
+**Most processes on Google Cloud should select `json`, not `gcp`.** Cloud Run, GKE and every platform that runs a logging agent over the container's stdout ingest one JSON object per line with a `severity` and a `message` — exactly what the `json` sink writes — and the lines arrive in Cloud Logging with no client library installed, no credentials to hold and no API call on the logging path. Select `gcp` for the process the agent cannot serve: one with nothing ingesting its stdout, or one that must write to a log name or a project that is not the ambient one.
+
+### Settings
+
+```toml
+[runtime.log.gcp]
+log_name = "pipelex"
+project_id = "my-project"
+credentials_file_path = "gcp_credentials.json"
+```
+
+- `log_name`: the Cloud Logging log the entries land under. Default: `"pipelex"`
+- `project_id`: the project to write to. Left unset, the client library resolves it from the credentials or from the metadata server of the machine the process runs on
+- `credentials_file_path`: a service-account JSON file to build the client from. Left unset, authentication is Application Default Credentials, which is what a process already running on Google Cloud has. This is a plain config value rather than a secret id read through the secrets provider, because the log sink is the first capability boot resolves — deliberately ahead of the secrets provider, so that every later line of the boot goes through the sink the configuration chose — and there is no provider to ask when this section is read
+
+### What each entry carries
+
+Each record becomes one Cloud Logging entry with a JSON payload:
+
+- The level maps onto the Cloud Logging severity scale. That scale has nothing below `DEBUG`, so Pipelex's two custom levels, `VERBOSE` and `DEV`, both land there
+- The payload carries `message`, `logger` and `exception` when the record carries one, then every field and the `data` attribute flat beside them. The keys the `json` sink reserves are reserved here too, `time` and `severity` included although the payload carries neither — the client library takes both out of band — so a field named like one of them is carried under a `field_` prefix under either sink rather than under one and not the other; a value JSON cannot carry — a non-finite float, a model, a circular structure — is written as text rather than costing the line
+- The run-scoped identifiers become the entry's **labels** rather than payload keys: `request_id`, `pipeline_run_id` and `pipe_run_id`, whichever of them the record carries. Cloud Logging indexes labels, so these are what a query filters a run by
+- The entry's `trace` field carries the run's own OpenTelemetry trace id, project-qualified as `projects/<project>/traces/<trace-id>`. The id is derived from `pipeline_run_id` by the same hash the tracer uses, so a line and the spans of the run it belongs to agree on it and Cloud Logging files them together
+- The entries leave through the client library's background-thread transport, which batches them off the thread that logged, so no record costs an API round trip on the calling thread. The teardown flushes and closes it, and the flush carries a deadline of its own because the library's does not
+- What the export path logs never leaves through the sink: the library reports a refused batch through a logger of its own, and a report exported through the pipeline it reports on would fail with it and be reported again. The handler rejects those records, and every record emitted on the library's export thread, before its lock is taken — the same guard the `otlp` sink carries, against the same deadlock at exit
+- A refused write is still said: the library marks a refused batch done, so the flush succeeds and nothing else would report it, and the entries in it are lost. The export path's warnings and errors are printed on stderr instead, the first one in each window of time with its traceback and the ones after it counted in a single line once that window has passed — with the next failure, on the next line the process logs, or at the teardown at the latest — so a process whose credentials Cloud Logging refuses says so without printing once per line it logs
+
## Example Configuration
```toml
@@ -257,6 +291,9 @@ keywords_to_hilight = ["error", "warning", "failed"]
[runtime.log.otlp]
headers = {}
+
+[runtime.log.gcp]
+log_name = "pipelex"
```
## Migrating From the Log Mode
@@ -279,7 +316,7 @@ Two of those keys chose a behaviour their deletion undoes, and no operation in t
2. **Production Environment**:
- - Select the `json` sink behind a log agent, or the `otlp` sink in front of a collector
+ - Select the `json` sink behind a log agent, the `otlp` sink in front of a collector, or the `gcp` sink for a process that must write to Google Cloud Logging directly
- Disable caller info for performance
- Use INFO or higher log levels
diff --git a/docs/under-the-hood/log-sink-plugins.md b/docs/under-the-hood/log-sink-plugins.md
index e0266b363..1b88914de 100644
--- a/docs/under-the-hood/log-sink-plugins.md
+++ b/docs/under-the-hood/log-sink-plugins.md
@@ -1,13 +1,13 @@
---
title: "Log Sink Plugins"
-description: "How Pipelex selects where its log records go by config, the keyed-registry-plus-config-selected-singleton seam a log sink plugin rides, the shipped json, console and otlp sinks, and how to author an out-of-tree sink."
+description: "How Pipelex selects where its log records go by config, the keyed-registry-plus-config-selected-singleton seam a log sink plugin rides, the shipped json, console, otlp and gcp sinks, and how to author an out-of-tree sink."
---
# Log Sink Plugins
Every record the runtime emits, a `log.info(...)` in a pipe operator, a warning from a provider, the failure line of a run, leaves the process through a single **log sink** installed on the root logger at boot. Which sink that is comes entirely from data: one config field, `runtime.log.sink`, names a sink, and a **log sink plugin** is what teaches Pipelex how to build it.
-Core names no sink by import or by string. The built-in sinks (`json`, `console`, `otlp`) are a plugin too, the always-on `LogSinkPlugin`, riding the exact same seam an out-of-tree package would. This page documents that seam, the contract a plugin registers, what a sink reads off a record, and how to write one.
+Core names no sink by import or by string. The built-in sinks (`json`, `console`, `otlp`, `gcp`) are a plugin too, the always-on `LogSinkPlugin`, riding the exact same seam an out-of-tree package would. This page documents that seam, the contract a plugin registers, what a sink reads off a record, and how to write one.
This is the third application of the mechanism the [storage provider](storage-provider-plugins.md) seam introduced and the [secrets provider](secrets-provider-plugins.md) seam reused; the three pages describe the same shape with the nouns swapped, and this one adds what is particular to logging: the sink is resolved after logging is already configured, and every sink shares one record contract.
@@ -99,7 +99,7 @@ Three rules follow for a sink author, and the shipped sinks honour all of them:
- **A sink serializes on emit, synchronously, on the calling thread.** A field's value rides the record by reference, so a value the caller mutates after the call is not what the record said; reading it at emit is what makes the record a faithful account of the call. A sink that queues, the `otlp` sink on its batching exporter for instance, translates the record into its wire form at emit and queues the translation. The `data` attribute needs no such care: it is already a JSON-ready snapshot of the call.
- **A sink renders every record it is handed and never raises.** A value the wire cannot carry is written as text, a JSON rendering for a mapping, a `repr` for what JSON refuses; a serialization failure is a fact about the value, never a reason to lose the line. A handler failure goes through the stdlib's `handleError`, as any handler's does.
-- **A sink reserves the keys it writes itself, on every record.** A carried attribute named like one of them is written under the `COLLIDING_FIELD_PREFIX` — `field_` — applied until the name lands free, which is the same treatment the record gives a field named after a stdlib attribute. Reserved unconditionally, not only when the sink happens to write the key on this record: a field's wire name must not depend on whether an exception was attached, and a field must not survive one sink and vanish on another. The `json` sink reserves `time`, `severity`, `logger`, `message` and `exception`; the `otlp` sink reserves its `code.*` and `exception.*` semantic-convention keys.
+- **A sink reserves the keys it writes itself, on every record.** A carried attribute named like one of them is written under the `COLLIDING_FIELD_PREFIX` — `field_` — applied until the name lands free, which is the same treatment the record gives a field named after a stdlib attribute. Reserved unconditionally, not only when the sink happens to write the key on this record: a field's wire name must not depend on whether an exception was attached, and a field must not survive one sink and vanish on another. The `json` sink reserves `time`, `severity`, `logger`, `message` and `exception`; the `gcp` sink reserves that same set even though only `message`, `logger` and `exception` are payload keys there, the client library carrying the time and the severity out of band, so a field named like one of them is prefixed under either sink rather than under one only; the `otlp` sink reserves its `code.*` and `exception.*` semantic-convention keys.
---
@@ -116,6 +116,7 @@ class LogSinkPlugin:
registrar.add_log_sink(method=LogSinkMethod.JSON, factory=_make_json_log_sink)
registrar.add_log_sink(method=LogSinkMethod.CONSOLE, factory=_make_console_log_sink)
registrar.add_log_sink(method=LogSinkMethod.OTLP, factory=_make_otlp_log_sink)
+ registrar.add_log_sink(method=LogSinkMethod.GCP, factory=_make_gcp_log_sink)
```
| Sink | What it does | Where it reads its settings |
@@ -123,8 +124,9 @@ class LogSinkPlugin:
| `json` | One JSON object per line on the configured stream: `time`, `severity`, `logger`, `message`, `exception` when there is one, then the fields, the context identifiers and `data` flat beside them, a field named like one of those keys under a `field_` prefix on every line, a non-finite float as the string `"NaN"`, `"Infinity"` or `"-Infinity"`. The key names are the ones the CloudWatch agent, the Google Cloud Logging agent and any OTLP collector ingest without a parser, and no ANSI ever. What the hosted plane's runner and worker select. | `console_log_target` |
| `console` | The Rich handler with the emoji formatter and every `[runtime.log.rich_log]` setting, byte for byte what the console showed before sinks existed. Rich is imported when the handler is built, and a process that selects another sink never loads it through this path. | `console_log_target`, `[runtime.log.rich_log]` |
| `otlp` | The OpenTelemetry logs signal: a `LoggerProvider` carrying the same service identity as the tracer, a `BatchLogRecordProcessor` and the OTLP HTTP log exporter. The message is the body, the level maps onto the OTel severity scale, the fields, identifiers and `data` ride as attributes (a mapping as JSON text), an exception lands under the `exception.*` semantic-convention keys, and a collector receives the logs beside the spans the runtime already exports. The keys the sink writes itself, the `code.*` source location and the `exception.*` set, are reserved on every record whether or not it carries an exception, so a field named like one of them rides under a `field_` prefix rather than being overwritten. A filter on the handler rejects the records of the sink's own export path, the SDK's by logger name and the transport's by the context value the SDK sets around an export, before the handler's lock is taken, so an export failure never re-enters the pipeline and a shutdown never waits on itself. | `[runtime.log.otlp]` |
+| `gcp` | Google Cloud Logging through the `google-cloud-logging` client library, behind the `gcp-logging` extra. Each record becomes one struct entry: the level maps onto the Cloud Logging severity scale (which has nothing below `DEBUG`, so `VERBOSE` and `DEV` both land there), the message, the logger, the exception and the fields become the JSON payload, the run-scoped identifiers become the entry's labels, which is what Cloud Logging indexes, and the entry's `trace` field carries the run's own OpenTelemetry trace id project-qualified, derived from `pipeline_run_id` by the same hash the tracer uses, so a line and the spans of its run agree on it. The entries leave through the client library's background-thread transport, which batches them off the calling thread. **Most processes on Google Cloud want `json` instead**: a platform whose logging agent reads the container's stdout, Cloud Run and GKE among them, ingests what that sink writes and needs no client at all; `gcp` is for a process with no such agent in front of it, or one writing to a log or a project that is not the ambient one. | `[runtime.log.gcp]` |
-The `otlp` factory imports the OpenTelemetry logs SDK when it runs, never at register, so registering the built-ins imports none of it, which the import-light guard pins.
+The `otlp` factory imports the OpenTelemetry logs SDK when it runs, and the `gcp` factory the Google Cloud Logging client library, never at register, so registering the built-ins imports neither, which the import-light guard pins.
### Why `console` is the default
@@ -134,7 +136,7 @@ The `otlp` factory imports the OpenTelemetry logs SDK when it runs, never at reg
## Selecting a sink by config
-`runtime.log.sink` is an **open `str` token**, not a closed enum. The built-ins use `"json"`, `"console"` and `"otlp"`; an external plugin registers its own. A config naming an external token **parses fine**, the token is stored verbatim and its installability is validated later, at registry lookup:
+`runtime.log.sink` is an **open `str` token**, not a closed enum. The built-ins use `"json"`, `"console"`, `"otlp"` and `"gcp"`; an external plugin registers its own. A config naming an external token **parses fine**, the token is stored verbatim and its installability is validated later, at registry lookup:
```toml
# .pipelex/pipelex.toml
diff --git a/pipelex/migration/goldens/pipelex-config/[email protected] b/pipelex/migration/goldens/pipelex-config/[email protected]
index 6140d1296..8d5b60c54 100644
--- a/pipelex/migration/goldens/pipelex-config/[email protected]
+++ b/pipelex/migration/goldens/pipelex-config/[email protected]
@@ -39,9 +39,10 @@ method = "env" # env (built-in); an external plugin may add e.g. vault
default_log_level = "INFO"
# sink names the registered log sink boot installs on the root logger, the way runtime.storage.method
# names a storage backend: "console" (the Rich handler, for a terminal), "json" (one JSON object per
-# line, for a server behind a log agent), "otlp" (the OpenTelemetry logs signal, for a collector), or a
-# token an installed plugin registers. "console" is the default so the CLI keeps its rendering; a
-# server selects "json". An unregistered token stops the boot naming the registered ones.
+# line, for a server behind a log agent), "otlp" (the OpenTelemetry logs signal, for a collector),
+# "gcp" (Google Cloud Logging through the client library), or a token an installed plugin registers.
+# "console" is the default so the CLI keeps its rendering; a server selects "json". An unregistered
+# token stops the boot naming the registered ones.
sink = "console"
# console_log_target controls the stream the console and json sinks write to (log.debug/info/...).
# Logs are diagnostics → stderr.
@@ -105,6 +106,16 @@ keywords_to_hilight = []
[runtime.log.otlp]
headers = {}
+# The settings of the "gcp" sink, which writes to Google Cloud Logging through the client library.
+# Most processes want "json" instead: a platform that runs a logging agent over the container's
+# stdout, Cloud Run and GKE among them, ingests the JSON objects that sink writes and needs no client
+# at all. Select "gcp" for a process that must write to Cloud Logging directly. log_name is the
+# Cloud Logging log the entries land under. A project_id key names the project when it is not the
+# ambient one the credentials or the metadata server declare, and a credentials_file_path key names a
+# service-account JSON file when Application Default Credentials are not what the process should use.
+[runtime.log.gcp]
+log_name = "pipelex"
+
# [runtime.log.redaction] governs the one processor every sink is behind: it scrubs the secret shapes
# the workspace already knows (an Authorization bearer token, an api-key or signature header, an OAuth
# code parameter, a cookie, a JSON secret entry, and the sk_ / plx_sk_ / pk_ / bl_ key prefixes) out of
diff --git a/pipelex/migration/goldens/pipelex-config/[email protected] b/pipelex/migration/goldens/pipelex-config/[email protected]
index 7eebe7542..94a2f350f 100644
--- a/pipelex/migration/goldens/pipelex-config/[email protected]
+++ b/pipelex/migration/goldens/pipelex-config/[email protected]
@@ -1044,6 +1044,27 @@
"default": "INFO",
"open_node": false
},
+ "runtime.log.gcp": {
+ "value_type": "table",
+ "required": true,
+ "open_node": false
+ },
+ "runtime.log.gcp.credentials_file_path": {
+ "value_type": "str",
+ "required": false,
+ "open_node": false
+ },
+ "runtime.log.gcp.log_name": {
+ "value_type": "str",
+ "required": true,
+ "default": "pipelex",
+ "open_node": false
+ },
+ "runtime.log.gcp.project_id": {
+ "value_type": "str",
+ "required": false,
+ "open_node": false
+ },
"runtime.log.is_caller_info_enabled": {
"value_type": "bool",
"required": true,
diff --git a/pipelex/pipelex.toml b/pipelex/pipelex.toml
index 6140d1296..8d5b60c54 100644
--- a/pipelex/pipelex.toml
+++ b/pipelex/pipelex.toml
@@ -39,9 +39,10 @@ method = "env" # env (built-in); an external plugin may add e.g. vault
default_log_level = "INFO"
# sink names the registered log sink boot installs on the root logger, the way runtime.storage.method
# names a storage backend: "console" (the Rich handler, for a terminal), "json" (one JSON object per
-# line, for a server behind a log agent), "otlp" (the OpenTelemetry logs signal, for a collector), or a
-# token an installed plugin registers. "console" is the default so the CLI keeps its rendering; a
-# server selects "json". An unregistered token stops the boot naming the registered ones.
+# line, for a server behind a log agent), "otlp" (the OpenTelemetry logs signal, for a collector),
+# "gcp" (Google Cloud Logging through the client library), or a token an installed plugin registers.
+# "console" is the default so the CLI keeps its rendering; a server selects "json". An unregistered
+# token stops the boot naming the registered ones.
sink = "console"
# console_log_target controls the stream the console and json sinks write to (log.debug/info/...).
# Logs are diagnostics → stderr.
@@ -105,6 +106,16 @@ keywords_to_hilight = []
[runtime.log.otlp]
headers = {}
+# The settings of the "gcp" sink, which writes to Google Cloud Logging through the client library.
+# Most processes want "json" instead: a platform that runs a logging agent over the container's
+# stdout, Cloud Run and GKE among them, ingests the JSON objects that sink writes and needs no client
+# at all. Select "gcp" for a process that must write to Cloud Logging directly. log_name is the
+# Cloud Logging log the entries land under. A project_id key names the project when it is not the
+# ambient one the credentials or the metadata server declare, and a credentials_file_path key names a
+# service-account JSON file when Application Default Credentials are not what the process should use.
+[runtime.log.gcp]
+log_name = "pipelex"
+
# [runtime.log.redaction] governs the one processor every sink is behind: it scrubs the secret shapes
# the workspace already knows (an Authorization bearer token, an api-key or signature header, an OAuth
# code parameter, a cookie, a JSON secret entry, and the sk_ / plx_sk_ / pk_ / bl_ key prefixes) out of
diff --git a/pipelex/plugins/log_sink_registry.py b/pipelex/plugins/log_sink_registry.py
index 0b571ae7d..55dc47aa4 100644
--- a/pipelex/plugins/log_sink_registry.py
+++ b/pipelex/plugins/log_sink_registry.py
@@ -15,7 +15,7 @@ class LogSinkRegistry:
"""Read view over the log-sink factories contributed by discovered plugins.
Keyed by the open sink ``method`` token (a ``str``; the built-in ``LogSinkPlugin`` registers the
- ``LogSinkMethod`` values, an external plugin registers e.g. ``"gcp"``). Built once at boot from the
+ ``LogSinkMethod`` values, an external plugin registers e.g. ``"syslog"``). Built once at boot from the
registrar's accumulated ``log_sinks``; boot reads ``runtime.log.sink`` and calls the looked-up
factory to produce the one sink installed on the root logger. Mirrors ``StorageProviderRegistry``.
"""
diff --git a/pipelex/providers/log_sinks/log_sink_plugin.py b/pipelex/providers/log_sinks/log_sink_plugin.py
index 6d695f31a..6f7df28c3 100644
--- a/pipelex/providers/log_sinks/log_sink_plugin.py
+++ b/pipelex/providers/log_sinks/log_sink_plugin.py
@@ -3,6 +3,7 @@ from pipelex.plugins.registrar import PluginRegistrar
from pipelex.system.runtime import RunEnvironment
from pipelex.system.telemetry.otel_constants import OTelConstants
from pipelex.tools.log.console_log_sink import ConsoleLogSink
+from pipelex.tools.log.gcp_log_sink import make_gcp_log_sink
from pipelex.tools.log.json_log_sink import JsonLogSink
from pipelex.tools.log.log_config import LogConfig
from pipelex.tools.log.log_sink import LogSink, LogSinkMethod, stream_for_target
@@ -45,14 +46,22 @@ def _make_otlp_log_sink(config: LogConfig) -> LogSink:
return OtlpLogSink(processor=BatchLogRecordProcessor(exporter), resource=resource)
+def _make_gcp_log_sink(config: LogConfig) -> LogSink:
+ # Deferred import: the Google Cloud Logging client library loads inside ``make_gcp_log_sink``,
+ # when this factory runs, so registering the built-ins imports none of it and a process on
+ # another sink never pays for it. A missing extra fails there, loud, with the install hint.
+ return make_gcp_log_sink(config=config.gcp)
+
+
class LogSinkPlugin:
- """Always-on built-in provider of the ``json`` / ``console`` / ``otlp`` log sinks.
+ """Always-on built-in provider of the ``json`` / ``console`` / ``otlp`` / ``gcp`` log sinks.
Core-unconditional: a process needs somewhere for its records to go, so this plugin cannot be
disabled into a boot with no sink (see ``KERNEL_CORE_UNCONDITIONAL_PLUGIN_NAMES``). It registers
one factory per built-in method; ``runtime.log.sink`` selects which one boot invokes. Importing
- this module is import-light: Rich loads when the console sink builds its handler, and the
- OpenTelemetry SDK when the ``otlp`` factory runs, never at register.
+ this module is import-light: Rich loads when the console sink builds its handler, the
+ OpenTelemetry SDK when the ``otlp`` factory runs, and the Google Cloud Logging client library
+ when the ``gcp`` factory runs, never at register.
"""
name = "log_sinks"
@@ -62,3 +71,4 @@ class LogSinkPlugin:
registrar.add_log_sink(method=LogSinkMethod.JSON, factory=_make_json_log_sink)
registrar.add_log_sink(method=LogSinkMethod.CONSOLE, factory=_make_console_log_sink)
registrar.add_log_sink(method=LogSinkMethod.OTLP, factory=_make_otlp_log_sink)
+ registrar.add_log_sink(method=LogSinkMethod.GCP, factory=_make_gcp_log_sink)
diff --git a/pipelex/tools/log/gcp_log_sink.py b/pipelex/tools/log/gcp_log_sink.py
new file mode 100644
index 000000000..8ad03c6e4
--- /dev/null
+++ b/pipelex/tools/log/gcp_log_sink.py
@@ -0,0 +1,439 @@
+"""The ``gcp`` sink: Google Cloud Logging through the client library, one ``LogEntry`` per record.
+
+Each record becomes one struct entry: the level maps onto the Cloud Logging severity scale, the
+message and the call's fields become the JSON payload, the run-scoped identifiers become labels, and
+the run's OpenTelemetry trace id becomes the entry's ``trace`` field, so Cloud Logging files the line
+under the same trace as the spans the runtime exports. The entries leave through the client library's
+transport, a batching background thread in production, so no record costs an API round trip on the
+thread that logged it. What that thread itself logs never leaves through the sink: the library reports
+a refused batch through a logger of its own, and a report exported through the pipeline it reports on
+fails with it and is reported again, so the handler rejects the export path before its lock is taken.
+
+**Most processes should not select this sink.** A process on Cloud Run, on GKE, or on any platform
+whose logging agent reads the container's stdout needs no client at all: the agent ingests one JSON
+object per line with a ``severity`` and a ``message``, which is exactly what the ``json`` sink emits,
+and the entries arrive in Cloud Logging with none of this sink's dependencies installed. Select
+``gcp`` for a process that must write to Cloud Logging directly — one with no ingesting agent in
+front of it, or one writing to a log or a project that is not the ambient one.
+
+The client library is imported when the sink is built and nowhere else in this module, so a process
+on another sink never loads it, and one selecting this sink without the extra fails at boot with
+``MissingDependencyError`` naming ``pipelex[gcp-logging]``.
+"""
+
+from __future__ import annotations
+
+import json
+import logging
+import math
+import threading
+import time
+from enum import StrEnum
+from typing import TYPE_CHECKING, Any, Protocol, cast
+
+from typing_extensions import override
+
+from pipelex.system.exceptions import MissingDependencyError
+from pipelex.tools.log.json_log_sink import EXCEPTION_KEY, FIXED_KEYS, LOGGER_KEY, MESSAGE_KEY
+from pipelex.tools.log.log_context import PIPE_RUN_ID_FIELD, PIPELINE_RUN_ID_FIELD, REQUEST_ID_FIELD
+from pipelex.tools.log.log_fields import COLLIDING_FIELD_PREFIX, carried_attributes
+from pipelex.tools.log.log_sink import LogSink, LogSinkMethod, render_json
+from pipelex.tools.misc.hash_utils import hash_md5_to_int
+
+if TYPE_CHECKING:
+ from pipelex.tools.log.log_config import GcpLogSinkConfig
+
+# The dependency the ``gcp-logging`` extra installs, and the extra's own name, as the install hint spells them.
+GCP_LOGGING_DEPENDENCY_NAME = "google-cloud-logging"
+GCP_LOGGING_EXTRA_NAME = "gcp-logging"
+
+# The sink writes three of the ``json`` sink's keys into the payload — its ``message``, ``logger`` and
+# ``exception``, imported rather than respelled — and reserves that sink's whole set against a carried
+# attribute, so one field keeps one wire name whichever of the two a process selects. ``time`` and
+# ``severity`` are not payload keys here, the client library carrying both out of band, but a field
+# named like one is ``field_time`` and ``field_severity`` under either sink rather than under one only.
+FIXED_PAYLOAD_KEYS = FIXED_KEYS
+
+# The stdlib formatter the ``json`` sink renders a traceback through, so both sinks spell one exception
+# the same way: the trailing newline stripped, and the stdlib's own placeholder for the
+# ``(None, None, None)`` triple a caller logging outside an ``except`` block produces.
+_EXCEPTION_FORMATTER = logging.Formatter()
+
+# The record attributes that become entry labels rather than payload keys: the run-scoped identifiers
+# the log context binds. Cloud Logging indexes labels, so these are what a query filters a run by.
+LABEL_ATTRIBUTES = (REQUEST_ID_FIELD, PIPELINE_RUN_ID_FIELD, PIPE_RUN_ID_FIELD)
+
+# The client library's own logging loggers, and the name its transport gives the thread that exports.
+# A record from either must not travel out through the sink that emitted it.
+GCP_LOGGING_LOGGER_PREFIXES = ("google.cloud.logging", "google.cloud.logging_v2")
+GCP_WORKER_THREAD_NAME = "google.cloud.logging.Worker"
+
+# How often an export failure is printed on stderr. The library reports a refused batch once per failed
+# commit and never retries it, so a refusal that persists — a missing permission, a revoked key — reports
+# at the rate the application logs. The first report in a window is printed with its traceback, and the
+# ones after it are counted and said in one line once the window has passed: with the next report, on
+# the next record the handler sees, or when the handler closes, whichever comes first. The OpenTelemetry SDK
+# deduplicates its own exporter's failures over the same window.
+EXPORT_FAILURE_REPORT_INTERVAL_SECONDS = 20.0
+
+# The deadline a flush waits for the transport's queue to drain. The client library's ``flush`` ends in
+# ``queue.join()``, which waits unbounded and takes no timeout, so the bound is imposed here rather
+# than passed: the drain runs on a thread of its own and the join is what carries the deadline. What is
+# still queued when it expires leaves through ``close``, whose grace period the library bounds itself.
+FLUSH_TIMEOUT_SECONDS = 5.0
+_FLUSH_THREAD_NAME = "pipelex-gcp-log-flush"
+
+
+class GcpLogSeverity(StrEnum):
+ """The Cloud Logging severities this sink writes. The API takes the name and uppercases it."""
+
+ DEBUG = "DEBUG"
+ INFO = "INFO"
+ WARNING = "WARNING"
+ ERROR = "ERROR"
+ CRITICAL = "CRITICAL"
+
+
+class GcpLogTransport(Protocol):
+ """What this sink needs of a Cloud Logging transport: send one entry, flush, close.
+
+ Declared here rather than imported from the client library, so this module loads without the
+ library installed and so the sink's own call sites are typed. ``send`` keeps the library's
+ positional signature because it is the library's shape and not ours to choose: the shipped
+ implementation *is* its ``BackgroundThreadTransport``, and a test substitutes a capture.
+ """
+
+ def send( # kw-only: ignore — the client library's own ``Transport.send`` signature, not ours to choose
+ self,
+ record: logging.LogRecord,
+ message: dict[str, Any],
+ **kwargs: Any,
+ ) -> None: ...
+
+ def flush(self) -> None: ...
+
+ def close(self) -> None: ...
+
+
+class GcpExportPathFilter(logging.Filter):
+ """Rejects the records the sink's own export path emits, before the handler's lock is taken.
+
+ Two guards. The client library's logging loggers are named ``google.cloud.logging*`` and are
+ rejected by name: its transport reports a failed batch through one of them, at ``ERROR``, and
+ nothing sets ``propagate = False`` on it — the library does that in its own ``setup_logging``,
+ which this sink deliberately does not call. Left to reach the handler, that report becomes an entry,
+ fails with the batch it reports on, and is reported again, forever. The second guard rejects every
+ record emitted on the transport's background thread, whatever its logger is called, which is what
+ catches the layers beneath: the auth stack and the HTTP or gRPC client log under their own names
+ and only ever reach this handler from that thread, the transport's ``send`` being the one call the
+ sink makes and the export being the one thing that thread does. Both names are the library's own,
+ and the tests against the installed library are what pin them.
+
+ A filter rather than a check inside ``emit``, because ``Handler.handle`` runs the filters before it
+ takes the handler's lock and ``emit`` after. The ``otlp`` sink carries the same design for the same
+ reason: an exporting thread blocking on that lock to report its own failure while the teardown holds
+ it and waits for the queue to drain is a deadlock at exit, and it was reproduced here with the
+ installed library.
+
+ A rejected record at ``WARNING`` or above is printed on stderr through the stdlib's last-resort
+ handler rather than dropped. The library reports a refused batch only through that record and then
+ marks the batch done, so a flush still succeeds, and the stdlib prints a record through its last
+ resort only when no handler is found, which the sink's handler always is: without this, a process
+ whose writes Cloud Logging refuses would lose every line and say nothing anywhere. The last resort
+ takes its own lock and never this handler's, so the report cannot reintroduce the deadlock, and the
+ reports are rate-limited by ``EXPORT_FAILURE_REPORT_INTERVAL_SECONDS``.
+ """
+
+ def __init__(self, *, report_interval_seconds: float = EXPORT_FAILURE_REPORT_INTERVAL_SECONDS) -> None:
+ super().__init__()
+ self._report_interval_seconds = report_interval_seconds
+ self._report_lock = threading.Lock()
+ self._last_report_at: float | None = None
+ self._unreported_count = 0
+
+ @override
+ def filter(self, record: logging.LogRecord) -> bool:
+ if not self._is_export_path(record=record):
+ # Read outside the lock, which keeps an ordinary record's cost to this one read: a count it
+ # misses is said on a later record, or when the handler closes.
+ if self._unreported_count:
+ self._report_count_once_its_window_has_passed()
+ return True
+ if record.levelno >= logging.WARNING:
+ self._report_on_stderr(record=record)
+ return False
+
+ def report_unreported(self) -> None:
+ """Print the failures counted and not yet printed, whatever the window: the handler's last word at close."""
+ with self._report_lock:
+ unreported_count = self._unreported_count
+ self._unreported_count = 0
+ self._print_unreported_count(unreported_count=unreported_count)
+
+ @classmethod
+ def _is_export_path(cls, *, record: logging.LogRecord) -> bool:
+ if threading.current_thread().name == GCP_WORKER_THREAD_NAME:
+ return True
+ return any(record.name == prefix or record.name.startswith(f"{prefix}.") for prefix in GCP_LOGGING_LOGGER_PREFIXES)
+
+ def _report_on_stderr(self, *, record: logging.LogRecord) -> None:
+ """Print the export path's report through the last resort, the first one per window in full."""
+ now = time.monotonic()
+ with self._report_lock:
+ if self._window_is_open(now=now):
+ self._unreported_count += 1
+ return
+ self._last_report_at = now
+ unreported_count = self._unreported_count
+ self._unreported_count = 0
+ self._print_unreported_count(unreported_count=unreported_count)
+ stderr_handler = logging.lastResort
+ if stderr_handler is not None:
+ stderr_handler.handle(record)
+
+ def _report_count_once_its_window_has_passed(self) -> None:
+ """Print the count an outage that has ended left behind, since no later failure comes to print it.
+
+ The window is left as it is: the count is one line, and a failure arriving next is still printed
+ in full rather than counted.
+ """
+ with self._report_lock:
+ if self._window_is_open(now=time.monotonic()):
+ return
+ unreported_count = self._unreported_count
+ self._unreported_count = 0
+ self._print_unreported_count(unreported_count=unreported_count)
+
+ def _window_is_open(self, *, now: float) -> bool:
+ return self._last_report_at is not None and now - self._last_report_at < self._report_interval_seconds
+
+ @classmethod
+ def _print_unreported_count(cls, *, unreported_count: int) -> None:
+ stderr_handler = logging.lastResort
+ if not unreported_count or stderr_handler is None:
+ return
+ stderr_handler.handle(
+ logging.makeLogRecord(
+ {
+ "name": __name__,
+ "levelno": logging.WARNING,
+ "levelname": logging.getLevelName(logging.WARNING),
+ "msg": "The gcp log sink's transport reported %d more export failures since the last one printed",
+ "args": (unreported_count,),
+ }
+ )
+ )
+
+
+def severity_for_level(*, levelno: int) -> GcpLogSeverity:
+ """The Cloud Logging severity for a stdlib level.
+
+ Cloud Logging's scale is coarser than ours and has nothing below ``DEBUG``, so both of our custom
+ levels land there: ``VERBOSE`` and ``DEV`` sit below ``INFO``, which is the whole of what the
+ severity can say about them.
+ """
+ if levelno < logging.INFO:
+ return GcpLogSeverity.DEBUG
+ if levelno < logging.WARNING:
+ return GcpLogSeverity.INFO
+ if levelno < logging.ERROR:
+ return GcpLogSeverity.WARNING
+ if levelno < logging.CRITICAL:
+ return GcpLogSeverity.ERROR
+ return GcpLogSeverity.CRITICAL
+
+
+def trace_name_for_run(*, project: str, pipeline_run_id: str) -> str:
+ """The fully qualified Cloud Logging trace name for one pipeline run.
+
+ The trace id is derived from the pipeline run id exactly as the tracer derives it, by the same
+ hash, so a line and the spans of the run it belongs to carry one id without either having to
+ reach the other. Cloud Logging wants that id project-qualified and as 32 hex digits.
+ """
+ return f"projects/{project}/traces/{hash_md5_to_int(pipeline_run_id):032x}"
+
+
+def _payload_value(*, value: Any) -> Any:
+ """The value as a Cloud Logging struct payload can carry it.
+
+ A string, a bool, an int, a finite float and ``None`` ride as they are. Everything else — a
+ mapping, a sequence, a model, a non-finite float, an object JSON refuses outright — goes through
+ the wire renderer and comes back as whatever JSON made of it, so the payload is always something
+ the client library can turn into a protobuf value and a serialization failure never costs the line.
+ """
+ if value is None or isinstance(value, (str, bool, int)):
+ return value
+ if isinstance(value, float) and math.isfinite(value):
+ return value
+ return json.loads(render_json(value=value))
+
+
+def _exception_text(*, record: logging.LogRecord) -> str | None:
+ """The record's exception as text, spelled as the ``json`` sink spells it, or ``None`` when it carries none.
+
+ The rendering goes through the stdlib formatter rather than through ``traceback`` directly, so the
+ two sinks cannot disagree about a traceback's trailing newline or about what an ``exc_info`` of
+ ``(None, None, None)`` means — a triple ``logging.error(msg, exc_info=True)`` builds when a caller
+ outside an ``except`` block asks for one, which a foreign library does.
+ """
+ if record.exc_info:
+ return record.exc_text or _EXCEPTION_FORMATTER.formatException(record.exc_info)
+ if record.exc_text:
+ return record.exc_text
+ return None
+
+
+def _entry_payload(*, record: logging.LogRecord) -> dict[str, Any]:
+ """The struct payload for one record: the message, the logger, the exception, then the fields.
+
+ The run-scoped identifiers are left out: they are the entry's labels. Everything else the call,
+ the record factory or the structured content attached rides flat beside the fixed keys, under a
+ ``field_`` prefix when its name is one of them.
+ """
+ payload: dict[str, Any] = {
+ MESSAGE_KEY: record.getMessage(),
+ LOGGER_KEY: record.name,
+ }
+ exception_text = _exception_text(record=record)
+ if exception_text is not None:
+ payload[EXCEPTION_KEY] = exception_text
+ for name, value in carried_attributes(record=record).items():
+ if name in LABEL_ATTRIBUTES:
+ continue
+ key = name
+ while key in payload or key in FIXED_PAYLOAD_KEYS:
+ key = f"{COLLIDING_FIELD_PREFIX}{key}"
+ payload[key] = _payload_value(value=value)
+ return payload
+
+
+def _entry_labels(*, record: logging.LogRecord) -> dict[str, str]:
+ """The entry's labels: the run-scoped identifiers the record carries, as text, and only the ones it has."""
+ labels: dict[str, str] = {}
+ for name in LABEL_ATTRIBUTES:
+ value = getattr(record, name, None)
+ if value is not None:
+ labels[name] = value if isinstance(value, str) else str(value)
+ return labels
+
+
+class GcpLogHandler(logging.Handler):
+ """Translates each stdlib record into one Cloud Logging entry and hands it to the transport."""
+
+ def __init__(self, *, transport: GcpLogTransport, project: str) -> None:
+ super().__init__(level=logging.NOTSET)
+ self._transport = transport
+ self._project = project
+ self._export_path_filter = GcpExportPathFilter()
+ self.addFilter(self._export_path_filter)
+
+ @override
+ def emit(self, record: logging.LogRecord) -> None:
+ try:
+ pipeline_run_id = getattr(record, PIPELINE_RUN_ID_FIELD, None)
+ trace = trace_name_for_run(project=self._project, pipeline_run_id=pipeline_run_id) if isinstance(pipeline_run_id, str) else None
+ self._transport.send(
+ record,
+ _entry_payload(record=record),
+ severity=severity_for_level(levelno=record.levelno).value,
+ labels=_entry_labels(record=record),
+ trace=trace,
+ )
+ except Exception: # ruff: ignore[blind-except]
+ # Unbounded code: a third-party SDK with no documented exception types, over values the caller attached.
+ # The stdlib's own contract for a handler is to report through ``handleError`` and never raise
+ # out of the log call.
+ self.handleError(record)
+
+ @override
+ def flush(self) -> None:
+ """Waits for the transport's queue to drain, and never longer than ``FLUSH_TIMEOUT_SECONDS``.
+
+ The library's own flush waits on the queue with no deadline, and the teardown that calls it runs
+ in a ``finally``: a batch the API is refusing, or an export the network is holding, would keep
+ the process alive with no way out. The drain is given a thread so the join can carry the bound,
+ and a failure it raises is re-raised here so the teardown still reports it.
+ """
+ failure: list[Exception] = []
+
+ def drain() -> None:
+ try:
+ self._transport.flush()
+ except Exception as exc: # ruff: ignore[blind-except]
+ # Unbounded code: the client library's flush, a third-party SDK with no documented exception types.
+ # Nothing is swallowed: the failure crosses to the caller's thread and is raised there.
+ failure.append(exc)
+
+ flushing = threading.Thread(target=drain, name=_FLUSH_THREAD_NAME, daemon=True)
+ flushing.start()
+ flushing.join(timeout=FLUSH_TIMEOUT_SECONDS)
+ if failure:
+ raise failure[0]
+
+ @override
+ def close(self) -> None:
+ """Closes the transport, then prints the export failures still counted.
+
+ In that order, because the close drains the queue and a refusal met there is counted too.
+ """
+ self._transport.close()
+ self._export_path_filter.report_unreported()
+ super().close()
+
+
+class GcpLogSink(LogSink):
+ """Google Cloud Logging behind one transport, a batching background thread in production.
+
+ The transport and the project are resolved before the sink is built, so the sink itself imports
+ nothing and a test builds it around a capture.
+ """
+
+ def __init__(self, *, transport: GcpLogTransport, project: str) -> None:
+ super().__init__()
+ self._transport = transport
+ self._project = project
+
+ @override
+ def make_handler(self) -> logging.Handler:
+ return GcpLogHandler(transport=self._transport, project=self._project)
+
+
+def make_gcp_log_sink(*, config: GcpLogSinkConfig) -> GcpLogSink:
+ """Build the sink that writes to Cloud Logging through the client library's background thread.
+
+ Where the dependency is paid for: the client library is imported here, so a process that selected
+ another sink never loads it, and one that selected this sink without the extra fails here, at
+ boot, with the extra and the ``json`` alternative named.
+
+ Raises:
+ MissingDependencyError: If ``google-cloud-logging`` is not installed.
+
+ """
+ try:
+ from google.cloud import logging as cloud_logging # ruff: ignore[import-outside-top-level]
+ from google.cloud.logging_v2.handlers.transports import ( # ruff: ignore[import-outside-top-level]
+ BackgroundThreadTransport,
+ )
+ except ImportError as exc:
+ msg = (
+ f"The '{LogSinkMethod.GCP}' log sink writes to Google Cloud Logging through the client library. "
+ f"Install the extra, or select the '{LogSinkMethod.JSON}' sink in [runtime.log]: a process whose "
+ "platform runs a logging agent over its stdout, on Cloud Run or on GKE, needs no client at all, "
+ "because that agent ingests the JSON objects that sink writes."
+ )
+ raise MissingDependencyError(
+ dependency_name=GCP_LOGGING_DEPENDENCY_NAME,
+ extra_name=GCP_LOGGING_EXTRA_NAME,
+ message=msg,
+ ) from exc
+
+ client: Any
+ if config.credentials_file_path is not None:
+ client = cloud_logging.Client.from_service_account_json( # pyright: ignore[reportUnknownMemberType]
+ config.credentials_file_path,
+ project=config.project_id,
+ )
+ else:
+ client = cloud_logging.Client(project=config.project_id)
+ transport = cast("GcpLogTransport", BackgroundThreadTransport(client, config.log_name))
+ return GcpLogSink(transport=transport, project=str(client.project))
diff --git a/pipelex/tools/log/log_config.py b/pipelex/tools/log/log_config.py
index d42123b1b..5b98b3ebe 100644
--- a/pipelex/tools/log/log_config.py
+++ b/pipelex/tools/log/log_config.py
@@ -77,6 +77,26 @@ class OtlpLogSinkConfig(ConfigModel):
headers: dict[str, str]
+class GcpLogSinkConfig(ConfigModel):
+ """The settings of the ``gcp`` sink.
+
+ ``log_name`` is the Cloud Logging log the entries land under. An absent ``project_id`` leaves the
+ project to the client library, which reads it from the credentials or from the metadata server of
+ the machine the process runs on. An absent ``credentials_file_path`` leaves authentication to
+ Application Default Credentials, which is what a process already running on Google Cloud has; a
+ path names a service-account JSON file to build the client from instead.
+
+ The path is a plain config value rather than a secret id resolved through the secrets provider,
+ because the log sink is the first capability boot resolves — ahead of the secrets provider, so
+ that every later line of the boot goes through the sink the configuration chose — and there is no
+ provider on the hub to ask at the moment this section is read.
+ """
+
+ log_name: str
+ project_id: str | None = None
+ credentials_file_path: str | None = None
+
+
class LogRedactionConfig(ConfigModel):
"""What the redaction processor removes from a record before any sink renders it.
@@ -133,6 +153,7 @@ class LogConfig(ConfigModel):
redaction: LogRedactionConfig
rich_log: RichLogConfig
otlp: OtlpLogSinkConfig
+ gcp: GcpLogSinkConfig
@field_validator("package_log_levels", mode="before")
@classmethod
diff --git a/pipelex/tools/log/log_sink.py b/pipelex/tools/log/log_sink.py
index 44841cbb4..72d13d5a8 100644
--- a/pipelex/tools/log/log_sink.py
+++ b/pipelex/tools/log/log_sink.py
@@ -3,9 +3,9 @@
A sink owns one stdlib handler on the root logger and everything about how a record leaves the
process: the stream, the wire shape, the exporter. Which sink a process runs is a registrar
capability selected by ``[runtime.log] sink``, exactly as the storage and secrets providers are: the
-built-in plugin registers ``json``, ``console`` and ``otlp`` under open string tokens, and an external
-plugin registers its own. This module holds what every sink shares, the base class with its processor
-slot and the stream resolution, and names no sink.
+built-in plugin registers ``json``, ``console``, ``otlp`` and ``gcp`` under open string tokens, and an
+external plugin registers its own. This module holds what every sink shares, the base class with its
+processor slot and the stream resolution, and names no sink.
"""
from __future__ import annotations
@@ -52,6 +52,7 @@ class LogSinkMethod(StrEnum):
JSON = "json"
CONSOLE = "console"
OTLP = "otlp"
+ GCP = "gcp"
class ProcessorFilter(logging.Filter):
diff --git a/pipelex/tools/storage/gcp_storage_provider.py b/pipelex/tools/storage/gcp_storage_provider.py
index ed76ef938..4abc446a0 100644
--- a/pipelex/tools/storage/gcp_storage_provider.py
+++ b/pipelex/tools/storage/gcp_storage_provider.py
@@ -67,7 +67,7 @@ class GcpStorageProvider(StorageProviderAbstract):
msg,
)
- from google.cloud import storage # type: ignore[import-untyped] # ruff: ignore[import-outside-top-level]
+ from google.cloud import storage # type: ignore[import-untyped, attr-defined] # ruff: ignore[import-outside-top-level]
credentials_path = Path(self._credentials_file_path)
if not credentials_path.exists():
diff --git a/pyproject.toml b/pyproject.toml
index d0252dd7e..5faab8090 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -80,6 +80,7 @@ docling = [
"lxml>=6.1.0",
]
fal = ["fal-client>=0.4.1"]
+gcp-logging = ["google-cloud-logging>=3.12.0"]
gcp-storage = [
"google-cloud-storage>=2.10.0",
"cryptography>=46.0.7",
diff --git a/subject_grants.toml b/subject_grants.toml
index d292614bf..a69a4fa5b 100644
--- a/subject_grants.toml
+++ b/subject_grants.toml
@@ -5092,6 +5092,10 @@ rationale = "Plugin protocol: registers into the registrar; single operand, cons
param = "config"
rationale = "Factory from source: builds the sink from the config; single operand, the LogSinkFactoryFn shape."
+["pipelex/providers/log_sinks/log_sink_plugin.py::_make_gcp_log_sink"]
+param = "config"
+rationale = "Factory from source: builds the sink from the config; single operand, the LogSinkFactoryFn shape."
+
["pipelex/providers/log_sinks/log_sink_plugin.py::_make_json_log_sink"]
param = "config"
rationale = "Factory from source: builds the sink from the config; single operand, the LogSinkFactoryFn shape."
diff --git a/tests/integration/pipelex/tools/storage/conftest.py b/tests/integration/pipelex/tools/storage/conftest.py
index 9af40af8f..8e0c1a4fb 100644
--- a/tests/integration/pipelex/tools/storage/conftest.py
+++ b/tests/integration/pipelex/tools/storage/conftest.py
@@ -103,7 +103,7 @@ def gcp_mock(tmp_path: Path, mocker: MockerFixture) -> dict[str, Any]:
Creates a mock that simulates GCS behavior using an in-memory dict.
"""
# Import the module first so it can be patched
- from google.cloud import storage # type: ignore[import-untyped] # ruff: ignore[import-outside-top-level]
+ from google.cloud import storage # type: ignore[import-untyped, attr-defined] # ruff: ignore[import-outside-top-level]
# Create mock credentials file
credentials_path = tmp_path / "gcp_credentials.json"
diff --git a/tests/unit/pipelex/tools/storage/test_gcp_storage_provider.py b/tests/unit/pipelex/tools/storage/test_gcp_storage_provider.py
index 97c0764b6..7c1e3f6a5 100644
--- a/tests/unit/pipelex/tools/storage/test_gcp_storage_provider.py
+++ b/tests/unit/pipelex/tools/storage/test_gcp_storage_provider.py
@@ -43,7 +43,7 @@ class TestGcpStorageProvider:
for test assertions.
"""
# Import the module first so it can be patched
- from google.cloud import storage # type: ignore[import-untyped] # ruff: ignore[import-outside-top-level]
+ from google.cloud import storage # type: ignore[import-untyped, attr-defined] # ruff: ignore[import-outside-top-level]
# Create mock objects
mock_blob = mocker.MagicMock()
diff --git a/tests/unit/pipelex/tools/test_log_gcp_client_library_contract.py b/tests/unit/pipelex/tools/test_log_gcp_client_library_contract.py
new file mode 100644
index 000000000..02b6e5876
--- /dev/null
+++ b/tests/unit/pipelex/tools/test_log_gcp_client_library_contract.py
@@ -0,0 +1,67 @@
+"""What the ``gcp`` sink assumes of ``google-cloud-logging``, asserted against the installed library.
+
+The sink declares the transport's shape rather than importing it, it computes the severity itself
+rather than letting the library derive one from the level, because the library's own normalization has
+no spelling for our ``VERBOSE`` and ``DEV``, and it rejects the library's own export path by the logger
+names and the thread name the library chooses. Every one of those is an assumption about a third party
+whose change would break a production sink silently and no other test would see: a renamed worker
+thread or a renamed transport logger would let a refused batch be reported through the pipeline that
+refused it, which is a spin that never ends and a deadlock at exit.
+"""
+
+from __future__ import annotations
+
+import logging
+from typing import Any, cast
+
+from google.cloud.logging_v2.entries import StructEntry
+from google.cloud.logging_v2.handlers.transports.background_thread import (
+ _WORKER_THREAD_NAME, # pyright: ignore[reportPrivateUsage]
+ _Worker, # pyright: ignore[reportPrivateUsage]
+)
+from google.cloud.logging_v2.handlers.transports.base import Transport
+
+from pipelex.tools.log.gcp_log_sink import (
+ GCP_LOGGING_LOGGER_PREFIXES,
+ GCP_WORKER_THREAD_NAME,
+ MESSAGE_KEY,
+ GcpLogSeverity,
+ trace_name_for_run,
+)
+
+
+class TestTheClientLibraryContract:
+ def test_the_transport_still_carries_the_three_methods_the_sink_calls(self) -> None:
+ for method_name in ("send", "flush", "close"):
+ assert callable(getattr(Transport, method_name))
+
+ def test_the_severity_the_sink_passes_overrides_the_one_the_library_derives_from_the_level(self) -> None:
+ # The worker only holds the logger for its own thread, which is never started here, so the
+ # queued entry can be read without a client.
+ worker: Any = _Worker(object())
+ record = logging.LogRecord(name="pipelex", level=5, pathname="", lineno=0, msg="verbose line", args=(), exc_info=None)
+ worker.enqueue(record, {MESSAGE_KEY: "verbose line"}, severity=GcpLogSeverity.DEBUG.value, labels={}, trace=None)
+
+ queued = cast("dict[str, Any]", worker._queue.get_nowait()) # ruff: ignore[private-member-access]
+ assert queued["severity"] == GcpLogSeverity.DEBUG.value
+ assert queued["message"] == {MESSAGE_KEY: "verbose line"}
+ assert queued["labels"]["python_logger"] == "pipelex"
+
+ def test_a_struct_entry_renders_the_severity_name_and_the_trace_the_sink_passes(self) -> None:
+ trace_name = trace_name_for_run(project="p", pipeline_run_id="plr-1")
+ # The library builds its entries from a namedtuple whose fields mypy does not see.
+ entry: Any = StructEntry(payload={MESSAGE_KEY: "m"}, severity=GcpLogSeverity.WARNING.value, trace=trace_name) # type: ignore[call-arg]
+
+ api_repr = cast("dict[str, Any]", entry.to_api_repr())
+ assert api_repr["severity"] == GcpLogSeverity.WARNING.value
+ assert api_repr["trace"] == trace_name
+
+ def test_the_export_thread_still_carries_the_name_the_sinks_guard_rejects(self) -> None:
+ assert GCP_WORKER_THREAD_NAME == _WORKER_THREAD_NAME
+
+ def test_the_transport_reports_a_refused_batch_under_a_logger_the_guard_rejects(self) -> None:
+ """The report the loop is made of: an ``ERROR`` on the library's own logger, propagating to the root."""
+ transport_logger = logging.getLogger("google.cloud.logging_v2.handlers.transports.background_thread")
+ assert any(transport_logger.name == prefix or transport_logger.name.startswith(f"{prefix}.") for prefix in GCP_LOGGING_LOGGER_PREFIXES)
+ assert transport_logger.propagate
+ assert transport_logger.isEnabledFor(logging.ERROR)
diff --git a/tests/unit/pipelex/tools/test_log_gcp_json_payload_parity.py b/tests/unit/pipelex/tools/test_log_gcp_json_payload_parity.py
new file mode 100644
index 000000000..17a26401a
--- /dev/null
+++ b/tests/unit/pipelex/tools/test_log_gcp_json_payload_parity.py
@@ -0,0 +1,105 @@
+"""One field keeps one wire name whichever of the ``json`` and ``gcp`` sinks a process selects.
+
+The ``gcp`` sink builds its own struct payload rather than rendering the ``json`` sink's line — the
+client library carries the time and the severity out of band and wants a structure rather than
+text — so the two spellings are two implementations of one contract, and nothing but a test holds them
+together. Each case here renders the same record through both and compares, and each was a
+disagreement before it was a test.
+"""
+
+from __future__ import annotations
+
+import json
+import logging
+import sys
+from typing import Any
+
+from google.cloud.logging_v2.handlers.transports.base import Transport
+from typing_extensions import override
+
+from pipelex.tools.log.gcp_log_sink import EXCEPTION_KEY, GcpLogHandler
+from pipelex.tools.log.json_log_sink import JsonLogFormatter
+from pipelex.tools.log.log_fields import attach_log_record_extra
+
+PROJECT = "a-test-project"
+
+
+class CapturingTransport(Transport): # pyright: ignore[reportUntypedBaseClass]
+ """The client library's transport contract, capturing the payload a comparison reads."""
+
+ def __init__(self) -> None:
+ self.payloads: list[dict[str, Any]] = []
+
+ @override
+ def send( # kw-only: ignore — the sink calls the library's signature
+ self,
+ record: logging.LogRecord,
+ message: dict[str, Any],
+ **kwargs: Any,
+ ) -> None:
+ self.payloads.append(message)
+
+ @override
+ def flush(self) -> None:
+ return None
+
+ @override
+ def close(self) -> None:
+ return None
+
+
+class TestTheGcpAndJsonPayloadsAgree:
+ @staticmethod
+ def _both_payloads(record: logging.LogRecord) -> tuple[dict[str, Any], dict[str, Any]]:
+ """The record as the ``json`` sink writes it and as the ``gcp`` sink hands it to the transport."""
+ json_payload = json.loads(JsonLogFormatter().format(record))
+ transport = CapturingTransport()
+ GcpLogHandler(transport=transport, project=PROJECT).handle(record)
+ (gcp_payload,) = transport.payloads
+ return json_payload, gcp_payload
+
+ @classmethod
+ def _record(cls, *, fields: dict[str, Any] | None = None, exc_info: Any = None) -> logging.LogRecord:
+ record = logging.LogRecord(name="my.module", level=logging.WARNING, pathname="", lineno=0, msg="hello", args=(), exc_info=exc_info)
+ # Through the attach path the log call itself uses, so a name the record or the formatter
+ # already owns is prefixed exactly once, where the sinks then see it.
+ attach_log_record_extra(record=record, extra=fields or {})
+ return record
+
+ def test_a_field_named_like_a_key_only_the_json_sink_writes_is_prefixed_under_both(self) -> None:
+ """``time`` and ``severity`` are not ``gcp`` payload keys, and a field named like one still keeps the ``json`` sink's wire name."""
+ json_payload, gcp_payload = self._both_payloads(self._record(fields={"time": "mine", "severity": "mine"}))
+
+ assert json_payload["field_time"] == "mine"
+ assert json_payload["field_severity"] == "mine"
+ assert gcp_payload["field_time"] == "mine"
+ assert gcp_payload["field_severity"] == "mine"
+ assert "time" not in gcp_payload
+ assert "severity" not in gcp_payload
+
+ def test_a_field_named_like_a_key_both_sinks_write_is_prefixed_under_both(self) -> None:
+ json_payload, gcp_payload = self._both_payloads(self._record(fields={"message": "mine", "logger": "mine", "exception": "mine"}))
+
+ for payload in (json_payload, gcp_payload):
+ assert payload["message"] == "hello"
+ assert payload["logger"] == "my.module"
+ assert payload["field_message"] == "mine"
+ assert payload["field_logger"] == "mine"
+ assert payload["field_exception"] == "mine"
+
+ def test_one_traceback_is_spelled_the_same_way_by_both_sinks(self) -> None:
+ try:
+ message = "kaput"
+ raise ValueError(message)
+ except ValueError:
+ exc_info = sys.exc_info()
+ json_payload, gcp_payload = self._both_payloads(self._record(exc_info=exc_info))
+
+ assert "ValueError: kaput" in gcp_payload[EXCEPTION_KEY]
+ assert gcp_payload[EXCEPTION_KEY] == json_payload[EXCEPTION_KEY]
+
+ def test_an_exception_asked_for_outside_an_except_block_lands_under_both_sinks(self) -> None:
+ """``logging.error(msg, exc_info=True)`` called with nothing in flight builds this triple, and a foreign library does it."""
+ json_payload, gcp_payload = self._both_payloads(self._record(exc_info=(None, None, None)))
+
+ assert gcp_payload[EXCEPTION_KEY] == json_payload[EXCEPTION_KEY]
diff --git a/tests/unit/pipelex/tools/test_log_gcp_sink.py b/tests/unit/pipelex/tools/test_log_gcp_sink.py
new file mode 100644
index 000000000..a3992c024
--- /dev/null
+++ b/tests/unit/pipelex/tools/test_log_gcp_sink.py
@@ -0,0 +1,478 @@
+"""The ``gcp`` sink: a record reaches the Cloud Logging transport as one struct entry.
+
+The sink is built around a fake transport, a subclass of the client library's own ``Transport``, so
+each entry is captured where the library would have batched it; production builds it on the
+``BackgroundThreadTransport`` around a real client instead. The guards on the export path are here
+too, since what they guard is the handler. ``test_log_gcp_sink_mapping.py`` reads the severity scale
+and the trace name on their own, ``test_log_gcp_json_payload_parity.py`` holds this payload and the
+``json`` sink's line together, and ``test_log_gcp_client_library_contract.py`` pins what the sink
+assumes of ``google-cloud-logging`` itself.
+"""
+
+from __future__ import annotations
+
+import logging
+import threading
+import time
+from typing import TYPE_CHECKING, Any
+
+import pytest
+from google.cloud.logging_v2.handlers.transports.base import Transport
+from typing_extensions import override
+
+from pipelex.system.configuration.config_loader import ConfigLoader
+from pipelex.tools.log.gcp_log_sink import (
+ EXCEPTION_KEY,
+ GCP_WORKER_THREAD_NAME,
+ LOGGER_KEY,
+ MESSAGE_KEY,
+ GcpExportPathFilter,
+ GcpLogSeverity,
+ GcpLogSink,
+)
+from pipelex.tools.log.log import Log
+from pipelex.tools.log.log_config import LogConfig
+from pipelex.tools.log.log_redaction import CYCLE_TEXT
+from pipelex.tools.misc.hash_utils import hash_md5_to_int
+from pipelex.tools.misc.toml_utils import load_toml_from_path
+
+if TYPE_CHECKING:
+ from collections.abc import Iterator
+
+ from pytest_mock import MockerFixture
+
+PROJECT = "a-test-project"
+
+
+class CapturedEntry:
+ """One entry the sink handed the transport, as the transport received it."""
+
+ def __init__(self, *, record: logging.LogRecord, payload: dict[str, Any], kwargs: dict[str, Any]) -> None:
+ self.record = record
+ self.payload = payload
+ self.severity: Any = kwargs.get("severity")
+ self.labels: dict[str, str] = kwargs.get("labels") or {}
+ self.trace: str | None = kwargs.get("trace")
+
+
+class FakeTransport(Transport): # pyright: ignore[reportUntypedBaseClass]
+ """The client library's transport contract, capturing instead of batching to the API."""
+
+ def __init__(self) -> None:
+ self.entries: list[CapturedEntry] = []
+ self.flush_count = 0
+ self.close_count = 0
+
+ @override
+ def send(self, record: logging.LogRecord, message: dict[str, Any], **kwargs: Any) -> None: # kw-only: ignore — the library's own signature
+ self.entries.append(CapturedEntry(record=record, payload=message, kwargs=kwargs))
+
+ @override
+ def flush(self) -> None:
+ self.flush_count += 1
+
+ @override
+ def close(self) -> None:
+ self.close_count += 1
+
+
+def _package_log_config() -> LogConfig:
+ config_dict = load_toml_from_path(ConfigLoader().pipelex_root_dir / "pipelex.toml")
+ return LogConfig.model_validate(config_dict["runtime"]["log"])
+
+
+def _own_entries(transport: FakeTransport) -> list[CapturedEntry]:
+ """The entries this module's own records produced, whatever else the process logged meanwhile."""
+ return [entry for entry in transport.entries if entry.record.name == __name__]
+
+
+class NeverDrainingTransport(Transport): # pyright: ignore[reportUntypedBaseClass]
+ """A transport whose flush waits on a queue that never drains, which is what the library's does."""
+
+ def __init__(self) -> None:
+ self.entered = threading.Event()
+ self.released = threading.Event()
+
+ @override
+ def send(self, record: logging.LogRecord, message: dict[str, Any], **kwargs: Any) -> None: # kw-only: ignore — the library's own signature
+ return None
+
+ @override
+ def flush(self) -> None:
+ self.entered.set()
+ # Bounded only so a regression fails the test instead of hanging the suite.
+ self.released.wait(timeout=10)
+
+ @override
+ def close(self) -> None:
+ return None
+
+
+class FailingFlushTransport(Transport): # pyright: ignore[reportUntypedBaseClass]
+ """A transport whose flush raises, as one refusing the API does."""
+
+ def __init__(self) -> None:
+ self.message = "the API refused the batch"
+
+ @override
+ def send(self, record: logging.LogRecord, message: dict[str, Any], **kwargs: Any) -> None: # kw-only: ignore — the library's own signature
+ return None
+
+ @override
+ def flush(self) -> None:
+ raise RuntimeError(self.message)
+
+ @override
+ def close(self) -> None:
+ return None
+
+
+class FailingCloseTransport(Transport): # pyright: ignore[reportUntypedBaseClass]
+ """A transport whose closing drain meets a refused batch, which the library reports through its own logger."""
+
+ def __init__(self) -> None:
+ self.handler: logging.Handler | None = None
+
+ @override
+ def send(self, record: logging.LogRecord, message: dict[str, Any], **kwargs: Any) -> None: # kw-only: ignore — the library's own signature
+ return None
+
+ @override
+ def flush(self) -> None:
+ return None
+
+ @override
+ def close(self) -> None:
+ assert self.handler is not None
+ self.handler.handle(_library_record(level=logging.ERROR, msg="Failed to submit the last batch"))
+
+
+class CapturingHandler(logging.Handler):
+ """Stands in for the stdlib's last-resort handler, keeping what it would have printed on stderr."""
+
+ def __init__(self) -> None:
+ super().__init__(level=logging.WARNING)
+ self.records: list[logging.LogRecord] = []
+
+ @override
+ def emit(self, record: logging.LogRecord) -> None:
+ self.records.append(record)
+
+
+class TestGcpLogSink:
+ @pytest.fixture
+ def gcp_log(self, caplog: pytest.LogCaptureFixture) -> Iterator[tuple[Log, FakeTransport]]:
+ # pytest's ``log_level`` option restores the root logger's level at every phase boundary, undoing the
+ # level ``configure`` sets from inside a fixture; the module's own logger is enabled explicitly and
+ # ``caplog`` restores it at teardown.
+ caplog.set_level(logging.INFO, logger=__name__)
+ transport = FakeTransport()
+ fresh = Log()
+ fresh.configure(log_config=_package_log_config())
+ fresh.install_sink(GcpLogSink(transport=transport, project=PROJECT))
+ try:
+ yield fresh, transport
+ finally:
+ fresh.reset()
+
+ def test_the_message_and_the_fields_land_in_the_struct_payload(self, gcp_log: tuple[Log, FakeTransport]) -> None:
+ fresh, transport = gcp_log
+ fresh.info("scanned", fields={"files": 7, "ratio": 0.5, "tags": ["a", "b"], "meta": {"k": "v"}})
+
+ (entry,) = _own_entries(transport)
+ assert entry.payload[MESSAGE_KEY] == "scanned"
+ assert entry.payload[LOGGER_KEY] == __name__
+ assert entry.payload["files"] == 7
+ assert entry.payload["ratio"] == 0.5
+ assert entry.payload["tags"] == ["a", "b"]
+ assert entry.payload["meta"] == {"k": "v"}
+ assert entry.severity == GcpLogSeverity.INFO.value
+
+ def test_the_run_scoped_identifiers_become_labels_and_stay_out_of_the_payload(self, gcp_log: tuple[Log, FakeTransport]) -> None:
+ fresh, transport = gcp_log
+ with fresh.context(request_id="r1", pipe_run_id="pr1"):
+ fresh.info("bound")
+
+ (entry,) = _own_entries(transport)
+ assert entry.labels == {"request_id": "r1", "pipe_run_id": "pr1"}
+ assert "request_id" not in entry.payload
+ assert "pipe_run_id" not in entry.payload
+
+ def test_the_trace_field_carries_the_runs_own_trace_id_project_qualified(self, gcp_log: tuple[Log, FakeTransport]) -> None:
+ fresh, transport = gcp_log
+ with fresh.context(pipeline_run_id="plr-01"):
+ fresh.info("running")
+
+ (entry,) = _own_entries(transport)
+ assert entry.trace == f"projects/{PROJECT}/traces/{hash_md5_to_int('plr-01'):032x}"
+ assert entry.labels == {"pipeline_run_id": "plr-01"}
+
+ def test_a_record_outside_any_run_carries_no_trace_and_no_labels(self, gcp_log: tuple[Log, FakeTransport]) -> None:
+ fresh, transport = gcp_log
+ fresh.info("unbound")
+
+ (entry,) = _own_entries(transport)
+ assert entry.trace is None
+ assert entry.labels == {}
+
+ def test_structured_content_rides_in_the_data_key_of_the_payload(self, gcp_log: tuple[Log, FakeTransport]) -> None:
+ fresh, transport = gcp_log
+ fresh.info({"key": "value", "nested": {"flag": True}}, title="Config")
+
+ (entry,) = _own_entries(transport)
+ assert entry.payload["data"] == {"key": "value", "nested": {"flag": True}}
+
+ def test_a_value_json_cannot_carry_is_written_as_text_rather_than_costing_the_line(self, gcp_log: tuple[Log, FakeTransport]) -> None:
+ """A non-finite float is spelled as text, and a cycle is cut by the redaction walk and keeps the payload a struct."""
+ fresh, transport = gcp_log
+ circular: dict[str, Any] = {}
+ circular["self"] = circular
+ fresh.info("odd values", fields={"nan": float("nan"), "inf": float("inf"), "circular": circular})
+
+ (entry,) = _own_entries(transport)
+ assert entry.payload[MESSAGE_KEY] == "odd values"
+ assert entry.payload["nan"] == "NaN"
+ assert entry.payload["inf"] == "Infinity"
+ assert entry.payload["circular"] == {"self": CYCLE_TEXT}
+
+ def test_a_raw_cycle_reaching_the_handler_is_written_as_text_rather_than_costing_the_line(self) -> None:
+ """The sink's own guard, for a process with redaction off: a value ``json`` refuses is written as its ``repr``, the payload stays a struct."""
+ transport = FakeTransport()
+ handler = GcpLogSink(transport=transport, project=PROJECT).make_handler()
+ cyclic: dict[str, Any] = {}
+ cyclic["me"] = cyclic
+ record = logging.LogRecord(name=__name__, level=logging.INFO, pathname="", lineno=0, msg="cyclic value", args=(), exc_info=None)
+ record.loop = cyclic
+
+ handler.handle(record)
+
+ (entry,) = transport.entries
+ assert entry.payload[MESSAGE_KEY] == "cyclic value"
+ assert isinstance(entry.payload["loop"], str)
+ assert "{...}" in entry.payload["loop"]
+
+ def test_a_field_named_like_a_fixed_key_keeps_its_value_under_the_prefix(self, gcp_log: tuple[Log, FakeTransport]) -> None:
+ fresh, transport = gcp_log
+ fresh.info("the message", fields={"logger": "mine"})
+
+ (entry,) = _own_entries(transport)
+ assert entry.payload[LOGGER_KEY] == __name__
+ assert entry.payload["field_logger"] == "mine"
+
+ def test_the_exception_lands_under_the_exception_key(self, gcp_log: tuple[Log, FakeTransport]) -> None:
+ fresh, transport = gcp_log
+ try:
+ msg = "boom"
+ raise ValueError(msg)
+ except ValueError:
+ fresh.error("failed", include_exception=True)
+
+ (entry,) = _own_entries(transport)
+ assert entry.severity == GcpLogSeverity.ERROR.value
+ assert "Traceback (most recent call last)" in entry.payload[EXCEPTION_KEY]
+ assert "ValueError: boom" in entry.payload[EXCEPTION_KEY]
+
+ @pytest.mark.parametrize(
+ ("method_name", "severity"),
+ [
+ ("verbose", GcpLogSeverity.DEBUG),
+ ("debug", GcpLogSeverity.DEBUG),
+ ("dev", GcpLogSeverity.DEBUG),
+ ("info", GcpLogSeverity.INFO),
+ ("warning", GcpLogSeverity.WARNING),
+ ("error", GcpLogSeverity.ERROR),
+ ("critical", GcpLogSeverity.CRITICAL),
+ ],
+ )
+ def test_every_level_maps_onto_the_cloud_logging_severity_scale(
+ self,
+ gcp_log: tuple[Log, FakeTransport],
+ caplog: pytest.LogCaptureFixture,
+ method_name: str,
+ severity: GcpLogSeverity,
+ ) -> None:
+ fresh, transport = gcp_log
+ caplog.set_level(logging.NOTSET + 1, logger=__name__)
+ getattr(fresh, method_name)("at every level")
+
+ (entry,) = _own_entries(transport)
+ assert entry.severity == severity.value
+
+ def test_the_teardown_flushes_and_closes_the_transport(self, caplog: pytest.LogCaptureFixture) -> None:
+ caplog.set_level(logging.INFO, logger=__name__)
+ transport = FakeTransport()
+ fresh = Log()
+ fresh.configure(log_config=_package_log_config())
+ fresh.install_sink(GcpLogSink(transport=transport, project=PROJECT))
+ fresh.reset()
+
+ assert transport.flush_count > 0
+
+ def test_the_client_librarys_own_export_failure_is_rejected_rather_than_exported(self, gcp_log: tuple[Log, FakeTransport]) -> None:
+ """The library reports a refused batch at ``ERROR``; exported, that report fails with the batch and is reported again."""
+ _, transport = gcp_log
+ logging.getLogger("google.cloud.logging_v2.handlers.transports.background_thread").error("Failed to submit 1 logs.")
+ logging.getLogger("google.cloud.logging").warning("dropped")
+
+ assert [entry for entry in transport.entries if entry.record.name.startswith("google.cloud.logging")] == []
+
+ def test_a_record_emitted_on_the_export_thread_is_rejected_whatever_its_logger_is_called(self, gcp_log: tuple[Log, FakeTransport]) -> None:
+ """The auth stack and the HTTP client log under their own names, and only ever reach this handler from that thread."""
+ _, transport = gcp_log
+
+ def log_as_the_exporting_thread() -> None:
+ logging.getLogger("urllib3.connectionpool").error("Retrying after connection broken")
+
+ exporting = threading.Thread(target=log_as_the_exporting_thread, name=GCP_WORKER_THREAD_NAME)
+ exporting.start()
+ exporting.join()
+ logging.getLogger("urllib3.connectionpool").error("Retrying, on any other thread")
+
+ urllib3_entries = [entry for entry in transport.entries if entry.record.name.startswith("urllib3")]
+ assert [entry.payload[MESSAGE_KEY] for entry in urllib3_entries] == ["Retrying, on any other thread"]
+
+ def test_the_export_paths_record_is_rejected_before_the_handler_lock_is_taken(self, gcp_log: tuple[Log, FakeTransport]) -> None:
+ """At exit the stdlib's shutdown holds this lock while it flushes, and an exporting thread reporting its failure must not wait on it."""
+ fresh, _ = gcp_log
+ assert fresh.sink is not None
+ handler = fresh.sink.handler
+ assert any(isinstance(handler_filter, GcpExportPathFilter) for handler_filter in handler.filters)
+ library_record = logging.LogRecord(
+ name="google.cloud.logging_v2.handlers.transports.background_thread",
+ level=logging.ERROR,
+ pathname="",
+ lineno=0,
+ msg="Failed to submit 1 logs.",
+ args=(),
+ exc_info=None,
+ )
+ lock_taken = threading.Event()
+ let_go = threading.Event()
+
+ def hold_the_lock() -> None:
+ handler.acquire()
+ lock_taken.set()
+ let_go.wait()
+ handler.release()
+
+ holder = threading.Thread(target=hold_the_lock)
+ holder.start()
+ lock_taken.wait()
+ handled = threading.Event()
+
+ def handle_the_librarys_record() -> None:
+ handler.handle(library_record)
+ handled.set()
+
+ try:
+ threading.Thread(target=handle_the_librarys_record, daemon=True).start()
+ assert handled.wait(timeout=2), "the guard ran after the lock was taken"
+ finally:
+ let_go.set()
+ holder.join()
+
+ def test_the_flush_gives_up_on_a_queue_that_never_drains(self, mocker: MockerFixture) -> None:
+ """The library's flush ends in ``queue.join()``, which takes no deadline, so the teardown would never return."""
+ mocker.patch("pipelex.tools.log.gcp_log_sink.FLUSH_TIMEOUT_SECONDS", 0.2)
+ transport = NeverDrainingTransport()
+ handler = GcpLogSink(transport=transport, project=PROJECT).make_handler()
+
+ started = time.monotonic()
+ try:
+ handler.flush()
+ waited = time.monotonic() - started
+ finally:
+ transport.released.set()
+
+ assert transport.entered.is_set(), "the flush never reached the transport"
+ assert waited < 5, f"the flush waited {waited:.1f}s on a queue that never drains"
+
+ def test_a_transport_that_refuses_the_flush_still_reports_it(self) -> None:
+ """The bound must not swallow what the teardown is there to report."""
+ handler = GcpLogSink(transport=FailingFlushTransport(), project=PROJECT).make_handler()
+
+ with pytest.raises(RuntimeError, match="the API refused the batch"):
+ handler.flush()
+
+ def test_an_export_failure_is_printed_on_stderr_rather_than_exported(self, gcp_log: tuple[Log, FakeTransport], mocker: MockerFixture) -> None:
+ """The library reports a refused batch only through this record, and the sink's own handler is never the place it can go."""
+ _, transport = gcp_log
+ stderr = CapturingHandler()
+ mocker.patch.object(logging, "lastResort", stderr)
+
+ logging.getLogger("google.cloud.logging_v2.handlers.transports.background_thread").error("Failed to submit 10 logs.")
+
+ assert [record.getMessage() for record in stderr.records] == ["Failed to submit 10 logs."]
+ assert [entry for entry in transport.entries if entry.record.name.startswith("google.cloud.logging")] == []
+
+ def test_the_export_paths_routine_records_are_not_printed(self, mocker: MockerFixture) -> None:
+ stderr = CapturingHandler()
+ mocker.patch.object(logging, "lastResort", stderr)
+ export_filter = GcpExportPathFilter()
+
+ assert not export_filter.filter(_library_record(level=logging.DEBUG, msg="Submitted 10 logs"))
+ assert stderr.records == []
+
+ def test_a_refusal_that_persists_is_counted_rather_than_printed_per_batch(self, mocker: MockerFixture) -> None:
+ """One report per refused commit is one per line the application logs; the stderr it takes must not grow with that."""
+ stderr = CapturingHandler()
+ mocker.patch.object(logging, "lastResort", stderr)
+ export_filter = GcpExportPathFilter(report_interval_seconds=0.5)
+
+ for batch_number in range(3):
+ export_filter.filter(_library_record(level=logging.ERROR, msg=f"Failed to submit batch {batch_number}"))
+ assert [record.getMessage() for record in stderr.records] == ["Failed to submit batch 0"]
+
+ time.sleep(0.6)
+ export_filter.filter(_library_record(level=logging.ERROR, msg="Failed to submit batch 3"))
+ assert [record.getMessage() for record in stderr.records] == [
+ "Failed to submit batch 0",
+ "The gcp log sink's transport reported 2 more export failures since the last one printed",
+ "Failed to submit batch 3",
+ ]
+
+ def test_a_count_left_when_the_failures_stop_is_printed_once_its_window_has_passed(self, mocker: MockerFixture) -> None:
+ """An outage that ends leaves its count behind, and no later failure comes to print it."""
+ stderr = CapturingHandler()
+ mocker.patch.object(logging, "lastResort", stderr)
+ export_filter = GcpExportPathFilter(report_interval_seconds=0.5)
+
+ for batch_number in range(3):
+ export_filter.filter(_library_record(level=logging.ERROR, msg=f"Failed to submit batch {batch_number}"))
+ assert export_filter.filter(_application_record())
+ assert [record.getMessage() for record in stderr.records] == ["Failed to submit batch 0"]
+
+ time.sleep(0.6)
+ assert export_filter.filter(_application_record())
+ assert [record.getMessage() for record in stderr.records] == [
+ "Failed to submit batch 0",
+ "The gcp log sink's transport reported 2 more export failures since the last one printed",
+ ]
+
+ def test_the_handler_prints_the_count_left_at_close_including_what_the_closing_drain_adds(self, mocker: MockerFixture) -> None:
+ """The close drains the queue, and a refusal met there is counted inside a window nothing else would close."""
+ stderr = CapturingHandler()
+ mocker.patch.object(logging, "lastResort", stderr)
+ transport = FailingCloseTransport()
+ handler = GcpLogSink(transport=transport, project=PROJECT).make_handler()
+ transport.handler = handler
+
+ handler.handle(_library_record(level=logging.ERROR, msg="Failed to submit batch 0"))
+ handler.close()
+
+ assert [record.getMessage() for record in stderr.records] == [
+ "Failed to submit batch 0",
+ "The gcp log sink's transport reported 1 more export failures since the last one printed",
+ ]
+
+
+def _application_record() -> logging.LogRecord:
+ """A record the application logs, which the filter passes."""
+ return logging.LogRecord(name=__name__, level=logging.INFO, pathname="", lineno=0, msg="an ordinary line", args=(), exc_info=None)
+
+
+def _library_record(*, level: int, msg: str) -> logging.LogRecord:
+ """A record as the client library's transport logger emits it."""
+ return logging.LogRecord(
+ name="google.cloud.logging_v2.handlers.transports.background_thread", level=level, pathname="", lineno=0, msg=msg, args=(), exc_info=None
+ )
diff --git a/tests/unit/pipelex/tools/test_log_gcp_sink_mapping.py b/tests/unit/pipelex/tools/test_log_gcp_sink_mapping.py
new file mode 100644
index 000000000..997c3c82e
--- /dev/null
+++ b/tests/unit/pipelex/tools/test_log_gcp_sink_mapping.py
@@ -0,0 +1,29 @@
+"""The two mappings the ``gcp`` sink owns, read without a handler in the way.
+
+The severity scale and the trace name are pure functions of a level and of a run id, so they are
+asserted directly rather than through an entry: what the sink does with them is
+``test_log_gcp_sink.py``'s subject.
+"""
+
+from __future__ import annotations
+
+import logging
+
+from pipelex.tools.log.gcp_log_sink import GcpLogSeverity, severity_for_level, trace_name_for_run
+from pipelex.tools.misc.hash_utils import hash_md5_to_int
+
+
+class TestGcpLogSinkMapping:
+ def test_the_two_custom_levels_land_on_debug(self) -> None:
+ assert severity_for_level(levelno=5) is GcpLogSeverity.DEBUG
+ assert severity_for_level(levelno=15) is GcpLogSeverity.DEBUG
+
+ def test_a_level_above_critical_still_maps_to_critical(self) -> None:
+ assert severity_for_level(levelno=logging.CRITICAL + 10) is GcpLogSeverity.CRITICAL
+
+ def test_the_trace_name_is_the_tracers_own_id_in_32_hex_digits(self) -> None:
+ trace_name = trace_name_for_run(project="p", pipeline_run_id="plr-42")
+ prefix, _, trace_id = trace_name.rpartition("/")
+ assert prefix == "projects/p/traces"
+ assert len(trace_id) == 32
+ assert int(trace_id, 16) == hash_md5_to_int("plr-42")
diff --git a/tests/unit/pipelex/tools/test_log_gcp_sink_without_client.py b/tests/unit/pipelex/tools/test_log_gcp_sink_without_client.py
new file mode 100644
index 000000000..284ac8b81
--- /dev/null
+++ b/tests/unit/pipelex/tools/test_log_gcp_sink_without_client.py
@@ -0,0 +1,70 @@
+"""Selecting the ``gcp`` sink without the client library fails at boot naming the extra and the ``json`` alternative.
+
+The dev environment installs every extra, so the subprocess evicts the ``google.cloud.logging``
+modules and installs a meta-path finder that refuses to import them again: the next import, the one
+the sink's factory performs, is exactly what a missing ``pipelex[gcp-logging]`` would be. A
+subprocess, because evicting a package from ``sys.modules`` in the test process would leave duplicate
+class objects behind for every later test. The sibling ``google.cloud`` packages are left alone, so
+the guard proves the factory's own import is what fails. Modelled on
+``test_log_console_sink_without_rich.py``.
+"""
+
+import subprocess # ruff: ignore[suspicious-subprocess-import]
+import sys
+import textwrap
+
+_GUARD_SCRIPT = textwrap.dedent(
+ """
+ import importlib.abc
+ import sys
+
+ from pipelex.system.exceptions import MissingDependencyError
+ from pipelex.tools.log.gcp_log_sink import (
+ GCP_LOGGING_DEPENDENCY_NAME,
+ GCP_LOGGING_EXTRA_NAME,
+ make_gcp_log_sink,
+ )
+ from pipelex.tools.log.log_config import GcpLogSinkConfig
+
+ BLOCKED_PREFIXES = ("google.cloud.logging", "google.cloud.logging_v2")
+
+ def is_blocked(fullname):
+ return any(fullname == prefix or fullname.startswith(f"{prefix}.") for prefix in BLOCKED_PREFIXES)
+
+ for name in [module for module in sys.modules if is_blocked(module)]:
+ del sys.modules[name]
+
+ class _Blocker(importlib.abc.MetaPathFinder):
+ def find_spec(self, fullname, path, target=None):
+ if is_blocked(fullname):
+ raise ImportError(f"no-cloud-logging guard blocked '{fullname}'")
+ return None
+
+ sys.meta_path.insert(0, _Blocker())
+
+ try:
+ make_gcp_log_sink(config=GcpLogSinkConfig(log_name="pipelex"))
+ except MissingDependencyError as exc:
+ message = str(exc)
+ assert exc.dependency_name == GCP_LOGGING_DEPENDENCY_NAME, message
+ assert exc.extra_name == GCP_LOGGING_EXTRA_NAME, message
+ assert f"pipelex[{GCP_LOGGING_EXTRA_NAME}]" in message, message
+ assert "json" in message, message
+ print("fails loud OK")
+ else:
+ raise SystemExit("expected MissingDependencyError from the gcp sink without the client library")
+ """
+)
+
+
+class TestGcpLogSinkWithoutClient:
+ def test_gcp_sink_fails_loud_naming_the_extra_and_the_json_alternative(self) -> None:
+ result = subprocess.run( # ruff: ignore[subprocess-without-shell-equals-true]
+ [sys.executable, "-c", _GUARD_SCRIPT],
+ capture_output=True,
+ text=True,
+ check=False,
+ timeout=120,
+ )
+ assert result.returncode == 0, f"no-cloud-logging guard failed:\nstdout={result.stdout}\nstderr={result.stderr}"
+ assert "fails loud OK" in result.stdout
diff --git a/uv.lock b/uv.lock
index 93db0070a..7555810d7 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1347,6 +1347,12 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/03/15/e56f351cf6ef1cfea58e6ac226a7318ed1deb2218c4b3cc9bd9e4b786c5a/google_api_core-2.30.3-py3-none-any.whl", hash = "sha256:a85761ba72c444dad5d611c2220633480b2b6be2521eca69cca2dbb3ffd6bfe8", size = 173274, upload-time = "2026-04-09T22:57:16.198Z" },
]
+[package.optional-dependencies]
+grpc = [
+ { name = "grpcio" },
+ { name = "grpcio-status" },
+]
+
[[package]]
name = "google-auth"
version = "2.50.0"
@@ -1378,6 +1384,35 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/2a/e0/cb454a95f460903e39f101e950038ec24a072ca69d0a294a6df625cc1627/google_auth_oauthlib-1.3.1-py3-none-any.whl", hash = "sha256:1a139ef23f1318756805b0e95f655c238bffd29655329a2978218248da4ee7f8", size = 19247, upload-time = "2026-03-30T20:02:23.894Z" },
]
+[[package]]
+name = "google-cloud-appengine-logging"
+version = "1.10.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "google-api-core", extra = ["grpc"] },
+ { name = "google-auth" },
+ { name = "grpcio" },
+ { name = "proto-plus" },
+ { name = "protobuf" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/7f/b9/fcafc8d2dc68975a65cdff74807547cff9b2a7b00e738d3f5ff0bd112867/google_cloud_appengine_logging-1.10.0.tar.gz", hash = "sha256:b5563e76010a36e6adf1cc489620c29ee4fb3b986b006d237e9a061eb0f0abb7", size = 17744, upload-time = "2026-06-03T14:52:40.298Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/a5/b3/4eeb9f59c4e7e07e1f08704b6508249eea5760878810014e636026300416/google_cloud_appengine_logging-1.10.0-py3-none-any.whl", hash = "sha256:193675caaf062c41688a3e2c744b73614db82408bc7fb060353b6878d7134492", size = 18143, upload-time = "2026-06-03T14:51:55.174Z" },
+]
+
+[[package]]
+name = "google-cloud-audit-log"
+version = "0.6.2"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "googleapis-common-protos" },
+ { name = "protobuf" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/69/91/e2a4ed95e790564b807a61fd54d90aa6bf2d3a9474bc5197651acf0cad13/google_cloud_audit_log-0.6.2.tar.gz", hash = "sha256:ea5dc892b1858d345aef0c5563a728534fa875bd0388765391574d3c57fd8f0e", size = 41010, upload-time = "2026-08-25T19:18:29.397Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/7d/f3/f24fba2cb01ad41615d55335306642e3ddf3a5c3cdda6b44754d37bd650e/google_cloud_audit_log-0.6.2-py3-none-any.whl", hash = "sha256:1f19bdf2586cfdb72054eec769ede153a037988b73a7d3b6d266f672ab426c00", size = 40382, upload-time = "2026-08-24T21:55:11.849Z" },
+]
+
[[package]]
name = "google-cloud-core"
version = "2.5.1"
@@ -1391,6 +1426,27 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/73/d9/5bb050cb32826466aa9b25f79e2ca2879fe66cb76782d4ed798dd7506151/google_cloud_core-2.5.1-py3-none-any.whl", hash = "sha256:ea62cdf502c20e3e14be8a32c05ed02113d7bef454e40ff3fab6fe1ec9f1f4e7", size = 29452, upload-time = "2026-03-30T22:48:31.567Z" },
]
+[[package]]
+name = "google-cloud-logging"
+version = "3.16.3"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "google-api-core", extra = ["grpc"] },
+ { name = "google-auth" },
+ { name = "google-cloud-appengine-logging" },
+ { name = "google-cloud-audit-log" },
+ { name = "google-cloud-core" },
+ { name = "grpc-google-iam-v1" },
+ { name = "grpcio" },
+ { name = "opentelemetry-api" },
+ { name = "proto-plus" },
+ { name = "protobuf" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/61/08/73f21dd94c7da7c2580dd179fdaebf72b74f2ea06d9812924dfd57d6d765/google_cloud_logging-3.16.3.tar.gz", hash = "sha256:5d7924bbb33c066bb43f70d33ba66749ff1c29b207de4c80b2bce1aacd53f676", size = 294772, upload-time = "2026-08-25T19:18:54.693Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/7a/0f/f741092958bbb063ccc8ee13e9d2db8c7abedf6208de10ae699ce3cf4bc7/google_cloud_logging-3.16.3-py3-none-any.whl", hash = "sha256:6275384f21d4b142d25731de3107de38408e807742290a9939e19ea68de8c283", size = 233851, upload-time = "2026-08-24T21:55:40.182Z" },
+]
+
[[package]]
name = "google-cloud-storage"
version = "3.10.1"
@@ -1483,6 +1539,90 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/b6/b0/be5d3329badb9230b765de6eea66b73abd5944bdeb5afb3562ddcd80ae84/googleapis_common_protos-1.74.0-py3-none-any.whl", hash = "sha256:702216f78610bb510e3f12ac3cafd281b7ac45cc5d86e90ad87e4d301a3426b5", size = 300743, upload-time = "2026-04-02T21:22:49.108Z" },
]
+[package.optional-dependencies]
+grpc = [
+ { name = "grpcio" },
+]
+
+[[package]]
+name = "grpc-google-iam-v1"
+version = "0.14.5"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "googleapis-common-protos", extra = ["grpc"] },
+ { name = "grpcio" },
+ { name = "protobuf" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/d2/d0/fa5bdd5f3f421bb68dc6dc162e9caaf942897ca41ce7255b524723c80f0b/grpc_google_iam_v1-0.14.5.tar.gz", hash = "sha256:07fd3a9fafb586588e771831fbfc8f6597050181d0c3b45e039d18b8fdc1aab5", size = 23736, upload-time = "2026-08-06T06:24:54.489Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/84/ab/be3ad0d46cffe35fd1e7cc3f9947edd6cb3c552229de3be2742f15f7ea47/grpc_google_iam_v1-0.14.5-py3-none-any.whl", hash = "sha256:0f5e680b20aa0a9441e68c769da04d94d70fca4e43751a82d8abb8aa6a7181ca", size = 32674, upload-time = "2026-08-06T06:23:49.467Z" },
+]
+
+[[package]]
+name = "grpcio"
+version = "1.84.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "typing-extensions" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/3f/4f/4435c0aae54657258d9cfcba78598f3d9e5fe4c82ff18d78558567b90faf/grpcio-1.84.0.tar.gz", hash = "sha256:19aaf172fc2edbefccce3f6e92c5150975dbe56c45744e9e87cf72ebdf85bfbe", size = 13493876, upload-time = "2026-09-14T06:59:33.291Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/2d/b9/46146728b3f4a5c7e34c17d0ab724d58b5456b116e76dc77d3ef4e79b135/grpcio-1.84.0-cp311-cp311-linux_armv7l.whl", hash = "sha256:4aaeceeb7fa7d824c322d1ec3208c8495c88478a927295553235435fc49043ad", size = 6454572, upload-time = "2026-09-14T06:57:14.651Z" },
+ { url = "https://files.pythonhosted.org/packages/e3/63/5d668b4102637410d700153fd12d6a798e3ff8308bd9dcbaeae93f191060/grpcio-1.84.0-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:06619ba1515e5ee69fb2a514e95dd8be05ce74cb3928d5b34f87f87c86fe3c27", size = 12359529, upload-time = "2026-09-14T06:57:17.202Z" },
+ { url = "https://files.pythonhosted.org/packages/18/2a/52e29c02047a493f15a78c0502bde4d3fab7c19c7813944d367cd501811c/grpcio-1.84.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:158c1c11cfb61b4849c3caf4d52de6f5ecd376e14446feb4a90dc95a90d616f5", size = 7029927, upload-time = "2026-09-14T06:57:19.767Z" },
+ { url = "https://files.pythonhosted.org/packages/0a/11/9962b313553647abb091943e0721e4a1662ecc63cdfe930abf00abcce47a/grpcio-1.84.0-cp311-cp311-manylinux2014_i686.manylinux_2_17_i686.whl", hash = "sha256:a9383401d9f116f98cacd4eba6c505a6edb80ba65badfc8e8ed8ae64983bcc44", size = 7782268, upload-time = "2026-09-14T06:57:22.381Z" },
+ { url = "https://files.pythonhosted.org/packages/e2/b7/14a9413cb7d4b2e782b4f79c81a918610caedf55138ab5916f5fdd4b002f/grpcio-1.84.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:bd8ea8eb3817b226057cc1c0e7ec4b378dcda52043b972b6ff12b1152178967d", size = 7187959, upload-time = "2026-09-14T06:57:24.686Z" },
+ { url = "https://files.pythonhosted.org/packages/ee/3b/6cc8e6aed8f23be40f52af341e5d4595ec3ec8d7572271a692b5c1212178/grpcio-1.84.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:756ea5c2da00fa65c930284892d2a9706828704ca3ba40b4c51c4834eb39fcfd", size = 7737554, upload-time = "2026-09-14T06:57:27.5Z" },
+ { url = "https://files.pythonhosted.org/packages/3c/7e/6f61002a01802ca9675e1b3599c9b0f9f3cf168ded94ebacc02199309f88/grpcio-1.84.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:28d2609691da93051e998495108bbddd2a9f7a561253bae94828d81290f30c15", size = 8792681, upload-time = "2026-09-14T06:57:29.731Z" },
+ { url = "https://files.pythonhosted.org/packages/eb/84/8bec1ae7e6732a9b435a394ddfdfffde46c2620ae0109823f7cce1a54455/grpcio-1.84.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:27b8b36200a9fbee6e120246f4a8a41657549107ef19fb2c819c4b2fd524f39a", size = 8145493, upload-time = "2026-09-14T06:57:32.672Z" },
+ { url = "https://files.pythonhosted.org/packages/59/84/c8c7bd210d657288f18af06522f150f61e81ea14fd3c7c135beed697c5fd/grpcio-1.84.0-cp311-cp311-win32.whl", hash = "sha256:465eef3d17e59ad22a556fc0138f7c7c799df426734344daec42c797d49fda99", size = 4495596, upload-time = "2026-09-14T06:57:34.799Z" },
+ { url = "https://files.pythonhosted.org/packages/da/1e/da99356b3b573af357d059753a47fba54f1ca1a9c0e4deccd0210cb7f4ba/grpcio-1.84.0-cp311-cp311-win_amd64.whl", hash = "sha256:f9a456bdbed52a01c9ab8423bdebab04a5363c78676edc55ab9b58bd13bdf9e1", size = 5259900, upload-time = "2026-09-14T06:57:37.067Z" },
+ { url = "https://files.pythonhosted.org/packages/0a/c1/4c9a2e0e6b0aaf02781404cad2f79211f989f2c827cf672a4a48d1604d3e/grpcio-1.84.0-cp312-cp312-linux_armv7l.whl", hash = "sha256:b5c6f20d657ae09ae4e30d9d3a21edd13f1219d58cc6f999b9d1bb63be9c1baa", size = 6415756, upload-time = "2026-09-14T06:57:39.345Z" },
+ { url = "https://files.pythonhosted.org/packages/b1/57/131e7007bdee9acb77a8dbe8a16fa9fef75f88c1695242d8ee0993ac2d3d/grpcio-1.84.0-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:406583b4e8fb2282ebd392e12b963e601c1f82e07125a8c2cb5b144e7e024796", size = 12339195, upload-time = "2026-09-14T06:57:42.373Z" },
+ { url = "https://files.pythonhosted.org/packages/db/d1/a7b7cda98fcab9b3d2916204a872d87371158a7a34e41768f524584fb64d/grpcio-1.84.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:fbdbcd06986ede3ce584083b1dc2afe6808e8943e5cf50ad11183c03aceda25a", size = 6984468, upload-time = "2026-09-14T06:57:45.035Z" },
+ { url = "https://files.pythonhosted.org/packages/19/81/c5be83e3ac9416f73c4c51fe1ea9c41a0c42fc3509e3505faa46f5046abe/grpcio-1.84.0-cp312-cp312-manylinux2014_i686.manylinux_2_17_i686.whl", hash = "sha256:23e6e8e8a75cff88e0a793bfd3becea03a13e2763ae90c1ff573bc19ca5b429a", size = 7749432, upload-time = "2026-09-14T06:57:47.395Z" },
+ { url = "https://files.pythonhosted.org/packages/a0/bf/258cd7c0a7ed92745dc93c31666d462d05b702807a689744bd49fb833bde/grpcio-1.84.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b44f0a0fc7bc6677d38cc80bca1a32814ce6c8f200fb8b3c1a61c9d77eaefbf3", size = 7156115, upload-time = "2026-09-14T06:57:49.657Z" },
+ { url = "https://files.pythonhosted.org/packages/2b/4b/7f829418dbfcf91b875e55e2973f1059a95decb4f081313416317ef04ec1/grpcio-1.84.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:210e4c32f907045eb8158273e60c6ab69a3947697df6245dbda381f26c59485b", size = 7708010, upload-time = "2026-09-14T06:57:52.496Z" },
+ { url = "https://files.pythonhosted.org/packages/34/f0/9932e2fec6a04205f8bf3f8f4d2020479dcdac88feb6f93822ed31bf0eba/grpcio-1.84.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:a71d24f40b0cc6798feaa978c7411dc1135b7018e9fc0442db611c139bf58344", size = 8759980, upload-time = "2026-09-14T06:57:55.312Z" },
+ { url = "https://files.pythonhosted.org/packages/2c/5c/b67407c6dbc480dfc0715f6eccdb1061e7c88d85f9a330a241d357a538c5/grpcio-1.84.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:f6c972474ce691aca74e58d17625450cef153dc4760364cadeb167983ea6d589", size = 8124904, upload-time = "2026-09-14T06:57:58.569Z" },
+ { url = "https://files.pythonhosted.org/packages/02/37/2bfdae2df8dfcfc0df619b628e0c7153ce703adae827243f44720322ccc1/grpcio-1.84.0-cp312-cp312-win32.whl", hash = "sha256:0d532ade4486dad9b302ffa4d4683d67561051c26d17c4023322845e9fa10140", size = 4478915, upload-time = "2026-09-14T06:58:00.714Z" },
+ { url = "https://files.pythonhosted.org/packages/85/2c/309268b7b39f6deb2342f634841e105623a0b67982e8b10ec516782ff1c6/grpcio-1.84.0-cp312-cp312-win_amd64.whl", hash = "sha256:49717e857899f4136d7657bf5aded61ac479110a075438290923a4d86af7cd02", size = 5253534, upload-time = "2026-09-14T06:58:03.336Z" },
+ { url = "https://files.pythonhosted.org/packages/5d/51/40f99701adb01d4e5316a2aaf13838da1a24d5c879cd8c95156d7c364454/grpcio-1.84.0-cp313-cp313-linux_armv7l.whl", hash = "sha256:209414080da8c20af94df1395b635da52dd57b5edc9e917e1deca0dc1c4bb55e", size = 6427619, upload-time = "2026-09-14T06:58:06.025Z" },
+ { url = "https://files.pythonhosted.org/packages/c5/4b/ed8e22a1237e6b2be6ef4f221d074a5b0e0dd8a0da8c944c04aea731f0eb/grpcio-1.84.0-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:e41c3993eee896c617dbd8a505085d28b6e84a0445ed9a1f40f95808473cf678", size = 12336549, upload-time = "2026-09-14T06:58:08.583Z" },
+ { url = "https://files.pythonhosted.org/packages/d3/50/00165b05cd73f45996748ea67ce9e55d08936f2fea94a7fd8541cc2d0e54/grpcio-1.84.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:fff5ef3fe1bba7d6147e5f19e01e5e122ac2c076486887ddcb8d42e663400fbe", size = 6989458, upload-time = "2026-09-14T06:58:11.884Z" },
+ { url = "https://files.pythonhosted.org/packages/26/38/d0486230e684d916f97429a53041db88410e662a38f2a8d09e2d90375840/grpcio-1.84.0-cp313-cp313-manylinux2014_i686.manylinux_2_17_i686.whl", hash = "sha256:b8c62888c3e49debf37ad9773e3c02f77b0c1e811f8fb0962f2b6c3bbab5b97a", size = 7757778, upload-time = "2026-09-14T06:58:14.849Z" },
+ { url = "https://files.pythonhosted.org/packages/da/56/548a643decb059ca244499c675ae2c13a15f523ba94592c2774bd80a13c1/grpcio-1.84.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:986e9751d416d7a6eaa2fecdac38da63153d63a4b340ba7d624889c490451500", size = 7159572, upload-time = "2026-09-14T06:58:17.87Z" },
+ { url = "https://files.pythonhosted.org/packages/db/f5/42caac81a79ec680f1f7a8eaf7ca90d2f93936ce0c3a073141ba96757f77/grpcio-1.84.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:5933a052946873d01a42119a05420d669bdca436aeba2d1851988ccb12b421c0", size = 7710547, upload-time = "2026-09-14T06:58:20.607Z" },
+ { url = "https://files.pythonhosted.org/packages/57/a4/828ad990b2410fee0a55cc73aa1bf98eb5b911c54847374ef4f24b9e877b/grpcio-1.84.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:e094dd21f077af8194923fc263cad872eaa1802bb0156fd7e5ae18e99cd86715", size = 8761519, upload-time = "2026-09-14T06:58:23.875Z" },
+ { url = "https://files.pythonhosted.org/packages/d5/a5/1f91af098919eaf5d80d5a61126ad9fae074e5190c25a3014ce1d8d0d890/grpcio-1.84.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:08735e3d08d24ab3132cf87e2e5dea8746cabcc7d676c2b0b7362f195feef9d9", size = 8121424, upload-time = "2026-09-14T06:58:27.006Z" },
+ { url = "https://files.pythonhosted.org/packages/8c/8f/77fd4a7a913b636785479922349c4cb98d94d05d15652e556b3ca0df6663/grpcio-1.84.0-cp313-cp313-win32.whl", hash = "sha256:70bb4ce8be0c5606bec259cbd7152374470396413b7863a658a08c849e6b29ff", size = 4477974, upload-time = "2026-09-14T06:58:29.528Z" },
+ { url = "https://files.pythonhosted.org/packages/d0/9a/1fa59ddbfc8898e5518d1447e46f771f387f0ed6132ad531395338e51a5c/grpcio-1.84.0-cp313-cp313-win_amd64.whl", hash = "sha256:b61692f0069b3eee2fc8a3a1b7f6c044df9e03fede6ce69b3ca832e1c39f26c5", size = 5255326, upload-time = "2026-09-14T06:58:31.781Z" },
+ { url = "https://files.pythonhosted.org/packages/26/6f/e25ca89ca5b0b7b95464c907a5c21a77c0ac8c4ee1dca164c4dd8f153ddb/grpcio-1.84.0-cp314-cp314-linux_armv7l.whl", hash = "sha256:026d757df86c5b7a41de8200b9a2cda454aaa5004cb0c7e3374c66eb82f61499", size = 6428207, upload-time = "2026-09-14T06:58:34.401Z" },
+ { url = "https://files.pythonhosted.org/packages/cd/b4/6b76b429f3f9b901cdbc306c81364d708bc957f847a05cbd1046cd2d05d8/grpcio-1.84.0-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:3de427b05f244ba2c2a9bdc67e7a6731c8340811524ecc4435466549f8af1d17", size = 12342420, upload-time = "2026-09-14T06:58:37.416Z" },
+ { url = "https://files.pythonhosted.org/packages/af/64/ac86d638ba7f73bee0dccb608ba551d4f63adf75151f00d2c43e46d3979e/grpcio-1.84.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:e90e3bdf7b5eac005fef631adae9cafde16f922def207b80a7c46b253c18ad20", size = 6998396, upload-time = "2026-09-14T06:58:40.535Z" },
+ { url = "https://files.pythonhosted.org/packages/4a/65/fa12e9ec9d7ebf8cc3e81428fa9e1ca0d30d22d546ce2baa4c64bc917cbc/grpcio-1.84.0-cp314-cp314-manylinux2014_i686.manylinux_2_17_i686.whl", hash = "sha256:e88d304f094f4937bc27ec6a435e218a084168f11ec630c8d5d39b431d08d81d", size = 7757538, upload-time = "2026-09-14T06:58:43.297Z" },
+ { url = "https://files.pythonhosted.org/packages/21/d7/94240c7fae121ff1f116dcf04a3b7ee0216a06832c704310363f72638d4c/grpcio-1.84.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:57dc36a5ab0e676f5f6e171de2917fd0aef73f32a9aaf23956bfe19997a30bd1", size = 7161480, upload-time = "2026-09-14T06:58:45.939Z" },
+ { url = "https://files.pythonhosted.org/packages/23/c9/7033e95d4b344969818b09185721c7608b47fc2498d97b5e4eec4995dbf3/grpcio-1.84.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:5deda5b4bf62769eb98c119cca43d40e1231e34846b19db5cdea821d446a2253", size = 7720191, upload-time = "2026-09-14T06:58:48.308Z" },
+ { url = "https://files.pythonhosted.org/packages/95/22/b45df2deba81d55069076859480bae7109c9eec02bce5515c799530cc2aa/grpcio-1.84.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:9bab4cf571653a8afffb83ce21aa27b51dfe629b526b7b6adec35491fe1fc2ea", size = 8762792, upload-time = "2026-09-14T06:58:51.068Z" },
+ { url = "https://files.pythonhosted.org/packages/de/c4/3e1c3d6155c16b8737cc31d5b477d6cf1fc7cdd10d58320cf0ec9b446f42/grpcio-1.84.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:c5559b492007dc09b4de9b95dab05f0b5e53547aad230cf07e46c7dd017a3be5", size = 8123299, upload-time = "2026-09-14T06:58:54.332Z" },
+ { url = "https://files.pythonhosted.org/packages/56/fe/f4864de5b815e5ba18858771f99381a398fac14117f89ef5291ed43d3c4e/grpcio-1.84.0-cp314-cp314-win32.whl", hash = "sha256:2c024da73b296f040b8360e60bd73a659b230093684a438da0e1260f34cc724e", size = 4562560, upload-time = "2026-09-14T06:58:56.894Z" },
+ { url = "https://files.pythonhosted.org/packages/44/03/640811d4d8c84f5e603995c5a9bab725223aa472cad9ca4286c3bbf1c3e3/grpcio-1.84.0-cp314-cp314-win_amd64.whl", hash = "sha256:800b7e00d92553313c0463c200087930aa78678ec1d528193aeb50906f55989b", size = 5394092, upload-time = "2026-09-14T06:58:59.61Z" },
+]
+
+[[package]]
+name = "grpcio-status"
+version = "1.84.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "googleapis-common-protos" },
+ { name = "grpcio" },
+ { name = "protobuf" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/52/45/f80309cdb6a7dbf8f65e2082dd2ddc9797ba7180516a73c54d966ba632c4/grpcio_status-1.84.0.tar.gz", hash = "sha256:5caf28ba7184b81f618b5f7f094859fd2541bf429d2189bbbcd715c9c2cdcee2", size = 14015, upload-time = "2026-09-14T07:10:29.402Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/71/c4/3a77e4273e866b1b0c412afd80882e95941a37170032b5109d847c501124/grpcio_status-1.84.0-py3-none-any.whl", hash = "sha256:0c182ca0d6e60acbfd0e14499cf39a155e4827a1c3fd9f7638e49af15a74c30a", size = 14639, upload-time = "2026-09-14T07:10:15.175Z" },
+]
+
[[package]]
name = "h11"
version = "0.16.0"
@@ -3401,6 +3541,9 @@ dynamodb = [
fal = [
{ name = "fal-client" },
]
+gcp-logging = [
+ { name = "google-cloud-logging" },
+]
gcp-storage = [
{ name = "cryptography" },
{ name = "google-cloud-storage" },
@@ -3448,6 +3591,7 @@ requires-dist = [
{ name = "fal-client", marker = "extra == 'fal'", specifier = ">=0.4.1" },
{ name = "filetype", specifier = ">=1.2.0" },
{ name = "google-auth-oauthlib", marker = "extra == 'google'", specifier = ">=1.2.1" },
+ { name = "google-cloud-logging", marker = "extra == 'gcp-logging'", specifier = ">=3.12.0" },
{ name = "google-cloud-storage", marker = "extra == 'gcp-storage'", specifier = ">=2.10.0" },
{ name = "google-genai", marker = "extra == 'google-genai'" },
{ name = "httpx", specifier = ">=0.23.0,<1.0.0" },
@@ -3521,7 +3665,7 @@ requires-dist = [
{ name = "typing-extensions", specifier = ">=4.13.2" },
{ name = "urllib3", specifier = ">=2.7.0" },
]
-provides-extras = ["anthropic", "bedrock", "docling", "fal", "gcp-storage", "google", "google-genai", "huggingface", "linkup", "mistralai", "dynamodb", "s3", "docs", "dev"]
+provides-extras = ["anthropic", "bedrock", "docling", "fal", "gcp-logging", "gcp-storage", "google", "google-genai", "huggingface", "linkup", "mistralai", "dynamodb", "s3", "docs", "dev"]
[[package]]
name = "pipelex-tools"
diff --git a/wip/structured-logs/review-deferrals.md b/wip/structured-logs/review-deferrals.md
index 1685a4536..da121890e 100644
--- a/wip/structured-logs/review-deferrals.md
+++ b/wip/structured-logs/review-deferrals.md
@@ -171,6 +171,43 @@ The reason it belongs there rather than here is that the cure is a contract choi
A later round that re-raises this should be closed against this entry rather than argued again.
+## L-260916-9f1908, round 1 (bar open)
+
+The branch is stacked on the sink seam, so the pass measured it against `dev` with a focus naming this member's own commits. Every reviewer but cubic raised the same defect independently, and the round-1 verifier reproduced it against the installed `google-cloud-logging`: the library reports a refused batch through its own transport logger, which propagates to the root because only its `setup_logging` sets `propagate = False`, so the report was exported, failed with the batch and was reported again, and with the teardown holding the handler lock while `queue.join()` waited on the worker, that was a deadlock at exit. The pass fixed it with a filter that rejects the library's logging loggers and the export thread before the lock, bounded the handler's flush, which had no deadline to pass, reserved the `json` sink's whole key set so a field named `time` or `severity` keeps one wire name under either sink, routed the traceback through the stdlib formatter the `json` sink uses, and split the test module to one class each. What follows was read as real and left.
+
+- **The migration entry's inline comment names the wrong recipe for a silenced file** (*verified*, code-review). The comment above the log-mode retirement in `pipelex/migration/ledgers/pipelex-config.toml` says `is_console_logging_enabled = false` is replaced by `default_log_level = "OFF"`; the entry's title, description and guidance, the changelog and `docs/configuration/config-practical/logging-config.md` all say `pipelex = "OFF"` under `package_log_levels`, and the verifier reproduced that `default_log_level` alone silences none of Pipelex's records, since the `pipelex` pin stops the effective-level walk. Round 2 on L-260916-aa6e58 corrected the recipe everywhere a person reads it and left this comment behind; a person reading the ledger source is the only one who meets it. A one-line fix on that branch, and the note on L-260916-aa6e58 carries it. The deletion itself stands as the entries above record it, and the verifier also confirmed that a safe entry's guidance is unreachable through both CLIs, which is L-260916-5d142f.
+- **A caller field named `_pipelex_forwarded` drops the record** (*verified*, code-review, restating round 4 on L-260916-aa6e58). Reproduced again against a real `Log`: any truthy value under that name loses the record from every sink. Filed as L-260916-40bf74, still open.
+- **The held stale-configuration warning is the oldest record the holding buffer drops** (*unverified*, code-review). The boot's stale-configuration warning is emitted after `Log.configure` and before `install_sink`, so it is held, and the holding handler evicts the oldest record at capacity, which makes the one warning a stale file produces the first casualty of a verbose boot. The round-1 entry on L-260916-aa6e58 records the window and the drop; evicting from the middle, or pinning warnings and above, would keep it, and the note on L-260916-a1dbd5 carries it.
+- **The `gcp` payload is a second implementation of the `json` sink's line** (*verified that the two disagreed*, cubic). This round made the reserved keys and the traceback agree and holds them together with `tests/unit/pipelex/tools/test_log_gcp_json_payload_parity.py`; the builders stay two. One payload builder in `pipelex/tools/log/log_sink.py`, which each sink then renders, is the structural fix, and worth doing before a third structured sink arrives.
+- **The `json` sink degrades every sibling field when one value defeats JSON** (*verified*, cubic's finding, surfaced by the verifier's comparison). `_json_line` in `pipelex/tools/log/json_log_sink.py` rewrites every non-fixed value as its `repr` when `json.dumps` refuses the payload, so a circular field turns an innocent sibling `{"a": 1}` into the string `"{'a': 1}"`; the `gcp` sink renders each value on its own and loses only the offending one. The `json` sink is the weaker of the two here, so the fix is per-value rendering there, owned by L-260916-aa6e58's sink; the note on it carries this.
+- **Rejected**: the run identifiers riding as `gcp` labels rather than payload keys is documented deliberately in `docs/configuration/config-practical/logging-config.md`, and the claim that the worker feeds its own queue without bound was refuted by measurement, since the worker drains each item and manufactures its successor, which is the spin this round fixed. That is a different growth from the one round 3 confirmed below, where the application outpaces a worker retrying a commit.
+
+## L-260916-9f1908, round 2 (bar defects)
+
+The pull request opened after round 1, so this round measured the gcp sink alone against `feature/Log-sink-seam`. The adversarial reviewer found that the round-1 export-path filter had made a refused write silent: the library marks a refused batch done after reporting it through the very record the filter rejects, and the stdlib's last resort never fires while a handler exists, so the flush succeeded while every line was lost. The verifier reproduced it, and the pass fixed it by printing the export path's warnings and errors through the last-resort handler, rate-limited. It also raised the extra's floor to `google-cloud-logging>=3.12.0`, since the verifier reproduced 3.11.4 failing the teardown with no `BackgroundThreadTransport.close()`, and named the allowed case under both blind excepts. Codex's advice to narrow the `emit` catch was rejected: a handler's `emit` must not raise out of the log call. What follows was read as real and left.
+
+- **Every entry is filed under the `global` monitored resource** (*verified*, code-review). `make_gcp_log_sink` builds the transport with no `resource`, so `BackgroundThreadTransport` falls back to `global`, and a process on a VM, on GKE or in a Cloud Run job does not appear in that resource's log views. The entries are not lost: a query by log name finds them. The library's own handler calls `detect_resource`, which always makes two metadata-server requests with a five-second timeout that does not cover DNS and swallows every failure; the verifier measured a refused port at no cost and a listener that never answers at ten seconds per boot. The choice between a configured resource and detection gated on a Google Cloud signal is a design decision, and nothing in the hosted plane selects this sink.
+- **A flush that reaches its deadline leaves a thread blocked** (*unverified*, cubic). When `FLUSH_TIMEOUT_SECONDS` expires, the drain thread stays in `queue.join()` while `close()` stops the worker. The queue is thread-safe, and the worker's close drains to the terminator, so the join returns unless a commit hangs past the close's grace period too; in that case one daemon thread outlives each such teardown.
+- **The declared minimum is never tested** (codex:review, the second half of the floor finding). The contract test in `tests/unit/pipelex/tools/test_log_gcp_client_library_contract.py` fails against 3.11.4 and passes against 3.12.0, which the verifier ran by hand, but CI runs only the locked version, so a future floor that is too low would pass again. A job that resolves the extras at their lowest versions is the cure, and it is a CI change for every extra rather than for this one.
+- **The payload builders stay two** (cubic, restating round 1). The round-1 entry stands.
+- **The `otlp` sink silences its exporter's failures the same way** (*verified*, the verifier's comparison). `ExportPathFilter` in `pipelex/tools/log/otlp_log_sink.py` rejects every `opentelemetry.*` record, and the verifier pointed the real exporter at a local collector answering 403: five posts refused, one failure record, nothing on stderr. The same last-resort report, with the SDK's own twenty-second deduplication already in front of it, is the fix; the sink is L-260916-aa6e58's, and the note on it carries this, together with the blind excepts in `otlp_log_sink.py` and `log_holding.py` that do not name the case the error-handling rule allows.
+
+## L-260916-9f1908, round 3 (bar necessity)
+
+The round measured PR #1209 against `feature/Log-sink-seam`, and codex:review found nothing. code-review found that round 2's rate limit could leave its count unprinted for good: the count of the failures suppressed within a window was printed only when a later failure opened the next window, so an outage that ended left it behind, and the constant's comment and the logging page both claimed otherwise. The verifier reproduced it end to end, with the count still pending after `Log.reset` and no count line on stderr, and the pass fixed it: the filter prints the count on the first record of any kind once its window has passed, and the handler, which now owns the filter, prints what is still counted after its transport's closing drain. What follows was read as real and left.
+
+- **The export queue has no bound** (*verified*, codex:adversarial). The client library's transport queue is `queue.Queue(0)`, and during a retryable outage one commit of 10 entries takes 41 to 60 seconds under the library's own retry deadline, so the queue grows at any logging rate above about 0.2 lines per second, at roughly 0.7 to 2 MiB per 1,000 lines. It dates from the sink's first commit, the library's own `CloudLoggingHandler` behaves the same way, and a bound needs a transport built on the library's public `Logger.batch()` surface rather than a wrapper around its private worker. Filed as L-260917-22dd32, with the measurements and the shapes of a fix.
+- **The export-path filter's docstring says nothing sets `propagate = False` on the library's logger** (*verified*, the verifier, raised by no reviewer). `api_core` sets it on the `google` logger when a gRPC client is built and that logger is not yet configured (`api_core/client_logging.py:122-125`). Pipelex's default `google = "INFO"` configures it first whenever `Log.configure` runs before any Google client exists; when it does not, the library's failure reports never reach the sink's filter and the stdlib's last resort prints each one, unrated. Nothing is lost, only the rate limit, and the claim dates from round 1.
+- **The trace id is derived with `hash_md5_to_int` rather than through `OtelFactory.make_trace_id`** (*unverified*, cubic). `trace_name_for_run` and its test both use the lower-level helper the tracer uses, so a change to the tracer's derivation would break log and span correlation while every `gcp` test still passed. A telemetry-level trace-id function both call is the cure.
+- **Restated**: the `global` monitored resource (cubic and code-review), the thread a flush past its deadline leaves blocked (cubic) and the two payload builders (cubic). The round-1 and round-2 entries stand.
+
+## L-260916-9f1908, round 4 (bar freeze)
+
+The bar changed no code. cubic and both Codex runs raised the unbounded export queue again, which round 3 verified and filed as L-260917-22dd32, and cubic restated the payload builders, the blocked flush thread and the `global` resource, whose entries above stand. code-review's two findings are new, and both were verified. Neither meets the sharp definition of a critical: the first breaks what the export-path filter claims to deliver, which `docs/workspace/review-profiles.md` defers at this bar and leaves to the person deciding the merge.
+
+- **A failed credential refresh over gRPC feeds a loop through the sink** (*verified*, code-review). Over gRPC the call credentials are refreshed on a thread gRPC creates for each plugin call, not on the export thread, and a failed refresh logs under `grpc._plugin_wrapping` and `google.auth.compute_engine._metadata`, names the filter does not reject. Those records are exported, the write carrying them fails the same way, and the library retries it, since the failure surfaces as UNAVAILABLE. The verifier installed the real sink against local endpoints, logged one application line and nothing more, and watched the queue climb for five minutes with compute-engine credentials whose metadata server is unreachable and with a user refresh token answering `invalid_grant`; a service-account key, the `credentials_file_path` case, signs its own JWT over gRPC and does not loop, and the HTTP transport keeps every record on the export thread and does not loop either. The filter's docstring, which says the auth stack reaches the handler only from the export thread, is wrong under gRPC. Filed as L-260917-896066 with the measurements and two shapes of a fix, the HTTP transport being the narrower.
+- **Every teardown prints two lines on stderr** (*verified by inspection*, code-review). `GcpLogHandler.close` reaches the library's `_Worker.stop` and `_close`, which print "Waiting up to 5 seconds." and "Sent all pending logs." whenever the worker is alive, and it always is at teardown. The logging page says the sink writes on stderr only what the export path reports; a process whose stderr must carry structured output alone would need the close's stderr redirected or the worker stopped without its prints.
+
## L-260916-4837d4, round 1 (bar open)
The branch stacks on `feature/Log-sink-seam`, so the pass measured it against `dev` with a focus naming its own commits. The pass fixed everything confirmed inside them: the exception text no sink scrubbed, the structured values scrubbed string by string and never by key, the model and the object the walk returned raw, the cycle branch that handed the raw container back, the cookie family that stopped at the first crumb and ran to the end of a multi-line message, the JSON-entry family that read a value up to the other quote and counted `code` a secret, the control-character escaping that corrupted `data`, the guard that failed open and could itself raise, and the processor a reinstalled sink accumulated. What follows was raised on code this branch does not touch and stands as traced on the sink member.