Skip to content

Commit

Permalink
fix web framework plugins error with http2 requests (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
rochdev committed Sep 23, 2019
1 parent ce466c1 commit 71114f9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/dd-trace/src/plugins/util/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const web = {
patch (req) {
if (req._datadog) return

if (req.stream) {
if (req.stream && req.stream._datadog) {
req._datadog = req.stream._datadog
return
}
Expand Down
25 changes: 25 additions & 0 deletions packages/dd-trace/test/plugins/util/web.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,31 @@ describe('plugins/util/web', () => {
})
})
})

it('should support HTTP2 compatibility API', () => {
req.stream = {}
req.method = 'GET'
req.headers = {
':scheme': 'https',
':authority': 'localhost',
':method': 'GET',
':path': '/user/123'
}
res.statusCode = '200'

web.instrument(tracer, config, req, res, 'test.request', span => {
const tags = span.context()._tags

res.end()

expect(tags).to.include({
[SPAN_TYPE]: WEB,
[HTTP_URL]: 'https://localhost/user/123',
[HTTP_METHOD]: 'GET',
[SPAN_KIND]: SERVER
})
})
})
})

describe('on request end', () => {
Expand Down

0 comments on commit 71114f9

Please sign in to comment.