dd-trace 2.35.0 → 2.36.0

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.
@@ -6,10 +6,6 @@ const os = require('os')
6
6
  const dependencies = require('./dependencies')
7
7
  const { sendData } = require('./send-data')
8
8
 
9
- const HEARTBEAT_INTERVAL = process.env.DD_TELEMETRY_HEARTBEAT_INTERVAL
10
- ? Number(process.env.DD_TELEMETRY_HEARTBEAT_INTERVAL) * 1000
11
- : 60000
12
-
13
9
  const telemetryStartChannel = dc.channel('datadog:telemetry:start')
14
10
  const telemetryStopChannel = dc.channel('datadog:telemetry:stop')
15
11
 
@@ -19,6 +15,7 @@ let pluginManager
19
15
  let application
20
16
  let host
21
17
  let interval
18
+ let heartbeatInterval
22
19
  const sentIntegrations = new Set()
23
20
 
24
21
  function getIntegrations () {
@@ -108,7 +105,7 @@ function createHostObject () {
108
105
  }
109
106
 
110
107
  function getTelemetryData () {
111
- return { config, application, host, heartbeatInterval: HEARTBEAT_INTERVAL }
108
+ return { config, application, host, heartbeatInterval }
112
109
  }
113
110
 
114
111
  function start (aConfig, thePluginManager) {
@@ -119,11 +116,13 @@ function start (aConfig, thePluginManager) {
119
116
  pluginManager = thePluginManager
120
117
  application = createAppObject()
121
118
  host = createHostObject()
119
+ heartbeatInterval = config.telemetry.heartbeatInterval
120
+
122
121
  dependencies.start(config, application, host)
123
122
  sendData(config, application, host, 'app-started', appStarted())
124
123
  interval = setInterval(() => {
125
124
  sendData(config, application, host, 'app-heartbeat')
126
- }, HEARTBEAT_INTERVAL)
125
+ }, heartbeatInterval)
127
126
  interval.unref()
128
127
  process.on('beforeExit', onBeforeExit)
129
128
 
@@ -1,4 +1,20 @@
1
1
  const request = require('../exporters/common/request')
2
+
3
+ function getHeaders (config, application, reqType) {
4
+ const headers = {
5
+ 'content-type': 'application/json',
6
+ 'dd-telemetry-api-version': 'v1',
7
+ 'dd-telemetry-request-type': reqType,
8
+ 'dd-client-library-language': application.language_name,
9
+ 'dd-client-library-version': application.tracer_version
10
+ }
11
+ const debug = config.telemetry && config.telemetry.debug
12
+ if (debug) {
13
+ headers['dd-telemetry-debug-enabled'] = 'true'
14
+ }
15
+ return headers
16
+ }
17
+
2
18
  let seqId = 0
3
19
 
4
20
  function getPayload (payload) {
@@ -25,11 +41,7 @@ function sendData (config, application, host, reqType, payload = {}) {
25
41
  port,
26
42
  method: 'POST',
27
43
  path: '/telemetry/proxy/api/v2/apmtelemetry',
28
- headers: {
29
- 'content-type': 'application/json',
30
- 'dd-telemetry-api-version': 'v1',
31
- 'dd-telemetry-request-type': reqType
32
- }
44
+ headers: getHeaders(config, application, reqType)
33
45
  }
34
46
  const data = JSON.stringify({
35
47
  api_version: 'v1',