dd-trace 3.6.0 → 3.7.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.
@@ -20,6 +20,7 @@ require,methods,MIT,Copyright 2013-2014 TJ Holowaychuk
20
20
  require,module-details-from-path,MIT,Copyright 2016 Thomas Watson Steen
21
21
  require,opentracing,MIT,Copyright 2016 Resonance Labs Inc
22
22
  require,path-to-regexp,MIT,Copyright 2014 Blake Embrey
23
+ require,protobufjs,BSD-3-Clause,Copyright 2016 Daniel Wirtz
23
24
  require,retry,MIT,Copyright 2011 Tim Koschützki Felix Geisendörfer
24
25
  require,semver,ISC,Copyright Isaac Z. Schlueter and Contributors
25
26
  dev,@types/node,MIT,Copyright Authors
package/index.d.ts CHANGED
@@ -176,7 +176,7 @@ export declare interface SamplingRule {
176
176
  /**
177
177
  * Sampling rate for this rule.
178
178
  */
179
- sampleRate: Number
179
+ sampleRate: number
180
180
 
181
181
  /**
182
182
  * Service on which to apply this rule. The rule will apply to all services if not provided.
@@ -196,12 +196,12 @@ export declare interface SpanSamplingRule {
196
196
  /**
197
197
  * Sampling rate for this rule. Will default to 1.0 (always) if not provided.
198
198
  */
199
- sampleRate?: Number
199
+ sampleRate?: number
200
200
 
201
201
  /**
202
202
  * Maximum number of spans matching a span sampling rule to be allowed per second.
203
203
  */
204
- maxPerSecond?: Number
204
+ maxPerSecond?: number
205
205
 
206
206
  /**
207
207
  * Service name or pattern on which to apply this rule. The rule will apply to all services if not provided.
@@ -297,7 +297,7 @@ export declare interface TracerOptions {
297
297
  * and controls the ingestion rate limit between the agent and the backend.
298
298
  * Defaults to deferring the decision to the agent.
299
299
  */
300
- rateLimit?: Number,
300
+ rateLimit?: number,
301
301
 
302
302
  /**
303
303
  * Sampling rules to apply to priority samplin. Each rule is a JSON,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "3.6.0",
3
+ "version": "3.7.1",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -59,8 +59,8 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@datadog/native-appsec": "^1.2.1",
62
- "@datadog/native-metrics": "^1.4.3",
63
- "@datadog/pprof": "^1.0.2",
62
+ "@datadog/native-metrics": "^1.5.0",
63
+ "@datadog/pprof": "^1.1.1",
64
64
  "@datadog/sketches-js": "^2.1.0",
65
65
  "crypto-randomuuid": "^1.0.0",
66
66
  "diagnostics_channel": "^1.1.0",
@@ -79,6 +79,7 @@
79
79
  "module-details-from-path": "^1.0.3",
80
80
  "opentracing": ">=0.12.1",
81
81
  "path-to-regexp": "^0.1.2",
82
+ "protobufjs": "^7.1.2",
82
83
  "retry": "^0.10.1",
83
84
  "semver": "^5.5.0"
84
85
  },
@@ -79,7 +79,7 @@ function limitDepth (input) {
79
79
  let child = input[key]
80
80
 
81
81
  if (isBSON(child)) {
82
- child = child.toJSON()
82
+ child = typeof child.toJSON === 'function' ? child.toJSON() : '?'
83
83
  }
84
84
 
85
85
  if (depth >= 10 || shouldHide(child)) {
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const URL = require('url').URL
3
+ const { URL, format } = require('url')
4
4
  const log = require('../../log')
5
5
  const Writer = require('./writer')
6
6
 
@@ -8,7 +8,11 @@ class AgentExporter {
8
8
  constructor (config, prioritySampler) {
9
9
  this._config = config
10
10
  const { url, hostname, port, lookup, protocolVersion, stats = {} } = config
11
- this._url = url || new URL(`http://${hostname || 'localhost'}:${port}`)
11
+ this._url = url || new URL(format({
12
+ protocol: 'http:',
13
+ hostname: hostname || 'localhost',
14
+ port
15
+ }))
12
16
 
13
17
  const headers = {}
14
18
  if (stats.enabled) {
@@ -1,11 +1,15 @@
1
- const { URL } = require('url')
1
+ const { URL, format } = require('url')
2
2
 
3
3
  const { Writer } = require('./writer')
4
4
 
5
5
  class SpanStatsExporter {
6
6
  constructor (config) {
7
7
  const { hostname = '127.0.0.1', port = 8126, tags, url } = config
8
- this._url = url || new URL(`http://${hostname || 'localhost'}:${port}`)
8
+ this._url = url || new URL(format({
9
+ protocol: 'http:',
10
+ hostname: hostname || 'localhost',
11
+ port
12
+ }))
9
13
  this._writer = new Writer({ url: this._url, tags })
10
14
  }
11
15
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  // TODO: capture every second and flush every 10 seconds
4
4
 
5
+ const { URL, format } = require('url')
5
6
  const v8 = require('v8')
6
7
  const os = require('os')
7
8
  const Client = require('./dogstatsd')
@@ -57,7 +58,11 @@ module.exports = {
57
58
  if (config.url) {
58
59
  clientConfig.metricsProxyUrl = config.url
59
60
  } else if (config.port) {
60
- clientConfig.metricsProxyUrl = new URL(`http://${config.hostname || 'localhost'}:${config.port}`)
61
+ clientConfig.metricsProxyUrl = new URL(format({
62
+ protocol: 'http:',
63
+ hostname: config.hostname || 'localhost',
64
+ port: config.port
65
+ }))
61
66
  }
62
67
 
63
68
  client = new Client(clientConfig)
@@ -1,7 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  // TODO (new internal tracer): use DC events for lifecycle metrics and test them
4
- const now = require('perf_hooks').performance.now
4
+ const { performance } = require('perf_hooks')
5
+ const now = performance.now.bind(performance)
5
6
  const dateNow = Date.now
6
7
  const semver = require('semver')
7
8
  const SpanContext = require('./span_context')
@@ -2,7 +2,7 @@
2
2
 
3
3
  const coalesce = require('koalas')
4
4
  const os = require('os')
5
- const { URL } = require('url')
5
+ const { URL, format } = require('url')
6
6
  const { AgentExporter } = require('./exporters/agent')
7
7
  const { FileExporter } = require('./exporters/file')
8
8
  const { ConsoleLogger } = require('./loggers/console')
@@ -59,10 +59,13 @@ class Config {
59
59
  this.sourceMap = sourceMap
60
60
  this.endpointCollection = endpointCollection
61
61
 
62
- const hostname = coalesce(options.hostname, DD_AGENT_HOST, 'localhost')
63
- const port = coalesce(options.port, DD_TRACE_AGENT_PORT, 8126)
64
- this.url = new URL(coalesce(options.url, DD_TRACE_AGENT_URL,
65
- `http://${hostname || 'localhost'}:${port || 8126}`))
62
+ const hostname = coalesce(options.hostname, DD_AGENT_HOST) || 'localhost'
63
+ const port = coalesce(options.port, DD_TRACE_AGENT_PORT) || 8126
64
+ this.url = new URL(coalesce(options.url, DD_TRACE_AGENT_URL, format({
65
+ protocol: 'http:',
66
+ hostname,
67
+ port
68
+ })))
66
69
 
67
70
  this.exporters = ensureExporters(options.exporters || [
68
71
  new AgentExporter(this)
@@ -65,8 +65,8 @@ class SpanAggStats {
65
65
  TopLevelHits: this.topLevelHits,
66
66
  Errors: this.errors,
67
67
  Duration: this.duration,
68
- OkSummary: this.okDistribution.toProto(),
69
- ErrorSummary: this.errorDistribution.toProto()
68
+ OkSummary: this.okDistribution.toProto(), // TODO: custom proto encoding
69
+ ErrorSummary: this.errorDistribution.toProto() // TODO: custom proto encoding
70
70
  }
71
71
  }
72
72
  }
@@ -7,7 +7,7 @@ const { sendData } = require('./send-data')
7
7
  const dc = require('diagnostics_channel')
8
8
  const { fileURLToPath } = require('url')
9
9
 
10
- const savedDependencies = []
10
+ const savedDependencies = new Set()
11
11
  const detectedDependencyNames = new Set()
12
12
  const FILE_URI_START = `file://`
13
13
  const moduleLoadStartChannel = dc.channel('dd-trace:moduleLoadStart')
@@ -18,10 +18,14 @@ function waitAndSend (config, application, host) {
18
18
  if (!immediate) {
19
19
  immediate = setImmediate(() => {
20
20
  immediate = null
21
- if (savedDependencies.length > 0) {
22
- const dependencies = savedDependencies.splice(0, 1000)
21
+ if (savedDependencies.size > 0) {
22
+ const dependencies = Array.from(savedDependencies.values()).splice(0, 1000).map(pair => {
23
+ savedDependencies.delete(pair)
24
+ const [name, version] = pair.split(' ')
25
+ return { name, version }
26
+ })
23
27
  sendData(config, application, host, 'app-dependencies-loaded', { dependencies })
24
- if (savedDependencies.length > 0) {
28
+ if (savedDependencies.size > 0) {
25
29
  waitAndSend(config, application, host)
26
30
  }
27
31
  }
@@ -49,7 +53,7 @@ function onModuleLoad (data) {
49
53
  if (basedir) {
50
54
  try {
51
55
  const { version } = requirePackageJson(basedir, module)
52
- savedDependencies.push({ name, version })
56
+ savedDependencies.add(`${name} ${version}`)
53
57
  waitAndSend(config, application, host)
54
58
  } catch (e) {
55
59
  // can not read the package.json, do nothing
@@ -75,7 +79,7 @@ function stop () {
75
79
  application = null
76
80
  host = null
77
81
  detectedDependencyNames.clear()
78
- savedDependencies.splice(0, savedDependencies.length)
82
+ savedDependencies.clear()
79
83
  if (moduleLoadStartChannel.hasSubscribers) {
80
84
  moduleLoadStartChannel.unsubscribe(onModuleLoad)
81
85
  }
@@ -3,9 +3,11 @@ let seqId = 0
3
3
  function sendData (config, application, host, reqType, payload = {}) {
4
4
  const {
5
5
  hostname,
6
- port
6
+ port,
7
+ url
7
8
  } = config
8
9
  const options = {
10
+ url,
9
11
  hostname,
10
12
  port,
11
13
  method: 'POST',