feat(gcp): Add span streaming support to GCP Cloud Functions integration#6440
Conversation
Migrate GCP integration to support spans-first tracing via the span streaming API. The integration now supports both: - Span streaming (new trace lifecycle) - Traditional transaction-based approach (fallback) Add request attributes to spans including headers, HTTP method, and query string. Include cloud provider context and segment source in span metadata. Add comprehensive tests for span streaming functionality including error handling, trace context propagation, and PII filtering for query strings. Depends on getsentry/sentry-conventions#403 being merged first. Fixes PY-2324 Fixes #6022
Codecov Results 📊✅ 88635 passed | ⏭️ 6007 skipped | Total: 94642 | Pass Rate: 93.65% | Execution Time: 294m 47s 📊 Comparison with Base Branch
All tests are passing successfully. ❌ Patch coverage is 14.81%. Project has 2330 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 89.96% 89.92% -0.04%
==========================================
Files 191 191 —
Lines 23092 23109 +17
Branches 7938 7948 +10
==========================================
+ Hits 20773 20779 +6
- Misses 2319 2330 +11
- Partials 1309 1307 -2Generated by Codecov Action |
…replacement marker
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 38121a2. Configure here.
| "function_name": environ.get("FUNCTION_NAME"), | ||
| "function_entry_point": environ.get("ENTRY_POINT"), | ||
| "function_identity": environ.get("FUNCTION_IDENTITY"), | ||
| "function_region": environ.get("FUNCTION_REGION"), | ||
| "function_project": environ.get("GCP_PROJECT"), | ||
| "execution_duration_in_millis": execution_duration_in_millis, | ||
| "configured_timeout_in_seconds": configured_timeout, |
There was a problem hiding this comment.
Some of these (name, entry point, identity, region, project, maybe execution time?) look like they'd make sense as attributes in span first. Don't know if OTel/we already have conventions for them, but might be worth adding.
There was a problem hiding this comment.
Most of these don't have an OTEL equivalent but I've added a number of them to our conventions as part of getsentry/sentry-conventions#403
There's also some that I've dropped, which I've outlined in a thread here
The addition of the execution time will be an interesting one - I think we'd need to handle it similar to another integration that had some trickiness around the setting of a span's end timestamp after that span had been completed 🤔
I've held off on adding this value for now though because I'm not convinced it's worth adding at this time - there's nothing that I could find in hex that indicates that users are creating alerts, dashboards, etc. with this value.
There was a problem hiding this comment.
In full agreement re: execution time (not worth it right now) and the dropped attrs.
I was mostly curious about the ones you've added to the conventions -- why not set them on spans in this integration?
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c3bbc45. Configure here.
| attributes={ | ||
| "sentry.op": OP.FUNCTION_GCP, | ||
| "sentry.origin": GcpIntegration.origin, | ||
| "sentry.span.source": SegmentSource.COMPONENT, |
There was a problem hiding this comment.
Inconsistent enum value usage for span attribute
Low Severity
SegmentSource.COMPONENT is passed directly as an attribute value, while the equivalent code in the aiohttp integration uses SegmentSource.ROUTE.value to extract the plain string. While SegmentSource is a str enum so both work today, passing the enum member rather than .value is inconsistent with the established pattern and could behave unexpectedly if serialization logic changes.
Reviewed by Cursor Bugbot for commit c3bbc45. Configure here.


Migrate GCP integration to support spans-first tracing via the span streaming API.
The integration now supports both:
Add request attributes to spans including headers, HTTP method, and query string.
Include cloud provider context and segment source in span metadata.
Add comprehensive tests for span streaming functionality including error handling,
trace context propagation, and PII filtering for query strings.
Fixes PY-2324 and #6022