dd-trace-php icon indicating copy to clipboard operation
dd-trace-php copied to clipboard

[WIP - Experimental] feat: Add Span End Callback

Open PROFeNoM opened this issue 1 year ago • 1 comments

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:

  1. Start a span using DD API
  2. Retrieve the current span using the OTel API
  3. Add a distributed tag, which subsequently changes the tracestate
  4. Close the span using the DD API
  5. Add a distributed tag, which subsequently changes the tracestate
  6. 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.

PROFeNoM avatar Dec 05 '23 14:12 PROFeNoM

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%]

pr-commenter[bot] avatar Jan 10 '24 15:01 pr-commenter[bot]

PROFeNoM avatar Apr 02 '24 09:04 PROFeNoM