dd-trace-php
dd-trace-php copied to clipboard
[WIP - Experimental] feat: Add Span End Callback
Description
Experimental
Leverage span end callback to end the OTel Span (if any) when a span is closed using the DD Api. This affects both OTel-created & remapped OTel spans. The goal is to fix edge cases + properly handle trace ids (See Tests Cases).
Sample Edge Case:
- Start a span using DD API
- Retrieve the current span using the OTel API
- Add a distributed tag, which subsequently changes the tracestate
- Close the span using the DD API
- Add a distributed tag, which subsequently changes the tracestate
- Create a read-only copy of the span and read its tracestate
At present, there are issues with the third and fifth steps where the trace states are not being updated correctly in accordance with the OTel-API. Once these changes are made, the trace states can be dynamically retrieved and distributed context changes will accurately be reflected in the OTel API.
TODO:
- [X] Fix crashing callback scenario
- [ ] Add intertwined, start trace interoperability tests
Reviewer checklist
- [ ] Test coverage seems ok.
- [ ] Appropriate labels assigned.
Benchmarks
Benchmark execution time: 2024-01-10 15:04:34
Comparing candidate commit 78fe75b06edae4ae8c69d691a9e0eb3a393394bc in PR branch alex/experiments/otel-end-callback with baseline commit 4568c413e6cd3fb9ba1cbb79e1fc5f3fcbfb50fd in branch master.
Found 1 performance improvements and 0 performance regressions! Performance is the same for 37 metrics, 52 unstable metrics.
scenario:PHPRedisBench/benchRedisBaseline
- 🟩
execution_time[-375.877µs; -131.577µs] or [-13.207%; -4.623%]