Skip to content

Cranker: Logging Improvements for Loki - #276

Merged
aoikurokawa merged 4 commits into
masterfrom
ak/log
Jul 24, 2026
Merged

Cranker: Logging Improvements for Loki#276
aoikurokawa merged 4 commits into
masterfrom
ak/log

Conversation

@aoikurokawa

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes cranker logging to be more Loki-friendly by moving toward single-line, key=value-style log messages and improving timestamp formatting for easier ingestion and ordering in log aggregators.

Changes:

  • Updated cranker runtime logs to structured-ish key=value messages and added warn! level where appropriate.
  • Improved env_logger timestamp formatting to include millisecond precision.
  • Reduced severity/noise for a common metrics emission condition by switching from error! to warn!.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crankers/src/vault_handler.rs Converts vault cranking logs to key=value style and adds warn-level retry logging.
crankers/src/metrics.rs Downgrades a missing-account condition from error to warn while continuing metrics emission for other vaults.
crankers/src/bin/main.rs Makes startup/config logging single-line and enables millisecond timestamps in env_logger for better log aggregation.
Comments suppressed due to low confidence (2)

crankers/src/metrics.rs:110

  • The code builds a Result just to check is_err() and then unwrap(); this is more complex than necessary and pays the cost of allocating an error message even on the success path. Prefer matching on Option from the map lookup directly.
        let try_st_deposit_account = st_ata_map
            .get(&get_associated_token_address(
                address,
                &vault.supported_mint,
            ))
            .ok_or_else(|| anyhow::anyhow!("ST deposit account not found in map"));

        if try_st_deposit_account.is_err() {
            warn!(
                "Skipping vault metrics, ST deposit account not found vault={}",
                address
            );
            continue;
        }

        let st_deposit_account = try_st_deposit_account.unwrap();

crankers/src/vault_handler.rs:162

  • When the retry limit is hit, the function logs the final RPC error but returns an anyhow! error without the underlying cause. Returning the terminal error (with context) makes upstream logs/metrics more actionable.
            if retries >= MAX_RETRIES {
                error!(
                    "Transaction failed permanently retries={}: {:?}",
                    MAX_RETRIES, err
                );
            }
        }

        Err(anyhow::anyhow!(
            "Transaction failed after {} retries",
            MAX_RETRIES
        ))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crankers/src/vault_handler.rs
Comment thread crankers/src/vault_handler.rs
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@aoikurokawa
aoikurokawa merged commit 387af54 into master Jul 24, 2026
9 checks passed
@aoikurokawa
aoikurokawa deleted the ak/log branch July 24, 2026 00:12
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.

3 participants