Skip to content

Instantly share code, notes, and snippets.

@avivl
Created March 18, 2018 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avivl/f49969508a846fbf0abd1a7a37825c52 to your computer and use it in GitHub Desktop.
Save avivl/f49969508a846fbf0abd1a7a37825c52 to your computer and use it in GitHub Desktop.
func (c *Collector) Collect(ctx *fasthttp.RequestCtx) {
defer func(begin time.Time) {
responseTime := float64(time.Since(begin).Nanoseconds() / 1000)
occtx, _ := tag.New(context.Background(), tag.Insert(codeKey, strconv.Itoa(ctx.Response.StatusCode())), )
stats.Record(occtx, requestCounter.M(1))
stats.Record(occtx, requestlatency.M(responseTime))
}(time.Now())
/*do some stuff */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment