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

refactor: remove dynamic labels from metrics #629

Merged
merged 1 commit into from
Aug 7, 2024
Merged

Conversation

zakir-code
Copy link
Contributor

@zakir-code zakir-code commented Aug 7, 2024

Summary by CodeRabbit

  • New Features
    • Enhanced telemetry tracking for various functions, providing clearer insights into metrics related to bridge calls and account migrations.
  • Improvements
    • Simplified telemetry labels and metrics for outgoing transactions and oracle status, improving readability and consistency.
    • Streamlined telemetry tracking process in multiple functions by reducing complexity and unnecessary intermediate structures.
  • Bug Fixes
    • Removed unused telemetry functionality in legacy code, simplifying implementation without affecting core functionality.

Copy link

coderabbitai bot commented Aug 7, 2024

Walkthrough

The recent changes enhance the clarity and specificity of telemetry metrics across various components. Key modifications include renaming functions and metric keys for better alignment with their purpose, streamlining telemetry reporting, and removing unnecessary imports. These adjustments collectively improve code maintainability and readability while preserving existing functionalities.

Changes

Files Change Summary
telemetry/metrics.go Renamed SetGaugeLabelsWithToken to SetGaugeLabelsWithDenom, streamlined telemetry handling, removed SetGaugeLabelsWithCoin.
x/crosschain/keeper/bridge_call_in.go Simplified telemetry label names for clarity, replaced constants with string literals in telemetry functions.
x/crosschain/keeper/bridge_call_out.go Improved telemetry tracking by using SetGaugeLabelsWithDenom, refined label composition for outgoing bridge calls.
x/crosschain/keeper/msg_server.go Renamed telemetry keys and labels for consistency, enhancing clarity in metrics reporting.
x/crosschain/keeper/oracle.go Updated metric labels for Oracle status, improving consistency in telemetry reporting.
x/crosschain/keeper/outgoing_pool.go Changed metric names and labels for outgoing transactions, replaced SetGaugeLabelsWithCoin with SetGaugeLabelsWithDenom.
x/crosschain/keeper/send_to_fx.go Added telemetry tracking for SendToFxExecuted, enhancing observability of the operation.
x/crosschain/legacy/precompile_events.go Removed telemetry functionality, simplifying the Fip20CrossChainEvents function.
x/migrate/keeper/msg_server.go Simplified telemetry logging in MigrateAccount by replacing complex counter incrementing with a single call.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant S as Server
    participant T as Telemetry

    C->>S: Initiate Operation
    S->>T: Log Metrics
    T-->>S: Acknowledge
    S-->>C: Return Response
Loading

🐇 In the code, we hop with glee,
Renamed and streamlined, oh what a spree!
Metrics now clearer, labels shine bright,
Our code's like a garden, blooming in light.
With every change, we bound and play,
Celebrating progress, hip-hip-hooray! 🎉


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 21caec3 and fa9416a.

Files selected for processing (9)
  • telemetry/metrics.go (1 hunks)
  • x/crosschain/keeper/bridge_call_in.go (2 hunks)
  • x/crosschain/keeper/bridge_call_out.go (1 hunks)
  • x/crosschain/keeper/msg_server.go (1 hunks)
  • x/crosschain/keeper/oracle.go (1 hunks)
  • x/crosschain/keeper/outgoing_pool.go (1 hunks)
  • x/crosschain/keeper/send_to_fx.go (2 hunks)
  • x/crosschain/legacy/precompile_events.go (2 hunks)
  • x/migrate/keeper/msg_server.go (2 hunks)
Files skipped from review due to trivial changes (4)
  • x/crosschain/keeper/msg_server.go
  • x/crosschain/keeper/oracle.go
  • x/crosschain/legacy/precompile_events.go
  • x/migrate/keeper/msg_server.go
Additional comments not posted (10)
telemetry/metrics.go (2)

26-26: LGTM!

The update aligns with the new function naming and logic.


15-21: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to SetGaugeLabelsWithDenom match the new signature.

Verification successful

Function usage verified and matches the new signature.

The function calls to SetGaugeLabelsWithDenom in the codebase correctly use the new signature.

  • x/crosschain/keeper/bridge_call_out.go
  • x/crosschain/keeper/outgoing_pool.go
  • x/crosschain/keeper/send_to_fx.go
  • telemetry/metrics.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetGaugeLabelsWithDenom` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'SetGaugeLabelsWithDenom'

Length of output: 1892

x/crosschain/keeper/send_to_fx.go (1)

32-47: LGTM!

The changes improve observability by adding telemetry counters and gauges.

x/crosschain/keeper/bridge_call_in.go (2)

41-45: LGTM!

The changes enhance clarity and maintainability by using consistent metric labels.


92-94: LGTM!

The changes enhance clarity and maintainability by using consistent metric labels.

x/crosschain/keeper/bridge_call_out.go (2)

66-71: Simplified telemetry tracking improves clarity and efficiency.

The removal of the tokenLabels slice and direct usage of telemetry labels improves the readability and maintainability of the code.


71-77: Telemetry label adjustments enhance specificity.

The changes to the telemetry labels, such as explicitly naming the module label as "module", enhance the clarity and specificity of the metrics.

x/crosschain/keeper/outgoing_pool.go (3)

64-67: Improved telemetry metric naming enhances clarity.

The change from types.MetricsKeyOutgoingTx to "outgoing_tx_amount" for the gauge label and "outgoing_tx" for the counter label improves the readability and specificity of the metrics.


67-67: Function call adjustment improves granularity.

The change from SetGaugeLabelsWithCoin to SetGaugeLabelsWithDenom, which takes the denomination and the amount as separate parameters, enhances the granularity of the outgoing transaction metrics.


69-74: Simplified telemetry labels enhance standardization.

The update to use more straightforward label names, such as changing types.MetricsLabelModule to "module" and types.MetricsLabelToken to "denom", simplifies the code and standardizes the label usage across the telemetry reporting.

@nulnut
Copy link
Contributor

nulnut commented Aug 7, 2024

mg

@zakir-code zakir-code merged commit eb613c6 into main Aug 7, 2024
9 checks passed
@zakir-code zakir-code deleted the zakir/metrics branch August 7, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants