diff --git a/packages/dd-trace/src/plugins/util/web.js b/packages/dd-trace/src/plugins/util/web.js index 06344c3db3f..3966f2098ec 100644 --- a/packages/dd-trace/src/plugins/util/web.js +++ b/packages/dd-trace/src/plugins/util/web.js @@ -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 } diff --git a/packages/dd-trace/test/plugins/util/web.spec.js b/packages/dd-trace/test/plugins/util/web.spec.js index e4d384a7c38..ef12125426f 100644 --- a/packages/dd-trace/test/plugins/util/web.spec.js +++ b/packages/dd-trace/test/plugins/util/web.spec.js @@ -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', () => {