Repository navigation
fix(py/google-cloud): fix metric exporter aggregation, credentials client forwarding, and structlog trace processor - #38
Merged
Conversation
huangjeff5
force-pushed
the
fix/py-gcp-telemetry-exporter
branch
from
November 9, 2026 19:07
eebfa7a to
0b4e255
Compare
huangjeff5
force-pushed
the
fix/py-gcp-telemetry-exporter
branch
from
November 9, 2026 20:13
f5fae11 to
267c293
Compare
…ient forwarding, and structlog trace processor
huangjeff5
force-pushed
the
fix/py-gcp-telemetry-exporter
branch
from
November 9, 2026 20:17
267c293 to
3a9838f
Compare
…ock/credentials objects in resolve_project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GenkitMetricExporter.__init__did not callsuper().__init__(), leaving_preferred_aggregationunset on the instance.PeriodicExportingMetricReaderthrewAttributeError: 'GenkitMetricExporter' object has no attribute '_preferred_aggregation'.enable_google_cloud_telemetry(credentials=...)forwardedcredentials=...directly intoGenkitGCPExporter(CloudTraceSpanExporter),CloudMonitoringMetricsExporter, andCloudLoggingExporter. None of these accept acredentialskeyword argument, causingTypeError._genkit_inject_trace_contextwas appended toprocessors. Because structlog renderers (ConsoleRenderer,JSONRenderer) transform event dictionaries into strings or bytes, processors appended after them run after rendering or miss log records.Mechanism
super().__init__(): Passpreferred_temporalityand the underlying exporter's_preferred_aggregationsoMetricExporterproperly populates both instance attributes.TraceServiceClient,MetricServiceClient, andLoggingServiceV2Clientinstances with the credentials object whencredentials=is supplied (either as a service account dict or agoogle.auth.credentials.Credentialsinstance), and pass them via theclient=kwarg. Ifprojectis not specified but present in the service account dict, resolveprojectfromcredentials['project_id']._genkit_inject_trace_contextimmediately before the first renderer processor so trace context fields (logging.googleapis.com/trace,spanId) are present inevent_dictwhen rendered.Verification
tests/tracing_test.pycoveringGenkitMetricExporteraggregation temporality preservation, client creation/forwarding undercredentials=, and structlog processor ordering.pytest packages/genkit-google-cloud(225 passed).ruff check,ruff format, andpyrightclean.