This repository was archived by the owner on Mar 11, 2026. It is now read-only.
feat: users can log raw http request objects with trace#1086
Merged
freelerobot merged 25 commits intomasterfrom Jun 7, 2021
Merged
feat: users can log raw http request objects with trace#1086freelerobot merged 25 commits intomasterfrom
freelerobot merged 25 commits intomasterfrom
Conversation
added 6 commits
June 1, 2021 00:09
…ng into writeHttpRequest
simonz130
approved these changes
Jun 5, 2021
Comment on lines
+235
to
+236
| if (this.metadata.traceSampled === undefined && match[5]) | ||
| this.metadata.traceSampled = match[5] === '1'; |
There was a problem hiding this comment.
I don't think there is much sense in having traceSampled value as true or false in this.metadata.traceSampled but having trace and spanId not set.
Probably we can reduce the "if" to just
if (match[5])
Contributor
Author
There was a problem hiding this comment.
the users can still submit a header of ';o=0'. Which is a redundant but valid way to indicate both i) there's no trace/span and ii) don't sample this trace and span
| this.metadata.httpRequest = makeHttpRequestData(rawReq); | ||
| // Infer trace & span if not user specified already. | ||
| if ('headers' in rawReq && rawReq.headers['x-cloud-trace-context']) { | ||
| const regex = /([a-f\d]+)?(\/?([a-f\d]+))?(;?o=(\d))?/; |
There was a problem hiding this comment.
I suggest you refactor this to prepare for recognition of trace/span from traceparent (the recognition itself might happen in a different PR).
Contributor
Author
There was a problem hiding this comment.
ah ok, ill do this in a following pr with a TODO note on recognizing trace-parent
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
A. Users can log raw http.incomingmessage (requests) now:
make-http-requestsout of /middleware subdirectories. Since it’s not just for middleware. This is cleaner, as http-request was already in the main directory.B. Users can force tracing by providing x-cloud-trace-context in http headers (in various formats):
See: https://cloud.google.com/trace/docs/setup#force-trace
trace,spanIDandtraceSampledfields in X-Cloud-Trace-Context can be optional (see context/trace_context.proto)Fixes: #1083