dd-trace 1.7.0 → 1.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.
- package/package.json +1 -1
- package/packages/dd-trace/lib/version.js +1 -1
- package/packages/dd-trace/src/constants.js +1 -6
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +0 -34
- package/packages/dd-trace/src/priority_sampler.js +1 -49
- package/NOTICE +0 -4
- package/packages/dd-trace/src/plugins/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = '1.7.
|
|
1
|
+
module.exports = '1.7.1'
|
|
@@ -10,10 +10,5 @@ module.exports = {
|
|
|
10
10
|
SAMPLING_RULE_DECISION: '_dd.rule_psr',
|
|
11
11
|
SAMPLING_LIMIT_DECISION: '_dd.limit_psr',
|
|
12
12
|
SAMPLING_AGENT_DECISION: '_dd.agent_psr',
|
|
13
|
-
|
|
14
|
-
SAMPLING_MECHANISM_AGENT: 1,
|
|
15
|
-
SAMPLING_MECHANISM_RULE: 3,
|
|
16
|
-
SAMPLING_MECHANISM_MANUAL: 4,
|
|
17
|
-
DATADOG_LAMBDA_EXTENSION_PATH: '/opt/extensions/datadog-agent',
|
|
18
|
-
UPSTREAM_SERVICES_KEY: '_dd.p.upstream_services'
|
|
13
|
+
DATADOG_LAMBDA_EXTENSION_PATH: '/opt/extensions/datadog-agent'
|
|
19
14
|
}
|
|
@@ -11,7 +11,6 @@ const spanKey = 'x-datadog-parent-id'
|
|
|
11
11
|
const originKey = 'x-datadog-origin'
|
|
12
12
|
const samplingKey = 'x-datadog-sampling-priority'
|
|
13
13
|
const sampleKey = 'x-datadog-sampled'
|
|
14
|
-
const tagsKey = 'x-datadog-tags'
|
|
15
14
|
const baggagePrefix = 'ot-baggage-'
|
|
16
15
|
const b3TraceKey = 'x-b3-traceid'
|
|
17
16
|
const b3TraceExpr = /^([0-9a-f]{16}){1,2}$/i
|
|
@@ -42,7 +41,6 @@ class TextMapPropagator {
|
|
|
42
41
|
this._injectSamplingPriority(spanContext, carrier)
|
|
43
42
|
this._injectBaggageItems(spanContext, carrier)
|
|
44
43
|
this._injectB3(spanContext, carrier)
|
|
45
|
-
this._injectTags(spanContext, carrier)
|
|
46
44
|
|
|
47
45
|
log.debug(() => `Inject into carrier: ${JSON.stringify(pick(carrier, logKeys))}.`)
|
|
48
46
|
}
|
|
@@ -55,7 +53,6 @@ class TextMapPropagator {
|
|
|
55
53
|
this._extractOrigin(carrier, spanContext)
|
|
56
54
|
this._extractBaggageItems(carrier, spanContext)
|
|
57
55
|
this._extractSamplingPriority(carrier, spanContext)
|
|
58
|
-
this._extractTags(carrier, spanContext)
|
|
59
56
|
|
|
60
57
|
log.debug(() => `Extract from carrier: ${JSON.stringify(pick(carrier, logKeys))}.`)
|
|
61
58
|
|
|
@@ -84,25 +81,6 @@ class TextMapPropagator {
|
|
|
84
81
|
})
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
_injectTags (spanContext, carrier) {
|
|
88
|
-
const trace = spanContext._trace
|
|
89
|
-
const tags = []
|
|
90
|
-
|
|
91
|
-
for (const key in trace.tags) {
|
|
92
|
-
if (!key.startsWith('_dd.p.')) continue
|
|
93
|
-
|
|
94
|
-
tags.push(`${key}=${trace.tags[key]}`)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const header = tags.join(',')
|
|
98
|
-
|
|
99
|
-
if (header.length <= 512) {
|
|
100
|
-
carrier[tagsKey] = header
|
|
101
|
-
} else {
|
|
102
|
-
trace.tags['_dd.propagation_error:max_size'] = 1
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
84
|
_injectB3 (spanContext, carrier) {
|
|
107
85
|
if (!this._config.experimental.b3) return
|
|
108
86
|
|
|
@@ -263,18 +241,6 @@ class TextMapPropagator {
|
|
|
263
241
|
}
|
|
264
242
|
}
|
|
265
243
|
|
|
266
|
-
_extractTags (carrier, spanContext) {
|
|
267
|
-
if (!carrier[tagsKey]) return
|
|
268
|
-
|
|
269
|
-
const pairs = carrier[tagsKey].split(',')
|
|
270
|
-
|
|
271
|
-
for (const pair of pairs) {
|
|
272
|
-
const [key, value] = pair.split('=')
|
|
273
|
-
|
|
274
|
-
spanContext._trace.tags[key] = value
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
244
|
_isSampled (sampled, debug) {
|
|
279
245
|
if (debug || sampled === '1') {
|
|
280
246
|
return true
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const coalesce = require('koalas')
|
|
4
3
|
const RateLimiter = require('./rate_limiter')
|
|
5
4
|
const Sampler = require('./sampler')
|
|
6
5
|
const ext = require('../../../ext')
|
|
7
6
|
const { setSamplingRules } = require('./startup-log')
|
|
8
7
|
|
|
9
8
|
const {
|
|
10
|
-
SAMPLING_MECHANISM_DEFAULT,
|
|
11
|
-
SAMPLING_MECHANISM_AGENT,
|
|
12
|
-
SAMPLING_MECHANISM_RULE,
|
|
13
|
-
SAMPLING_MECHANISM_MANUAL,
|
|
14
9
|
SAMPLING_RULE_DECISION,
|
|
15
10
|
SAMPLING_LIMIT_DECISION,
|
|
16
|
-
SAMPLING_AGENT_DECISION
|
|
17
|
-
UPSTREAM_SERVICES_KEY
|
|
11
|
+
SAMPLING_AGENT_DECISION
|
|
18
12
|
} = require('./constants')
|
|
19
13
|
|
|
20
14
|
const SERVICE_NAME = ext.tags.SERVICE_NAME
|
|
@@ -28,7 +22,6 @@ const USER_KEEP = ext.priority.USER_KEEP
|
|
|
28
22
|
const DEFAULT_KEY = 'service:,env:'
|
|
29
23
|
|
|
30
24
|
const defaultSampler = new Sampler(AUTO_KEEP)
|
|
31
|
-
const serviceNames = new Map()
|
|
32
25
|
|
|
33
26
|
class PrioritySampler {
|
|
34
27
|
constructor (env, { sampleRate, rateLimit = 100, rules = [] } = {}) {
|
|
@@ -59,14 +52,9 @@ class PrioritySampler {
|
|
|
59
52
|
|
|
60
53
|
if (this.validate(tag)) {
|
|
61
54
|
context._sampling.priority = tag
|
|
62
|
-
context._sampling.mechanism = SAMPLING_MECHANISM_MANUAL
|
|
63
55
|
} else if (auto) {
|
|
64
56
|
context._sampling.priority = this._getPriorityFromAuto(root)
|
|
65
|
-
} else {
|
|
66
|
-
return
|
|
67
57
|
}
|
|
68
|
-
|
|
69
|
-
this._addUpstreamService(root)
|
|
70
58
|
}
|
|
71
59
|
|
|
72
60
|
update (rates) {
|
|
@@ -127,7 +115,6 @@ class PrioritySampler {
|
|
|
127
115
|
|
|
128
116
|
_getPriorityByRule (context, rule) {
|
|
129
117
|
context._trace[SAMPLING_RULE_DECISION] = rule.sampleRate
|
|
130
|
-
context._sampling.mechanism = SAMPLING_MECHANISM_RULE
|
|
131
118
|
|
|
132
119
|
return rule.sampler.isSampled(context) && this._isSampledByRateLimit(context) ? USER_KEEP : USER_REJECT
|
|
133
120
|
}
|
|
@@ -146,44 +133,9 @@ class PrioritySampler {
|
|
|
146
133
|
|
|
147
134
|
context._trace[SAMPLING_AGENT_DECISION] = sampler.rate()
|
|
148
135
|
|
|
149
|
-
if (sampler === defaultSampler) {
|
|
150
|
-
context._sampling.mechanism = SAMPLING_MECHANISM_DEFAULT
|
|
151
|
-
} else {
|
|
152
|
-
context._sampling.mechanism = SAMPLING_MECHANISM_AGENT
|
|
153
|
-
}
|
|
154
|
-
|
|
155
136
|
return sampler.isSampled(context) ? AUTO_KEEP : AUTO_REJECT
|
|
156
137
|
}
|
|
157
138
|
|
|
158
|
-
_addUpstreamService (span) {
|
|
159
|
-
const context = span.context()
|
|
160
|
-
const trace = context._trace
|
|
161
|
-
const service = this._toBase64(context._tags['service.name'])
|
|
162
|
-
const priority = context._sampling.priority
|
|
163
|
-
const mechanism = context._sampling.mechanism
|
|
164
|
-
const rate = Math.ceil(coalesce(
|
|
165
|
-
context._trace[SAMPLING_RULE_DECISION],
|
|
166
|
-
context._trace[SAMPLING_AGENT_DECISION]
|
|
167
|
-
) * 10000) / 10000
|
|
168
|
-
const group = `${service}|${priority}|${mechanism}|${rate}`
|
|
169
|
-
const groups = trace.tags[UPSTREAM_SERVICES_KEY]
|
|
170
|
-
? `${trace.tags[UPSTREAM_SERVICES_KEY]};${group}`
|
|
171
|
-
: group
|
|
172
|
-
|
|
173
|
-
trace.tags[UPSTREAM_SERVICES_KEY] = groups
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
_toBase64 (serviceName) {
|
|
177
|
-
let encoded = serviceNames.get(serviceName)
|
|
178
|
-
|
|
179
|
-
if (!encoded) {
|
|
180
|
-
encoded = Buffer.from(serviceName).toString('base64')
|
|
181
|
-
serviceNames.set(serviceName, encoded)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return encoded
|
|
185
|
-
}
|
|
186
|
-
|
|
187
139
|
_normalizeRules (rules, sampleRate) {
|
|
188
140
|
return rules
|
|
189
141
|
.concat({ sampleRate })
|
package/NOTICE
DELETED
|
Binary file
|