span suppression strategy
implement a span suppression strategy, modelled on Java's implementation. An instrumentation can suppress some later spans (stop them from being created), via SpanSuppression::suppressSpanKind(). The strategies are stored in Context, and can be activated and detached like other context values. Instrumentations should check span suppression before creating a new span.
Closes: #1579
Codecov Report
Attention: Patch coverage is 87.09677% with 8 lines in your changes missing coverage. Please review.
Project coverage is 70.84%. Comparing base (
91e05d9) to head (15dc601). Report is 29 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/API/Trace/SpanSuppression.php | 63.15% | 7 Missing :warning: |
| ...I/Trace/SpanSuppression/Strategy/StrategyTrait.php | 94.44% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #1583 +/- ##
============================================
- Coverage 70.86% 70.84% -0.02%
- Complexity 2765 2798 +33
============================================
Files 407 411 +4
Lines 8346 8424 +78
============================================
+ Hits 5914 5968 +54
- Misses 2432 2456 +24
| Flag | Coverage Δ | |
|---|---|---|
| 8.1 | 70.61% <87.09%> (+0.05%) |
:arrow_up: |
| 8.2 | 70.81% <87.09%> (+0.02%) |
:arrow_up: |
| 8.3 | 70.80% <87.09%> (-0.01%) |
:arrow_down: |
| 8.4 | 70.81% <87.09%> (+0.02%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| ...uppression/Strategy/SemConvSuppressionStrategy.php | 100.00% <100.00%> (ø) |
|
| ...ppression/Strategy/SpanKindSuppressionStrategy.php | 100.00% <100.00%> (ø) |
|
| ...I/Trace/SpanSuppression/Strategy/StrategyTrait.php | 94.44% <94.44%> (ø) |
|
| src/API/Trace/SpanSuppression.php | 63.15% <63.15%> (ø) |
... and 12 files with indirect coverage changes
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 91e05d9...15dc601. Read the comment docs.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
I wonder if this could also be used for limitting the recursive span scenario with templating languages we talked about. @brettmc Do you see that we could enhance this for looking at presence of attributes or instrumentation names?
Example:
Twig is rendering templates recursively
index.html.twig
- header.html.twig
- - meta.html.twig
- - meta.html.twig
- - meta.html.twig
- - ....
- body.html.twig
- - content.html.twig
- - - blog_list.html.twig
- - - - blog_article.html.twig
- - - - ...
As a library author, i would probably want to define
SpanSuppression::suppress('io.open-telemetry.php.twig')
or similar, so that i can capture the overall render time of the templates, but stop recursion on the top level.
Would prefer an injectable abstraction layer similar to Javas SpanSuppressionStrategy instead of static methods to allow users to opt-out of span suppression.
I've made a start on this. I think there are some improvements that could be made:
- storing the active strategies in context rather than a static variable?
- config from env var and/or declarative config
- what are all the possible inputs to a decision?
Do you see that we could enhance this for looking at presence of attributes or instrumentation names?
@cedricziel yes, I think we could. In the twig example, what feature of the recursive spans can be used to make the decision? The tracer name? One of the SemConv attributes? This could be helpful in working out the possible inputs to the decision.