Skip to content
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

feat(thread): rewrite thread parse method #21

Merged
merged 3 commits into from
Nov 20, 2024

Conversation

MateuszKepczynskiSauce
Copy link
Collaborator

@MateuszKepczynskiSauce MateuszKepczynskiSauce commented Sep 23, 2024

Stop generating stack frames like "(" but rather generate valid function names and line number.
Stop generating stack frames from Backtrace library when the user generates a string report

@MateuszKepczynskiSauce MateuszKepczynskiSauce changed the title feat(thread): rewrite thread parse method. [BT-4946] feat(thread): rewrite thread parse method Sep 23, 2024
Comment on lines 199 to 208
func createUuid() string {
var uuid_bytes [16]byte
_, _ = rng.Read(uuid_bytes[:]) // This function is documented to never fail.
var uuidBytes [16]byte
_, _ = rng.Read(uuidBytes[:]) // This function is documented to never fail.
return fmt.Sprintf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uuid_bytes[0], uuid_bytes[1], uuid_bytes[2], uuid_bytes[3],
uuid_bytes[4], uuid_bytes[5],
uuid_bytes[6], uuid_bytes[7],
uuid_bytes[8], uuid_bytes[9],
uuid_bytes[10], uuid_bytes[11], uuid_bytes[12], uuid_bytes[13], uuid_bytes[14], uuid_bytes[15])
uuidBytes[0], uuidBytes[1], uuidBytes[2], uuidBytes[3],
uuidBytes[4], uuidBytes[5],
uuidBytes[6], uuidBytes[7],
uuidBytes[8], uuidBytes[9],
uuidBytes[10], uuidBytes[11], uuidBytes[12], uuidBytes[13], uuidBytes[14], uuidBytes[15])
}
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit/this is outside this pull request:
Maybe we should move this code to a different file/helper?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's just a variable name change to stick to go rules.
Its not impacting anything beside good looking code.

Copy link

@cstrahan cstrahan 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 👍.

Some future ideas, though I don't know how practical they are for our needs:

The goroutine symbolization can be done with a combination of runtime.CallersFrames and (runtime.Callers or runtime.GoroutineProfile). That might have lower overhead than calling runtime.Stack + parsing. The downside is that this doesn't give you the goroutine ids. There is, however, a workaround for when we only want to trace the current goroutine: you can use https://github.com/petermattis/goid to fish the goroutine id out of the runtime for the calling goroutine.

Copy link
Contributor

@konraddysput konraddysput left a comment

Choose a reason for hiding this comment

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

Can we also set a faulting thread based on the stack trace? Do we know which one thread is a faulting thread?

frames []frame
type Thread struct {
Name string `json:"name"`
Stacks []StackFrame `json:"stack"`
Copy link
Contributor

Choose a reason for hiding this comment

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

there is also a "fault" boolean variable associated with a thread

image

@MateuszKepczynskiSauce MateuszKepczynskiSauce merged commit 251c7db into master Nov 20, 2024
6 checks passed
@MateuszKepczynskiSauce MateuszKepczynskiSauce deleted the feat/new-parse-thread-logic branch November 20, 2024 07:43
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.

3 participants