Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/capabilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ futures-core = "0.3"
anyhow = "1"
# TODO: Replace this temporary libdatadog PR rev with the official release/tag
# that contains DataDog/libdatadog#2235, then regenerate Cargo.lock.
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "8cd68ab922fb7aade0f089ccfc91291d874673af" }
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "6356aee4c69b51f27e7e82e43b1797f60b74905a" }

[dev-dependencies]
wasm-bindgen-test = "0.3"
14 changes: 7 additions & 7 deletions crates/pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ serde_json = "1"
libdatadog-nodejs-capabilities = { path = "../capabilities" }
# TODO: Replace these temporary libdatadog PR revs with the official release/tag
# that contains DataDog/libdatadog#2235, then regenerate Cargo.lock.
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "8cd68ab922fb7aade0f089ccfc91291d874673af" }
libdd-common = { git = "https://github.com/DataDog/libdatadog.git", rev = "8cd68ab922fb7aade0f089ccfc91291d874673af", default-features = false }
libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog.git", rev = "8cd68ab922fb7aade0f089ccfc91291d874673af", default-features = false }
libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog.git", rev = "8cd68ab922fb7aade0f089ccfc91291d874673af", default-features = false, features = ["change-buffer"] }
libdd-trace-stats = { git = "https://github.com/DataDog/libdatadog.git", rev = "8cd68ab922fb7aade0f089ccfc91291d874673af", default-features = false }
libdd-trace-protobuf = { git = "https://github.com/DataDog/libdatadog.git", rev = "8cd68ab922fb7aade0f089ccfc91291d874673af", default-features = false }
libdd-shared-runtime = { git = "https://github.com/DataDog/libdatadog.git", rev = "8cd68ab922fb7aade0f089ccfc91291d874673af", default-features = false }
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "6356aee4c69b51f27e7e82e43b1797f60b74905a" }
libdd-common = { git = "https://github.com/DataDog/libdatadog.git", rev = "6356aee4c69b51f27e7e82e43b1797f60b74905a", default-features = false }
libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog.git", rev = "6356aee4c69b51f27e7e82e43b1797f60b74905a", default-features = false }
libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog.git", rev = "6356aee4c69b51f27e7e82e43b1797f60b74905a", default-features = false, features = ["change-buffer"] }
libdd-trace-stats = { git = "https://github.com/DataDog/libdatadog.git", rev = "6356aee4c69b51f27e7e82e43b1797f60b74905a", default-features = false }
libdd-trace-protobuf = { git = "https://github.com/DataDog/libdatadog.git", rev = "6356aee4c69b51f27e7e82e43b1797f60b74905a", default-features = false }
libdd-shared-runtime = { git = "https://github.com/DataDog/libdatadog.git", rev = "6356aee4c69b51f27e7e82e43b1797f60b74905a", default-features = false }
rmp-serde = "1"
bytes = "1"
http = "1"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datadog/libdatadog",
"version": "0.17.0",
"version": "0.18.0",
"description": "Node.js binding for libdatadog",
"main": "index.js",
"scripts": {
Expand Down
35 changes: 34 additions & 1 deletion test/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class NativeSpansInterface {
this.cqbCount = 0
}

const view = this._cqbView
let view = this._cqbView
// Op header: opcode (u16 LE) + span_id (u64 LE) = 10 bytes. Rust reads the
// opcode as a u16, then the span_id as a u64.
view.setUint16(this.cqbIndex, op, true)
Expand All @@ -250,6 +250,10 @@ class NativeSpansInterface {
for (const arg of args) {
if (typeof arg === 'string') {
const stringId = this.getStringId(arg)
if (this._wasmMemory.buffer !== view.buffer) {
this._refreshViews()
view = this._cqbView
}
view.setUint32(this.cqbIndex, stringId, true)
this.cqbIndex += 4
} else {
Expand Down Expand Up @@ -743,6 +747,28 @@ describe('pipeline', { skip }, () => {
assert.strictEqual(span.getTag('bulk-key'), 'bulk-val')
})

it('refreshes change-buffer views when string interning grows memory', () => {
const span = nativeSpans.createSpan()
const getStringId = nativeSpans.getStringId.bind(nativeSpans)
let grew = false
nativeSpans.getStringId = (str) => {
const id = getStringId(str)
if (!grew) {
grew = true
wasmMemory.grow(1)
}
return id
}

try {
span.setTag('grow-key', 'grow-value')

assert.strictEqual(span.getTag('grow-key'), 'grow-value')
} finally {
nativeSpans.getStringId = getStringId
}
})

it('rejects a malformed (non-terminated) stringTableInsertMany entry', () => {
const ptr = nativeSpans.state.string_table_input_ptr()
const len = nativeSpans.state.string_table_input_len()
Expand Down Expand Up @@ -944,6 +970,7 @@ describe('pipeline', { skip }, () => {
method: req.method,
url: req.url,
ct: req.headers['content-type'],
clientComputedStats: req.headers['datadog-client-computed-stats'],
len: Buffer.concat(chunks).length,
body: Buffer.concat(chunks).toString(),
})
Expand All @@ -956,6 +983,7 @@ describe('pipeline', { skip }, () => {
const ns = new NativeSpansInterface({
agentUrl: `http://127.0.0.1:${port}`,
tracerVersion: '7.0.0-pre',
clientComputedStats: true,
})
ns.state.setOtlpEndpoint(`http://127.0.0.1:${port}/v1/traces`)
const span = ns.createSpan()
Expand All @@ -975,6 +1003,11 @@ describe('pipeline', { skip }, () => {
const body = JSON.parse(req.body)
assert.strictEqual(body.resourceSpans[0].scopeSpans[0].scope.name, 'dd-trace-js')
assert.strictEqual(body.resourceSpans[0].scopeSpans[0].scope.version, '7.0.0-pre')
assert.strictEqual(req.clientComputedStats, 'yes')
const resourceAttrs = body.resourceSpans[0].resource.attributes
assert.ok(resourceAttrs.some((attr) => {
return attr.key === '_dd.stats_computed' && attr.value.stringValue === 'true'
}), 'OTLP resource should mark client-computed stats')
} finally {
server.closeAllConnections?.()
server.close()
Expand Down
Loading