-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add inflation metric #77
Conversation
WalkthroughThe recent changes introduce robust functionalities for handling inflation data within the application. Key additions include an inflation JSON configuration file, a dedicated fetcher and generator for inflation data, and an enhanced RPC structure for querying inflation metrics. These updates streamline data retrieval and monitoring, laying the groundwork for comprehensive financial analysis capabilities. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App as Application
participant Fetcher as InflationFetcher
participant RPC as RPC Client
participant Generator as InflationGenerator
participant Metrics as Prometheus
User->>App: Request Inflation Data
App->>Fetcher: Fetch Inflation Data
Fetcher->>RPC: GetInflation()
RPC-->>Fetcher: Return InflationResponse
Fetcher-->>App: Provide Inflation Data
App->>Generator: Generate Metrics
Generator->>Metrics: Collect Inflation Metrics
Metrics-->>App: Metrics Updated
App-->>User: Respond with Inflation Data
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #77 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 63 65 +2
Lines 2585 2657 +72
=========================================
+ Hits 2585 2657 +72 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Outside diff range, codebase verification and nitpick comments (2)
pkg/app.go (2)
98-98
: Add a comment for the new inflation fetcher.Consider adding a comment to explain the purpose of the new
NewInflationFetcher
for consistency with other fetchers.// NewInflationFetcher fetches inflation data fetchersPkg.NewInflationFetcher(logger, appConfig.Chains, rpcs, tracer),
124-124
: Add a comment for the new inflation generator.Consider adding a comment to explain the purpose of the new
NewInflationGenerator
for consistency with other generators.// NewInflationGenerator generates inflation metrics generatorsPkg.NewInflationGenerator(),
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (9)
- assets/inflation.json (1 hunks)
- pkg/app.go (2 hunks)
- pkg/constants/constants.go (1 hunks)
- pkg/fetchers/inflation.go (1 hunks)
- pkg/fetchers/inflation_test.go (1 hunks)
- pkg/generators/inflation.go (1 hunks)
- pkg/generators/inflation_test.go (1 hunks)
- pkg/tendermint/rpc.go (1 hunks)
- pkg/types/tendermint.go (1 hunks)
Files skipped from review due to trivial changes (1)
- assets/inflation.json
Additional context used
Learnings (1)
pkg/fetchers/inflation_test.go (2)
Learnt from: freak12techno PR: QuokkaStake/cosmos-validators-exporter#63 File: pkg/fetchers/validators.go:28-34 Timestamp: 2024-06-23T11:24:50.154Z Learning: The constructor function `NewValidatorsFetcher` in `pkg/fetchers/validators.go` is now covered by tests in `validators_test.go`.
Learnt from: freak12techno PR: QuokkaStake/cosmos-validators-exporter#63 File: pkg/fetchers/soft_opt_out_threshold.go:28-34 Timestamp: 2024-06-23T11:25:06.862Z Learning: The `NewSoftOptOutThresholdFetcher` constructor function in `pkg/fetchers/soft_opt_out_threshold.go` is now covered by tests as verified by the presence of its usage in `pkg/fetchers/soft_opt_out_threshold_test.go`.
Additional comments not posted (17)
pkg/generators/inflation.go (3)
11-16
: LGTM!The
InflationGenerator
struct andNewInflationGenerator
function are correctly defined.
24-40
: LGTM!The Prometheus gauge creation and data population are correctly implemented.
40-41
: LGTM!The return statement is correct.
pkg/generators/inflation_test.go (2)
17-24
: LGTM!The
TestInflationGeneratorNoState
test is correctly written and follows best practices.
26-45
: LGTM!The
TestInflationGeneratorNotEmptyState
test is well-structured and covers the necessary assertions.pkg/constants/constants.go (1)
24-24
: LGTM!The new constant
FetcherNameInflation
is correctly added and follows the existing pattern.pkg/fetchers/inflation.go (5)
17-22
: LGTM! Struct definition is well-defined.The
InflationFetcher
struct is well-defined with appropriate fields for logger, chains, RPCs, and tracer.
24-26
: LGTM! Struct definition is simple and well-defined.The
InflationData
struct is simple and well-defined with a single field for inflation data.
28-39
: LGTM! Constructor function is well-implemented.The
NewInflationFetcher
function is well-implemented. It initializes the fields and returns a new instance ofInflationFetcher
.
42-89
: LGTM! Function implementation is well-implemented.The
Fetch
function retrieves inflation data for multiple chains concurrently. It uses goroutines and a wait group to fetch data concurrently. It handles errors and logs them appropriately. The use of mutex ensures thread safety when updating shared data.
92-94
: LGTM! Function implementation is simple and well-implemented.The
Name
function returns the name of the fetcher.pkg/types/tendermint.go (1)
203-206
: LGTM! Type definition is simple and well-implemented.The
InflationResponse
type definition has fields for code and inflation.pkg/fetchers/inflation_test.go (5)
20-50
: LGTM! Test function is well-implemented.The
TestInflationFetcherBase
function tests the basic functionality ofInflationFetcher
. It checks the initialization and name of the fetcher.
52-81
: LGTM! Test function is well-implemented.The
TestInflationFetcherQueryDisabled
function tests the behavior when the inflation query is disabled. It checks that no queries are made and the inflation data is empty.
83-120
: LGTM! Test function is well-implemented.The
TestInflationFetcherQueryError
function tests the behavior when there is an error querying the inflation data. It checks that the query is marked as unsuccessful and the inflation data is empty.
122-159
: LGTM! Test function is well-implemented.The
TestInflationFetcherNodeError
function tests the behavior when the node returns an error response. It checks that the query is marked as unsuccessful and the inflation data is empty.
161-205
: LGTM! Test function is well-implemented.The
TestInflationFetcherQuerySuccess
function tests the behavior when the inflation query is successful. It checks that the query is marked as successful and the inflation data is correctly populated.
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation