Set response trace context based on that of incoming requests#463
Set response trace context based on that of incoming requests#463kjin merged 4 commits intogoogleapis:masterfrom
Conversation
ofrobots
left a comment
There was a problem hiding this comment.
I don't think the two commits are individually landable because of the API change in trace-api.js. It would be preferable if the test improvements were completely standalone or were done in a follow-on.
| }; | ||
| api.runInRootSpan(options, function(rootSpan) { | ||
| // Set response trace context. | ||
| var outgoingTraceContext = |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| // we use the path part of the url as the span name and add the full | ||
| // url as a label | ||
| // req.path would be more desirable but is not set at the time our middlewear runs. | ||
| // req.path would be more desirable but is not set at the time our middleware runs. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| skipFrames + 1); | ||
| return new RootSpan(api.agent_, rootContext); | ||
| } | ||
| } No newline at end of file |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| return null; | ||
| } | ||
| // We assume that if no value is set for options, we treat the incoming | ||
| // context as if it had options set to 1. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@ofrobots I haven't done any test refactoring in this PR, what do you mean by that the "two commits aren't individually landable"? |
|
'improvements' removes |
|
Oh I see - I was planning to squash these commits. |
b28f75b to
7f50aad
Compare
|
@GoogleCloudPlatform/node-team CI passed, PTAL |
| var traceContext = this.agent_.parseContextFromHeader(incomingTraceContext); | ||
| if (!traceContext) { | ||
| return ''; | ||
| } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| enhancedDatabaseReportingEnabled: function() { return false; }, | ||
| runInRootSpan: function(opts, fn) { return fn(null); }, | ||
| createChildSpan: function(opts) { return null; }, | ||
| getResponseTraceContext: function(context, traced) { return null; }, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| traceId: matches[1], | ||
| spanId: matches[2], | ||
| options: Number(matches[3]) | ||
| options: typeof(matches[3]) === 'undefined' ? 0 : Number(matches[3]) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
6841c6b to
2743047
Compare
googleapis/synthtool@9982024 commit 99820243d348191bc9c634f2b48ddf65096285ed Author: Alexander Fenster <[email protected]> Date: Tue Mar 31 11:56:27 2020 -0700 fix: update template files for Node.js libraries (#463)
Previously, plugins that patched web frameworks would add in response headers the trace context corresponding to the locally-created root span. This should actually be set to the trace context of the incoming request (modified based on whether this request was traced).