Skip to content

WIP: separate span and noop into their own storages #5393

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/datadog-plugin-dns/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ describe('Plugin', () => {
clearTimeout(timer)
})

storage('legacy').run({ noop: true }, () => {
storage('noop').run(true, () => {
resolver.resolve('lvh.me', () => {})
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-plugin-fetch/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ describe('Plugin', function () {

const store = storage('legacy').getStore()

storage('legacy').enterWith({ noop: true })
storage('noop').enterWith(true)

fetch(`http://localhost:${port}/user`).catch(() => {})

Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-plugin-http/test/client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ describe('Plugin', () => {
appListener = server(app, port => {
const store = storage('legacy').getStore()

storage('legacy').enterWith({ noop: true })
storage('noop').enterWith(true)
const req = http.request(tracer._tracer._url.href)

req.on('error', () => {})
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-plugin-mariadb/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MariadbPlugin extends MySQLPlugin {

this.addSub(`apm:${this.component}:pool:skip`, () => {
skippedStore = storage('legacy').getStore()
storage('legacy').enterWith({ noop: true })
storage('noop').enterWith(true)
})

this.addSub(`apm:${this.component}:pool:unskip`, () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/exporters/common/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function createAgentClass (BaseAgent) {
}

_noop (callback) {
return storage('legacy').run({ noop: true }, callback)
return storage('noop').run(true, callback)
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/exporters/common/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function request (data, options, callback) {

const store = storage('legacy').getStore()

storage('legacy').enterWith({ noop: true })
storage('noop').enterWith(true)

const req = client.request(options, onResponse)

Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/log/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let logChannel = new LogChannel()
function withNoop (fn) {
const store = storage('legacy').getStore()

storage('legacy').enterWith({ noop: true })
storage('noop').enterWith(true)
fn()
storage('legacy').enterWith(store)
}
Expand Down
8 changes: 5 additions & 3 deletions packages/dd-trace/src/plugins/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class Subscription {
this._channel = dc.channel(event)
this._handler = (message, name) => {
const store = storage('legacy').getStore()
if (!store || !store.noop) {
const noop = storage('noop').getStore()
if (!store || !noop) {
handler(message, name)
}
}
Expand All @@ -31,8 +32,9 @@ class StoreBinding {
this._channel = dc.channel(event)
this._transform = data => {
const store = storage('legacy').getStore()
const noop = storage('noop').getStore()

return !store || !store.noop
return !store || !noop
? transform(data)
: store
}
Expand Down Expand Up @@ -69,7 +71,7 @@ module.exports = class Plugin {
// TODO: Implement filters on resource name for all plugins.
/** Prevents creation of spans here and for all async descendants. */
skip () {
storage('legacy').enterWith({ noop: true })
storage('noop').enterWith(true)
}

addSub (channelName, handler) {
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/plugins/util/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function sanitizedExec (
errorMetric
) {
const store = storage('legacy').getStore()
storage('legacy').enterWith({ noop: true })
storage('noop').enterWith(true)

let startTime
if (operationMetric) {
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/profiling/exporters/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function sendRequest (options, form, callback) {
const request = options.protocol === 'https:' ? httpsRequest : httpRequest

const store = storage('legacy').getStore()
storage('legacy').enterWith({ noop: true })
storage('noop').enterWith(true)
requestCounter.inc()
const start = perf.now()
const req = request(options, res => {
Expand Down
1 change: 1 addition & 0 deletions packages/dd-trace/src/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

const oldStore = storage('legacy').getStore()
const newStore = span ? storage('legacy').getStore(span._store) : oldStore
// span ? storage('legacy').getStore(span) : oldStore

Check failure on line 21 in packages/dd-trace/src/scope.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 spaces but found 18

storage('legacy').enterWith({ ...newStore, span })

Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/test/log.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('log', () => {

it('should call the logger in a noop context', () => {
logger.debug = () => {
expect(storage('legacy').getStore()).to.have.property('noop', true)
expect(storage('noop').getStore()).to.be.true
}

log.use(logger).debug('debug')
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/test/plugins/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ module.exports = {
const emit = server.emit

server.emit = function () {
storage('legacy').enterWith({ noop: true })
storage('noop').enterWith(true)
return emit.apply(this, arguments)
}

Expand Down
1 change: 1 addition & 0 deletions packages/dd-trace/test/setup/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,6 @@ exports.mochaHooks = {
agent.reset()
runtimeMetrics.stop()
storage('legacy').enterWith(undefined)
storage('noop').enterWith(undefined)
}
}
4 changes: 2 additions & 2 deletions packages/dd-trace/test/telemetry/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('telemetry', () => {
// If we don't no-op the server inside it, it will trace it, which will
// screw up this test file entirely. -- bengl

storage('legacy').run({ noop: true }, () => {
storage('noop').run(true, () => {
traceAgent = http.createServer(async (req, res) => {
const chunks = []
for await (const chunk of req) {
Expand Down Expand Up @@ -895,7 +895,7 @@ describe('AVM OSS', () => {
before((done) => {
clock = sinon.useFakeTimers()

storage('legacy').run({ noop: true }, () => {
storage('noop').run(true, () => {
traceAgent = http.createServer(async (req, res) => {
const chunks = []
for await (const chunk of req) {
Expand Down
Loading