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.
This commit is contained in:
Arran Schlosberg 2025-03-20 15:24:22 +00:00 committed by GitHub
parent 7b8d20f3d5
commit 7be6bee7ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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