Move the metrics-enabled toggle into pkg/metric
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 58/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- go, prometheus
- Domain
- backend, observability-sre
Research direction
Start by exploring the pkg/metric package, especially metric.Options, NewPrometheusMetricsRegistryWithOptions, MetricsRegistry, and NewMetricsManagerForSubsystem. Compare the current enablement wrappers in transaction-manager's internal/metrics/metrics.go and event_metrics.go. Done means disabled registries and managers consistently no-op while the default remains enabled, including handles passed through MetricsRegistry().
Written by the indexing model from the issue text.
Description
Move the metrics-enabled toggle into pkg/metric
Problem
pkg/metric's MetricsRegistry/MetricsManager interfaces have no concept of "enabled". Every New*Metric, Set*, Inc*, and Observe* method unconditionally does the real prometheus work.
Because of that, every consuming service has to hand-roll its own enablement gate around each call. transaction-manager is a good example: internal/metrics/metrics.go computes a local metricsEnabled bool from config (monitoring.enabled / deprecated metrics.enabled), then wraps roughly 20 separate methods (across metrics.go and event_metrics.go) in if mm.metricsEnabled { ... }, one at a time.
This duplication is easy to get wrong or incomplete. We recently found one gap in transaction-manager: Manager.MetricsRegistry() hands the raw registry to downstream connector code (for registering custom metrics) without exposing whether metrics are actually enabled, so callers had no way to check before registering. That particular gap is fixed locally, but the underlying pattern (each service reimplementing its own enabled/disabled wrapper) is duplicated per-repo and will likely resurface elsewhere in the firefly microservice fleet.
Proposal
Move the enabled/disabled concept into pkg/metric itself:
- Add an
Enabled boolfield tometric.Options(defaulttrue), passed throughNewPrometheusMetricsRegistryWithOptions. - Expose
IsEnabled() boolonMetricsRegistry. - Have the
MetricsManagerreturned byNewMetricsManagerForSubsystemself-gate itsNew*Metric/Set*/Inc*/Observe*calls on that flag, becoming a no-op when disabled.
With that in place, consuming services no longer need a local enabled bool or per-method gating: they set Enabled once at registry construction time based on their own config, and every metrics call and every handle obtained from the registry (including MetricsRegistry()-style pass-throughs to downstream code) is consistent by construction.
Reference
Context from hyperledger-firefly/transaction-manager: internal/metrics/metrics.go, internal/metrics/event_metrics.go.
- Dominant language
- Go
- Stars
- 5
- Forks
- 15
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from hyperledger-firefly/common
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
hyperledger-firefly/common#236 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
hyperledger-firefly/common#188 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
hyperledger-firefly/common#156 · 2 comments ·
-
Intermittent test failureMay be free again @EnriqueL8 claimed this 902 days ago, and no pull request is open. Open
hyperledger-firefly/common#136 · 1 assignee ·
-
Cache entries are not automatically reaped when they reach their TTLMay be free again @peterbroadhurst claimed this 1208 days ago, and no pull request is open. Open
hyperledger-firefly/common#85 · 1 assignee ·
All issues in hyperledger-firefly/common
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/rocketmq-dashboard#7243 ·
Maintainers usually reply within 3 days
-
Missing example coverage: getClockPossibly taken @camunda-sdk-automation claimed this today. Opennew-operations
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
camunda/orchestration-cluster-api-go#75 · 2 comments ·
Maintainers usually reply within 1 day
-
[schema-coverage] elasticstack_kibana_security_entity_store_statusPossibly taken @github-actions claimed this today. Openacceptance-tests phase-coding schema-coverage testing triaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
elastic/terraform-provider-elasticstack#5396 ·
Maintainers usually reply within 1 day
-
Go device SDK: Whisper transcriber keeps buffering and transcribing audio appended after Stop()Possibly taken @apoorvdarshan claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
BasedHardware/omi#22770 ·
Maintainers usually reply within 1 day
-
Bug v3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day