Skip to content

Commit bf54af2

Browse files
authored
fix requests to the agent being traced (#1274)
1 parent cb158d1 commit bf54af2

File tree

5 files changed

+11
-27
lines changed

5 files changed

+11
-27
lines changed

packages/dd-trace/src/opentracing/tracer.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,6 @@ class DatadogTracer extends Tracer {
5656
}
5757
}
5858

59-
startSpan (name, fields) {
60-
if (fields) {
61-
if (fields.references) {
62-
return super.startSpan(name, fields)
63-
} else if (fields.childOf) {
64-
let parent = fields.childOf
65-
if (parent instanceof Span) {
66-
parent = parent.context()
67-
}
68-
if (parent instanceof SpanContext) {
69-
return this._startSpanInternal(name, fields, parent, REFERENCE_CHILD_OF)
70-
}
71-
}
72-
}
73-
return this._startSpanInternal(name, fields, null, null)
74-
}
75-
7659
_startSpan (name, fields) {
7760
const reference = getParent(fields.references)
7861
const type = reference && reference.type()

packages/dd-trace/src/scope/async_resource.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
const { createHook, executionAsyncResource } = require('async_hooks')
44
const Base = require('./base')
55

6+
let singleton = null
7+
68
class Scope extends Base {
79
constructor (config) {
10+
if (singleton) return singleton
11+
812
super()
913

14+
singleton = this
15+
1016
this._ddResourceStore = Symbol('ddResourceStore')
1117
this._config = config
1218
this._stack = []

packages/dd-trace/test/opentracing/tracer.spec.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const opentracing = require('opentracing')
44
const os = require('os')
55
const SpanContext = require('../../src/opentracing/span_context')
6+
const NoopSpan = require('../../src/noop/span')
67
const Reference = opentracing.Reference
78

89
describe('Tracer', () => {
@@ -297,13 +298,9 @@ describe('Tracer', () => {
297298
it('should return the same instance when the parent is a noop', () => {
298299
tracer = new Tracer(config)
299300

300-
sampler.isSampled.returns(false)
301-
const parent = tracer.startSpan('parent', fields)
302-
sampler.isSampled.returns(true)
301+
const parent = new NoopSpan(tracer)
303302

304-
fields.references = [
305-
new Reference(opentracing.REFERENCE_CHILD_OF, parent)
306-
]
303+
fields.childOf = parent
307304

308305
span = tracer.startSpan('name', fields)
309306

packages/dd-trace/test/plugins/util/redis.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict'
22

3+
wrapIt()
4+
35
describe('plugins/util/redis', () => {
46
let redis
57
let tracer

packages/dd-trace/test/scope/async_resource.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ function test () {
2727
span = new Span()
2828
})
2929

30-
afterEach(() => {
31-
scope.disable()
32-
})
33-
3430
it('should not break propagation for nested resources', () => {
3531
scope.activate(span, () => {
3632
const asyncResource = new AsyncResource(

0 commit comments

Comments
 (0)