Skip to content

fix(native-spans): Bun-compatible transport head + UDS client stats#170

Merged
bengl merged 1 commit into
mainfrom
bengl/native-bun-uds
Jul 10, 2026
Merged

fix(native-spans): Bun-compatible transport head + UDS client stats#170
bengl merged 1 commit into
mainfrom
bengl/native-bun-uds

Conversation

@bengl

@bengl bengl commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Two native-spans fixes for the dd-trace-js native pipeline (targets v0.16.0).

1. Bun-compatible transport request head

crates/capabilities/src/http_transport.js injected the Rust-rendered HTTP/1.1 request head via the Node-internal req._header. Bun's node:http ignores req._header, so under Bun trace requests went out as POST / with no headers and the agent dropped them (dd-trace-js bun-runtime CI).

Parse the (entity-merged) head into { method, path, headers } via a new parseRequestHead and pass them to transport.request(...) — no more req._header. Portable across Node and Bun (and no longer depends on an undocumented Node internal). Verified end-to-end: a mock-agent repro sends POST /v0.4/traces with Content-Type: application/msgpack + datadog-meta-lang on both Node and Bun 1.3.14.

2. Client /v0.6/stats over a Unix domain socket

crates/pipeline/src/stats.rs built the stats URI with a raw format! + parse, so for a unix:// agent URL the socket path stayed in the URI path and the request never reached the socket (dd-trace-js uds-express4 test_resource_renaming stats aggregation).

Build the base URI with libdd_common::parse_uri (exactly like the trace exporter), which hex-encodes the socket path into the URI authority (reversed by the transport's decode_socket_path), then append /v0.6/stats to the base path preserving the authority. Adds libdd-common as an explicit dep (was transitive).

Tests

  • 18 transport tests + 50 pipeline tests pass.
  • New pipeline test flushes /v0.6/stats over a real Unix socket.
  • The existing pipeline flush test covers the Node trace path through the new head-parsing.

@github-actions

Copy link
Copy Markdown

Overall package size

Self size: 30.1 MB
Deduped: 30.1 MB
No deduping: 30.1 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------|

🤖 This report was automatically generated by heaviest-objects-in-the-universe

Two fixes for the dd-trace-js native pipeline:

- Transport: parse the Rust-rendered HTTP/1.1 request head into
  {method, path, headers} for http.request() instead of injecting it via the
  Node-internal req._header. Bun's node:http ignores req._header, so trace
  requests went out as POST / with no headers and the agent dropped them
  (bun-runtime CI). Verified end-to-end on both Node and Bun.

- Client stats: build the /v0.6/stats URI via libdd_common::parse_uri (like the
  trace exporter) so a unix:// agent URL's socket path is hex-encoded into the
  URI authority and the request routes over the socket. Previously the raw parse
  left the path in the URI path and stats never reached a UDS agent
  (uds-express4 resource_renaming). Adds libdd-common as an explicit dep and a
  pipeline test that flushes /v0.6/stats over a Unix socket.
@bengl bengl force-pushed the bengl/native-bun-uds branch from 6ed5277 to 03d2dbc Compare July 10, 2026 20:38
@bengl bengl marked this pull request as ready for review July 10, 2026 20:39
@bengl bengl requested review from a team as code owners July 10, 2026 20:39

@ekump ekump left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

non-blocking since I know there are tests in dd-trace-js, but the parsing logic could probably be better covered in this repo.

@bengl bengl merged commit 0e96992 into main Jul 10, 2026
47 checks passed
@bengl bengl deleted the bengl/native-bun-uds branch July 10, 2026 21:07
@bengl bengl mentioned this pull request Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants