feat(metrics): add prefix; use base unit for time
ci/woodpecker/push/docs Pipeline was successful
Details
ci/woodpecker/push/lint Pipeline was successful
Details
ci/woodpecker/push/arch Pipeline was successful
Details
ci/woodpecker/push/build Pipeline was successful
Details
ci/woodpecker/push/test Pipeline was successful
Details
ci/woodpecker/push/man Pipeline was successful
Details
ci/woodpecker/push/docker Pipeline was successful
Details
ci/woodpecker/push/deploy Pipeline was successful
Details
ci/woodpecker/push/docs Pipeline was successful
Details
ci/woodpecker/push/lint Pipeline was successful
Details
ci/woodpecker/push/arch Pipeline was successful
Details
ci/woodpecker/push/build Pipeline was successful
Details
ci/woodpecker/push/test Pipeline was successful
Details
ci/woodpecker/push/man Pipeline was successful
Details
ci/woodpecker/push/docker Pipeline was successful
Details
ci/woodpecker/push/deploy Pipeline was successful
Details
parent
849bf54979
commit
60d5fb77e0
|
@ -10,8 +10,9 @@ fn (mut app App) v1_metrics() web.Result {
|
||||||
return app.status(.not_found)
|
return app.status(.not_found)
|
||||||
}
|
}
|
||||||
|
|
||||||
mut exporter := metrics.new_prometheus_exporter([0.01, 0.05, 0.1, 0.5, 1, 100])
|
mut exporter := metrics.new_prometheus_exporter([0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5,
|
||||||
exporter.load(app.collector)
|
10])
|
||||||
|
exporter.load('vieter_', app.collector)
|
||||||
|
|
||||||
// TODO stream to connection instead
|
// TODO stream to connection instead
|
||||||
body := exporter.export_to_string() or { return app.status(.internal_server_error) }
|
body := exporter.export_to_string() or { return app.status(.internal_server_error) }
|
||||||
|
|
|
@ -335,11 +335,15 @@ fn handle_conn<T>(mut conn net.TcpConn, mut app T, routes map[string]Route) {
|
||||||
labels := [
|
labels := [
|
||||||
['method', app.req.method.str()]!,
|
['method', app.req.method.str()]!,
|
||||||
['path', app.req.url]!,
|
['path', app.req.url]!,
|
||||||
|
// Not all methods properly set this value yet I think
|
||||||
['status', app.status.int().str()]!,
|
['status', app.status.int().str()]!,
|
||||||
]
|
]
|
||||||
app.collector.counter_increment(name: 'http_requests_total', labels: labels)
|
app.collector.counter_increment(name: 'http_requests_total', labels: labels)
|
||||||
app.collector.histogram_record(time.ticks() - app.page_gen_start,
|
// Prometheus prefers metrics containing base units, as defined here
|
||||||
name: 'http_requests_time_ms'
|
// https://prometheus.io/docs/practices/naming/
|
||||||
|
app.collector.histogram_record(f64(time.ticks() - app.page_gen_start) / 1000,
|
||||||
|
|
||||||
|
name: 'http_requests_duration_seconds'
|
||||||
labels: labels
|
labels: labels
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue