-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add coroutine labels #258
Add coroutine labels #258
Conversation
WalkthroughThe changes in the pull request focus on the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant GoPanicWrap
participant pprof
Caller->>GoPanicWrap: Call with ctx, wg, name, body, labels
GoPanicWrap->>pprof: Start profiling
GoPanicWrap->>body: Execute body function
body-->>GoPanicWrap: Complete execution
GoPanicWrap->>pprof: Stop profiling
GoPanicWrap->>Caller: Return
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (1)
pkg/tracing/tracing.go (1)
113-119
: Document the relationship with profiling and tracingWhile the implementation is solid, consider adding documentation that explains:
- The relationship between pprof labels and Datadog tracing
- The performance implications of adding labels
- Example usage with labels
Example documentation:
// GoPanicWrap extends PanicWrap by running the body in a goroutine and // synchronizing the goroutine exit with the WaitGroup. // The body must respect cancellation of the Context. +// +// The optional labels parameter allows adding pprof labels to the goroutine +// for better identification during debugging. These labels are visible in +// goroutine dumps and profiles but do not affect Datadog tracing. +// +// Example: +// GoPanicWrap(ctx, wg, "worker", workFn, "queue", "high-priority")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- pkg/tracing/tracing.go (2 hunks)
🔇 Additional comments (2)
pkg/tracing/tracing.go (2)
8-8
: LGTM: Appropriate import for goroutine labelingThe addition of
runtime/pprof
is well-placed and necessary for implementing goroutine labeling functionality.
122-127
: 🛠️ Refactor suggestionConsider validating labels and verify performance impact
The implementation looks correct, but consider these improvements:
- Add validation for labels to ensure they come in key-value pairs:
+ if len(labels)%2 != 0 { + panic("labels must be provided in key-value pairs") + } expandedLabels := append(labels, "name", name)
- The addition of pprof labeling might have a performance impact on goroutine creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice quality-of-life improvement. Are you often using the go debugger?
@richardhuaaa with most changes |
This is a little change that makes using the Go debugger so much easier. You can identify the goroutine by its name and other additional labels.
We don't always use the tracing tool to start our goroutines, but we do the major ones. We can always expand this to other locations that would benefit from easy identification.
See attached screenshot.
Summary by CodeRabbit
New Features
GoPanicWrap
function to accept additional profiling labels for improved performance analysis.Bug Fixes
GoPanicWrap
function to include profiling context, ensuring more accurate performance metrics.