From e10b450abd2fd859baf6893636a6191a3a6b6872 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sat, 28 Jan 2023 17:35:01 +0100 Subject: [PATCH] fix: metrics no longer bloat memory --- src/server/api_metrics.v | 3 +-- src/server/server.v | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/server/api_metrics.v b/src/server/api_metrics.v index cde44372..5ba04520 100644 --- a/src/server/api_metrics.v +++ b/src/server/api_metrics.v @@ -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 diff --git a/src/server/server.v b/src/server/server.v index ae086f5b..c6bdd1a6 100644 --- a/src/server/server.v +++ b/src/server/server.v @@ -92,11 +92,14 @@ 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