From 42ad5a5bd5fbc19bf6bee755f2a4b4de8f8adc01 Mon Sep 17 00:00:00 2001 From: George Tsagkarelis Date: Thu, 16 Jan 2025 12:39:18 +0100 Subject: [PATCH] monitoring: add config for collector timeout --- monitoring/config.go | 14 ++++++++++++-- sample-tapd.conf | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/monitoring/config.go b/monitoring/config.go index 53dd37381..5b2202642 100644 --- a/monitoring/config.go +++ b/monitoring/config.go @@ -1,6 +1,8 @@ package monitoring import ( + "time" + "github.com/lightninglabs/taproot-assets/tapdb" "github.com/lightninglabs/taproot-assets/tapgarden" "github.com/lightninglabs/taproot-assets/universe" @@ -10,6 +12,8 @@ import ( // PrometheusConfig is the set of configuration data that specifies if // Prometheus metric exporting is activated, and if so the listening address of // the Prometheus server. +// +// nolint: lll type PrometheusConfig struct { // Active, if true, then Prometheus metrics will be exported. Active bool `long:"active" description:"if true prometheus metrics will be exported"` @@ -18,6 +22,11 @@ type PrometheusConfig struct { // main Prometheus server to scrape our metrics. ListenAddr string `long:"listenaddr" description:"the interface we should listen on for prometheus"` + // CollectorRPCTimeout is the context timeout to be used by the RPC + // calls performed during metrics collection. This should not be greater + // than the scrape interval of prometheus. + CollectorRPCTimeout time.Duration `long:"collector-rpc-timeout" description:"the default timeout to be used in the RPC calls performed during metric collection"` + // RPCServer is a pointer to the main RPC server. We use this to export // generic RPC metrics to monitor the health of the service. RPCServer *grpc.Server @@ -45,7 +54,8 @@ type PrometheusConfig struct { // metrics exporter. func DefaultPrometheusConfig() PrometheusConfig { return PrometheusConfig{ - ListenAddr: "127.0.0.1:8989", - Active: false, + ListenAddr: "127.0.0.1:8989", + Active: false, + CollectorRPCTimeout: defaultTimeout, } } diff --git a/sample-tapd.conf b/sample-tapd.conf index 25b63ec8e..ba91f742b 100644 --- a/sample-tapd.conf +++ b/sample-tapd.conf @@ -346,6 +346,9 @@ ; The interface we should listen on for prometheus ; prometheus.listenaddr=127.0.0.1:8989 +; The default timeout used in prometheus collectors. +; prometheus.collector-rpc-timeout=25s + ; Enable additional histogram to track gRPC call processing performance ; (latency, etc) ; prometheus.perfhistograms=false