dd-trace 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Datadog dd-trace-js
2
+ Copyright 2016-Present Datadog, Inc.
3
+
4
+ This product includes software developed at Datadog, Inc. (https://www.datadoghq.com/).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -20,9 +20,9 @@ addHook({ name: 'mysql', file: 'lib/Connection.js', versions: ['>=2'] }, Connect
20
20
  }
21
21
 
22
22
  const sql = arguments[0].sql ? arguments[0].sql : arguments[0]
23
- const startArgs = [sql, this.config]
23
+ const conf = this.config
24
24
 
25
- startCh.publish(startArgs)
25
+ startCh.publish({ sql, conf })
26
26
 
27
27
  try {
28
28
  const res = query.apply(this, arguments)
@@ -8,10 +8,10 @@ const {
8
8
  const shimmer = require('../../datadog-shimmer')
9
9
 
10
10
  addHook({ name: 'mysql2', file: 'lib/connection.js', versions: ['>=1'] }, Connection => {
11
- const startCh = channel('apm:mysql:query:start')
12
- const asyncEndCh = channel('apm:mysql:query:async-end')
13
- const endCh = channel('apm:mysql:query:end')
14
- const errorCh = channel('apm:mysql:query:error')
11
+ const startCh = channel('apm:mysql2:query:start')
12
+ const asyncEndCh = channel('apm:mysql2:query:async-end')
13
+ const endCh = channel('apm:mysql2:query:end')
14
+ const errorCh = channel('apm:mysql2:query:error')
15
15
 
16
16
  shimmer.wrap(Connection.prototype, 'addCommand', addCommand => function (cmd) {
17
17
  if (!startCh.hasSubscribers) return addCommand.apply(this, arguments)
@@ -45,7 +45,7 @@ addHook({ name: 'mysql2', file: 'lib/connection.js', versions: ['>=1'] }, Connec
45
45
  return asyncResource.bind(function executeWithTrace (packet, connection) {
46
46
  const sql = cmd.statement ? cmd.statement.query : cmd.sql
47
47
 
48
- startCh.publish([sql, config])
48
+ startCh.publish({ sql, conf: config })
49
49
 
50
50
  if (this.onResult) {
51
51
  const onResult = asyncResource.bind(this.onResult)
@@ -80,7 +80,7 @@ const helpers = {
80
80
  if (!span) return
81
81
 
82
82
  const service = services[serviceName] && services[serviceName]
83
- if (service.requestInject) service.requestInject(span, request, tracer)
83
+ if (service && service.requestInject) service.requestInject(span, request, tracer)
84
84
  },
85
85
 
86
86
  wrapCb (cb, serviceName, tags, request, tracer, childOf) {
@@ -4,7 +4,6 @@ const Plugin = require('../../dd-trace/src/plugins/plugin')
4
4
  const { storage } = require('../../datadog-core')
5
5
  const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
6
6
 
7
- // This plugin supports both mysql and mysql2
8
7
  class MySQLPlugin extends Plugin {
9
8
  static get name () {
10
9
  return 'mysql'
@@ -13,7 +12,7 @@ class MySQLPlugin extends Plugin {
13
12
  constructor (...args) {
14
13
  super(...args)
15
14
 
16
- this.addSub('apm:mysql:query:start', ([sql, conf]) => {
15
+ this.addSub(`apm:${this.constructor.name}:query:start`, ({ sql, conf }) => {
17
16
  const store = storage.getStore()
18
17
  const childOf = store ? store.span : store
19
18
  const span = this.tracer.startSpan('mysql.query', {
@@ -38,18 +37,18 @@ class MySQLPlugin extends Plugin {
38
37
  this.enter(span, store)
39
38
  })
40
39
 
41
- this.addSub('apm:mysql:query:end', () => {
40
+ this.addSub(`apm:${this.constructor.name}:query:end`, () => {
42
41
  this.exit()
43
42
  })
44
43
 
45
- this.addSub('apm:mysql:query:error', err => {
44
+ this.addSub(`apm:${this.constructor.name}:query:error`, err => {
46
45
  if (err) {
47
46
  const span = storage.getStore().span
48
47
  span.setTag('error', err)
49
48
  }
50
49
  })
51
50
 
52
- this.addSub('apm:mysql:query:async-end', () => {
51
+ this.addSub(`apm:${this.constructor.name}:query:async-end`, () => {
53
52
  const span = storage.getStore().span
54
53
  span.finish()
55
54
  })
@@ -0,0 +1,11 @@
1
+ 'use strict'
2
+
3
+ const MySQLPlugin = require('../../datadog-plugin-mysql/src')
4
+
5
+ class MySQL2Plugin extends MySQLPlugin {
6
+ static get name () {
7
+ return 'mysql2'
8
+ }
9
+ }
10
+
11
+ module.exports = MySQL2Plugin
@@ -1 +1 @@
1
- module.exports = '2.1.0'
1
+ module.exports = '2.1.1'
@@ -35,7 +35,7 @@ module.exports = {
35
35
  'mongodb-core': require('../../../datadog-plugin-mongodb-core/src'),
36
36
  'mongoose': require('../../../datadog-plugin-mongoose/src'),
37
37
  'mysql': require('../../../datadog-plugin-mysql/src'),
38
- 'mysql2': require('../../../datadog-plugin-mysql/src'),
38
+ 'mysql2': require('../../../datadog-plugin-mysql2/src'),
39
39
  'net': require('../../../datadog-plugin-net/src'),
40
40
  'next': require('../../../datadog-plugin-next/src'),
41
41
  'oracledb': require('../../../datadog-plugin-oracledb/src'),
@@ -0,0 +1,13 @@
1
+ 'use strict'
2
+
3
+ const spawnWrap = require('spawn-wrap')
4
+ const path = require('path')
5
+
6
+ spawnWrap(['--require', path.join(__dirname, '..', 'init.js')])
7
+
8
+ const { spawn } = require('child_process')
9
+
10
+ const [command, ...argv] = process.argv.slice(2)
11
+ spawn(command, argv, {
12
+ stdio: 'inherit'
13
+ })