Skip to content

Comments

feat: add optional drift-core rust acceleration path#121

Merged
jy-tan merged 15 commits intomainfrom
use-drift-core
Feb 21, 2026
Merged

feat: add optional drift-core rust acceleration path#121
jy-tan merged 15 commits intomainfrom
use-drift-core

Conversation

@jy-tan
Copy link
Contributor

@jy-tan jy-tan commented Feb 20, 2026

Summary

Add Rust-core acceleration paths to the Node SDK export pipeline, wire Rust opt-in through instrumentation e2e runners/CI, and document Node-specific Rust binding behavior.

Also includes mysql2 replay correctness/stability fixes that were uncovered during broader CI/e2e validation in this branch.

Changes

  • Add src/core/rustCoreBinding.ts bridge and route span payload processing/building through Rust helpers with fail-open fallback to JS paths.
  • Update SpanTransformer to use Rust-assisted payload/schema/hash processing and prebuild span protobuf bytes when available.
  • Update ApiSpanAdapter to use Rust-built ExportSpansRequest bytes when all spans have prebuilt bytes, while preserving existing typed-proto fallback behavior.
  • Extend CleanSpanData with optional protoSpanBytes to support mixed fast-path export flow.
  • Enable Rust path propagation in instrumentation e2e run.sh scripts and set TUSK_USE_RUST_CORE=1 in .github/workflows/e2e.yml so CI exercises Rust-enabled e2e.
  • Add exact dependency on @use-tusk/drift-core-node@0.1.6 in package.json and lockfile.
  • Add docs/rust-core-bindings.md for Node (enablement, fallback behavior, native platform concerns).
  • Fix postgres e2e benchmark stability by changing cache insert endpoints to upsert (onConflictDoUpdate) for duplicate key scenarios.

Mysql2 Replay Follow-ups

These fixes are included in this PR because mysql2 replay started failing in CI while validating the broader branch. Root cause was record/replay identity drift in mysql2 paths (pool connection context/shape/normalization), not Rust protobuf/export logic.

  • Fix replay identity drift between record/replay for pool connection paths.
  • Normalize dynamic SQL for mock matching (e.g. knex savepoint names like trxNN) to reduce nondeterministic replay misses.
  • Keep mysql2 request shape normalization consistent in replay mock paths (e.g. bindings/value shape parity).
  • Prevent pooled-connection context bleed by refreshing bound OTel context on each checkout instead of pinning first-use context.
  • Align replay stack-trace filtering for mysql2 connection-mock paths to better match record-mode traces.
  • Remove temporary debug-only e2e diagnostics / forced mysql2 sequential mode used during incident triage.

While the Rust refactor did not introduce the mysql2 logic changes directly, enabling the Rust path and running wider/more frequent e2e coverage in CI may have made pre-existing mysql2 replay fragility easier to surface. Keeping these fixes in the same branch avoids shipping known flaky replay behavior and keeps CI green for the end-to-end changes being introduced.

Notes

  • Rust path remains opt-in via TUSK_USE_RUST_CORE.
  • Runtime remains fail-open: unsupported/missing native bindings fall back to non-Rust code paths.

@jy-tan jy-tan changed the title feat: integrate rust core bindings and rust-enabled e2e coverage feat: add optional drift-core rust acceleration path Feb 20, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 35 files

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/instrumentation/libraries/mysql2/mocks/TdMysql2ConnectionMock.ts">

<violation number="1" location="src/instrumentation/libraries/mysql2/mocks/TdMysql2ConnectionMock.ts:61">
P2: Execute replay input values can omit `values` for no-parameter queries while recording stores an empty array, causing replay matching failures. Preserve the empty-array default to match recording behavior.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/instrumentation/libraries/mysql2/Instrumentation.ts">

<violation number="1" location="src/instrumentation/libraries/mysql2/Instrumentation.ts:1643">
P2: Pooled connections can be reused across requests, but the new guard prevents rebinding to the current request context. Because the wrapper closures capture the original `parentContext`, later checkouts will keep using a stale context, causing cross-request trace contamination. Update the binding to store the current context and reuse wrappers without pinning the first context forever.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/instrumentation/libraries/mysql2/mocks/TdMysql2ConnectionMock.ts">

<violation number="1" location="src/instrumentation/libraries/mysql2/mocks/TdMysql2ConnectionMock.ts:42">
P2: The mock now captures stack traces but excludes `Mysql2Instrumentation` instead of the mock class. That leaves `TdMysql2ConnectionMock` frames in the replay stack trace while record mode stacks don’t include them, which can cause mock lookup mismatches when stackTrace is part of the replay request payload. Exclude the mock class (and optionally the instrumentation class) to keep record/replay stacks aligned.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@jy-tan jy-tan merged commit a209242 into main Feb 21, 2026
15 checks passed
@jy-tan jy-tan deleted the use-drift-core branch February 21, 2026 19:37
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