[SVLS-7168] Create inferred Span for GCP Push Subscriptions (including Cloud Events) #6415
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.
What does this PR do?
Extends the official PubSub plugin capabilities and optimizes Datadog tracing instrumentation for Google Cloud Pub/Sub push messages and Cloud Events across all Node.js web frameworks.
GCP sends push → HTTP server receives POST request
Plugin detects → "This is a Pub/Sub push!" (via User-Agent: APIs-Google)
Plugin creates → PubSub.delivery synthetic span with parent trace id from producer cloud run service (This will be reworked in another PR)
Plugin creates → HTTP span as child of PubSub span
Express inherits → Express spans inherit via scope activation
Your app processes → Business logic with automatic tracing
This makes the spans have this hierarchy :
pubsub.delivery (created by gcp-pubsub-push.js)
└── http.request (manually created as child)
└── express.request (inherits via scope activation)
└── express.middleware (inherits via scope activation)
└── your-business-logic (main.js)
Follow-up PR will be opened to create the synthetic span in the flame graph
Motivation
An inferred span for the HTTP push post to the Cloud Run service from a pub/sub topic
Example full Push Direct Span of a cloud run service triggering another service using a direct push subscription
Example full Eventarc pubsub trigger span of a cloud run service triggering another service using an Eventarc cloud event trigger
Plugin Checklist
Additional Notes
The changes had to be made in server.js because in Push Subscription, the Cloud Run Service receives HTTP Requests.
Follow-up PR to #6260
Additional information can be found in this doc