-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: propagate context in koa tracing #594
Conversation
src/plugins/plugin-koa.ts
Outdated
@@ -16,6 +16,7 @@ | |||
'use strict'; | |||
|
|||
const shimmer = require('shimmer'); | |||
const co = require('co'); | |||
var urlParse = require('url').parse; | |||
|
|||
function startSpanForRequest(api, req, res, next) { |
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.
src/plugins/plugin-koa.ts
Outdated
@@ -16,6 +16,7 @@ | |||
'use strict'; | |||
|
|||
const shimmer = require('shimmer'); | |||
const co = require('co'); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/plugins/test-trace-koa.ts
Outdated
@@ -42,7 +42,7 @@ describe('koa', function() { | |||
}); | |||
|
|||
Object.keys(appBuilders).forEach(function(version) { | |||
describe(version, function() { | |||
describe.skip(version, function() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/plugins/plugin-koa.ts
Outdated
|
||
startSpanForRequest(api, req, res, next); | ||
|
||
console.log(next); |
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.
src/plugins/plugin-koa.ts
Outdated
|
||
console.log(next); | ||
next = startSpanForRequest(api, req, res, next); | ||
console.log(next); |
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.
src/plugins/plugin-koa.ts
Outdated
@@ -16,6 +16,7 @@ | |||
'use strict'; | |||
|
|||
const shimmer = require('shimmer'); | |||
const co = require('co'); | |||
var urlParse = require('url').parse; | |||
|
|||
function startSpanForRequest(api, req, res, next) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
870d481
to
21c4c2c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope the functions are type-declared (at least for exported functions). But I guess that can be a separate PR.
@jinwoo Yep, adding types for plugins is in the pipeline. I'm trying to figure out how to import types for multiple versions of the same module, which is the major blocker. |
Fixes #593
The Koa tracing plugin ignored the return value of
api.wrap
, resulting in trace context not being propagated correctly. This affects both Koa 1 and 2, but Koa 1 needs different patching logic altogether (as it relies on generator functions).