Skip to content

Commit

Permalink
present: include elapsed time in json
Browse files Browse the repository at this point in the history
When requesting json output from data monitoring pipelines it's useful
to get the exact elapsed time, similarly to ps output.
  • Loading branch information
egonelbre committed May 8, 2024
1 parent d4f45e4 commit 28ec870
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions present/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ func formatSpan(s *monkit.Span) interface{} {
Id int64 `json:"id"`
} `json:"trace"`
Start int64 `json:"start"`
Elapsed int64 `json:"elapsed"`
Orphaned bool `json:"orphaned"`
Args []string `json:"args"`
Annotations [][]string `json:"annotations"`
}{}

js.Id = s.Id()
if parent_id, ok := s.ParentId(); ok {
js.ParentId = &parent_id
Expand All @@ -48,6 +50,7 @@ func formatSpan(s *monkit.Span) interface{} {
js.Func.Name = s.Func().ShortName()
js.Trace.Id = s.Trace().Id()
js.Start = s.Start().UnixNano()
js.Elapsed = time.Since(s.Start()).Nanoseconds()
js.Orphaned = s.Orphaned()
js.Args = make([]string, 0, len(s.Args()))
for _, arg := range s.Args() {
Expand Down

0 comments on commit 28ec870

Please sign in to comment.