fix(sdk/trace): guard Shutdown against nil exporter - #8901
Open
AruneshDwivedi wants to merge 2 commits into
Open
fix(sdk/trace): guard Shutdown against nil exporter#8901AruneshDwivedi wants to merge 2 commits into
AruneshDwivedi wants to merge 2 commits into
Conversation
NewSimpleSpanProcessor(nil) stores a nil exporter but Shutdown later dereferences it without a nil check, panicking and terminating the host process during telemetry shutdown. Add an early return when ssp.exporter is nil, matching the constructor's tested behavior of accepting a nil exporter. Add a regression test. Signed-off-by: Arunesh Dwivedi <arunesh@example.com>
The nil-exporter constructor test declared ssp inside the if-condition, making it unreachable when checking Shutdown. Hoist the declaration so the regression test actually exercises Shutdown(nil). Signed-off-by: Arunesh Dwivedi <arunesh@example.com>
AruneshDwivedi
requested review from
MrAlias,
XSAM,
dashpole,
dmathieu,
flc1125 and
pellared
as code owners
August 30, 2026 17:37
dashpole
reviewed
Aug 31, 2026
|
|
||
| // Shutdown shuts down the exporter this SimpleSpanProcessor exports to. | ||
| func (ssp *simpleSpanProcessor) Shutdown(ctx context.Context) error { | ||
| if ssp.exporter == nil { |
Contributor
There was a problem hiding this comment.
Reading ssp.exporter here without acquiring ssp.exporterMu can lead to a data race with concurrent calls. Consider moving the nil check inside stopOnce.Do after acquiring ssp.exporterMu (e.g. returning early if exp == nil).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8901 +/- ##
=====================================
Coverage 88.4% 88.4%
=====================================
Files 331 331
Lines 21001 21003 +2
=====================================
+ Hits 18572 18575 +3
+ Misses 2429 2428 -1
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NewSimpleSpanProcessor(nil) stores a nil exporter but Shutdown later dereferences it without a nil check, panicking and terminating the host process during telemetry shutdown.
Add an early return when ssp.exporter is nil, matching the constructor tested behavior of accepting a nil exporter. Extend the existing test to verify Shutdown does not panic.