Skip to content

Commit d43c70a

Browse files
rochdevwatson
authored andcommitted
replace msgpack-lite with official library for tests (#5173)
* replace msgpack-lite with official library for tests * remove int64-buffer * fix serializing traces in tests * replace bigint with int instead of str * fix moleculer test * fix llmobs tests * fix langchain tests
1 parent aac2baf commit d43c70a

File tree

20 files changed

+87
-124
lines changed

20 files changed

+87
-124
lines changed

LICENSE-3rdparty.csv

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dev,@apollo/server,MIT,Copyright (c) 2016-2020 Apollo Graph, Inc. (Formerly Mete
3535
dev,@types/node,MIT,Copyright Authors
3636
dev,@eslint/eslintrc,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
3737
dev,@eslint/js,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
38+
dev,@msgpack/msgpack,ISC,Copyright 2019 The MessagePack Community
3839
dev,@stylistic/eslint-plugin-js,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
3940
dev,autocannon,MIT,Copyright 2016 Matteo Collina
4041
dev,aws-sdk,Apache 2.0,Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -58,12 +59,10 @@ dev,get-port,MIT,Copyright Sindre Sorhus
5859
dev,glob,ISC,Copyright Isaac Z. Schlueter and Contributors
5960
dev,globals,MIT,Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
6061
dev,graphql,MIT,Copyright 2015 Facebook Inc.
61-
dev,int64-buffer,MIT,Copyright 2015-2016 Yusuke Kawasaki
6262
dev,jszip,MIT,Copyright 2015-2016 Stuart Knightley and contributors
6363
dev,knex,MIT,Copyright (c) 2013-present Tim Griesser
6464
dev,mkdirp,MIT,Copyright 2010 James Halliday
6565
dev,mocha,MIT,Copyright 2011-2018 JS Foundation and contributors https://js.foundation
66-
dev,msgpack-lite,MIT,Copyright 2015 Yusuke Kawasaki
6766
dev,multer,MIT,Copyright 2014 Hage Yaapa
6867
dev,nock,MIT,Copyright 2017 Pedro Teixeira and other contributors
6968
dev,nyc,ISC,Copyright 2015 Contributors

integration-tests/ci-visibility-intake.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const express = require('express')
22
const bodyParser = require('body-parser')
3-
const msgpack = require('msgpack-lite')
4-
const codec = msgpack.createCodec({ int64: true })
3+
const msgpack = require('@msgpack/msgpack')
54
const http = require('http')
65
const multer = require('multer')
76
const upload = multer()
@@ -81,7 +80,7 @@ class FakeCiVisIntake extends FakeAgent {
8180
res.status(200).send({ rate_by_service: { 'service:,env:': 1 } })
8281
this.emit('message', {
8382
headers: req.headers,
84-
payload: msgpack.decode(req.body, { codec }),
83+
payload: msgpack.decode(req.body, { useBigInt64: true }),
8584
url: req.url
8685
})
8786
})
@@ -100,7 +99,7 @@ class FakeCiVisIntake extends FakeAgent {
10099
res.status(200).send('OK')
101100
this.emit('message', {
102101
headers: req.headers,
103-
payload: msgpack.decode(req.body, { codec }),
102+
payload: msgpack.decode(req.body, { useBigInt64: true }),
104103
url: req.url
105104
})
106105
}, waitingTime || 0)

integration-tests/helpers/fake-agent.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ const EventEmitter = require('events')
55
const http = require('http')
66
const express = require('express')
77
const bodyParser = require('body-parser')
8-
const msgpack = require('msgpack-lite')
9-
const codec = msgpack.createCodec({ int64: true })
8+
const msgpack = require('@msgpack/msgpack')
109
const upload = require('multer')()
1110

1211
module.exports = class FakeAgent extends EventEmitter {
@@ -241,7 +240,7 @@ function buildExpressServer (agent) {
241240
res.status(200).send({ rate_by_service: { 'service:,env:': 1 } })
242241
agent.emit('message', {
243242
headers: req.headers,
244-
payload: msgpack.decode(req.body, { codec })
243+
payload: msgpack.decode(req.body, { useBigInt64: true })
245244
})
246245
})
247246

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"@apollo/server": "^4.11.0",
119119
"@eslint/eslintrc": "^3.1.0",
120120
"@eslint/js": "^9.11.1",
121+
"@msgpack/msgpack": "^3.0.0-beta3",
121122
"@stylistic/eslint-plugin-js": "^2.8.0",
122123
"@types/node": "^16.0.0",
123124
"autocannon": "^4.5.2",
@@ -142,12 +143,10 @@
142143
"glob": "^7.1.6",
143144
"globals": "^15.10.0",
144145
"graphql": "0.13.2",
145-
"int64-buffer": "^0.1.9",
146146
"jszip": "^3.5.0",
147147
"knex": "^2.4.2",
148148
"mkdirp": "^3.0.1",
149149
"mocha": "^10",
150-
"msgpack-lite": "^0.1.26",
151150
"multer": "^1.4.5-lts.1",
152151
"nock": "^11.3.3",
153152
"nyc": "^15.1.0",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const os = require('os')
66
const agent = require('../../dd-trace/test/plugins/agent')
77
const { expectedSchema, rawExpectedSchema } = require('./naming')
88

9-
const sort = trace => trace.sort((a, b) => a.start.toNumber() - b.start.toNumber())
9+
const sort = trace => trace.sort((a, b) => Number(a.start - b.start))
1010

1111
describe('Plugin', () => {
1212
let broker

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const dns = require('dns')
44
const agent = require('../../dd-trace/test/plugins/agent')
55
const { expectSomeSpan } = require('../../dd-trace/test/plugins/helpers')
6-
const { Int64BE } = require('int64-buffer') // TODO remove dependency
76
const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
87

98
describe('Plugin', () => {
@@ -66,7 +65,7 @@ describe('Plugin', () => {
6665
'span.kind': 'client',
6766
'ipc.path': '/tmp/dd-trace.sock'
6867
},
69-
parent_id: new Int64BE(parent.context()._spanId._buffer)
68+
parent_id: BigInt(parent.context()._spanId.toString(10))
7069
}).then(done).catch(done)
7170

7271
tracer.scope().activate(parent, () => {
@@ -121,7 +120,7 @@ describe('Plugin', () => {
121120
'tcp.remote.port': port,
122121
'tcp.local.port': socket.localPort
123122
},
124-
parent_id: new Int64BE(parent.context()._spanId._buffer)
123+
parent_id: BigInt(parent.context()._spanId.toString(10))
125124
}, 2000).then(done).catch(done)
126125
})
127126
})
@@ -152,7 +151,7 @@ describe('Plugin', () => {
152151
'tcp.remote.port': port,
153152
'tcp.local.port': socket.localPort
154153
},
155-
parent_id: new Int64BE(parent.context()._spanId._buffer)
154+
parent_id: BigInt(parent.context()._spanId.toString(10))
156155
}).then(done).catch(done)
157156
})
158157
})
@@ -168,7 +167,7 @@ describe('Plugin', () => {
168167
'span.kind': 'client',
169168
'ipc.path': '/tmp/dd-trace.sock'
170169
},
171-
parent_id: new Int64BE(parent.context()._spanId._buffer)
170+
parent_id: BigInt(parent.context()._spanId.toString(10))
172171
}).then(done).catch(done)
173172

174173
tracer.scope().activate(parent, () => {

packages/dd-trace/src/id.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ let batch = 0
1515
// Internal representation of a trace or span ID.
1616
class Identifier {
1717
constructor (value, radix = 16) {
18-
this._isUint64BE = true // msgpack-lite compatibility
1918
this._buffer = radix === 16
2019
? createBuffer(value)
2120
: fromString(value, radix)
@@ -31,7 +30,6 @@ class Identifier {
3130
return this._buffer
3231
}
3332

34-
// msgpack-lite compatibility
3533
toArray () {
3634
if (this._buffer.length === 8) {
3735
return this._buffer

packages/dd-trace/test/datastreams/processor.spec.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require('../setup/tap')
44

55
const { hostname } = require('os')
6-
const Uint64 = require('int64-buffer').Uint64BE
76

87
const { LogCollapsingLowestDenseDDSketch } = require('@datadog/sketches-js')
98

@@ -66,8 +65,8 @@ describe('StatsPoint', () => {
6665
payloadSize.accept(100)
6766

6867
const encoded = aggStats.encode()
69-
expect(encoded.Hash.toString()).to.equal(new Uint64(DEFAULT_CURRENT_HASH).toString())
70-
expect(encoded.ParentHash.toString()).to.equal(new Uint64(DEFAULT_PARENT_HASH).toString())
68+
expect(encoded.Hash.toString(16)).to.equal(DEFAULT_CURRENT_HASH.toString('hex'))
69+
expect(encoded.ParentHash.toString(16)).to.equal(DEFAULT_PARENT_HASH.toString('hex'))
7170
expect(encoded.EdgeTags).to.deep.equal(aggStats.edgeTags)
7271
expect(encoded.EdgeLatency).to.deep.equal(edgeLatency.toProto())
7372
expect(encoded.PathwayLatency).to.deep.equal(pathwayLatency.toProto())
@@ -278,8 +277,8 @@ describe('DataStreamsProcessor', () => {
278277
payloadSize.accept(mockCheckpoint.payloadSize)
279278

280279
const encoded = checkpointBucket.encode()
281-
expect(encoded.Hash.toString()).to.equal(new Uint64(DEFAULT_CURRENT_HASH).toString())
282-
expect(encoded.ParentHash.toString()).to.equal(new Uint64(DEFAULT_PARENT_HASH).toString())
280+
expect(encoded.Hash.toString(16)).to.equal(DEFAULT_CURRENT_HASH.toString('hex'))
281+
expect(encoded.ParentHash.toString(16)).to.equal(DEFAULT_PARENT_HASH.toString('hex'))
283282
expect(encoded.EdgeTags).to.deep.equal(mockCheckpoint.edgeTags)
284283
expect(encoded.EdgeLatency).to.deep.equal(edgeLatency.toProto())
285284
expect(encoded.PathwayLatency).to.deep.equal(pathwayLatency.toProto())

packages/dd-trace/test/datastreams/writer.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
require('../setup/tap')
33
const pkg = require('../../../../package.json')
44
const stubRequest = sinon.stub()
5-
const msgpack = require('msgpack-lite')
6-
const codec = msgpack.createCodec({ int64: true })
5+
const msgpack = require('@msgpack/msgpack')
76

87
const stubZlib = {
98
gzip: (payload, _opts, fn) => {
@@ -34,7 +33,7 @@ describe('DataStreamWriter unix', () => {
3433
writer = new DataStreamsWriter(unixConfig)
3534
writer.flush({})
3635
const stubRequestCall = stubRequest.getCalls()[0]
37-
const decodedPayload = msgpack.decode(stubRequestCall?.args[0], { codec })
36+
const decodedPayload = msgpack.decode(stubRequestCall?.args[0])
3837
const requestOptions = stubRequestCall?.args[1]
3938
expect(decodedPayload).to.deep.equal({})
4039
expect(requestOptions).to.deep.equal({

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
require('./setup/tap')
44

5-
const Uint64BE = require('int64-buffer').Uint64BE
65
const agent = require('./plugins/agent')
76

87
const { SAMPLING_PRIORITY_KEY, DECISION_MAKER_KEY } = require('../src/constants')
@@ -34,8 +33,8 @@ describe('dd-trace', () => {
3433
expect(payload[0][0].service).to.equal('test')
3534
expect(payload[0][0].name).to.equal('hello')
3635
expect(payload[0][0].resource).to.equal('/hello/:name')
37-
expect(payload[0][0].start).to.be.instanceof(Uint64BE)
38-
expect(payload[0][0].duration).to.be.instanceof(Uint64BE)
36+
expect(typeof payload[0][0].start).to.equal('bigint')
37+
expect(typeof payload[0][0].duration).to.equal('bigint')
3938
expect(payload[0][0].metrics).to.have.property(SAMPLING_PRIORITY_KEY)
4039
expect(payload[0][0].meta).to.have.property(DECISION_MAKER_KEY)
4140
})

0 commit comments

Comments
 (0)