Skip to content

feat(metrics): migrate sei-cosmos module packages to OpenTelemetry (PLT-414)#3512

Open
amir-deris wants to merge 3 commits into
mainfrom
amir/plt-413-migrate-more-packages-to-otel
Open

feat(metrics): migrate sei-cosmos module packages to OpenTelemetry (PLT-414)#3512
amir-deris wants to merge 3 commits into
mainfrom
amir/plt-413-migrate-more-packages-to-otel

Conversation

@amir-deris
Copy link
Copy Markdown
Contributor

@amir-deris amir-deris commented May 27, 2026

Summary

Migrates the following sei-cosmos packages from legacy telemetry/go-metrics to OpenTelemetry, using the dual-emit pattern (OTel instrument recorded first, old call retained with TODO(PLT-414) for removal once verified):

  • types/modulemodule_total_mid_block_duration, module_mid_block_duration (per-module label)
  • x/evidencebegin_blocker_duration
  • x/capabilitybegin_blocker_duration
  • x/crisisend_blocker_duration, init_genesis_unmarshal_duration
  • x/distributionbegin_blocker_duration
  • x/govend_blocker_duration
  • x/slashingbegin_blocker_duration; keeper: validator_slashed (with type + validator attributes)
  • x/stakingbegin_blocker_duration, end_blocker_duration

Each package gets a new metrics.go defining its OTel meter and instruments, following the pattern established in x/upgrade (PLT-353).

@cursor
Copy link
Copy Markdown

cursor Bot commented May 27, 2026

PR Summary

Low Risk
Observability-only changes with dual emission; no changes to slashing, staking, or block execution logic beyond metric recording.

Overview
This PR moves sei-cosmos block and genesis timing metrics from legacy telemetry to OpenTelemetry, while dual-emitting the old calls until PLT-414 verification (each new record is followed by a TODO(PLT-414) legacy path).

New per-package metrics.go files define OTel meters and instruments. ABCI hooks now record histograms for begin/end blocker duration (and crisis InitGenesis unmarshal). types/module adds module_total_mid_block_duration and per-module module_mid_block_duration, with precomputed module attributes in SetOrderMidBlockers to avoid per-block allocations in MidBlock.

Slashing adds an OTel validator_slashed counter (with type and validator labels) on double-sign and downtime paths. Staking keeper OTel instrument names are prefixed (staking_keeper_*) for clearer namespacing.

No consensus or business-logic behavior changes—observability only, with a planned follow-up to drop legacy telemetry.

Reviewed by Cursor Bugbot for commit 97bc34d. Bugbot is set up for automated code reviews on this repo. Configure here.

@amir-deris amir-deris changed the title Added otel to more sei-cosmos modules feat(metrics): migrate sei-cosmos module packages to OpenTelemetry (PLT-414) May 27, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 27, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 27, 2026, 10:57 PM

@amir-deris amir-deris requested review from bdchatham and masih May 27, 2026 20:49
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

❌ Patch coverage is 79.77528% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.22%. Comparing base (3936ac9) to head (97bc34d).

Files with missing lines Patch % Lines
sei-cosmos/types/module/metrics.go 50.00% 1 Missing and 1 partial ⚠️
sei-cosmos/x/capability/metrics.go 50.00% 1 Missing and 1 partial ⚠️
sei-cosmos/x/crisis/metrics.go 50.00% 1 Missing and 1 partial ⚠️
sei-cosmos/x/distribution/metrics.go 50.00% 1 Missing and 1 partial ⚠️
sei-cosmos/x/evidence/metrics.go 50.00% 1 Missing and 1 partial ⚠️
sei-cosmos/x/gov/metrics.go 50.00% 1 Missing and 1 partial ⚠️
sei-cosmos/x/slashing/keeper/metrics.go 50.00% 1 Missing and 1 partial ⚠️
sei-cosmos/x/slashing/metrics.go 50.00% 1 Missing and 1 partial ⚠️
sei-cosmos/x/staking/metrics.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3512      +/-   ##
==========================================
- Coverage   59.04%   58.22%   -0.82%     
==========================================
  Files        2199     2138      -61     
  Lines      182096   174001    -8095     
==========================================
- Hits       107513   101311    -6202     
+ Misses      64933    63694    -1239     
+ Partials     9650     8996     -654     
Flag Coverage Δ
sei-chain-pr 73.46% <79.77%> (?)
sei-db 70.41% <ø> (ø)
sei-db-state-db ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-cosmos/types/module/module.go 60.33% <100.00%> (+1.56%) ⬆️
sei-cosmos/x/capability/abci.go 100.00% <100.00%> (ø)
sei-cosmos/x/crisis/abci.go 100.00% <100.00%> (ø)
sei-cosmos/x/crisis/module.go 68.85% <100.00%> (+0.51%) ⬆️
sei-cosmos/x/distribution/abci.go 100.00% <100.00%> (ø)
sei-cosmos/x/evidence/abci.go 46.15% <100.00%> (+23.93%) ⬆️
sei-cosmos/x/gov/abci.go 94.93% <100.00%> (+0.27%) ⬆️
sei-cosmos/x/slashing/abci.go 93.75% <100.00%> (+0.89%) ⬆️
sei-cosmos/x/slashing/keeper/infractions.go 96.39% <100.00%> (+0.03%) ⬆️
sei-cosmos/x/slashing/keeper/keeper.go 85.41% <100.00%> (+0.31%) ⬆️
... and 11 more

... and 70 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread sei-cosmos/x/capability/metrics.go
Copy link
Copy Markdown
Contributor

@bdchatham bdchatham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two focused follow-ups from a cross-review pass. (Both non-blocking on their own — the larger naming-collision discussion on the per-package begin_blocker_duration / end_blocker_duration instruments is separate.)

Comment thread sei-cosmos/x/slashing/keeper/metrics.go
Comment thread sei-cosmos/types/module/module.go Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 97bc34d. Configure here.

Comment thread sei-cosmos/x/slashing/keeper/metrics.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants