Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
timecraft: add trace command
Browse files Browse the repository at this point in the history
Signed-off-by: Achille Roussel <[email protected]>
  • Loading branch information
achille-roussel committed Jun 1, 2023
1 parent 418fdf3 commit b5d76b5
Show file tree
Hide file tree
Showing 9 changed files with 716 additions and 20 deletions.
9 changes: 4 additions & 5 deletions describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"time"

pprof "github.com/google/pprof/profile"
"github.com/google/uuid"
"github.com/stealthrocket/timecraft/format"
"github.com/stealthrocket/timecraft/internal/print/human"
"github.com/stealthrocket/timecraft/internal/print/jsonprint"
Expand Down Expand Up @@ -362,9 +361,9 @@ func descriptorAndData(desc *format.Descriptor, data any) any {
}

func lookupProcessByLogID(ctx context.Context, reg *timemachine.Registry, id string) (format.UUID, *format.Descriptor, *format.Process, error) {
processID, err := uuid.Parse(id)
processID, err := parseProcessID(id)
if err != nil {
return processID, nil, nil, errors.New(`malformed process id (not a UUID)`)
return processID, nil, nil, err
}
manifest, err := reg.LookupLogManifest(ctx, processID)
if err != nil {
Expand Down Expand Up @@ -703,9 +702,9 @@ func describeLog(ctx context.Context, reg *timemachine.Registry, id string, conf
logSegmentNumber = n
}

processID, err := uuid.Parse(logID)
processID, err := parseProcessID(logID)
if err != nil {
return nil, errors.New(`malformed process id (not a UUID)`)
return nil, err
}

m, err := reg.LookupLogManifest(ctx, processID)
Expand Down
5 changes: 2 additions & 3 deletions export.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"os"

"github.com/google/uuid"
"github.com/stealthrocket/timecraft/format"
)

Expand Down Expand Up @@ -61,9 +60,9 @@ func export(ctx context.Context, args []string) error {

var hash format.Hash
if resource.typ == "process" {
processID, err := uuid.Parse(args[1])
processID, err := parseProcessID(args[1])
if err != nil {
return errors.New(`malformed process id (not a UUID)`)
return err
}
manifest, err := registry.LookupLogManifest(ctx, processID)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Runtime Commands:
Debugging Commands:
profile Generate performance profile from execution records
trace Generate traces from execution records
Other Commands:
config View or edit the timecraft configuration
Expand Down Expand Up @@ -67,6 +68,8 @@ func help(ctx context.Context, args []string) error {
msg = runUsage
case "replay":
msg = replayUsage
case "trace":
msg = traceUsage
case "version":
msg = versionUsage
default:
Expand Down
Loading

0 comments on commit b5d76b5

Please sign in to comment.