Skip to content

Fix inverted condition in LegacySpanProcessorInstrumentation#finishSpans#8145

Merged
jack-berg merged 1 commit intoopen-telemetry:mainfrom
antonio-mazzini:fix-legacy-span-processor-metric
Mar 6, 2026
Merged

Fix inverted condition in LegacySpanProcessorInstrumentation#finishSpans#8145
jack-berg merged 1 commit intoopen-telemetry:mainfrom
antonio-mazzini:fix-legacy-span-processor-metric

Conversation

@antonio-mazzini
Copy link
Contributor

@antonio-mazzini antonio-mazzini commented Mar 5, 2026

Resolves #8142

Summary

Fix the inverted condition in LegacySpanProcessorInstrumentation#finishSpans() that prevents the processedSpans metric from being reported correctly.

The comment states "Legacy metrics only record when no error", but the condition was error != null (records only when there IS an error). Changed to error == null to match the intended behavior.

Changes

  • sdk/trace/src/main/java/io/opentelemetry/sdk/trace/export/LegacySpanProcessorInstrumentation.java: Changed error != null to error == null in finishSpans() method.

@antonio-mazzini antonio-mazzini requested a review from a team as a code owner March 5, 2026 17:56
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 5, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: antonio-mazzini / name: Antonio Mazzini (ad14b0b)

@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.29%. Comparing base (f08b49c) to head (ad14b0b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8145      +/-   ##
============================================
+ Coverage     90.28%   90.29%   +0.01%     
  Complexity     7649     7649              
============================================
  Files           843      843              
  Lines         23059    23059              
  Branches       2309     2309              
============================================
+ Hits          20818    20822       +4     
+ Misses         1520     1518       -2     
+ Partials        721      719       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

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

@antonio-mazzini
Copy link
Contributor Author

recheck

@trask
Copy link
Member

trask commented Mar 5, 2026

/easycla

@antonio-mazzini
Copy link
Contributor Author

recheck

Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

Thanks! Sorry about that

@jack-berg
Copy link
Member

/easycla

@antonio-mazzini antonio-mazzini force-pushed the fix-legacy-span-processor-metric branch from 141e315 to 95029b8 Compare March 6, 2026 07:54
The condition checking for error was inverted, preventing the
processedSpans metric from being reported correctly when spans
complete without errors.
@antonio-mazzini antonio-mazzini force-pushed the fix-legacy-span-processor-metric branch from 95029b8 to ad14b0b Compare March 6, 2026 08:36
@jack-berg jack-berg merged commit e8920e7 into open-telemetry:main Mar 6, 2026
27 checks passed
@otelbot
Copy link
Contributor

otelbot bot commented Mar 6, 2026

Thank you for your contribution @antonio-mazzini! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LegacySpanProcessorInstrumentation has a bug in reporting the "processedSpans" metric

4 participants