Skip to content

Refactor to use the C++ Tracer instead of the legacy Lua implementation - #109

Draft
xlamorlette-datadog wants to merge 3 commits into
mainfrom
cpp-ffi-rewrite
Draft

xlamorlette-datadog wants to merge 3 commits into
mainfrom
cpp-ffi-rewrite

Conversation

@xlamorlette-datadog

@xlamorlette-datadog xlamorlette-datadog commented Apr 23, 2026 •

Copy link
Copy Markdown
Collaborator

This is a refactor of the Kong plugin to use the C++ Tracer (dd-trace-cpp) via FFI (Foreign Function Interface: calls via a C binding), instead of the legacy Lua implementation of the Datadog APM tracing capabilities.

The following PR should be considered with this one: #104.

* feat: add tracer.lua FFI module and build infrastructure

* fix: make dd-trace-cpp opt-in and add error checking to build script
* feat: add ffi_span.lua with metatype span methods

* fix: address review feedback - graceful error handling, type validation, error messages

* fix: address round 3 review feedback - rename accessors, consistent error returns, value type validation
* refactor: rewrite handler.lua to use tracer.lua FFI module

Replace pure-Lua tracing modules (sampler, propagation, agent_writer,
span, msgpack_encode) with dd-trace-cpp via the tracer.lua FFI bindings.
The C++ library handles sampling, propagation, timestamps, and trace
submission internally.

- Update handler.lua to use ddtrace.get_or_create/extract_or_create_span
- Remove 7 Lua modules and 5 corresponding test files
- Remove lua-resty-http dependency from rockspec
- Fix datadog_span_id bug (was incorrectly set to trace_id)
- Mark integration trace submission test as pending (dd-trace-cpp async)

* refactor: address FFI handler review feedback
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