Skip to content

Conversation

@ntnn
Copy link
Contributor

@ntnn ntnn commented Apr 22, 2025

Was looking for exactly that today.

Summary by CodeRabbit

  • New Features

    • Added the ability to track and display the function that created each goroutine in stack traces.
    • Introduced a new filter option to ignore goroutines based on their creator function.
  • Tests

    • Enhanced tests to verify correct parsing and filtering based on the goroutine creator function.

Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
@CLAassistant
Copy link

CLAassistant commented Apr 22, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link

coderabbitai bot commented Apr 22, 2025

Walkthrough

The changes introduce the ability to track and retrieve the creator function of a goroutine within the stack parsing logic. The Stack struct is extended with a createdBy field, and a corresponding accessor method is added. The stack parsing logic is updated to extract the creator function from stack traces. Tests are updated to verify this new functionality. Additionally, a new option function is introduced to filter out goroutines based on their creator function, and a corresponding test is added to validate this filter.

Changes

File(s) Change Summary
internal/stack/stacks.go Added createdBy field to Stack struct, new CreatedBy() method, and logic to parse creator function from stack trace.
internal/stack/stacks_test.go Extended tests to verify parsing and retrieval of the createdBy field in stack traces.
options.go Added IgnoreCreatedBy option function to filter goroutines by their creator function.
options_test.go Added test for IgnoreCreatedBy option to confirm filtering of goroutines by creator function.

Poem

A new field hops into Stack’s embrace,
Tracking the creator’s name and place.
The tests now check who gave life’s spark,
Filtering by creator—no shot in the dark!
With every trace and every run,
More insight for debugging fun!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Collaborator

@abhinav abhinav left a comment

Choose a reason for hiding this comment

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

LGTM

CC @sywhang @r-hang

@codecov
Copy link

codecov bot commented Apr 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.61%. Comparing base (4ff5fa6) to head (cbb740d).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #136      +/-   ##
==========================================
+ Coverage   98.57%   98.61%   +0.03%     
==========================================
  Files           5        5              
  Lines         351      360       +9     
==========================================
+ Hits          346      355       +9     
  Misses          4        4              
  Partials        1        1              

☔ 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.

Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
options_test.go (1)

74-95: Well-structured test for the new IgnoreCreatedBy option.

The test effectively verifies that the IgnoreCreatedBy option correctly filters out goroutines created by the specified function name. It follows the same pattern as other option tests in the file, which is good for consistency.

The test properly manages resources by closing the channel to allow the goroutine to exit, preventing any leaks from the test itself.

Consider adding a brief comment at the beginning of the test explaining its purpose, similar to the comments on lines 67-69 for the IgnoreAnyFunction test.

 func TestOptionsIgnoreCreatedBy(t *testing.T) {
+	// Test that IgnoreCreatedBy correctly filters goroutines created by the specified function.
 	stopCh := make(chan struct{})
 	go func() {
 		<-stopCh
 	}()
 	defer close(stopCh)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f0d509 and 8e6e7f5.

📒 Files selected for processing (1)
  • options_test.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
options_test.go (2)
internal/stack/stacks.go (2)
  • Current (251-253)
  • All (246-248)
options.go (1)
  • IgnoreCreatedBy (91-95)

@ntnn
Copy link
Contributor Author

ntnn commented May 5, 2025

Bump - FYI the CI failure is golangci-lint complaining about the config.

@abhinav
Copy link
Collaborator

abhinav commented May 5, 2025

@sywhang @r-hang would someone from UBer mind reviewing?

@abhinav
Copy link
Collaborator

abhinav commented May 5, 2025

For the lint failure, we need to run golangci-lint migrate.

Copy link
Contributor

@sywhang sywhang left a comment

Choose a reason for hiding this comment

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

LGTM, please address the golangci-lint issue and we can merge.

@ntnn
Copy link
Contributor Author

ntnn commented Oct 3, 2025

The golangci-lint issue is that your workflow is running golangci-lint v2 but your config is v1.
The automatic migration with golangci-lint migrate fails:

jsonschema: "linters-settings.govet.enable.0" does not validate with "/properties/linters-settings/properties/govet/properties/enable/items/$ref/enum": value must be one of 'appends', 'asmdecl', 'assign', 'atomic', 'atomicalign', 'bools', 'buildtag', 'cgocall', 'composites', 'copylocks', 'deepequalerrors', 'defers', 'directive', 'errorsas', 'fieldalignment', 'findcall', 'framepointer', 'httpresponse', 'ifaceassert', 'loopclosure', 'lostcancel', 'nilfunc', 'nilness', 'printf', 'reflectvaluecompare', 'shadow', 'shift', 'sigchanyzer', 'slog', 'sortslice', 'stdmethods', 'stdversion', 'stringintconv', 'structtag', 'testinggoroutine', 'tests', 'timeformat', 'unmarshal', 'unreachable', 'unsafeptr', 'unusedresult', 'unusedwrite', 'waitgroup'
Failed executing command with error: the configuration contains invalid elements

I'd suggest you decide the migration of the golangci-lint issue within the project.

Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
@ntnn ntnn force-pushed the ignore-created-by branch from f686317 to cbb740d Compare October 3, 2025 23:36
@ntnn
Copy link
Contributor Author

ntnn commented Oct 15, 2025

@abhinav @sywhang ptal

@mjudeikis
Copy link

@abhinav @sywhang gentle reminder :)

Copy link
Collaborator

@abhinav abhinav left a comment

Choose a reason for hiding this comment

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

This looks good to me.
Will defer to Uber folks to merge.
Someone may need to upgrade to golangci-lint v2 on a separate branch.
I agree that that's out of scope for this PR.

@mjudeikis
Copy link

ping pong. Just gentle reminder :)

@r-hang r-hang merged commit 3b3a1f5 into uber-go:master Dec 10, 2025
5 of 6 checks passed
@ntnn ntnn deleted the ignore-created-by branch December 10, 2025 19:02
r-hang added a commit that referenced this pull request Dec 10, 2025
A golangci-lint failure was raised in
#136

$ golangci-lint config verify
```
⎿  Error: jsonschema: "linters-settings.govet.enable.0" does not validate with
 "/properties/linters-settings/properties/govet/properties/enable/items/$ref/enum": value must be one of 'appends', 'asmdecl',
 'assign', 'atomic', 'atomicalign', 'bools', 'buildtag', 'cgocall', 'composites', 'copylocks', 'deepequalerrors', 'defers',
 'directive', 'errorsas', 'fieldalignment', 'findcall', 'framepointer', 'httpresponse', 'ifaceassert', 'loopclosure', 'lostcancel',
  'nilfunc', 'nilness', 'printf', 'reflectvaluecompare', 'shadow', 'shift', 'sigchanyzer', 'slog', 'sortslice', 'stdmethods',
 'stdversion', 'stringintconv', 'structtag', 'testinggoroutine', 'tests', 'timeformat', 'unmarshal', 'unreachable', 'unsafeptr',
 'unusedresult', 'unusedwrite', 'waitgroup'
 Failed executing command with error: the configuration contains invalid elements
 ```

 After the fix
 $ golangci-lint config verify yields no errors.
r-hang added a commit that referenced this pull request Dec 10, 2025
A golangci-lint failure was raised in
#136

$ golangci-lint config verify
```
⎿  Error: jsonschema: "linters-settings.govet.enable.0" does not validate with
 "/properties/linters-settings/properties/govet/properties/enable/items/$ref/enum": value must be one of 'appends', 'asmdecl',
 'assign', 'atomic', 'atomicalign', 'bools', 'buildtag', 'cgocall', 'composites', 'copylocks', 'deepequalerrors', 'defers',
 'directive', 'errorsas', 'fieldalignment', 'findcall', 'framepointer', 'httpresponse', 'ifaceassert', 'loopclosure', 'lostcancel',
  'nilfunc', 'nilness', 'printf', 'reflectvaluecompare', 'shadow', 'shift', 'sigchanyzer', 'slog', 'sortslice', 'stdmethods',
 'stdversion', 'stringintconv', 'structtag', 'testinggoroutine', 'tests', 'timeformat', 'unmarshal', 'unreachable', 'unsafeptr',
 'unusedresult', 'unusedwrite', 'waitgroup'
 Failed executing command with error: the configuration contains invalid elements
 ```

 After the fix
 $ golangci-lint config verify
 yields no errors.
ntnn added a commit to ntnn/kcp that referenced this pull request Dec 10, 2025
uber-go/goleak#136 has been merged so upstream
can be used again.

Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
ntnn added a commit to ntnn/kcp that referenced this pull request Dec 10, 2025
uber-go/goleak#136 has been merged so upstream
can be used again.

Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
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.

7 participants