-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
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]) | ||
} |
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.
small nit/this is outside this pull request:
Maybe we should move this code to a different file/helper?
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.
It's just a variable name change to stick to go rules.
Its not impacting anything beside good looking code.
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.
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.
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.
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"` |
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.
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