Skip to content

Commit dfe8e04

Browse files
committed
test: rename agent.use() to .assertSomeTraces()
1 parent 1faa159 commit dfe8e04

File tree

61 files changed

+299
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+299
-299
lines changed

packages/datadog-plugin-amqplib/test/index.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ describe('Plugin', () => {
479479
channel.sendToQueue(ok.queue, Buffer.from('dsm test'))
480480

481481
let produceSpanMeta = {}
482-
agent.use(traces => {
482+
agent.assertSomeTraces(traces => {
483483
const span = traces[0][0]
484484

485485
if (span.resource.startsWith('basic.publish')) {
@@ -502,7 +502,7 @@ describe('Plugin', () => {
502502
if (err) return done(err)
503503

504504
let consumeSpanMeta = {}
505-
agent.use(traces => {
505+
agent.assertSomeTraces(traces => {
506506
const span = traces[0][0]
507507

508508
if (span.resource.startsWith('basic.deliver')) {

packages/datadog-plugin-aws-sdk/test/aws-sdk.spec.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('Plugin', () => {
2525
})
2626

2727
it('should instrument service methods with a callback', (done) => {
28-
agent.use(traces => {
28+
agent.assertSomeTraces(traces => {
2929
const span = sort(traces[0])[0]
3030

3131
expect(span).to.include({
@@ -48,7 +48,7 @@ describe('Plugin', () => {
4848
})
4949

5050
it('should instrument service methods using promise()', (done) => {
51-
agent.use(traces => {
51+
agent.assertSomeTraces(traces => {
5252
const span = sort(traces[0])[0]
5353

5454
expect(span).to.include({
@@ -92,7 +92,7 @@ describe('Plugin', () => {
9292
})
9393

9494
it('should instrument service methods with a callback', (done) => {
95-
agent.use(traces => {
95+
agent.assertSomeTraces(traces => {
9696
const span = sort(traces[0])[0]
9797

9898
expect(span).to.include({
@@ -117,7 +117,7 @@ describe('Plugin', () => {
117117
it('should mark error responses', (done) => {
118118
let error
119119

120-
agent.use(traces => {
120+
agent.assertSomeTraces(traces => {
121121
const span = sort(traces[0])[0]
122122

123123
expect(span).to.include({
@@ -148,7 +148,7 @@ describe('Plugin', () => {
148148

149149
if (!semver.intersects(version, '<3')) {
150150
it('should instrument service methods using promises', (done) => {
151-
agent.use(traces => {
151+
agent.assertSomeTraces(traces => {
152152
const span = sort(traces[0])[0]
153153

154154
expect(span).to.include({
@@ -162,7 +162,7 @@ describe('Plugin', () => {
162162
})
163163
} else if (!semver.intersects(version, '<2.3.0')) {
164164
it('should instrument service methods using promise()', (done) => {
165-
agent.use(traces => {
165+
agent.assertSomeTraces(traces => {
166166
const span = sort(traces[0])[0]
167167

168168
expect(span).to.include({
@@ -178,7 +178,7 @@ describe('Plugin', () => {
178178
it('should instrument service methods using promise() with custom promises', (done) => {
179179
AWS.config.setPromisesDependency(null)
180180

181-
agent.use(traces => {
181+
agent.assertSomeTraces(traces => {
182182
const span = sort(traces[0])[0]
183183

184184
expect(span).to.include({
@@ -235,7 +235,7 @@ describe('Plugin', () => {
235235
})
236236

237237
it('should be configured', (done) => {
238-
agent.use(traces => {
238+
agent.assertSomeTraces(traces => {
239239
const span = sort(traces[0])[0]
240240
expect(span).to.include({
241241
name: 'aws.request',
@@ -277,7 +277,7 @@ describe('Plugin', () => {
277277
it('should allow disabling a specific service', (done) => {
278278
let total = 0
279279

280-
agent.use(traces => {
280+
agent.assertSomeTraces(traces => {
281281
const span = sort(traces[0])[0]
282282

283283
expect(span).to.include({
@@ -289,7 +289,7 @@ describe('Plugin', () => {
289289
total++
290290
}).catch(() => {}, { timeoutMs: 100 })
291291

292-
agent.use(traces => {
292+
agent.assertSomeTraces(traces => {
293293
const span = sort(traces[0])[0]
294294

295295
expect(span).to.include({

packages/datadog-plugin-aws-sdk/test/bedrockruntime.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('Plugin', () => {
5454

5555
const command = new AWS.InvokeModelCommand(request)
5656

57-
agent.use(traces => {
57+
agent.assertSomeTraces(traces => {
5858
const span = traces[0][0]
5959
expect(span.meta).to.include({
6060
'aws.operation': 'invokeModel',

packages/datadog-plugin-aws-sdk/test/dynamodb.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ describe('Plugin', () => {
153153

154154
describe('with payload tagging', () => {
155155
it('adds request and response payloads as flattened tags for putItem', async () => {
156-
const agentPromise = agent.use(traces => {
156+
const agentPromise = agent.assertSomeTraces(traces => {
157157
const span = traces[0][0]
158158

159159
expect(span.resource).to.equal(`putItem ${oneKeyTableName}`)
@@ -179,7 +179,7 @@ describe('Plugin', () => {
179179
})
180180

181181
it('adds request and response payloads as flattened tags for updateItem', async () => {
182-
const agentPromise = agent.use(traces => {
182+
const agentPromise = agent.assertSomeTraces(traces => {
183183
const span = traces[0][0]
184184

185185
expect(span.resource).to.equal(`updateItem ${oneKeyTableName}`)
@@ -210,7 +210,7 @@ describe('Plugin', () => {
210210
})
211211

212212
it('adds request and response payloads as flattened tags for deleteItem', async () => {
213-
const agentPromise = agent.use(traces => {
213+
const agentPromise = agent.assertSomeTraces(traces => {
214214
const span = traces[0][0]
215215

216216
expect(span.resource).to.equal(`deleteItem ${oneKeyTableName}`)
@@ -246,7 +246,7 @@ describe('Plugin', () => {
246246
// Wait a bit to ensure the put completes
247247
await wait(100)
248248

249-
const agentPromise = agent.use(traces => {
249+
const agentPromise = agent.assertSomeTraces(traces => {
250250
const span = traces[0][0]
251251

252252
expect(span.resource).to.equal(`getItem ${oneKeyTableName}`)
@@ -292,7 +292,7 @@ describe('Plugin', () => {
292292
if (expectedHashes) {
293293
expectedLength = Array.isArray(expectedHashes) ? expectedHashes.length : 1
294294
}
295-
const agentPromise = agent.use(traces => {
295+
const agentPromise = agent.assertSomeTraces(traces => {
296296
const span = traces[0][0]
297297
const links = JSON.parse(span.meta?.['_dd.span_links'] || '[]')
298298

packages/datadog-plugin-aws-sdk/test/kinesis.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ describe('Kinesis', function () {
143143
})
144144

145145
it('generates tags for proper input', done => {
146-
agent.use(traces => {
146+
agent.assertSomeTraces(traces => {
147147
const span = traces[0][0]
148148
expect(span.meta).to.include({
149149
streamname: streamName,
@@ -219,7 +219,7 @@ describe('Kinesis', function () {
219219

220220
it('injects DSM pathway hash during Kinesis getRecord to the span', done => {
221221
let getRecordSpanMeta = {}
222-
agent.use(traces => {
222+
agent.assertSomeTraces(traces => {
223223
const span = traces[0][0]
224224

225225
if (span.name === 'aws.response') {
@@ -242,7 +242,7 @@ describe('Kinesis', function () {
242242

243243
it('injects DSM pathway hash during Kinesis putRecord to the span', done => {
244244
let putRecordSpanMeta = {}
245-
agent.use(traces => {
245+
agent.assertSomeTraces(traces => {
246246
const span = traces[0][0]
247247

248248
if (span.resource.startsWith('putRecord')) {

packages/datadog-plugin-aws-sdk/test/lambda.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('Plugin', () => {
8484
it('should propagate the tracing context with existing ClientContext and `custom` key', (done) => {
8585
let receivedContext
8686

87-
agent.use(traces => {
87+
agent.assertSomeTraces(traces => {
8888
const span = traces[0][0]
8989
const clientContextSent = Buffer.from(receivedContext, 'base64').toString('utf-8')
9090
const injectedTraceData = JSON.parse(clientContextSent).custom
@@ -115,7 +115,7 @@ describe('Plugin', () => {
115115
it('should propagate the tracing context with existing ClientContext and no `custom` key', (done) => {
116116
let receivedContext
117117

118-
agent.use(traces => {
118+
agent.assertSomeTraces(traces => {
119119
const span = traces[0][0]
120120
const clientContextSent = Buffer.from(receivedContext, 'base64').toString('utf-8')
121121
const injectedTraceData = JSON.parse(clientContextSent).custom
@@ -142,7 +142,7 @@ describe('Plugin', () => {
142142
it('should propagate the tracing context without an existing ClientContext', (done) => {
143143
let receivedContext
144144

145-
agent.use(traces => {
145+
agent.assertSomeTraces(traces => {
146146
const span = traces[0][0]
147147
const clientContextSent = Buffer.from(receivedContext, 'base64').toString('utf-8')
148148
const injectedTraceData = JSON.parse(clientContextSent).custom

packages/datadog-plugin-aws-sdk/test/s3.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('Plugin', () => {
7676

7777
describe('span pointers', () => {
7878
it('should add span pointer for putObject operation', (done) => {
79-
agent.use(traces => {
79+
agent.assertSomeTraces(traces => {
8080
try {
8181
const span = traces[0][0]
8282
const links = JSON.parse(span.meta?.['_dd.span_links'] || '[]')
@@ -106,7 +106,7 @@ describe('Plugin', () => {
106106
})
107107

108108
it('should add span pointer for copyObject operation', (done) => {
109-
agent.use(traces => {
109+
agent.assertSomeTraces(traces => {
110110
try {
111111
const span = traces[0][0]
112112
const links = JSON.parse(span.meta?.['_dd.span_links'] || '[]')
@@ -181,7 +181,7 @@ describe('Plugin', () => {
181181

182182
s3.completeMultipartUpload(completeParams, (err) => {
183183
if (err) done(err)
184-
agent.use(traces => {
184+
agent.assertSomeTraces(traces => {
185185
const span = traces[0][0]
186186
const operation = span.meta?.['aws.operation']
187187
if (operation === 'completeMultipartUpload') {
@@ -209,7 +209,7 @@ describe('Plugin', () => {
209209
it('should allow disabling a specific span kind of a service', (done) => {
210210
let total = 0
211211

212-
agent.use(traces => {
212+
agent.assertSomeTraces(traces => {
213213
const span = traces[0][0]
214214
expect(span).to.include({
215215
name: 'aws.request',

packages/datadog-plugin-aws-sdk/test/sns.spec.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Sns', function () {
2727

2828
let childSpansFound = 0
2929
const assertPropagation = (done, childSpans = 1) => {
30-
agent.use(traces => {
30+
agent.assertSomeTraces(traces => {
3131
const span = traces[0][0]
3232

3333
if (span.resource.startsWith('publish')) {
@@ -112,7 +112,7 @@ describe('Sns', function () {
112112
})
113113

114114
it('adds request and response payloads as flattened tags', done => {
115-
agent.use(traces => {
115+
agent.assertSomeTraces(traces => {
116116
const span = traces[0][0]
117117

118118
expect(span.resource).to.equal(`publish ${TopicArn}`)
@@ -145,7 +145,7 @@ describe('Sns', function () {
145145
})
146146

147147
it('expands and redacts keys identified as expandable', done => {
148-
agent.use(traces => {
148+
agent.assertSomeTraces(traces => {
149149
const span = traces[0][0]
150150

151151
expect(span.resource).to.equal(`publish ${TopicArn}`)
@@ -175,7 +175,7 @@ describe('Sns', function () {
175175

176176
describe('user-defined redaction', () => {
177177
it('redacts user-defined keys to suppress in request', done => {
178-
agent.use(traces => {
178+
agent.assertSomeTraces(traces => {
179179
const span = traces[0][0]
180180

181181
expect(span.resource).to.equal(`publish ${TopicArn}`)
@@ -208,7 +208,7 @@ describe('Sns', function () {
208208

209209
// TODO add response tests
210210
it('redacts user-defined keys to suppress in response', done => {
211-
agent.use(traces => {
211+
agent.assertSomeTraces(traces => {
212212
const span = traces[0][0]
213213
expect(span.resource).to.equal(`getTopicAttributes ${TopicArn}`)
214214
expect(span.meta).to.include({
@@ -252,7 +252,7 @@ describe('Sns', function () {
252252
})
253253

254254
it('redacts phone numbers in request', done => {
255-
agent.use(traces => {
255+
agent.assertSomeTraces(traces => {
256256
const span = traces[0][0]
257257

258258
expect(span.resource).to.equal('publish')
@@ -271,7 +271,7 @@ describe('Sns', function () {
271271
})
272272

273273
it('redacts phone numbers in response', done => {
274-
agent.use(traces => {
274+
agent.assertSomeTraces(traces => {
275275
const span = traces[0][0]
276276

277277
expect(span.resource).to.equal('publish')
@@ -292,7 +292,7 @@ describe('Sns', function () {
292292

293293
describe('subscription confirmation tokens', () => {
294294
it('redacts tokens in request', done => {
295-
agent.use(traces => {
295+
agent.assertSomeTraces(traces => {
296296
const span = traces[0][0]
297297

298298
expect(span.resource).to.equal(`confirmSubscription ${TopicArn}`)
@@ -478,7 +478,7 @@ describe('Sns', function () {
478478
}
479479

480480
it('generates tags for proper publish calls', done => {
481-
agent.use(traces => {
481+
agent.assertSomeTraces(traces => {
482482
const span = traces[0][0]
483483

484484
expect(span.resource).to.equal(`publish ${TopicArn}`)
@@ -542,7 +542,7 @@ describe('Sns', function () {
542542
if (err) return done(err)
543543

544544
let publishSpanMeta = {}
545-
agent.use(traces => {
545+
agent.assertSomeTraces(traces => {
546546
const span = traces[0][0]
547547

548548
if (span.resource.startsWith('publish')) {
@@ -573,7 +573,7 @@ describe('Sns', function () {
573573
if (err) return done(err)
574574

575575
let consumeSpanMeta = {}
576-
agent.use(traces => {
576+
agent.assertSomeTraces(traces => {
577577
const span = traces[0][0]
578578

579579
if (span.name === 'aws.response') {

0 commit comments

Comments
 (0)