Skip to content

otellogr: Fix nil context panic #6527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jan 20, 2025
Merged

Conversation

flc1125
Copy link
Member

@flc1125 flc1125 commented Dec 23, 2024

Fixes #6509

@flc1125 flc1125 requested review from pellared and a team as code owners December 23, 2024 14:37
Copy link

codecov bot commented Dec 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.7%. Comparing base (4e900d0) to head (e0c6e07).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #6527     +/-   ##
=======================================
- Coverage   68.7%   68.7%   -0.1%     
=======================================
  Files        200     200             
  Lines      16872   16873      +1     
=======================================
- Hits       11604   11602      -2     
- Misses      4925    4927      +2     
- Partials     343     344      +1     
Files with missing lines Coverage Δ
bridges/otellogr/logsink.go 100.0% <100.0%> (ø)

... and 1 file with indirect coverage changes

@dmathieu dmathieu changed the title Fixed an issue where otellogr emits nil context which leads to panic in exporters Fix nil context panic in otelloger Jan 6, 2025
- Remove `ctx` field and related context handling from `LogSink` struct
- Simplify `Enabled` method to use `context.Background()` directly
- Remove `WithContext` method and associated tests
- Clean up test cases related to context handling
Copy link
Member

@dmathieu dmathieu left a comment

Choose a reason for hiding this comment

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

I'm not sure a consensus has been reached in #6509.

@pellared pellared changed the title Fix nil context panic in otelloger otellogr: Fix nil context panic Jan 7, 2025
@pellared
Copy link
Member

pellared commented Jan 7, 2025

I'm not sure a consensus has been reached in #6509.

I think this is the proper fix and we probably do not need anything more than this.

@flc1125
Copy link
Member Author

flc1125 commented Jan 14, 2025

Ready for approval.

@@ -352,6 +352,40 @@ func TestLogSink(t *testing.T) {
}
}

// fix https://github.com/open-telemetry/opentelemetry-go-contrib/issues/6509
func TestLogSinkCtxInInfo(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't we add test cases to TestLogSink instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Upon checking, the structure of TestLogSink is currently not suitable for my testing scenario. If adjustments are needed, more changes might be required.

Copy link
Member

Choose a reason for hiding this comment

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

OK. Approving. I can look and try refactoring it tomorrow.

@pellared
Copy link
Member

@scorpionknifes, PTAL as a codeowner

Copy link
Member

@scorpionknifes scorpionknifes left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM (not a go approver)

@@ -352,6 +352,40 @@ func TestLogSink(t *testing.T) {
}
}

// fix https://github.com/open-telemetry/opentelemetry-go-contrib/issues/6509
func TestLogSinkCtxInInfo(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

OK. Approving. I can look and try refactoring it tomorrow.

@pellared pellared merged commit 45e0b8b into open-telemetry:main Jan 20, 2025
26 checks passed
@flc1125 flc1125 deleted the fix-issue-6509 branch January 21, 2025 02:16
@MrAlias MrAlias added this to the v1.35.0 milestone Feb 6, 2025
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.

otellogr emits nil context causing panic in exporters
5 participants