Skip to content

Upgrade dependencies & move to tracing#15

Merged
jfro merged 2 commits intomainfrom
jtk/dep-upgrades
Feb 20, 2025
Merged

Upgrade dependencies & move to tracing#15
jfro merged 2 commits intomainfrom
jtk/dep-upgrades

Conversation

@jfro
Copy link
Member

@jfro jfro commented Feb 19, 2025

Summary by CodeRabbit

  • Chores
    • Upgraded the package version and dependency libraries, ensuring enhanced stability.
  • New Features
    • Introduced a modern logging system with configurable, environment-aware settings for clearer, more flexible log output.
  • Refactor
    • Streamlined metrics handling by shifting to a more structured, method-based approach for updating counters and gauges.

@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2025

Walkthrough

The changes update the package configuration, logging, and metrics handling across the repository. In Cargo.toml, dependency versions are bumped and the logging dependency is switched to tracing and tracing-subscriber. In example files, the logging setup is replaced with a new configuration based on tracing_subscriber and metric update calls now use method chaining. In the library code, logging macros are replaced with tracing variants and the SqliteExporter installation method signature is refined. In src/recorder.rs, method signatures now accept an additional metadata parameter.

Changes

File(s) Change Summary
Cargo.toml Package version updated from 0.4.1 → 0.5.0; dependency versions updated for libsqlite3-sys (0.26.0 → 0.31.0), metrics (0.21.0 → 0.24.1), and thiserror (1.0 → 2.0.11); new dependency tracing added; dev-dependency changed from pretty_env_logger to tracing-subscriber with env-filter feature.
examples/…/import_csv.rs
examples/…/large-file.rs
examples/…/simple.rs
Logging setup replaced: removed pretty_env_logger in favor of tracing_subscriber with formatting and filter layers; metrics update calls changed from direct macros to method chaining (increment() and set()) for enhanced clarity.
src/lib.rs Replaced logging from log macros with tracing macros; updated the SqliteExporter::install method signature to return Result<(), SetRecorderError<Self>> and modified the recorder installation to use metrics::set_global_recorder(self).
src/recorder.rs Updated register_counter, register_gauge, and register_histogram method signatures to include an additional _metadata: &Metadata parameter; corresponding import adjustments made.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application (main)
    participant Logger as Tracing Subscriber
    participant Env as Environment Variable

    App->>Logger: Initialize formatting and filter layers
    Note over Env, Logger: Filter reads env var (default "info")
    Logger-->>App: Logger configured
    App->>App: Call metrics functions with new methods
Loading
sequenceDiagram
    participant App as Application
    participant Exp as SqliteExporter
    participant Rec as metrics::set_global_recorder

    App->>Exp: Call install()
    Exp->>Rec: Set global recorder with self
    Rec-->>Exp: Return installation result
    Exp-->>App: Return installation result
Loading

Poem

I'm a rabbit with a joyful tune,
Hopping over changes beneath the moon.
Logging revamped with a tracing glow,
Metrics now classy with a brand new flow.
Code snuggled tight, bugs out of sight—
A jolly leap into a brighter night!
🐇🌟


🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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

🧹 Nitpick comments (3)
src/lib.rs (2)

426-427: Ensure error type is properly handled downstream.

Changing the install method to return Result<(), SetRecorderError<Self>> captures the specific exporter type in the error. Verify all call sites handle this specialized error gracefully (e.g., producing meaningful messages or logs).


454-456: Consider the data volume in this test loop.

Recording metrics continuously at short intervals can produce a large volume of data. If the test’s intention is stress testing, this is fine. Otherwise, you could reduce frequency or limit iteration to prevent excessive storage usage.

src/recorder.rs (1)

184-184: Consider utilizing the metadata parameter.

The _metadata parameter is currently unused (indicated by the underscore prefix). Consider using this metadata for enhanced logging or database storage as suggested by the comment on line 183.

-    fn register_counter(&self, key: &Key, _metadata: &Metadata) -> Counter {
+    fn register_counter(&self, key: &Key, metadata: &Metadata) -> Counter {
         let sender = self.sender.clone();
+        // Store metadata in SQLite for informational usage
+        if let Err(e) = self.sender.try_send(Event::StoreMetadata(key.clone(), metadata.clone())) {
+            error!("Error sending metadata: {:?}", e);
+        }

Also applies to: 200-200, 216-216

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc406fb and 168892b.

📒 Files selected for processing (6)
  • Cargo.toml (2 hunks)
  • examples/import_csv.rs (1 hunks)
  • examples/large-file.rs (3 hunks)
  • examples/simple.rs (3 hunks)
  • src/lib.rs (3 hunks)
  • src/recorder.rs (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (windows-latest)
🔇 Additional comments (13)
src/lib.rs (1)

8-8: Adopted tracing macros successfully.

Switching from log to tracing aligns with the PR's objective to migrate to the new logging framework. This line is correct and consistent with the rest of your changes.

examples/import_csv.rs (2)

2-2: Imported tracing_subscriber for logging.

Pulling in tracing_subscriber is consistent with the transition away from older logging frameworks.


5-11: Configured environment-based filter and formatted logging.

The fallback to info if the environment variable is undefined is a sensible default. This setup ensures logs are clearly formatted and adjustable based on runtime needs.

examples/simple.rs (3)

4-4: Switched to tracing_subscriber import.

This addition mirrors the project's overall move away from pretty_env_logger.


18-25: Initialized structured logging.

Combining the filter and formatting layers provides a clean, extensible logging approach. No issues observed here.


34-36: Updated counters and gauges with method-based API.

Using .increment() and .set() is aligned with the new metrics API. This change ensures consistency across the codebase.

examples/large-file.rs (3)

4-5: LGTM! Imports align with the PR objectives.

The imports correctly include the necessary tracing_subscriber modules for the new logging setup.


20-27: LGTM! Logging setup follows best practices.

The logging configuration is well-structured:

  • Uses environment-based filter with fallback to "info" level
  • Properly layers the formatting and filtering components

38-44: LGTM! Metrics recording updated to use modern method chaining.

The changes consistently use .set() for gauges and .increment() for counters, improving code readability.

src/recorder.rs (1)

3-10: LGTM! Import organization improved.

The imports are well-organized and include the necessary Metadata type for the updated method signatures.

Cargo.toml (3)

3-3: LGTM! Version bump follows semver.

The version increase to 0.5.0 is appropriate for the new features and dependency updates.


26-26: LGTM! Logging transition complete.

The replacement of pretty_env_logger with tracing-subscriber aligns with the PR objectives.


18-21:

Details

✅ Verification successful

Verify compatibility with the latest versions.

The dependency updates include significant version jumps. Let's verify compatibility:


🌐 Web query:

What are the latest versions of libsqlite3-sys, metrics, and thiserror crates?

💡 Result:

The latest versions of these Rust crates as of February 2025 are:

libsqlite3-sys
Latest stable release: v0.31[9]

metrics
Latest stable release: v0.24[1]

thiserror
Latest stable release: v2.x[2]

Key details from recent updates:

  • libsqlite3-sys reached v0.31 with support for SQLite v3.14+[6][9]
  • metrics added new features like BTreeMap<String,String> label support and atomic type exports[1][10]
  • thiserror maintains parallel thiserror-core releases for no_std environments while expanding error handling macros[5][8]

These versions reflect ongoing maintenance updates rather than major breaking changes according to their respective changelogs and documentation sources[1][6][9].

Citations:


Dependency Versions Verified

  • Cargo.toml (Lines 18-21):
    • libsqlite3-sys: Currently set to “0.31.0” while the latest stable patch is “0.31.9”. The changelog indicates these are maintenance updates with no reported breaking changes—upgrade to 0.31.9 is optional but may provide additional bug fixes.
    • metrics: “0.24.1” is confirmed as the latest release.
    • thiserror: “2.0.11” fits within the most recent v2.x series.

Compatibility with the latest versions has been verified. If there’s no specific reason to remain at an older patch for libsqlite3-sys, consider updating to the latest patch release.

@jfro jfro merged commit bbbf2ad into main Feb 20, 2025
4 checks passed
@jfro jfro deleted the jtk/dep-upgrades branch February 20, 2025 14:23
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.

1 participant