Skip to content

Commit

Permalink
feat: add new trace function to elton.Context
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Oct 9, 2021
1 parent cc95d38 commit 14e8224
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,13 @@ func (c *Context) GetTrace() *Trace {
return GetTrace(c.Context())
}

// NewTrace returns a new trace and set it to context value
func (c *Context) NewTrace() *Trace {
trace := NewTrace()
c.WithContext(context.WithValue(c.Context(), ContextTraceKey, trace))
return trace
}

// ServerTiming converts trace info to http response server timing
func (c *Context) ServerTiming(traceInfos TraceInfos, prefix string) {
value := traceInfos.ServerTiming(prefix)
Expand Down

0 comments on commit 14e8224

Please sign in to comment.