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

June 2021 status? #4

Open
simonhf opened this issue Jun 1, 2021 · 1 comment
Open

June 2021 status? #4

simonhf opened this issue Jun 1, 2021 · 1 comment

Comments

@simonhf
Copy link

simonhf commented Jun 1, 2021

Is go-trace still a thing even though we're up to 1.16 now? If this package is no longer maintained, is it already out-of-date? If so, is there an alternative package somewhere which has similar-ish functionality?

@cstockton
Copy link
Owner

I just checked and it looks like I started a version4 fix:

git status .
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	deleted:    cmd/tracecat/main.go
	deleted:    cmd/tracegrep/main.go
	modified:   doc.go
	modified:   encoding/decoder.go
	modified:   encoding/decoder_test.go
	modified:   encoding/encoder.go
	modified:   encoding/encoder_test.go
	modified:   encoding/encoding.go
	modified:   encoding/encoding_test.go
	deleted:    encoding/event.go
	modified:   encoding/example_test.go
	deleted:    encoding/state.go
	deleted:    encoding/state_test.go


Untracked files:
  (use "git add <file>..." to include in what will be committed)
	correlate/
	encoding/benchmark_test.go
	event/
	example_test.go
	internal/
	trace.go
	trace_test.go
	tracegentest.go

no changes added to commit (use "git add" and/or "git commit -a")

This was feb 2018, so I don't know how many trace versions have been released since then. It looks like this is the last trace version I supported:

 // encodeHeader will encode a valid trace version object into a well formed
 // trace header.
-func encodeHeader(w io.Writer, v Version) (err error) {
+func encodeHeader(w io.Writer, v event.Version) (err error) {
        var n int
        switch v {
-       case Version1:
+       case event.Version1:
                n, err = w.Write([]byte("go 1.5 trace\x00\x00\x00\x00"))
-       case Version2:
+       case event.Version2:
                n, err = w.Write([]byte("go 1.7 trace\x00\x00\x00\x00"))
-       case Version3:
+       case event.Version3:
                n, err = w.Write([]byte("go 1.8 trace\x00\x00\x00\x00"))
+       case event.Version4:
+               n, err = w.Write([]byte("go 1.9 trace\x00\x00\x00\x00"))
+       default:
+               err = errors.New(`trace header version was invalid`)
        }
        if err == nil && n != 16 {
                err = io.ErrShortWrite

Looks like this "Version4" (go ver 1.9) had the same frame size and arg offset as the previous version, with only two new events:

	schema{"EvGCMarkAssistStart", Version4, []string{ArgTimestamp, ArgStackID}},
	schema{"EvGCMarkAssistDone", Version4, []string{ArgTimestamp}},

Checking out the current runtime, there are only a few more:

	traceEvUserTaskCreate    = 45 // trace.NewContext [timestamp, internal task id, internal parent task id, stack, name string]
	traceEvUserTaskEnd       = 46 // end of a task [timestamp, internal task id, stack]
	traceEvUserRegion        = 47 // trace.WithRegion [timestamp, internal task id, mode(0:start, 1:end), stack, name string]
	traceEvUserLog           = 48 // trace.Log [timestamp, internal task id, key string id, stack, value string]

I'm not familiar with the trace.NewContext API, but these could potentially be fairly straight forward to add on. I imagine I started this work one weekend but couldn't finish and got busy at my day job, I could commit it for you but it is definitely incomplete. It appears I mixed it up with some refactoring as well >_< as it comes in at around 7K loc.

Let me know if you want to take a stab at it, I'll add ya to repo.

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

No branches or pull requests

2 participants