-
Notifications
You must be signed in to change notification settings - Fork 340
remove async storage from http2 server instrumentation #5947
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
base: master
Are you sure you want to change the base?
Changes from 20 commits
fe7f4c9
efb43ac
3a5a4b9
f591353
fec0b82
6e4c8d5
df2f297
ee086fb
b88d8f1
5dbad1a
4f2e32b
d984ae5
5d2d2cf
8f22eea
de7e856
2101189
f3b0f95
9280d18
a11dbb2
48b1f1e
1734964
57e0ac6
2d4d910
650a39e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,17 @@ const HTTP2_HEADER_PATH = ':path' | |
const contexts = new WeakMap() | ||
const ends = new WeakMap() | ||
|
||
const TracingPlugin = require('../tracing') | ||
|
||
function startSpanHelper (tracer, name, options, traceCtx, config = {}) { | ||
return TracingPlugin.prototype.startSpan.call( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like an anti-pattern, prototype methods are meant to become available on instances of the class, not be accessed directly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed the implementation to create a new instance of tracing plugin for web to use. |
||
{ component: 'web', config }, | ||
name, | ||
{ ...options, tracer }, | ||
traceCtx | ||
) | ||
} | ||
|
||
const web = { | ||
TYPE: WEB, | ||
|
||
|
@@ -93,7 +104,7 @@ const web = { | |
analyticsSampler.sample(span, config.measured, true) | ||
}, | ||
|
||
startSpan (tracer, config, req, res, name) { | ||
startSpan (tracer, config, req, res, name, traceCtx) { | ||
wconti27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const context = this.patch(req) | ||
|
||
let span | ||
|
@@ -102,7 +113,7 @@ const web = { | |
context.span.context()._name = name | ||
span = context.span | ||
} else { | ||
span = web.startChildSpan(tracer, name, req) | ||
span = web.startChildSpan(tracer, name, req, traceCtx) | ||
} | ||
|
||
context.tracer = tracer | ||
|
@@ -163,10 +174,11 @@ const web = { | |
const tracer = context.tracer | ||
const childOf = this.active(req) | ||
const config = context.config | ||
const traceCtx = context.traceCtx | ||
|
||
if (config.middleware === false) return this.bindAndWrapMiddlewareErrors(fn, req, tracer, childOf) | ||
|
||
const span = tracer.startSpan(name, { childOf }) | ||
const span = startSpanHelper(tracer, name, { childOf }, traceCtx, config) | ||
|
||
analyticsSampler.sample(span, config.measured) | ||
|
||
|
@@ -258,20 +270,20 @@ const web = { | |
}, | ||
|
||
// Extract the parent span from the headers and start a new span as its child | ||
startChildSpan (tracer, name, req) { | ||
startChildSpan (tracer, name, req, traceCtx) { | ||
const headers = req.headers | ||
const context = contexts.get(req) | ||
const reqCtx = contexts.get(req) | ||
let childOf = tracer.extract(FORMAT_HTTP_HEADERS, headers) | ||
|
||
// we may have headers signaling a router proxy span should be created (such as for AWS API Gateway) | ||
if (tracer._config?.inferredProxyServicesEnabled) { | ||
const proxySpan = createInferredProxySpan(headers, childOf, tracer, context) | ||
const proxySpan = createInferredProxySpan(headers, childOf, tracer, reqCtx, traceCtx, startSpanHelper) | ||
if (proxySpan) { | ||
childOf = proxySpan | ||
} | ||
} | ||
|
||
const span = tracer.startSpan(name, { childOf, links: childOf?._links }) | ||
const span = startSpanHelper(tracer, name, { childOf }, traceCtx) | ||
|
||
return span | ||
}, | ||
|
Uh oh!
There was an error while loading. Please reload this page.