Skip to content
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

fix(server/v2/api/telemetry): enable global metrics #22571

Merged
merged 5 commits into from
Nov 20, 2024
Merged

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Nov 20, 2024

Description

This enables metrics by passing a callback to v2 telemetry to avoid imports


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Introduced dynamic control over telemetry enabling with a new function.
    • Updated telemetry server initialization to require an enabling function.
  • Bug Fixes

    • Enhanced error handling during telemetry server instantiation to prevent nil function usage.

Copy link
Contributor

coderabbitai bot commented Nov 20, 2024

📝 Walkthrough

Walkthrough

The pull request introduces modifications to the telemetry server's initialization process by updating the New function in the Server struct to require an additional parameter, enableTelemetry func(). This change ensures that telemetry functionality is conditionally enabled based on the provided function. Additionally, a new EnableTelemetry function is added to manage the telemetry state dynamically. The changes affect how the telemetry server is instantiated and how its operational state is determined, while other functionalities remain intact.

Changes

File Path Change Summary
server/v2/api/telemetry/server.go Updated New function signature to include enableTelemetry func(). Added nil check for this parameter.
simapp/v2/simdv2/cmd/commands.go Modified InitRootCmd to call telemetry.New with the new enableTelemetry parameter.
telemetry/metrics.go Added EnableTelemetry function to control the telemetry state dynamically. Updated New function to initialize telemetry based on configuration.

Possibly related PRs

  • feat(server/v2): wire telemetry + server refactors #21746: This PR modifies the telemetry.New function to include an additional parameter for enabling telemetry, which directly relates to the changes made in the main PR that also updates the New function in the Server struct to include the enableTelemetry parameter.
  • refactor(server/v2/telemetry): swap redirects #22520: This PR alters the Start method of the Server struct in the telemetry package, which is relevant as it involves changes to the telemetry server's behavior, although it does not directly modify the New function itself.

Suggested reviewers

  • kocubinski
  • hieuvubk
  • sontrinh16
  • akhilkumarpilli

📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d01cb11 and 8e3dc25.

📒 Files selected for processing (1)
  • simapp/v2/simdv2/cmd/commands.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • simapp/v2/simdv2/cmd/commands.go

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added C:server/v2 Issues related to server/v2 C:server/v2 api labels Nov 20, 2024
@tac0turtle tac0turtle marked this pull request as ready for review November 20, 2024 14:09
Copy link
Contributor

@tac0turtle your pull request is missing a changelog!

Comment on lines 24 to 30
return globalTelemetryEnabled
}

// SetTelemetryEnabled allows for the global telemetry enabled state to be set.
func EnableTelemetry() {
globalTelemetryEnabled = true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Change potentially affects state.

Call sequence:

github.com/cosmos/cosmos-sdk/telemetry.IsTelemetryEnabled (telemetry/metrics.go:23)
github.com/cosmos/cosmos-sdk/telemetry.IncrCounter (telemetry/metrics.go:53)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).deliverTx (telemetry/metrics.go:761)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).internalFinalizeBlock (telemetry/metrics.go:747)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).FinalizeBlock (telemetry/metrics.go:902)

@tac0turtle tac0turtle changed the title fix(v2): enable metrics fix(v2): enable global metrics Nov 20, 2024
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

ACK, just some nits

telemetry/metrics.go Show resolved Hide resolved
server/v2/api/telemetry/metrics.go Outdated Show resolved Hide resolved
@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Nov 20, 2024
@julienrbrt
Copy link
Member

Adding backport label because of simappv2 and sdk changes.

@julienrbrt julienrbrt changed the title fix(v2): enable global metrics fix(server/v2/api/telemetry): enable global metrics Nov 20, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
server/v2/api/telemetry/server.go (1)

42-48: Enhance panic message for better debugging

While the validation and conditional invocation logic is correct, the panic message could be more descriptive.

Consider this improvement:

-		panic("enableTelemetry must be provided")
+		panic("telemetry: enableTelemetry callback function must be provided")
server/v2/api/telemetry/metrics.go (1)

Line range hint 153-154: Enhance error message consistency and specificity.

Consider standardizing error messages for better debugging and consistency:

-    return GatherResponse{}, errors.New("prometheus metrics are not enabled")
+    return GatherResponse{}, fmt.Errorf("prometheus metrics: not enabled")

-    return GatherResponse{}, errors.New("non in-memory metrics sink does not support generic format")
+    return GatherResponse{}, fmt.Errorf("metrics sink: generic format not supported for non in-memory sink")

-    return GatherResponse{}, fmt.Errorf("failed to gather in-memory metrics: %w", err)
+    return GatherResponse{}, fmt.Errorf("metrics gather: failed to collect in-memory metrics: %w", err)

Also applies to: 166-167, 182-183

telemetry/metrics.go (1)

27-30: Consider refactoring telemetry state management

The current design splits telemetry state management between New() and EnableTelemetry(), which could lead to confusion about the proper way to manage telemetry state. Consider adopting a more structured approach:

  1. Move state management into a dedicated type
  2. Make the initialization path clear and consistent
  3. Document the expected usage pattern

Consider this alternative design:

type TelemetryManager struct {
    enabled atomic.Bool
    mu      sync.RWMutex
    metrics *Metrics
}

func NewTelemetryManager(cfg Config) (*TelemetryManager, error) {
    tm := &TelemetryManager{}
    if cfg.Enabled {
        if err := tm.Enable(cfg); err != nil {
            return nil, err
        }
    }
    return tm, nil
}

func (tm *TelemetryManager) Enable(cfg Config) error {
    tm.mu.Lock()
    defer tm.mu.Unlock()
    
    if tm.enabled.Load() {
        return nil
    }
    
    metrics, err := initializeMetrics(cfg)
    if err != nil {
        return err
    }
    
    tm.metrics = metrics
    tm.enabled.Store(true)
    return nil
}
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 50c5963 and ff7807d.

📒 Files selected for processing (4)
  • server/v2/api/telemetry/metrics.go (1 hunks)
  • server/v2/api/telemetry/server.go (2 hunks)
  • simapp/v2/simdv2/cmd/commands.go (2 hunks)
  • telemetry/metrics.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
server/v2/api/telemetry/metrics.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/api/telemetry/server.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/v2/simdv2/cmd/commands.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

telemetry/metrics.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

🔇 Additional comments (5)
server/v2/api/telemetry/server.go (2)

31-31: LGTM: Function signature change aligns with PR objectives

The addition of enableTelemetry func() parameter is a clean way to implement the callback pattern and avoid unnecessary imports.


Line range hint 50-54: Verify metrics initialization behavior

The metrics initialization happens after the telemetry enabling. Let's verify that NewMetrics properly handles the telemetry state.

✅ Verification successful

Metrics initialization properly handles telemetry state

The NewMetrics implementation in server/v2/api/telemetry/metrics.go correctly handles the telemetry state by:

  • Checking the Enable flag in the config
  • Returning nil, nil when telemetry is disabled
  • Only proceeding with metrics initialization when telemetry is enabled

The implementation is safe and behaves as expected with respect to the telemetry state.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for NewMetrics implementation to verify state handling
ast-grep --pattern 'func NewMetrics($config $_) ($_, $_) {
  $$$
}'

Length of output: 69


Script:

#!/bin/bash
# Let's try a broader search for NewMetrics function
rg "func NewMetrics" -A 10

# Also search for any metrics-related type definitions and initialization
rg "type.*Metrics" -A 5

# Search for metrics configuration handling
rg "metrics.*config" -A 5

Length of output: 14565

server/v2/api/telemetry/metrics.go (1)

62-64: LGTM! Early return pattern improves control flow.

The early return when metrics are disabled is a good practice that prevents unnecessary resource allocation. However, let's verify the impact on existing callers.

✅ Verification successful

Let me check how the callers handle the nil return value.


Let me check the server implementation to see how metrics are used after initialization.


Early return pattern is safe and correctly handled

The nil return from NewMetrics is properly handled in the codebase:

  • The server stores metrics in Server.metrics field which can be nil
  • The metrics handler is only registered when config.Enable is true
  • The server's Start method has an early return when telemetry is disabled
  • No unsafe nil pointer dereferences are possible as the metrics handler is not registered when disabled
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for NewMetrics calls to ensure callers handle nil return
rg -A 3 "NewMetrics\(" 

Length of output: 999


Script:

#!/bin/bash
# Check how the server handles nil metrics
ast-grep --pattern 'metrics, err := NewMetrics($$$)
  $$$
  if metrics != nil {
    $$$
  }'

Length of output: 94


Script:

#!/bin/bash
# Get the server implementation to see metrics usage
cat server/v2/api/telemetry/server.go

Length of output: 3223

simapp/v2/simdv2/cmd/commands.go (2)

28-28: LGTM! Import added correctly.

The new import for telemetry is properly aliased and follows Go conventions.


121-124: LGTM! Telemetry initialization updated correctly.

The addition of sdktelemetry.EnableTelemetry callback aligns with the PR objective of enabling metrics within the v2 telemetry framework.

Let's verify the telemetry initialization:

✅ Verification successful

Telemetry initialization is correctly implemented

The telemetry initialization in the code is properly done:

  1. The telemetry server is initialized with the correct parameters:

    • Global configuration from deps.GlobalConfig
    • Logger instance
    • EnableTelemetry callback function from sdktelemetry package
  2. The telemetry package provides proper metrics collection and measurement capabilities:

    • Module-specific measurements
    • Transaction metrics
    • Query metrics
    • Server info metrics
  3. The telemetry configuration is properly integrated into the server config structure and can be enabled/disabled through configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the telemetry initialization and usage
# Check if EnableTelemetry is properly defined and exported
ast-grep --pattern 'func EnableTelemetry() bool { $$$'

# Check for any direct telemetry.New calls to ensure consistent usage
rg 'telemetry\.New\(' -A 2

Length of output: 367


Script:

#!/bin/bash
# Let's check the telemetry package to understand the New function signature and usage
rg -t go 'func New.*\(' --context 3

# Also check for any other telemetry initialization patterns
rg -t go 'type.*[Tt]elemetry' --context 2

# Check imports of telemetry package
rg -t go '^import.*telemetry'

Length of output: 452779


Script:

#!/bin/bash
# Let's check the telemetry package and its usage in the codebase
rg -t go 'telemetry\.' --context 3

# Also check for any telemetry configuration
rg -t go 'EnableTelemetry' --context 3

Length of output: 17069

Comment on lines 27 to 30
// SetTelemetryEnabled allows for the global telemetry enabled state to be set.
func EnableTelemetry() {
globalTelemetryEnabled = true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider thread safety and design implications of EnableTelemetry

The current implementation has several concerns:

  1. Thread safety: Access to globalTelemetryEnabled isn't synchronized, which could lead to race conditions in concurrent environments.
  2. The function contradicts the documented behavior that states the variable "does not change for the lifetime of the program"
  3. One-way operation: Consider whether disabling telemetry should also be supported

Consider this thread-safe implementation:

+var telemetryMu sync.RWMutex

 func EnableTelemetry() {
+    telemetryMu.Lock()
+    defer telemetryMu.Unlock()
     globalTelemetryEnabled = true
 }

 func IsTelemetryEnabled() bool {
+    telemetryMu.RLock()
+    defer telemetryMu.RUnlock()
     return globalTelemetryEnabled
 }

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
server/v2/api/telemetry/server.go (1)

42-44: Consider using error return instead of panic

While panicking in constructors is a common Go pattern, this validation case might be better handled by returning an error. This would allow callers to handle the invalid state more gracefully.

Consider this alternative:

-	if enableTelemetry == nil {
-		panic("enableTelemetry must be provided")
-	}
+	if enableTelemetry == nil {
+		return nil, fmt.Errorf("enableTelemetry callback cannot be nil")
+	}
simapp/v2/simdv2/cmd/commands.go (1)

121-124: LGTM: Clean implementation of telemetry enablement

The addition of EnableTelemetry callback is a good architectural choice as it:

  1. Implements the PR objective of enabling metrics
  2. Avoids unnecessary imports in the telemetry package
  3. Maintains proper error handling and initialization order
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 50c5963 and ff7807d.

📒 Files selected for processing (4)
  • server/v2/api/telemetry/metrics.go (1 hunks)
  • server/v2/api/telemetry/server.go (2 hunks)
  • simapp/v2/simdv2/cmd/commands.go (2 hunks)
  • telemetry/metrics.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
server/v2/api/telemetry/metrics.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/api/telemetry/server.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/v2/simdv2/cmd/commands.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

telemetry/metrics.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

🔇 Additional comments (5)
server/v2/api/telemetry/server.go (2)

31-31: LGTM: Function signature change is well-designed

The addition of enableTelemetry func() parameter is clean and follows Go idioms for callback passing.


46-48: Consider handling potential callback errors

The enableTelemetry callback is executed without any error handling. While it's currently defined as func(), consider whether it should return an error that could be propagated to the caller.

Let's check how this callback is used across the codebase:

Consider updating the signature to handle potential errors:

-func New[T transaction.Tx](cfg server.ConfigMap, logger log.Logger, enableTelemetry func()) (*Server[T], error) {
+func New[T transaction.Tx](cfg server.ConfigMap, logger log.Logger, enableTelemetry func() error) (*Server[T], error) {
    // ...
    if srv.config.Enable {
-        enableTelemetry()
+        if err := enableTelemetry(); err != nil {
+            return nil, fmt.Errorf("failed to enable telemetry: %w", err)
+        }
    }
server/v2/api/telemetry/metrics.go (1)

62-64: Verify nil handling in callers of NewMetrics

The early return of nil, nil when metrics are disabled is a good practice. However, we should ensure all callers properly handle the nil case to prevent potential panics.

✅ Verification successful

Early return with nil, nil is safe and properly handled

Based on the codebase analysis:

  1. The only direct caller of NewMetrics is in server/v2/api/telemetry/server.go
  2. The caller properly checks for error: if err != nil { return nil, fmt.Errorf(...) }
  3. The metrics field is optional in the Server struct, indicating it's designed to handle nil metrics
  4. The early return pattern aligns with Go's idiomatic approach for optional features
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for direct calls to NewMetrics and verify nil checks
ast-grep --pattern 'metrics, err := telemetry.NewMetrics($_)
$$$
if err != nil {
  $$$
}
if metrics != nil {
  $$$
}'

Length of output: 119


Script:

#!/bin/bash
# Let's try a broader search for NewMetrics usage
rg "NewMetrics" -A 5 -B 2

Length of output: 2155


Script:

#!/bin/bash
# Let's check how srv.metrics is used in the server code
rg "srv\.metrics" -A 2 -B 2

Length of output: 310


Script:

#!/bin/bash
# Let's examine the Server struct and any methods that might use metrics
rg -A 10 -B 2 "type Server struct"

Length of output: 790

simapp/v2/simdv2/cmd/commands.go (1)

28-28: LGTM: Import added for telemetry enablement

The addition of the SDK telemetry package aligns with the PR objective and follows Go import conventions.

telemetry/metrics.go (1)

27-30: ⚠️ Potential issue

Critical: Address concurrent access and state management concerns

The current implementation has several issues:

  1. Race Condition: The globalTelemetryEnabled variable is not protected against concurrent access, which could lead to race conditions in a concurrent environment.
  2. Immutability Violation: The comment on line 19 states that globalTelemetryEnabled "does not change for the lifetime of the program", but this function violates that contract.
  3. Documentation Mismatch: The comment suggests setting the state, but the function only enables it.

Consider this safer implementation:

- // SetTelemetryEnabled allows for the global telemetry enabled state to be set.
+ // EnableTelemetry enables telemetry for the application.
+ // Note: This operation is not thread-safe and should only be called during initialization.
 func EnableTelemetry() {
+    if !globalTelemetryEnabled {
 	globalTelemetryEnabled = true
+    }
 }

Let's verify the usage pattern to ensure it's only called during initialization:

Comment on lines 62 to 64
if !cfg.Enable {
return nil, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Document nil return and consider adding IsEnabled method

To improve safety and usability:

  1. Document that NewMetrics returns nil when metrics are disabled
  2. Consider adding an IsEnabled() bool method to safely check metrics state

Add documentation and helper method:

+ // NewMetrics creates a new instance of Metrics.
+ // Returns nil if metrics are disabled in the configuration.
 func NewMetrics(cfg *Config) (*Metrics, error) {
   if !cfg.Enable {
     return nil, nil
   }
// Add this helper method to the Metrics struct
func (m *Metrics) IsEnabled() bool {
    return m != nil
}

Copy link
Member

@facundomedica facundomedica left a comment

Choose a reason for hiding this comment

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

agree with the nits pointed by Julien 👌

Comment on lines 24 to +30
return globalTelemetryEnabled
}

// EnableTelemetry allows for the global telemetry enabled state to be set.
func EnableTelemetry() {
globalTelemetryEnabled = true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Change potentially affects state.

Call sequence:

github.com/cosmos/cosmos-sdk/telemetry.IsTelemetryEnabled (telemetry/metrics.go:23)
github.com/cosmos/cosmos-sdk/telemetry.IncrCounter (telemetry/metrics.go:53)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).deliverTx (telemetry/metrics.go:761)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).internalFinalizeBlock (telemetry/metrics.go:747)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).FinalizeBlock (telemetry/metrics.go:902)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
math/dec_test.go (1)

453-454: Fix indentation for consistency.

The indentation uses tabs but appears misaligned with other test cases in the file.

-		{math.LegacyNewDecWithPrec(4, 2), 0, math.LegacyOneDec()},                                            // 0.04 ^ 0 => 1.0
-		{math.LegacyNewDec(0), 1, math.LegacyNewDec(0)},                                                      // 0 ^ 1 => 0
+		{math.LegacyNewDecWithPrec(4, 2), 0, math.LegacyOneDec()},                                         // 0.04 ^ 0 => 1.0
+		{math.LegacyNewDec(0), 1, math.LegacyNewDec(0)},                                                   // 0 ^ 1 => 0
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a1f6f08 and d01cb11.

📒 Files selected for processing (2)
  • math/dec_test.go (1 hunks)
  • server/v2/cometbft/abci.go (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
math/dec_test.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

server/v2/cometbft/abci.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

🔇 Additional comments (3)
server/v2/cometbft/abci.go (2)

292-292: Improved error wrapping in simulation response

The change from %v to %w verb in fmt.Errorf is a good improvement as it properly wraps the original error, preserving the error chain for better debugging and error handling upstream.


37-40: LGTM: Import changes are necessary

The added imports are required for handling codec types, SDK types, and transaction types, which are used in the error handling improvements.

math/dec_test.go (1)

453-454: LGTM! Good test coverage for edge cases.

The test cases appropriately cover important edge cases:

  1. Testing 0.04^0 which should equal 1.0 (any number raised to power 0)
  2. Testing 0^1 which should equal 0 (zero raised to any positive power)

@julienrbrt julienrbrt added this pull request to the merge queue Nov 20, 2024
Merged via the queue into main with commit b45cf75 Nov 20, 2024
74 of 75 checks passed
@julienrbrt julienrbrt deleted the marko/fix_metrics branch November 20, 2024 17:44
mergify bot pushed a commit that referenced this pull request Nov 20, 2024
(cherry picked from commit b45cf75)

# Conflicts:
#	server/v2/api/telemetry/server.go
julienrbrt added a commit that referenced this pull request Nov 20, 2024
alpe added a commit that referenced this pull request Nov 21, 2024
* main:
  fix(server/v2/api/telemetry): enable global metrics  (#22571)
alpe added a commit that referenced this pull request Nov 21, 2024
* main:
  build(deps): Bump cosmossdk.io/math from 1.3.0 to 1.4.0 (#22580)
  fix(server/v2/api/telemetry): enable global metrics  (#22571)
  refactor(server/v2/cometbft): add `codec.Codec` and clean-up APIs (#22566)
  feat(core/coretesting): make memDB satisfy db.Db interface (#22570)
  Merge commit from fork
  fix(server(/v2)): fix fallback genesis path (#22564)
  fix: only overwrite context chainID when necessary (#22568)
  docs(client): Update setFeeGranter and setFeePayer comments (#22526)
  fix(baseapp): populate header info in `NewUncachedContext` (#22557)
  build(deps): Bump buf.build/gen/go/cometbft/cometbft/protocolbuffers/go from 1.35.1-20240701160653-fedbb9acfd2f.1 to 1.35.2-20240701160653-fedbb9acfd2f.1 in /api (#22551)
  build(deps): Bump github.com/creachadair/atomicfile from 0.3.5 to 0.3.6 in /tools/confix (#22552)
  docs: Update reference of Approximation (#22550)
  fix(server/v2/comebft): wire missing services + fix simulation (#21964)
  ci: fix permissions for GITHUB_TOKEN on dependabot workflows (#22547)
  ci: fix permissions for GITHUB_TOKEN in spell check workflow (#22545)
  build(deps): Bump google.golang.org/protobuf from 1.35.1 to 1.35.2 (#22537)
  fix(cosmovisor): premature upgrade on restart (#22528)
  fix(store/v2/pebble): handle version 0 in keys (#22524)
  refactor(server/v2/telemetry): swap redirects (#22520)
  docs: Update content in  CODE_OF_CONDUCT.md (#22518)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:server/v2 api C:server/v2 Issues related to server/v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants