fix: metrics no longer bloat memory
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

pull/346/head
Jef Roosens 2023-01-28 17:35:01 +01:00
parent 8f32888dff
commit e10b450abd
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 5 additions and 3 deletions

View File

@ -10,8 +10,7 @@ fn (mut app App) v1_metrics() web.Result {
return app.status(.not_found)
}
mut exporter := metrics.new_prometheus_exporter([0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5,
10])
mut exporter := metrics.new_prometheus_exporter()
exporter.load('vieter_', app.collector)
// TODO stream to connection instead

View File

@ -92,12 +92,15 @@ pub fn server(conf Config) ! {
util.exit_with_message(1, 'Failed to initialize database: $err.msg()')
}
collector := if conf.collect_metrics {
mut collector := if conf.collect_metrics {
&metrics.MetricsCollector(metrics.new_default_collector())
} else {
&metrics.MetricsCollector(metrics.new_null_collector())
}
collector.histogram_buckets_set('http_requests_duration_seconds', [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5,
10] )
mut app := &App{
logger: logger
api_key: conf.api_key