This repository has been archived by the owner on Feb 17, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #150
NOTE
There is no actionable insight provided on the issue. I believe I have no business implementing this (Probably someone is already working on this internally). I got too excited when I came across this project and had a lot of idle time so I decided to take this challenge.
There is a lot of shortcomings on this PR ( again, sorry to bother you guys), however I think I figured out the fundamentals of having the feature introduced. I will go into more details on this.
What is missing ?
Tests : there are no unit tests included because I wasn't sure which direction you had in mind regarding this feature. I however made sure to make minimal changes to ensure someone can review the changes in one sitting.
JSON
andYAML
output: Only table output is implemented showing function duration and function nameTop down rendering like in https://justine.lol/ftrace/ : Reading segments logs returns them in an opposite order from
ftrace
. Sorting can fix this, in order to minimize changes this commit doesn't sort the call stackOutput looks like
Limiting: Generated trace can be long, there is no way to limit rendered output
Sampling : No way to sample the traced functions
Fine tune which functions to trace: Currently we trace everything including system calls which may be redundant considering we already have api for tracing system calls Adding support for this is straightforward so I had to de prioritize.
How it works ?
wazero has experimental api for hooking function calls
https://pkg.go.dev/github.com/tetratelabs/[email protected]/experimental#FunctionListenerFactory
We take advantage of this to provide custom implementation of this api and store the collected data in our segment registry.
For now same segment (0) is used for system calls and function calls , Initially I had separate segment for function calls segment(1) but I had to make a lot of changes to glue things together. I settled with the same segment but it should be possible to switch to separate segments.
I am more than happy to own the issue if I get feedback on which direction you had in mind . But also I won't mind if this PR is closed.
Usage
This project has the highest quality go code base on github (apart from the go standard library).
I came across this on saturday and found my way to implement this feature on sunday.
Thanks for the project.