Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP - Experimental] feat: Add Span End Callback #2407

Closed
wants to merge 6 commits into from

Conversation

PROFeNoM
Copy link
Contributor

@PROFeNoM PROFeNoM commented Dec 5, 2023

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:

  • Fix crashing callback scenario
  • Add intertwined, start trace interoperability tests

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@PROFeNoM PROFeNoM added 🐛 bug Something isn't working ☠️ do-not-merge/WIP labels Dec 5, 2023
@PROFeNoM PROFeNoM self-assigned this Dec 5, 2023
Comment on lines +29 to +35
private static function getRootSpan(SpanData $span): RootSpanData
{
while (!($span instanceof RootSpanData) && $span->parent) {
$span = $span->parent;
}
return $span;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to self: May be wrong when considering intertwined start_trace_span & OTel starts w/ setParent(false)

@PROFeNoM PROFeNoM force-pushed the alex/experiments/otel-end-callback branch from 4d19b4f to 78fe75b Compare January 10, 2024 14:36
@pr-commenter
Copy link

pr-commenter bot commented Jan 10, 2024

Benchmarks

Benchmark execution time: 2024-01-10 15:04:34

Comparing candidate commit 78fe75b in PR branch alex/experiments/otel-end-callback with baseline commit 4568c41 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%]

@PROFeNoM
Copy link
Contributor Author

PROFeNoM commented Apr 2, 2024

@PROFeNoM PROFeNoM closed this Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant