Skip to content

Comments

span suppression strategy#1583

Closed
brettmc wants to merge 5 commits intoopen-telemetry:mainfrom
brettmc:span-suppression-strategy
Closed

span suppression strategy#1583
brettmc wants to merge 5 commits intoopen-telemetry:mainfrom
brettmc:span-suppression-strategy

Conversation

@brettmc
Copy link
Contributor

@brettmc brettmc commented May 7, 2025

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

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.
@brettmc brettmc requested a review from a team as a code owner May 7, 2025 02:08
@codecov
Copy link

codecov bot commented May 7, 2025

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 ⚠️
...I/Trace/SpanSuppression/Strategy/StrategyTrait.php 94.44% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             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%) ⬆️
8.2 70.81% <87.09%> (+0.02%) ⬆️
8.3 70.80% <87.09%> (-0.01%) ⬇️
8.4 70.81% <87.09%> (+0.02%) ⬆️

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 data
Powered by Codecov. Last update 91e05d9...15dc601. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@Nevay Nevay left a comment

Choose a reason for hiding this comment

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

Should SpanSuppression be marked experimental? We should have a plan on how to evolve the API to allow semconv based suppression considering that this is the default choosen by Java.

Would prefer an injectable abstraction layer similar to Javas SpanSuppressionStrategy instead of static methods to allow users to opt-out of span suppression.

@cedricziel
Copy link
Contributor

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.

@brettmc brettmc marked this pull request as draft May 13, 2025 07:23
@brettmc
Copy link
Contributor Author

brettmc commented May 13, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

implement span suppression

4 participants