dd-trace 0.36.1 → 0.36.5

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.
Files changed (78) hide show
  1. package/LICENSE-3rdparty.csv +5 -6
  2. package/index.d.ts +10 -0
  3. package/package.json +4 -5
  4. package/packages/datadog-plugin-aws-sdk/src/index.js +3 -5
  5. package/packages/datadog-plugin-cucumber/src/index.js +1 -2
  6. package/packages/datadog-plugin-elasticsearch/src/index.js +23 -26
  7. package/packages/datadog-plugin-fastify/src/fastify.js +53 -0
  8. package/packages/datadog-plugin-graphql/src/index.js +6 -6
  9. package/packages/datadog-plugin-http/src/client.js +13 -9
  10. package/packages/datadog-plugin-jest/src/index.js +26 -7
  11. package/packages/datadog-plugin-mocha/src/index.js +7 -2
  12. package/packages/datadog-plugin-mongodb-core/src/unified.js +42 -1
  13. package/packages/datadog-plugin-next/src/index.js +70 -8
  14. package/packages/datadog-plugin-tedious/src/index.js +0 -8
  15. package/packages/dd-trace/lib/version.js +1 -1
  16. package/packages/dd-trace/src/dogstatsd.js +15 -6
  17. package/packages/dd-trace/src/histogram.js +4 -10
  18. package/packages/dd-trace/src/plugins/util/web.js +1 -0
  19. package/packages/dd-trace/src/proxy.js +9 -2
  20. package/prebuilds/darwin-ia32/node-57.node +0 -0
  21. package/prebuilds/darwin-ia32/node-59.node +0 -0
  22. package/prebuilds/darwin-ia32/node-64.node +0 -0
  23. package/prebuilds/darwin-ia32/node-67.node +0 -0
  24. package/prebuilds/darwin-ia32/node-72.node +0 -0
  25. package/prebuilds/darwin-ia32/node-79.node +0 -0
  26. package/prebuilds/darwin-ia32/node-83.node +0 -0
  27. package/prebuilds/darwin-ia32/node-88.node +0 -0
  28. package/prebuilds/darwin-ia32/node-93.node +0 -0
  29. package/prebuilds/darwin-x64/node-57.node +0 -0
  30. package/prebuilds/darwin-x64/node-59.node +0 -0
  31. package/prebuilds/darwin-x64/node-64.node +0 -0
  32. package/prebuilds/darwin-x64/node-67.node +0 -0
  33. package/prebuilds/darwin-x64/node-72.node +0 -0
  34. package/prebuilds/darwin-x64/node-79.node +0 -0
  35. package/prebuilds/darwin-x64/node-83.node +0 -0
  36. package/prebuilds/darwin-x64/node-88.node +0 -0
  37. package/prebuilds/darwin-x64/node-93.node +0 -0
  38. package/prebuilds/linux-ia32/node-57.node +0 -0
  39. package/prebuilds/linux-ia32/node-59.node +0 -0
  40. package/prebuilds/linux-ia32/node-64.node +0 -0
  41. package/prebuilds/linux-ia32/node-67.node +0 -0
  42. package/prebuilds/linux-ia32/node-72.node +0 -0
  43. package/prebuilds/linux-ia32/node-79.node +0 -0
  44. package/prebuilds/linux-x64/node-57.node +0 -0
  45. package/prebuilds/linux-x64/node-59.node +0 -0
  46. package/prebuilds/linux-x64/node-64.node +0 -0
  47. package/prebuilds/linux-x64/node-67.node +0 -0
  48. package/prebuilds/linux-x64/node-72.node +0 -0
  49. package/prebuilds/linux-x64/node-79.node +0 -0
  50. package/prebuilds/linux-x64/node-83.node +0 -0
  51. package/prebuilds/linux-x64/node-88.node +0 -0
  52. package/prebuilds/linux-x64/node-93.node +0 -0
  53. package/prebuilds/win32-ia32/node-57.node +0 -0
  54. package/prebuilds/win32-ia32/node-59.node +0 -0
  55. package/prebuilds/win32-ia32/node-64.node +0 -0
  56. package/prebuilds/win32-ia32/node-67.node +0 -0
  57. package/prebuilds/win32-ia32/node-72.node +0 -0
  58. package/prebuilds/win32-ia32/node-79.node +0 -0
  59. package/prebuilds/win32-ia32/node-83.node +0 -0
  60. package/prebuilds/win32-ia32/node-88.node +0 -0
  61. package/prebuilds/win32-ia32/node-93.node +0 -0
  62. package/prebuilds/win32-x64/node-57.node +0 -0
  63. package/prebuilds/win32-x64/node-59.node +0 -0
  64. package/prebuilds/win32-x64/node-64.node +0 -0
  65. package/prebuilds/win32-x64/node-67.node +0 -0
  66. package/prebuilds/win32-x64/node-72.node +0 -0
  67. package/prebuilds/win32-x64/node-79.node +0 -0
  68. package/prebuilds/win32-x64/node-83.node +0 -0
  69. package/prebuilds/win32-x64/node-88.node +0 -0
  70. package/prebuilds/win32-x64/node-93.node +0 -0
  71. package/scripts/check_licenses.js +38 -17
  72. package/scripts/postpublish.js +16 -3
  73. package/scripts/prebuilds.js +2 -2
  74. package/scripts/prepublish.js +1 -1
  75. package/scripts/version.js +31 -22
  76. package/NOTICE +0 -4
  77. package/packages/dd-trace/src/metrics_worker.js +0 -18
  78. package/scripts/tracer-runner.js +0 -13
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ // TODO: either instrument all or none of the render functions
4
+
3
5
  function createWrapHandleRequest (tracer, config) {
4
6
  return function wrapHandleRequest (handleRequest) {
5
7
  return function handleRequestWithTrace (req, res, pathname, query) {
@@ -28,6 +30,22 @@ function createWrapHandleApiRequest (tracer, config) {
28
30
  }
29
31
  }
30
32
 
33
+ function createWrapRenderToResponse (tracer, config) {
34
+ return function wrapRenderToResponse (renderToResponse) {
35
+ return function renderToResponseWithTrace (ctx) {
36
+ return trace(tracer, config, ctx.req, ctx.res, () => renderToResponse.apply(this, arguments))
37
+ }
38
+ }
39
+ }
40
+
41
+ function createWrapRenderErrorToResponse (tracer, config) {
42
+ return function wrapRenderErrorToResponse (renderErrorToResponse) {
43
+ return function renderErrorToResponseWithTrace (ctx) {
44
+ return trace(tracer, config, ctx.req, ctx.res, () => renderErrorToResponse.apply(this, arguments))
45
+ }
46
+ }
47
+ }
48
+
31
49
  function createWrapRenderToHTML (tracer, config) {
32
50
  return function wrapRenderToHTML (renderToHTML) {
33
51
  return function renderToHTMLWithTrace (req, res, pathname, query, parsedUrl) {
@@ -36,12 +54,26 @@ function createWrapRenderToHTML (tracer, config) {
36
54
  }
37
55
  }
38
56
 
39
- function createWrapRenderToHTMLWithComponents (tracer, config) {
40
- return function wrapHandleRenderToHTMLWithComponents (renderToHTMLWithComponents) {
41
- return function renderToHTMLWithComponentsWithTrace (req, res, page) {
42
- addPage(req, page)
57
+ function createWrapRenderErrorToHTML (tracer, config) {
58
+ return function wrapRenderErrorToHTML (renderErrorToHTML) {
59
+ return function renderErrorToHTMLWithTrace (err, req, res, pathname, query) {
60
+ return trace(tracer, config, req, res, () => renderErrorToHTML.apply(this, arguments))
61
+ }
62
+ }
63
+ }
43
64
 
44
- return renderToHTMLWithComponents.apply(this, arguments)
65
+ function createWrapFindPageComponents (tracer, config) {
66
+ return function wrapFindPageComponents (findPageComponents) {
67
+ return function findPageComponentsWithTrace (pathname, query) {
68
+ const result = findPageComponents.apply(this, arguments)
69
+ const span = tracer.scope().active()
70
+ const req = span && span._nextReq
71
+
72
+ if (result) {
73
+ addPage(req, pathname)
74
+ }
75
+
76
+ return result
45
77
  }
46
78
  }
47
79
  }
@@ -75,6 +107,10 @@ function trace (tracer, config, req, res, handler) {
75
107
 
76
108
  const promise = scope.activate(span, handler)
77
109
 
110
+ // HACK: Store the request object on the span for findPageComponents.
111
+ // TODO: Use CLS when it will be available in core.
112
+ span._nextReq = req
113
+
78
114
  promise.then(() => finish(span, config, req, res), err => {
79
115
  span.setTag('error', err)
80
116
  finish(span, config, req, res)
@@ -84,6 +120,8 @@ function trace (tracer, config, req, res, handler) {
84
120
  }
85
121
 
86
122
  function addPage (req, page) {
123
+ if (!req || !req._datadog_next) return
124
+
87
125
  req._datadog_next.span.addTags({
88
126
  'resource.name': `${req.method} ${page}`.trim(),
89
127
  'next.page': page
@@ -114,7 +152,7 @@ function getHooks (config) {
114
152
  module.exports = [
115
153
  {
116
154
  name: 'next',
117
- versions: ['>=9.5'],
155
+ versions: ['>=9.5 <11.1'],
118
156
  file: 'dist/next-server/server/next-server.js',
119
157
  patch ({ default: Server }, tracer, config) {
120
158
  config = normalizeConfig(config)
@@ -122,13 +160,37 @@ module.exports = [
122
160
  this.wrap(Server.prototype, 'handleRequest', createWrapHandleRequest(tracer, config))
123
161
  this.wrap(Server.prototype, 'handleApiRequest', createWrapHandleApiRequest(tracer, config))
124
162
  this.wrap(Server.prototype, 'renderToHTML', createWrapRenderToHTML(tracer, config))
125
- this.wrap(Server.prototype, 'renderToHTMLWithComponents', createWrapRenderToHTMLWithComponents(tracer, config))
163
+ this.wrap(Server.prototype, 'renderErrorToHTML', createWrapRenderErrorToHTML(tracer, config))
164
+ this.wrap(Server.prototype, 'findPageComponents', createWrapFindPageComponents(tracer, config))
126
165
  },
127
166
  unpatch ({ default: Server }) {
128
167
  this.unwrap(Server.prototype, 'handleRequest')
129
168
  this.unwrap(Server.prototype, 'handleApiRequest')
130
169
  this.unwrap(Server.prototype, 'renderToHTML')
131
- this.unwrap(Server.prototype, 'renderToHTMLWithComponents')
170
+ this.unwrap(Server.prototype, 'renderErrorToHTML')
171
+ this.unwrap(Server.prototype, 'findPageComponents')
172
+ }
173
+ },
174
+
175
+ {
176
+ name: 'next',
177
+ versions: ['>=11.1'],
178
+ file: 'dist/server/next-server.js',
179
+ patch ({ default: Server }, tracer, config) {
180
+ config = normalizeConfig(config)
181
+
182
+ this.wrap(Server.prototype, 'handleRequest', createWrapHandleRequest(tracer, config))
183
+ this.wrap(Server.prototype, 'handleApiRequest', createWrapHandleApiRequest(tracer, config))
184
+ this.wrap(Server.prototype, 'renderToResponse', createWrapRenderToResponse(tracer, config))
185
+ this.wrap(Server.prototype, 'renderErrorToResponse', createWrapRenderErrorToResponse(tracer, config))
186
+ this.wrap(Server.prototype, 'findPageComponents', createWrapFindPageComponents(tracer, config))
187
+ },
188
+ unpatch ({ default: Server }) {
189
+ this.unwrap(Server.prototype, 'handleRequest')
190
+ this.unwrap(Server.prototype, 'handleApiRequest')
191
+ this.unwrap(Server.prototype, 'renderToResponse')
192
+ this.unwrap(Server.prototype, 'renderErrorToResponse')
193
+ this.unwrap(Server.prototype, 'findPageComponents')
132
194
  }
133
195
  }
134
196
  ]
@@ -5,8 +5,6 @@ const Kinds = require('../../../ext/kinds')
5
5
  const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
6
6
  const tx = require('../../dd-trace/src/plugins/util/tx')
7
7
 
8
- const procnameRegex = /^sp_[a-z]+$/
9
-
10
8
  function createWrapMakeRequest (tracer, config) {
11
9
  return function wrapMakeRequest (makeRequest) {
12
10
  return function makeRequestWithTrace (request) {
@@ -33,7 +31,6 @@ function createWrapMakeRequest (tracer, config) {
33
31
 
34
32
  addConnectionTags(span, connectionConfig)
35
33
  addDatabaseTags(span, connectionConfig)
36
- addProcIdTags(span, request)
37
34
 
38
35
  analyticsSampler.sample(span, config.analytics)
39
36
  request.callback = tx.wrap(span, request.callback)
@@ -77,11 +74,6 @@ function addDatabaseTags (span, connectionConfig) {
77
74
  span.setTag('db.instance', connectionConfig.options.instanceName)
78
75
  }
79
76
 
80
- function addProcIdTags (span, request) {
81
- if (!procnameRegex.test(request.sqlTextOrProcedure)) return
82
- span.setTag('tds.proc.name', request.sqlTextOrProcedure)
83
- }
84
-
85
77
  module.exports = [
86
78
  {
87
79
  name: 'tedious',
@@ -1 +1 @@
1
- module.exports = '0.36.1'
1
+ module.exports = '0.36.5'
@@ -1,7 +1,8 @@
1
1
  'use strict'
2
2
 
3
- const dgram = require('dgram')
4
3
  const lookup = require('dns').lookup // cache to avoid instrumentation
4
+ const dgram = require('dgram')
5
+ const isIP = require('net').isIP
5
6
  const log = require('./log')
6
7
 
7
8
  const MAX_BUFFER_SIZE = 1024 // limit from the agent
@@ -11,6 +12,7 @@ class Client {
11
12
  options = options || {}
12
13
 
13
14
  this._host = options.host || 'localhost'
15
+ this._family = isIP(this._host)
14
16
  this._port = options.port || 8125
15
17
  this._prefix = options.prefix || ''
16
18
  this._tags = options.tags || []
@@ -36,11 +38,14 @@ class Client {
36
38
 
37
39
  this._queue = []
38
40
 
39
- lookup(this._host, (err, address, family) => {
40
- if (err) return log.error(err)
41
-
42
- queue.forEach(buffer => this._send(address, family, buffer))
43
- })
41
+ if (this._family !== 0) {
42
+ this._sendAll(queue, this._host, this._family)
43
+ } else {
44
+ lookup(this._host, (err, address, family) => {
45
+ if (err) return log.error(err)
46
+ this._sendAll(queue, address, family)
47
+ })
48
+ }
44
49
  }
45
50
 
46
51
  _send (address, family, buffer) {
@@ -51,6 +56,10 @@ class Client {
51
56
  socket.send(buffer, 0, buffer.length, this._port, address)
52
57
  }
53
58
 
59
+ _sendAll (queue, address, family) {
60
+ queue.forEach((buffer) => this._send(address, family, buffer))
61
+ }
62
+
54
63
  _add (stat, value, type, tags) {
55
64
  const message = `${this._prefix + stat}:${value}|${type}`
56
65
 
@@ -1,15 +1,9 @@
1
1
  'use strict'
2
2
 
3
- const hdr = require('hdr-histogram-js')
4
-
5
- const highestTrackableValue = 3.6e12 // 1 hour
3
+ const { DDSketch } = require('@datadog/sketches-js')
6
4
 
7
5
  class Histogram {
8
6
  constructor () {
9
- this._histogram = hdr.build({
10
- highestTrackableValue
11
- })
12
-
13
7
  this.reset()
14
8
  }
15
9
 
@@ -22,7 +16,7 @@ class Histogram {
22
16
  get p95 () { return this.percentile(95) }
23
17
 
24
18
  percentile (percentile) {
25
- return this._histogram.getValueAtPercentile(percentile)
19
+ return this._histogram.getValueAtQuantile(percentile / 100) || 0
26
20
  }
27
21
 
28
22
  record (value) {
@@ -36,7 +30,7 @@ class Histogram {
36
30
  this._count++
37
31
  this._sum += value
38
32
 
39
- this._histogram.recordValue(value)
33
+ this._histogram.accept(value)
40
34
  }
41
35
 
42
36
  reset () {
@@ -45,7 +39,7 @@ class Histogram {
45
39
  this._sum = 0
46
40
  this._count = 0
47
41
 
48
- this._histogram.reset()
42
+ this._histogram = new DDSketch()
49
43
  }
50
44
  }
51
45
 
@@ -302,6 +302,7 @@ function addAllowHeaders (req, headers) {
302
302
  const allowHeaders = splitHeader(headers['access-control-allow-headers'])
303
303
  const requestHeaders = splitHeader(req.headers['access-control-request-headers'])
304
304
  const contextHeaders = [
305
+ 'x-datadog-origin',
305
306
  'x-datadog-parent-id',
306
307
  'x-datadog-sampled',
307
308
  'x-datadog-sampling-priority',
@@ -6,7 +6,6 @@ const DatadogTracer = require('./tracer')
6
6
  const Config = require('./config')
7
7
  const Instrumenter = require('./instrumenter')
8
8
  const metrics = require('./metrics')
9
- const profiler = require('./profiler')
10
9
  const log = require('./log')
11
10
  const { setStartupLogInstrumenter } = require('./startup-log')
12
11
  const analyticsSampler = require('./analytics_sampler')
@@ -33,7 +32,15 @@ class Tracer extends BaseTracer {
33
32
  log.use(config.logger)
34
33
  log.toggle(config.debug, config.logLevel, this)
35
34
 
36
- profiler.start(config)
35
+ if (config.hasOwnProperty('profiling') && config.profiling.enabled) {
36
+ // do not stop tracer initialization if the profiler fails to be imported
37
+ try {
38
+ const profiler = require('./profiler')
39
+ profiler.start(config)
40
+ } catch (e) {
41
+ log.error(e)
42
+ }
43
+ }
37
44
 
38
45
  if (config.enabled) {
39
46
  if (config.runtimeMetrics) {
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -6,13 +6,16 @@ const readline = require('readline')
6
6
  const pkg = require(path.join(__dirname, '..', '/package.json'))
7
7
 
8
8
  const filePath = path.join(__dirname, '..', '/LICENSE-3rdparty.csv')
9
- const deps = Object.keys(pkg.dependencies || {})
10
- .concat(Object.keys(pkg.devDependencies || {}))
11
- .concat(Object.keys(pkg.optionalDependencies || {}))
12
- .sort()
9
+ const deps = new Set(Object.keys(pkg.dependencies || {}))
10
+ const devDeps = new Set(Object.keys(pkg.devDependencies || {}))
13
11
 
14
12
  let index = 0
15
- const licenses = []
13
+
14
+ const licenses = {
15
+ require: new Set(),
16
+ dev: new Set(),
17
+ file: new Set()
18
+ }
16
19
 
17
20
  const lineReader = readline.createInterface({
18
21
  input: fs.createReadStream(filePath)
@@ -24,25 +27,43 @@ lineReader.on('line', line => {
24
27
  const type = columns[0]
25
28
  const license = columns[1]
26
29
 
27
- if (type === 'require' || type === 'dev') {
28
- licenses.push(license)
29
- }
30
+ licenses[type].add(license)
30
31
  }
31
32
 
32
33
  index++
33
34
  })
34
35
 
35
36
  lineReader.on('close', () => {
37
+ if (!checkLicenses(deps, 'require') || !checkLicenses(devDeps, 'dev')) {
38
+ process.exit(1)
39
+ }
40
+ })
41
+
42
+ function checkLicenses (typeDeps, type) {
36
43
  /* eslint-disable no-console */
37
44
 
38
- if (JSON.stringify(deps) !== JSON.stringify(licenses.sort())) {
39
- console.log('Dependencies:')
40
- console.log(deps.join(','))
41
- console.log()
42
- console.log('Licenses:')
43
- console.log(licenses.join(','))
44
- console.log()
45
+ const missing = []
46
+ const extraneous = []
45
47
 
46
- throw new Error(`Dependencies and 3rd party licenses mismatch`)
48
+ for (const dep of typeDeps) {
49
+ if (!licenses[type].has(dep)) {
50
+ missing.push(dep)
51
+ }
47
52
  }
48
- })
53
+
54
+ for (const dep of licenses[type]) {
55
+ if (!typeDeps.has(dep)) {
56
+ extraneous.push(dep)
57
+ }
58
+ }
59
+
60
+ if (missing.length) {
61
+ console.log(`Missing 3rd-party license for ${missing.join(', ')}.`)
62
+ }
63
+
64
+ if (extraneous.length) {
65
+ console.log(`Extraneous 3rd-party license for ${extraneous.join(', ')}.`)
66
+ }
67
+
68
+ return missing.length === 0 && extraneous.length === 0
69
+ }
@@ -4,8 +4,21 @@ const exec = require('./helpers/exec')
4
4
 
5
5
  const pkg = require('../package.json')
6
6
 
7
- const betaExpr = /\d+\.\d+\.\d+-beta\.\d+/
7
+ const betaExpr = /\d+\.\d+\.\d+-.*/
8
+ const legacyExpr = /0\.\d+\.\d+/
8
9
 
9
- if (!betaExpr.test(pkg.version)) {
10
- exec(`node scripts/publish_docs.js "v${pkg.version}"`)
10
+ if (!betaExpr.test(pkg.version) && !legacyExpr.test(pkg.version)) {
11
+ const releaseBranches = exec.pipe('git fetch && git branch -a | grep -E "/v\\d+\\.x"')
12
+ .trim()
13
+ .split(/\s+/)
14
+ const releaseMajors = releaseBranches
15
+ .map(branch => parseInt(branch.replace(/[^0-9]/g, '')))
16
+ .sort()
17
+ .reverse()
18
+ const latestMajor = releaseMajors[0]
19
+ const currentMajor = parseInt(pkg.version.split('.')[0])
20
+
21
+ if (currentMajor === latestMajor) {
22
+ exec(`node scripts/publish_docs.js "v${pkg.version}"`)
23
+ }
11
24
  }
@@ -50,7 +50,7 @@ function validatePrebuilds () {
50
50
  const content = fs.readFileSync(path.join('prebuilds', platform, file))
51
51
  const sum = fs.readFileSync(path.join('prebuilds', platform, `${file}.sha1`), 'ascii')
52
52
 
53
- if (sum !== checksum(content)) {
53
+ if (sum !== checksum(content, { algorithm: 'sha256' })) {
54
54
  throw new Error(`Invalid checksum for "prebuilds/${platform}/${file}".`)
55
55
  }
56
56
  })
@@ -62,7 +62,7 @@ function validatePrebuilds () {
62
62
 
63
63
  function createChecksum () {
64
64
  const file = path.join(os.tmpdir(), 'prebuilds.tgz')
65
- const sum = checksum(fs.readFileSync(file))
65
+ const sum = checksum(fs.readFileSync(file), { algorithm: 'sha256' })
66
66
 
67
67
  fs.writeFileSync(`${file}.sha1`, sum)
68
68
  }
@@ -145,7 +145,7 @@ function validatePrebuilds () {
145
145
  const content = fs.readFileSync(file)
146
146
  const sum = fs.readFileSync(path.join(`${file}.sha1`), 'ascii')
147
147
 
148
- if (sum !== checksum(content)) {
148
+ if (sum !== checksum(content, { algorithm: 'sha256' })) {
149
149
  throw new Error('Invalid checksum for "prebuilds.tgz".')
150
150
  }
151
151
  }
@@ -8,30 +8,39 @@ const title = require('./helpers/title')
8
8
 
9
9
  const pkg = require('../package.json')
10
10
  const increment = getIncrement()
11
- const version = semver.inc(pkg.version, increment)
12
- const branch = `v${semver.major(version)}.${semver.minor(version)}`
13
- const tag = `v${version}`
14
- const isNewBranch = semver.major(pkg.version) !== semver.major(version) ||
15
- semver.minor(pkg.version) !== semver.minor(version)
16
-
17
- title(`Bumping version to v${version} in a new branch`)
18
-
19
- pkg.version = version
20
-
21
- if (isNewBranch) {
22
- exec(`git pull`)
23
- exec(`git checkout -b ${branch}`)
24
- } else {
25
- exec(`git checkout ${branch}`)
26
- exec('git pull')
11
+ const version = semver.inc(pkg.version, increment, 'pre')
12
+
13
+ title(`Bumping version to v${version}.`)
14
+
15
+ const currentBranch = exec.pipe(`git branch --show-current`)
16
+
17
+ if (currentBranch === 'master') {
18
+ const major = semver.major(pkg.version)
19
+ const nextMajor = semver.major(pkg.version) + 1
20
+
21
+ exec(`git checkout -b v${major}.x`)
22
+ exec(`git push -u origin HEAD`)
23
+
24
+ bump(`${nextMajor}.0.0-pre`)
25
+
26
+ exec(`git checkout v${major}.x`)
27
27
  }
28
28
 
29
- write('package.json', JSON.stringify(pkg, null, 2) + '\n')
30
- write('packages/dd-trace/lib/version.js', `module.exports = '${version}'\n`)
31
- add('package.json')
32
- add('packages/dd-trace/lib/version.js')
33
- exec(`git commit -m "${tag}"`)
34
- exec(`git push -u origin HEAD`)
29
+ bump(version)
30
+
31
+ exec(`git checkout ${currentBranch}`)
32
+
33
+ function bump (newVersion) {
34
+ pkg.version = newVersion
35
+
36
+ exec(`git checkout -b v${newVersion}-bump`)
37
+ write('package.json', JSON.stringify(pkg, null, 2) + '\n')
38
+ write('packages/dd-trace/lib/version.js', `module.exports = '${newVersion}'\n`)
39
+ add('package.json')
40
+ add('packages/dd-trace/lib/version.js')
41
+ exec(`git commit -m "v${newVersion}"`)
42
+ exec(`git push -u origin HEAD`)
43
+ }
35
44
 
36
45
  function getIncrement () {
37
46
  const increments = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease']
package/NOTICE DELETED
@@ -1,4 +0,0 @@
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/).
@@ -1,18 +0,0 @@
1
- const path = require('path')
2
- const nativeMetrics = require('node-gyp-build')(path.join(__dirname, '..', '..', '..'))
3
- const workerThreads = require('worker_threads')
4
-
5
- const INTERVAL = 1 * 1000
6
-
7
- if (workerThreads.isMainThread) {
8
- nativeMetrics.start()
9
- const worker = new workerThreads.Worker(__filename)
10
- setInterval(() => {
11
- console.log(require('v8').getHeapSpaceStatistics()[0])
12
- }, INTERVAL)
13
- } else {
14
- setInterval(() => {
15
- const stats = nativeMetrics.stats()
16
- console.log(stats.heap.spaces)
17
- }, INTERVAL)
18
- }