Skip to content
Open
Show file tree
Hide file tree
Changes from 160 commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
e999e87
feat(native-spans): add native subsystem (WASM pipeline + interface +…
bengl May 12, 2026
8ac997a
feat(native-spans): integrate native mode into tracer, span processor…
bengl May 12, 2026
8709a90
test(native-spans): add unit + integration specs
bengl May 12, 2026
dc06728
chore(native-spans): benchmarks and test env hygiene
bengl May 12, 2026
535cde6
refactor(native-spans): require @datadog/libdatadog; remove JS pipeline
bengl May 14, 2026
f6a11e7
fix(native-spans): publish first-flush channel from native exporter
bengl May 27, 2026
16bfa63
fix(config): drop dead OTLP-protocol-mismatch override
bengl May 27, 2026
1897881
chore(native-spans): scrub dangling span_format.js comment refs
bengl May 27, 2026
d214d24
fix(native-spans): forward sampling-decision metrics to native exporter
bengl May 27, 2026
8ce7eda
fix(native-spans): emit single-span ingestion tags from SpanSampler
bengl May 27, 2026
d7c9084
fix(native-spans): re-register extra services during span processing
bengl May 27, 2026
0f3420c
refactor(config): remove dead _DD_APM_TRACING_AGENTLESS_ENABLED knob
bengl May 29, 2026
1185e61
refactor(native-spans): drop async/await in flushSpans
bengl May 29, 2026
1326740
fix(native-spans): restore _dd.tags.process emission on local root span
bengl May 29, 2026
23e97fc
feat(native-spans): set _dd.measured when span.kind is non-internal
bengl May 29, 2026
c1fef97
fix(native-spans): restore tag coercion parity with legacy formatter
bengl Jun 1, 2026
f3cde7c
fix(native-spans): feed agent sampling rates back into priority sampler
bengl Jun 2, 2026
d67328b
feat(native-spans): migrate native layer from slot-index to span_id p…
bengl Jun 24, 2026
18c8f6f
feat(native-spans): forward meta_struct to native storage
bengl Jun 25, 2026
1affd4b
feat(native-spans): route unix socket and named-pipe agent URLs natively
bengl Jun 25, 2026
f454175
feat(native-spans): emit exporter health metrics on the native path
bengl Jun 25, 2026
73ce1c0
feat(native-spans): forward span_events to the native top-level field
bengl Jun 25, 2026
730b231
feat(native-spans): add v0.5 output negotiation to the native exporter
bengl Jun 26, 2026
729fecc
fix(native-spans): address Codex review — otel error guard, tag-updat…
bengl Jun 29, 2026
6ce033b
fix(native-spans): address Codex re-review — LE span-id fold, 128-bit…
bengl Jun 29, 2026
5416a35
feat(native): export traces via OTLP when OTEL_TRACES_EXPORTER=otlp
bengl Jun 30, 2026
25b23e4
refactor(native): tighten OTLP config wiring
bengl Jun 30, 2026
0c5f157
fix(native): stop the exporter on a fatal libdatadog build error
bengl Jun 30, 2026
3f58bfc
chore(deps): bump @datadog/libdatadog to 0.11.0
bengl Jul 1, 2026
39a0f74
chore: merge master into bengl/native-spans-attempt-3
bengl Jul 1, 2026
cd9b24c
chore(config): regenerate config types after master merge
bengl Jul 2, 2026
c67e070
chore(deps): bump @datadog/libdatadog to 0.12.1
bengl Jul 2, 2026
a1976b6
fix(native): refresh change-buffer views at queue-write entry
bengl Jul 2, 2026
1d70bef
fix(native): tolerate "span not found" instead of crashing the host
bengl Jul 2, 2026
2180c7f
fix(native): preserve the change queue when a span send fails
bengl Jul 6, 2026
4c2fcd2
fix(native): send one chunk per trace so multi-trace flushes stay cor…
bengl Jul 6, 2026
1a8175c
chore(deps): bump @datadog/libdatadog to 0.12.2
bengl Jul 6, 2026
7b8fabc
chore: merge master into bengl/native-spans-attempt-3
bengl Jul 6, 2026
989d775
bench(native-spans): port benches to span_id protocol, retire exporti…
bengl Jul 6, 2026
a757f57
style(native): satisfy comma-dangle and padded-blocks lint
bengl Jul 6, 2026
6976e05
test: accept POST /v0.x/traces in the plugin test agent
bengl Jul 6, 2026
e1cd69f
fix(native): dispatch batched addTags to the native span
bengl Jul 7, 2026
0b2b6f8
fix(native): read span ids via toBuffer so parent_id survives export
bengl Jul 7, 2026
d0f4210
test: backfill error: 0 for native spans in the plugin test agent
bengl Jul 7, 2026
6e0df34
feat(native): apply OTel HTTP semantics on the native span path
bengl Jul 7, 2026
949b5aa
fix(ci-visibility): restore the JS pipeline for Test Optimization
bengl Jul 7, 2026
a275009
chore: merge master into bengl/native-spans-attempt-3
bengl Jul 7, 2026
73a2a89
fix(bundlers): externalize @datadog/libdatadog for esbuild and webpack
bengl Jul 7, 2026
b6cdadf
fix(native): mirror a pre-set sampling priority to the native span
bengl Jul 7, 2026
dd31960
fix(native): sync trace propagation tags (_dd.p.tid) to the native span
bengl Jul 7, 2026
2d5ac44
test: accept POST /v0.4/traces in the integration-test FakeAgent
bengl Jul 7, 2026
d7febf6
fix(native): pin span start time so the wire start matches _startTime
bengl Jul 8, 2026
ad2c357
fix(native): create the native stats collector when stats computation…
bengl Jul 8, 2026
9edf5f1
test(llmobs): read service from the top-level span field
bengl Jul 8, 2026
c76dab4
test(bundlers): resolve @datadog/libdatadog in the openfeature reloca…
bengl Jul 8, 2026
5250691
test: expect native-init debug lines in the forced-runtime init tests
bengl Jul 8, 2026
4631b64
fix(native): omit undefined-valued keys when msgpack-encoding
bengl Jul 8, 2026
78481bb
fix(native): default native span events on so span_events is exported
bengl Jul 8, 2026
e1716a9
chore(deps): bump @datadog/libdatadog to 0.13.0 and send client-compu…
bengl Jul 8, 2026
82457b6
fix(native): sync trace tags after git metadata so _dd.git.* is exported
bengl Jul 8, 2026
dff52c1
fix(native): default a span's resource to its operation name
bengl Jul 8, 2026
3f8b33c
fix(native): log the exported payload in debug for parity
bengl Jul 8, 2026
8d5401c
fix(native): match the JS formatter for bare service + error-shaped tags
bengl Jul 8, 2026
ed37238
test: backfill parent_id:0 in the plugin test agent
bengl Jul 8, 2026
0cafbb8
fix(native): send one payload per trace at flushInterval:0
bengl Jul 8, 2026
ce56432
fix(native): stamp language and _dd.origin like the JS formatter
bengl Jul 9, 2026
063111c
fix(native): coerce the operation name so an undefined name can't crash
bengl Jul 9, 2026
4edc3bc
style: fix import order and an over-long test title
bengl Jul 9, 2026
47bfd6e
fix(native): flip the error bit for error.message / error.stack
bengl Jul 9, 2026
4fcb12a
fix(native): don't inherit the global version on a different-service …
bengl Jul 9, 2026
1672e59
test(llmobs): expect the base service, not the schematized service name
bengl Jul 9, 2026
d6be43b
fix(native): make trace.tags the single source of _dd.p.dm
bengl Jul 9, 2026
baa753b
fix(native): expose a _writer.flush shim on the native exporter
bengl Jul 9, 2026
13319cb
fix(native): flatten span-event array attributes into indexed scalar …
bengl Jul 9, 2026
6bbf0c8
fix(native): restore OTLP span metrics
bengl Jul 9, 2026
b88c830
test(http2): bind the live tracer from agent.load so manual spans don…
bengl Jul 9, 2026
340be70
style(native): satisfy lint in span-event encoder and operation-name …
bengl Jul 9, 2026
633d292
fix(mongodb-core): sync peer.service to native so the DBM comment mat…
bengl Jul 9, 2026
500404f
test: decode native top-level span_events in unformatSpanEvents
bengl Jul 9, 2026
2f88b66
Merge remote-tracking branch 'origin/master' into bengl/native-spans-…
bengl Jul 9, 2026
2f5bb9c
chore(deps): bump @datadog/libdatadog to 0.14.0
bengl Jul 9, 2026
2ba8153
fix(native-spans): stop syncing tags to native after a span is exported
bengl Jul 9, 2026
b49d593
fix(native-spans): strip nulls from meta_struct to match the legacy e…
bengl Jul 10, 2026
393dbb3
fix(native-spans): satisfy eslint (no-useless-undefined, no-private-t…
bengl Jul 10, 2026
a34eb7a
feat(native-spans): expose a force stats-flush for the parametric sta…
bengl Jul 10, 2026
ce7d5a2
chore(deps): bump @datadog/libdatadog to 0.15.0
bengl Jul 10, 2026
8bd434d
ci(system-tests): pin system-tests ref to the native stats-flush branch
bengl Jul 10, 2026
55f6668
fix(native-spans): typed array span-event attrs + `events` tag fallback
bengl Jul 10, 2026
5c26f9e
chore(codeowners): own native-spans files (lang-platform-js)
bengl Jul 10, 2026
dc41800
fix(native-spans): route the electron exporter through the JS pipeline
bengl Jul 10, 2026
dd7bfa4
fix(native-spans): publish first-flush on send attempt, not success
bengl Jul 10, 2026
3a9a1b1
test(init): gate native-init debug lines on a supported runtime
bengl Jul 10, 2026
8031d49
chore(deps): bump @datadog/libdatadog to 0.16.0
bengl Jul 11, 2026
5fab654
fix(native-spans): report JavaScriptCore interpreter under Bun
bengl Jul 13, 2026
c17c51e
fix(native-spans): force-flush client stats via _writer.flush shim
bengl Jul 13, 2026
2cfc06a
fix(native-spans): suppress native v0.6 stats when OTLP trace metrics…
bengl Jul 13, 2026
5d778b1
test(native-spans): accept any truthy Datadog-Client-Computed-Stats v…
bengl Jul 13, 2026
e13a103
fix(native-spans): add setTag to mongodb benchmark stub span
bengl Jul 13, 2026
996aa6a
fix(native-spans): default DD_TRACE_NATIVE_SPAN_EVENTS back to false
bengl Jul 13, 2026
f399674
fix(native-spans): add trailing comma in _writer shim (lint)
bengl Jul 13, 2026
007b8c8
fix(native-spans): stamp process tags before export
bengl Jul 13, 2026
80da20c
test(test-optimization): accept native trace POSTs
bengl Jul 14, 2026
daaeaef
Merge remote-tracking branch 'origin/master' into bengl/native-spans-…
bengl Jul 14, 2026
fcb3902
fix(native-spans): emit collapsed stats health metric
bengl Jul 15, 2026
37c0314
Merge remote-tracking branch 'origin/master' into bengl/native-spans-…
bengl Jul 15, 2026
94cc3ee
chore(codeowners): own JS span processor
bengl Jul 15, 2026
6aec7c3
test(aerospike): target native-batched command spans
bengl Jul 15, 2026
324273b
chore(native): bump libdatadog to 0.17.0
bengl Jul 16, 2026
e02d720
Merge remote-tracking branch 'origin/master' into bengl/native-spans-…
bengl Jul 16, 2026
f2129aa
test(opentelemetry): read native exports in next span naming spec
bengl Jul 16, 2026
fd17aa8
bench(sirun): bound native benchmark runtime
bengl Jul 16, 2026
9c59e4e
test(aerospike): close agent between config suites
bengl Jul 17, 2026
7c1b0b0
fix(native): bump libdatadog to 0.18.0
bengl Jul 17, 2026
1827feb
perf(native): reduce addTags overhead
bengl Jul 17, 2026
2a0dcd1
perf(native): reduce processor flush overhead
bengl Jul 17, 2026
5e27669
style(native): fix span lint failures
bengl Jul 17, 2026
059671d
ci: update serverless benchmark ref
bengl Jul 20, 2026
f10468c
fix(native): replay error meta at export
bengl Jul 20, 2026
47614d9
fix(native): wait for in-flight sends during flush
bengl Jul 20, 2026
db6a3c9
perf(native): avoid batch arrays for setTag
bengl Jul 20, 2026
72cf390
fix(native): bump libdatadog to 0.18.1
bengl Jul 20, 2026
4d1e86f
fix(native): flush pending spans before setUrl
bengl Jul 20, 2026
b9f433e
merge master into native spans
bengl Jul 20, 2026
bf4c846
fix(native): defer setUrl until active spans drain
bengl Jul 20, 2026
a1bdbac
test(native): cover wasm memory growth view refresh
bengl Jul 21, 2026
c74fd33
fix(aerospike): preserve callback parent context
bengl Jul 21, 2026
36032cc
ci: restore serverless benchmark ref
bengl Jul 22, 2026
6db723c
fix(openfeature): register feature from bootstrap
bengl Jul 22, 2026
2d43162
fix(native): keep libdatadog optional
bengl Jul 22, 2026
b1ba53c
fix(native): use js spans in aws lambda
bengl Jul 22, 2026
f625bb5
Merge remote-tracking branch 'origin/master' into native spans
bengl Jul 22, 2026
8ad4ec6
fix(native): preserve JS fallback and chunk boundaries
bengl Jul 22, 2026
ab8ccdc
fix(native-spans): harden native span cleanup
bengl Jul 24, 2026
5cb4811
fix(bench): restore native span drain helper
bengl Jul 27, 2026
2ea449e
Merge remote-tracking branch 'origin/master' into bengl/native-spans-…
bengl Jul 27, 2026
41805d1
test(native-spans): align tracing specs with final sync
bengl Jul 27, 2026
ed328a9
test(native-spans): fix lint and windows ci validation
bengl Jul 29, 2026
ab8472b
Merge remote-tracking branch 'origin/master' into bengl/native-spans-…
bengl Jul 29, 2026
5c80167
ci(native-spans): harden benchmark dependency install
bengl Jul 29, 2026
5419f3b
ci(native-spans): bypass proxy for benchmark registry fetches
bengl Jul 29, 2026
9346fe9
ci(native-spans): pass benchmark proxy bypass downstream
bengl Jul 29, 2026
ce2b703
ci(native-spans): harden serverless benchmark installs
bengl Jul 29, 2026
eb9dc11
ci(native-spans): use npm registry for serverless benchmark
bengl Jul 29, 2026
cced1e7
fix(native-spans): correct flush protocol and WASM reclamation
bengl Jul 30, 2026
0d5b587
fix(native-spans): send one request per trace chunk again
bengl Jul 30, 2026
8cb759d
fix(native-spans): let an explicit agent exporter win in a Lambda
bengl Jul 30, 2026
25364a4
fix(native-spans): restore the parent commit's payload composition
bengl Jul 30, 2026
b52ea60
fix(native-spans): reset the export path to the last green state
bengl Jul 30, 2026
b092cfd
fix(native-spans): honour a custom DNS lookup by using the JS pipeline
bengl Jul 30, 2026
9e5b16d
fix(native-spans): stop registering the primary service as an extra s…
bengl Jul 31, 2026
7e706a5
fix(native-spans): drop span events with a non-string name
bengl Jul 31, 2026
25d2a94
fix(native-spans): apply sampling rates from every request in a flush
bengl Jul 31, 2026
3786df7
fix(native-spans): restore container-tag hash updates on agent responses
bengl Jul 31, 2026
956052e
fix(native-spans): keep OTLP export when a custom lookup is configured
bengl Jul 31, 2026
e6dfb9f
fix(opentelemetry): guard forceFlush for exporters without flush
bengl Jul 31, 2026
78201a7
fix(native-spans): normalize core span fields before native export
bengl Jul 31, 2026
3f3148e
fix(native-spans): keep OTLP span events on the native event slot
bengl Jul 31, 2026
bca8cc8
perf(native-spans): reduce change-buffer writes
bengl Aug 3, 2026
3b2aeab
perf(native-spans): fast sync primitive tags
bengl Aug 3, 2026
429a2c1
refactor(native-spans): simplify native pipeline
bengl Aug 6, 2026
fdffe88
bench(native-spans): use JS exporting processor
bengl Aug 6, 2026
edcaa00
bench(native-spans): support baseline benchmark source
bengl Aug 6, 2026
93e1e27
refactor(native-spans): simplify span processing
bengl Aug 6, 2026
240baef
perf(native-spans): bound exporter batching
BridgeAR Aug 4, 2026
d0eb020
perf(native-spans): reuse trace ID bytes
BridgeAR Aug 4, 2026
f6da51c
perf(native-spans): keep context shapes stable
BridgeAR Aug 4, 2026
5629dd2
fix(native-spans): preserve long resource names
BridgeAR Aug 4, 2026
56f9631
fix(native-spans): preserve base service in fast sync
BridgeAR Aug 4, 2026
cbf2cbf
bench(spans): discard native mutations before processing
BridgeAR Aug 4, 2026
a127870
test(native-spans): reuse existing test contracts
bengl Aug 6, 2026
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
10 changes: 8 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@
/packages/dd-trace/test/plugins/util/test.spec.js @DataDog/ci-app-libraries
/packages/dd-trace/test/plugins/util/test-environment.spec.js @DataDog/ci-app-libraries
/packages/dd-trace/src/encode/agentless-ci-visibility.js @DataDog/ci-app-libraries
/packages/dd-trace/src/encode/agentless-json.js @DataDog/ci-app-libraries
/packages/dd-trace/src/encode/coverage-ci-visibility.js @DataDog/ci-app-libraries
/packages/dd-trace/src/encode/tags-processors.js @DataDog/ci-app-libraries
/packages/dd-trace/src/encode/agentless-json.js @DataDog/ci-app-libraries
/packages/dd-trace/src/exporters/agentless/ @DataDog/ci-app-libraries
/packages/dd-trace/src/encode/tags-processors.js @DataDog/ci-app-libraries
/packages/dd-trace/src/git_metadata.js @DataDog/ci-app-libraries
/packages/dd-trace/src/git_metadata_tagger.js @DataDog/ci-app-libraries
/packages/dd-trace/src/plugins/util/ci.js @DataDog/ci-app-libraries
Expand Down Expand Up @@ -343,6 +343,7 @@
/benchmark/sirun/exporting-pipeline/ @DataDog/lang-platform-js
/benchmark/sirun/id/ @DataDog/lang-platform-js
/benchmark/sirun/log/ @DataDog/lang-platform-js
/benchmark/sirun/native-span-drain.js @DataDog/lang-platform-js
/benchmark/sirun/runtime-metrics/ @DataDog/lang-platform-js
/benchmark/sirun/scope/ @DataDog/lang-platform-js
/benchmark/sirun/shimmer-runtime/ @DataDog/lang-platform-js
Expand Down Expand Up @@ -372,8 +373,13 @@
/packages/datadog-core/ @DataDog/lang-platform-js
/packages/datadog-shimmer/ @DataDog/lang-platform-js
/packages/dd-trace/*/crashtracking/ @DataDog/lang-platform-js
/packages/dd-trace/src/native/ @DataDog/lang-platform-js
/packages/dd-trace/src/exporters/native/ @DataDog/lang-platform-js
/packages/dd-trace/test/native/ @DataDog/lang-platform-js
/packages/dd-trace/src/bootstrap.js @DataDog/lang-platform-js
/packages/dd-trace/src/feature-registry.js @DataDog/lang-platform-js
/packages/dd-trace/src/js_span_processor.js @DataDog/lang-platform-js
/packages/dd-trace/test/js_span_processor.spec.js @DataDog/lang-platform-js
/packages/dd-trace/src/exporters/common/ @DataDog/lang-platform-js
/packages/dd-trace/src/exporters/common/client-library-headers.js @DataDog/lang-platform-js @DataDog/feature-flagging-and-experimentation-sdk
/packages/dd-trace/src/proxy.js @DataDog/lang-platform-js
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
packages: write
with:
library: nodejs
# TEMPORARY: pin system-tests to the branch that flushes native client stats
# on /trace/stats/flush (DataDog/system-tests#7293). Revert to the default
# (drop this `ref`) once #7293 merges to system-tests main.
ref: bengl/parametric-native-stats-flush
binaries_artifact: system_tests_binaries
desired_execution_time: 300 # 5 minutes
scenarios_groups: tracer-release
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Temporary Items
logs
*.log
node-*-junit.xml
.junit-tmp/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down
8 changes: 8 additions & 0 deletions .gitlab/benchmarks/gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ variables:
needs: [ ]
tags: ["runner:apm-k8s-m7i-metal"]
image: $MICROBENCHMARKS_CI_IMAGE
variables:
KUBERNETES_POD_ANNOTATIONS_1: "beta.fabric.datadoghq.com/no-proxy-additions=registry.yarnpkg.com"
rules:
- if: '$CI_COMMIT_REF_NAME =~ /^graphite-base\/.*$/'
when: never
Expand Down Expand Up @@ -177,4 +179,10 @@ benchmark-serverless-trigger:
UPSTREAM_GITLAB_USER_EMAIL: $GITLAB_USER_EMAIL
# only available on Merge Requests
UPSTREAM_MERGE_TARGET_BRANCH: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
# The downstream serverless-tools hard cap can lag current main layer sizes;
# keep PRs gated by size increase while allowing the largest measured current-main layer.
MAX_LAYER_UNCOMPRESSED_SIZE_KB: "25280"
KUBERNETES_POD_ANNOTATIONS_1: "beta.fabric.datadoghq.com/no-proxy-additions=registry.yarnpkg.com,registry.npmjs.org"
YARN_REGISTRY: "https://registry.npmjs.org"
YARN_NETWORK_TIMEOUT: "600000"
DD_TAGS: "SLS_CI_BRANCH:$SLS_CI_BRANCH"
4 changes: 2 additions & 2 deletions benchmark/sirun/collect-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const SG_FILE = path.join(require('os').tmpdir(), 'sg-overview.txt')
// Curated per-bench judgment the run cannot measure.
const HIGH_MEANING = new Set([
'shimmer-runtime', 'shimmer-startup', 'scope', 'id', 'spans', 'encoding',
'exporting-pipeline', 'propagation', 'async_hooks', 'url', 'startup', 'fs',
'native-spans', 'propagation', 'async_hooks', 'url', 'startup', 'fs',
])
const LOW_MEANING = new Set(['plugin-dns'])

const CRITICAL_PATH = new Set([
'shimmer-runtime', 'shimmer-startup', 'scope', 'id', 'spans', 'encoding',
'exporting-pipeline', 'propagation', 'async_hooks', 'startup',
'native-spans', 'propagation', 'async_hooks', 'startup',
])
const LIVE = new Set(['appsec', 'appsec-iast', 'plugin-http', 'plugin-net'])
const BACKGROUND = new Set(['runtime-metrics', 'profiler', 'log', 'llmobs', 'debugger'])
Expand Down
47 changes: 47 additions & 0 deletions benchmark/sirun/native-span-drain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict'

const DEFAULT_DRAIN_THRESHOLD = 5000

function createNativeSpanDrain (tracer, threshold = DEFAULT_DRAIN_THRESHOLD) {
const nativeSpans = tracer._tracer._nativeSpans
const pendingSpanIds = nativeSpans ? [] : null

function add (span) {
if (pendingSpanIds) {
pendingSpanIds.push(span.context()._nativeSpanId)
}
}

function addAll (spans) {
if (!pendingSpanIds) return

for (const span of spans) {
pendingSpanIds.push(span.context()._nativeSpanId)
}
}

async function drain () {
if (!pendingSpanIds || pendingSpanIds.length === 0) return

nativeSpans.flushChangeQueue()

const spanIds = Buffer.allocUnsafe(pendingSpanIds.length * 8)
let offset = 0
for (const spanId of pendingSpanIds) {
spanIds.set(spanId, offset)
offset += 8
}

nativeSpans._state.prepareChunk(pendingSpanIds.length, false, spanIds)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Group benchmark drains by trace segment

In the spans and plugin-redis-traced benchmarks, this array contains thousands of independently created root spans, each with a different native segment, but it is passed to one prepareChunk call. The native flush contract in native_spans.js requires each prepared group to contain exactly one trace/segment; combining them applies one segment's chunk handling to unrelated traces and then clears every ID from the helper, so native state may not be reclaimed correctly and the measured memory/time results are invalid. Group IDs by trace segment and prepare each group separately.

Useful? React with 👍 / 👎.

await nativeSpans._state.sendPreparedChunk().catch(() => {})
pendingSpanIds.length = 0
}

function needsDrain () {
return pendingSpanIds && pendingSpanIds.length >= threshold
}

return { add, addAll, drain, needsDrain }
}

module.exports = { createNativeSpanDrain }
4 changes: 3 additions & 1 deletion benchmark/sirun/plugin-mongodb-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const OPERATIONS = Number(process.env.OPERATIONS)
// `Object.create`) is required because `DatabasePlugin` uses private methods
// that demand a real instance.
let lastMeta
const FAKE_SPAN = { finish () {} }
// bindStart calls span.setTag('peer.service', ...) (query.js), so the stub must
// implement setTag alongside finish (matching the other plugin benchmarks).
const FAKE_SPAN = { finish () {}, setTag () {} }
const SERVICE_RESULT = { name: 'mongo-prod', source: 'mongodb' }
class BenchedMongoPlugin extends MongodbCorePlugin {
addTraceSubs () { /* skip diagnostic-channel subscriptions */ }
Expand Down
49 changes: 32 additions & 17 deletions benchmark/sirun/plugin-redis-traced/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
'use strict'

const assert = require('node:assert/strict')
const nock = require('nock')

const guard = require('../startup-guard')
const { createNativeSpanDrain } = require('../native-span-drain')

nock.disableNetConnect()
nock('http://127.0.0.1:8126').persist().put(/.*/).reply(200, '{}').post(/.*/).reply(200, '{}')

// Full traced redis command, end to end. Where the isolated plugin-redis bench
// stubs startSpan to measure only the meta assembly, this drives the real tracer
// and the real redis plugin over the diagnostic channels the instrumentation
// uses, so each iteration pays the whole per-command cost: bindStart meta build,
// span start, context entry via runStores, span finish and the real processor
// (priority/span sampling, git-metadata tagging, span formatting and stats).
// Only the exporter is swapped for a no-op, so the processor still formats and
// erases each finished trace but nothing is buffered, encoded, or leaves the
// process.
const tracer = require('../../..').init()
tracer._tracer._processor._exporter = { export () {} }
// The exporter is replaced with a collector so JS spans still format+erase and
// native spans can be periodically drained without measuring real network I/O.
const tracer = require('../../..').init({ hostname: '127.0.0.1', port: 8126 })
const nativeSpanDrain = createNativeSpanDrain(tracer)
tracer._tracer._processor._exporter = {
export (spans) {
nativeSpanDrain.addAll(spans)
},
}

const RedisPlugin = require('../../../packages/datadog-plugin-redis/src/index')
const { channel } = require('../../../packages/datadog-instrumentations/src/helpers/instrument')
Expand Down Expand Up @@ -68,16 +78,21 @@ assert.equal(preSpan.context().getTag('db.type'), 'redis', 'span is missing the
finishCh.publish(preCtx)
assert.ok(preSpan._duration !== undefined, 'finish channel did not finish the span')

guard.loopStart()
for (let i = 0; i < OPERATIONS; i++) {
const ctx = makeCtx(COMMANDS[i % len])
startCh.runStores(ctx, NOOP)
finishCh.publish(ctx)
async function main () {
await nativeSpanDrain.drain()

guard.loopStart()
for (let i = 0; i < OPERATIONS; i++) {
const ctx = makeCtx(COMMANDS[i % len])
startCh.runStores(ctx, NOOP)
finishCh.publish(ctx)
if (nativeSpanDrain.needsDrain()) await nativeSpanDrain.drain()
}
await nativeSpanDrain.drain()
// Native mode is much heavier than the older baseline source at this count. Keep
// the lower count for CI runtime, but relax the startup-share guard so the fast
// baseline run records an A/B result instead of failing as benchmark setup.
guard.done(0.50)
}
// This is the heaviest per-iteration loop in the suite (a full span lifecycle
// through the real processor), so the instruction-counting pass on the stable
// machine scales steeply with the count: ~600k overran the one-minute budget,
// 450k keeps the variant under it while staying deterministic. At that count the
// fixed full-tracer init still settles around 15% of the run -- pushing it below
// 10% would need a count that overruns the budget -- so allow an 18% startup share.
guard.done(0.18)

main()
4 changes: 2 additions & 2 deletions benchmark/sirun/plugin-redis-traced/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"run": "node index.js",
"run_with_affinity": "bash -c \"taskset -c $CPU_AFFINITY node index.js\"",
"cachegrind": false,
"iterations": 15,
"iterations": 8,
"instructions": true,
"variants": {
"command": {
"env": { "OPERATIONS": "450000" }
"env": { "OPERATIONS": "100000" }
}
}
}
4 changes: 3 additions & 1 deletion benchmark/sirun/runall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ else
source /usr/local/nvm/nvm.sh
fi

YARN_INSTALL_FLAGS=(--ignore-engines --network-timeout 600000)

(
cd ../../ &&
npm install --global yarn || (sleep 60 && npm install --global yarn) \
&& yarn install --ignore-engines || (sleep 60 && yarn install --ignore-engines) \
&& yarn install "${YARN_INSTALL_FLAGS[@]}" || (sleep 60 && yarn install "${YARN_INSTALL_FLAGS[@]}") \
&& PLUGINS="graphql|express" yarn services
)

Expand Down
14 changes: 7 additions & 7 deletions benchmark/sirun/spans/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,46 @@
"run": "node spans.js",
"run_with_affinity": "bash -c \"taskset -c $CPU_AFFINITY node spans.js\"",
"cachegrind": false,
"iterations": 12,
"iterations": 6,
"instructions": true,
"variants": {
"finish-immediately": {
"env": {
"DD_TRACE_SCOPE": "noop",
"FINISH": "now",
"OPERATIONS": "2000000"
"OPERATIONS": "250000"
}
},
"finish-later": {
"iterations": 16,
"iterations": 8,
"env": {
"DD_TRACE_SCOPE": "noop",
"FINISH": "later",
"OPERATIONS": "3000000"
"OPERATIONS": "250000"
}
},
"finish-immediately-with-tags": {
"env": {
"DD_TRACE_SCOPE": "noop",
"FINISH": "now",
"SHAPE": "tags",
"OPERATIONS": "2000000"
"OPERATIONS": "200000"
}
},
"finish-immediately-with-many-tags": {
"env": {
"DD_TRACE_SCOPE": "noop",
"FINISH": "now",
"SHAPE": "many-tags",
"OPERATIONS": "2000000"
"OPERATIONS": "100000"
}
},
"finish-immediately-with-tags-and-otel": {
"env": {
"DD_TRACE_SCOPE": "noop",
"FINISH": "now",
"SHAPE": "tags-and-otel",
"OPERATIONS": "2000000"
"OPERATIONS": "100000"
}
}
}
Expand Down
Loading