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 telemetry from the store. Clean up metadata count telemetry. #2177

Merged
merged 10 commits into from
Oct 11, 2024

Conversation

SpicyLemon
Copy link
Contributor

@SpicyLemon SpicyLemon commented Oct 11, 2024

Description

closes: #2144

This PR does the following:

  1. Propagates the telemetry settings to the store so that we hopefully get cometbft telemetry again.
  2. Removes all the metadata count telemetry stuff. It wasn't actually working and no one seemed to care.
  3. Tweak isTestnetFlagSet to make it more accurately check for stuff.

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Added relevant changelog entries under .changelog/unreleased (see Adding Changes).
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Summary by CodeRabbit

  • New Features

    • Enhanced telemetry system with restored data collection from cometbft.
    • Improved command-line argument handling and telemetry configuration management.
  • Bug Fixes

    • Removed non-functional telemetry counters from the metadata module, simplifying its structure.
  • Documentation

    • Expanded comments to clarify functionality related to command-line arguments and telemetry settings.
  • Tests

    • Added new test functions to validate telemetry and command-line argument handling.
  • Chores

    • Streamlined event handling and validation processes across various components.

…ce that's the standard order of precedence. Also allow the flag to have the form '(--testnet|-t)=(true|false)'. And overhaul the comment on it with more details.
…tance of a flag should take precidence. Unit tests on isTestnetFlagSet.
… tests on getTelemetryGlobalLabels as well as a canary for if the SDK tries to break it.
@SpicyLemon SpicyLemon marked this pull request as ready for review October 11, 2024 02:29
@SpicyLemon SpicyLemon requested a review from a team as a code owner October 11, 2024 02:29
Copy link
Contributor

coderabbitai bot commented Oct 11, 2024

Walkthrough

The changes in this pull request primarily focus on the removal of non-functional telemetry components from the metadata module, which simplifies its structure. Additionally, the telemetry system is fixed to restore functionality that was lost in version 1.19. Enhancements to command-line argument handling and telemetry configuration are also introduced, along with new tests to validate these functionalities. The logging capabilities are extended with a new debug logger, and several methods in the keeper package are modified to streamline event handling and validation processes.

Changes

File Path Change Summary
.changelog/unreleased/bug-fixes/2144-remove-metadata-count-telemetry.md Removed non-functional telemetry counters and related types, constants, and functions from the metadata module.
.changelog/unreleased/bug-fixes/2177-add-store-telemetry.md Restored telemetry data collection from cometbft that was removed in version 1.19.
cmd/provenanced/cmd/root.go Enhanced command-line argument handling, added telemetry metrics setup, and improved telemetry configuration extraction.
cmd/provenanced/cmd/root_test.go Added new tests for command-line argument handling and telemetry configuration validation.
internal/logger.go Introduced a new debug logger function for enhanced logging capabilities.
x/metadata/keeper/objectstore.go Removed deferred telemetry function calls in object store locator management methods.
x/metadata/keeper/record.go Simplified event handling by removing action tracking in record management methods.
x/metadata/keeper/scope.go Enhanced error handling and validation logic in scope management methods.
x/metadata/keeper/session.go Streamlined session management by removing action tracking and clarifying validation logic.
x/metadata/keeper/specification.go Removed action tracking from specification management methods and improved validation logic.

Assessment against linked issues

Objective Addressed Explanation
Ensure metadata telemetry is recorded (2144)
Restore telemetry data collection (2177)

Possibly related PRs

Suggested reviewers

  • iramiller
  • Taztingo

Poem

🐰 In the meadow where data flows,
We tidied up the telemetry rows.
With counters gone, the code is light,
New logs and tests bring pure delight!
Hopping forward, we clear the way,
For cleaner paths in the light of day! 🌼


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.

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.

@SpicyLemon SpicyLemon added this to the v1.20.0 milestone Oct 11, 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: 2

🧹 Outside diff range and nitpick comments (2)
internal/logger.go (2)

34-40: LGTM! Consider a minor comment improvement.

The new NewBufferedDebugLogger function is well-implemented and consistent with the existing logging functions. It correctly creates a debug-level logger using the NewBufferedLogger function.

Consider updating the comments to match the style of NewBufferedInfoLogger:

 // NewBufferedDebugLogger creates a new logger with level debug that writes to the provided buffer.
 // Error log lines will start with "ERR ".
 // Info log lines will start with "INF ".
-// Debug log lines will start with "DBG ".
+// Debug log lines are included and will start with "DBG ".

This change would emphasize that debug logs are included, contrasting with the info logger where they are omitted.


34-40: Positive enhancement to logging capabilities

The addition of NewBufferedDebugLogger is a valuable enhancement to the logging infrastructure. It expands the available logging options while maintaining consistency with existing functions. This change aligns well with the PR objectives of improving telemetry and logging capabilities.

Consider documenting this new logging option in any relevant developer guides or README files to ensure that other developers are aware of this new capability for debug-level logging.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ce5e5f2 and 6c42a84.

📒 Files selected for processing (11)
  • .changelog/unreleased/bug-fixes/2144-remove-metadata-count-telemetry.md (1 hunks)
  • .changelog/unreleased/bug-fixes/2177-add-store-telemetry.md (1 hunks)
  • cmd/provenanced/cmd/root.go (4 hunks)
  • cmd/provenanced/cmd/root_test.go (2 hunks)
  • internal/logger.go (1 hunks)
  • x/metadata/keeper/objectstore.go (0 hunks)
  • x/metadata/keeper/record.go (0 hunks)
  • x/metadata/keeper/scope.go (0 hunks)
  • x/metadata/keeper/session.go (0 hunks)
  • x/metadata/keeper/specification.go (0 hunks)
  • x/metadata/types/events.go (0 hunks)
💤 Files with no reviewable changes (6)
  • x/metadata/keeper/objectstore.go
  • x/metadata/keeper/record.go
  • x/metadata/keeper/scope.go
  • x/metadata/keeper/session.go
  • x/metadata/keeper/specification.go
  • x/metadata/types/events.go
✅ Files skipped from review due to trivial changes (1)
  • .changelog/unreleased/bug-fixes/2177-add-store-telemetry.md
🧰 Additional context used
🪛 LanguageTool
.changelog/unreleased/bug-fixes/2144-remove-metadata-count-telemetry.md

[uncategorized] ~1-~1: Possible missing comma found.
Context: ...he telemetry counters from the metadata module since it wasn't actually doing anything...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (8)
cmd/provenanced/cmd/root.go (5)

16-16: Importing viper for configuration management

The addition of "github.com/spf13/viper" is appropriate and ensures that configuration settings are handled effectively.


23-23: Adding metrics package for telemetry support

Including "cosmossdk.io/store/metrics" allows the application to set up store metrics, enhancing telemetry functionality.


310-310: Integrating store metrics with telemetry configuration

The use of setStoreMetrics(getTelemetryGlobalLabels(logger, appOpts)) appropriately configures store metrics based on telemetry settings, enhancing observability.


474-481: Properly setting store metrics when telemetry is enabled

The setStoreMetrics function correctly configures the base application to set store metrics when telemetry is enabled, ensuring metrics are captured as intended.


493-533: Retrieving telemetry configuration from application options effectively

The getTelemetryGlobalLabels function efficiently extracts telemetry settings from appOpts, accommodating both cases where appOpts is a *viper.Viper instance and when it is not. This ensures that telemetry configurations are accurately applied.

cmd/provenanced/cmd/root_test.go (3)

340-476: Well-Structured Tests for isTestnetFlagSet Function

The added test cases comprehensively cover various combinations of environment variables and command-line arguments, ensuring robust validation of the isTestnetFlagSet function's behavior.


478-688: Comprehensive Testing of Telemetry Configuration

The TestGetTelemetryGlobalLabels function effectively tests multiple scenarios for telemetry settings using both Viper and custom options. This ensures that the telemetry global labels and enabled states are correctly handled across different configurations.


690-710: Proactive Canary Test for Telemetry Keys Integrity

The TestTelemetryKeysCanary function serves as a safeguard against future changes in the SDK that might affect telemetry functionality. This proactive approach helps maintain the integrity of telemetry configuration keys and types.

@SpicyLemon SpicyLemon enabled auto-merge (squash) October 11, 2024 17:35
@SpicyLemon SpicyLemon merged commit 8e021c0 into main Oct 11, 2024
34 checks passed
@SpicyLemon SpicyLemon deleted the dwedul/add-store-telemetry branch October 11, 2024 17:44
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.

Metadata telemetry not being recorded
4 participants