Created
March 18, 2018 14:17
-
-
Save avivl/f49969508a846fbf0abd1a7a37825c52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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