opentelemetry-php icon indicating copy to clipboard operation
opentelemetry-php copied to clipboard

PoC: Implement span suppression strategies

Open Nevay opened this issue 7 months ago • 2 comments

Alternative to #1583

Span suppression is implemented in the SDK -> instrumentation does not need to handle suppression. (Everything besides SemanticConvention and SemanticConventionResolver could be moved to the SDK.)

Provides three span suppression strategies: Noop: does not suppress anything SpanKind: suppresses nested spans with the same span kind (except for internal) SemConv: attempts to resolve the semantic convention based on span attributes, otherwise falls back to span kind suppression

Nevay avatar May 17 '25 12:05 Nevay

I'm happy to accept this as-is and complete it incrementally, if you don't have much time. If you're happy with that, can you add @experimental tags everywhere, and fix the (hopefully minor) CI issues. I've documented some steps to get this towards readiness in #1579

brettmc avatar May 22 '25 04:05 brettmc

Codecov Report

:x: Patch coverage is 77.27273% with 30 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 68.36%. Comparing base (00417cf) to head (f05250b). :warning: Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...cConventionSuppressionStrategy/WildcardPattern.php 0.00% 12 Missing :warning:
...ppressionStrategy/SemanticConventionSuppressor.php 81.48% 5 Missing :warning:
src/SDK/Trace/TracerProviderBuilder.php 0.00% 4 Missing :warning:
...c/API/Trace/SpanSuppression/SemanticConvention.php 0.00% 2 Missing :warning:
src/SDK/Trace/Span.php 50.00% 2 Missing :warning:
...onStrategy/CompiledSemanticConventionAttribute.php 0.00% 2 Missing :warning:
...SpanKindSuppressionStrategy/SpanKindSuppressor.php 77.77% 2 Missing :warning:
src/SDK/Trace/SpanBuilder.php 80.00% 1 Missing :warning:
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1599      +/-   ##
============================================
+ Coverage     68.24%   68.36%   +0.12%     
- Complexity     2919     2978      +59     
============================================
  Files           435      447      +12     
  Lines          8876     9008     +132     
============================================
+ Hits           6057     6158     +101     
- Misses         2819     2850      +31     
Flag Coverage Δ
8.1 68.01% <77.27%> (+0.18%) :arrow_up:
8.2 68.15% <77.27%> (+0.02%) :arrow_up:
8.3 68.25% <77.27%> (+0.20%) :arrow_up:
8.4 68.22% <77.27%> (+0.14%) :arrow_up:
8.5 68.21% <77.27%> (+0.17%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/API/Trace/Span.php 94.44% <ø> (ø)
...ession/NoopSuppressionStrategy/NoopSuppression.php 100.00% <100.00%> (ø)
...oopSuppressionStrategy/NoopSuppressionStrategy.php 100.00% <100.00%> (ø)
...ression/NoopSuppressionStrategy/NoopSuppressor.php 100.00% <100.00%> (ø)
...pressionStrategy/SemanticConventionSuppression.php 100.00% <100.00%> (ø)
...Strategy/SemanticConventionSuppressionStrategy.php 100.00% <100.00%> (ø)
...panKindSuppressionStrategy/SpanKindSuppression.php 100.00% <100.00%> (ø)
...uppressionStrategy/SpanKindSuppressionStrategy.php 100.00% <100.00%> (ø)
src/SDK/Trace/Tracer.php 89.47% <100.00%> (+0.58%) :arrow_up:
src/SDK/Trace/TracerProvider.php 100.00% <100.00%> (ø)
... and 8 more

... and 4 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 00417cf...f05250b. 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.

codecov[bot] avatar May 25 '25 10:05 codecov[bot]

Is there any movement in this at all?

Currently have a lot of pain when using some of the symfony / psr auto instrumentation bundles for HTTP requests, hope this will alleviate the problem.

See a lot of nested spans that are identical in name that are sometimes 5/6 levels deep.

image

jamespavett avatar Sep 26 '25 12:09 jamespavett

Does this PR expose any way to configure which suppression strategy is used by the SDK when used via autoinstrumentation bundles?

Was expecting to see some environment variable configuration, but haven't seen any.

jamespavett avatar Sep 29 '25 08:09 jamespavett

Does this PR expose any way to configure which suppression strategy is used by the SDK when used via autoinstrumentation bundles? Was expecting to see some environment variable configuration, but haven't seen any.

No. I think that will be a follow-up, which is called out in #1579. I think it's too complicated to work with env vars, and so would require YAML-based declarative config (happy to be proven wrong, though). So step 1, let's get it in, then do some field testing that it works, then make it more useful/accessible.

brettmc avatar Sep 29 '25 10:09 brettmc