Skip to content

Commit afb0a31

Browse files
committed
flatten payload onto context
1 parent a68ab86 commit afb0a31

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

packages/datadog-instrumentations/src/mysql.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ addHook({ name: 'mysql', file: 'lib/Connection.js', versions: ['>=2'] }, Connect
1515

1616
const sql = arguments[0].sql || arguments[0]
1717
const conf = this.config
18-
const payload = { sql, conf }
19-
const ctx = { payload }
18+
const ctx = { sql, conf }
2019

2120
return startCh.runStores(ctx, () => {
2221
if (arguments[0].sql) {
23-
arguments[0].sql = payload.sql
22+
arguments[0].sql = ctx.sql
2423
} else {
25-
arguments[0] = payload.sql
24+
arguments[0] = ctx.sql
2625
}
2726

2827
try {
@@ -80,7 +79,7 @@ addHook({ name: 'mysql', file: 'lib/Pool.js', versions: ['>=2'] }, Pool => {
8079
const cb = arguments[arguments.length - 1]
8180
if (typeof cb === 'function') {
8281
arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => function () {
83-
return finishPoolQueryCh.runStores(ctx, cb, this, arguments)
82+
return finishPoolQueryCh.runStores(ctx, cb, this, ...arguments)
8483
})
8584
}
8685

packages/datadog-plugin-mysql/src/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@ class MySQLPlugin extends DatabasePlugin {
88
static get system () { return 'mysql' }
99

1010
bindStart (ctx) {
11-
const { payload } = ctx
12-
const service = this.serviceName({ pluginConfig: this.config, dbConfig: payload.conf, system: this.system })
11+
const service = this.serviceName({ pluginConfig: this.config, dbConfig: ctx.conf, system: this.system })
1312
const span = this.startSpan(this.operationName(), {
1413
service,
15-
resource: payload.sql,
14+
resource: ctx.sql,
1615
type: 'sql',
1716
kind: 'client',
1817
meta: {
1918
'db.type': this.system,
20-
'db.user': payload.conf.user,
21-
'db.name': payload.conf.database,
22-
'out.host': payload.conf.host,
23-
[CLIENT_PORT_KEY]: payload.conf.port
19+
'db.user': ctx.conf.user,
20+
'db.name': ctx.conf.database,
21+
'out.host': ctx.conf.host,
22+
[CLIENT_PORT_KEY]: ctx.conf.port
2423
}
2524
}, ctx)
26-
payload.sql = this.injectDbmQuery(span, payload.sql, service)
25+
ctx.sql = this.injectDbmQuery(span, ctx.sql, service)
2726

2827
return ctx.currentStore
2928
}

0 commit comments

Comments
 (0)