feat(server): ability to disable metrics
Some checks failed
ci/woodpecker/pr/docs Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/man Pipeline failed
ci/woodpecker/pr/docker Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
Some checks failed
ci/woodpecker/pr/docs Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/man Pipeline failed
ci/woodpecker/pr/docker Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
This commit is contained in:
parent
c0f58ddc77
commit
4ca2521937
6 changed files with 25 additions and 9 deletions
|
|
@ -148,6 +148,7 @@ pub fn (ctx &Context) is_authenticated() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// body sends the given body as an HTTP response.
|
||||
pub fn (mut ctx Context) body(status http.Status, content_type string, body string) Result {
|
||||
ctx.status = status
|
||||
ctx.content_type = content_type
|
||||
|
|
@ -334,11 +335,13 @@ fn handle_conn<T>(mut conn net.TcpConn, mut app T, routes map[string]Route) {
|
|||
labels := [
|
||||
['method', app.req.method.str()]!,
|
||||
['path', app.req.url]!,
|
||||
['status', app.status.int().str()]!
|
||||
['status', app.status.int().str()]!,
|
||||
]
|
||||
app.collector.counter_increment(name: 'http_requests_total', labels: labels)
|
||||
app.collector.histogram_record(time.ticks() - app.page_gen_start, name: 'http_requests_time_ms', labels: labels)
|
||||
/* app.collector.histogram_ */
|
||||
app.collector.histogram_record(time.ticks() - app.page_gen_start,
|
||||
name: 'http_requests_time_ms'
|
||||
labels: labels
|
||||
)
|
||||
|
||||
unsafe {
|
||||
free(app)
|
||||
|
|
|
|||
Reference in a new issue