From 7be6bee7ab32ebb89cafa134d5f9c30b8c5df733 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg <519948+ARR4N@users.noreply.github.com> Date: Thu, 20 Mar 2025 15:24:22 +0000 Subject: [PATCH] chore: enable metrics by default (#165) ## Why this should be merged The `metrics.Enabled` global is misleadingly named and disables _constructors_, not individual metrics when they're used. This resulted in all `ava-labs/coreth` metrics being no-ops because it was only set to `true` after they were all constructed. As the majority of metrics are globals, they're created during package initialisation so simply setting `metrics.Enabled = true` somewhere in `coreth` isn't a guarantee of ordering. The old `coreth/metrics` package simply set the global to `true` by default. ## How this works `metrics.Enabled = true` at the point of declaration. ## How this was tested Local inspection of metrics on a running binary. --- metrics/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metrics/metrics.go b/metrics/metrics.go index fc9f8ca883..6049ccbf18 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -18,11 +18,11 @@ import ( ) // Enabled is checked by the constructor functions for all of the -// standard metrics. If it is true, the metric returned is a stub. +// standard metrics. If it is false, the metric returned is a stub. // // This global kill-switch helps quantify the observer effect and makes // for less cluttered pprof profiles. -var Enabled = false +var Enabled = true // EnabledExpensive is a soft-flag meant for external packages to check if costly // metrics gathering is allowed or not. The goal is to separate standard metrics