Skip to content

chore(logging): reduce log noise - #1276

Merged
steebchen merged 1 commit into
mainfrom
terragon/debug-loglevel-llmgateway-worker-ceveun
Dec 31, 2025
Merged

steebchen merged 1 commit into
mainfrom
terragon/debug-loglevel-llmgateway-worker-ceveun

Conversation

@steebchen

@steebchen steebchen commented Dec 1, 2025

Copy link
Copy Markdown
Member

Summary

  • Change log level from info to debug for worker and statistics calculation logs to reduce noise in production.
  • No functional changes; logging verbosity is reduced while error handling remains unchanged.

Changes

Logging Level Adjustments

  • apps/worker/src/services/stats-calculator.ts
    • Replaced info logs with debug for the following events:
      • Starting minutely history calculation
      • Recording history results for mappings and models
      • Starting 5-minute aggregated statistics calculation
      • Updated statistics for providers
      • Updated statistics for models
      • Updated statistics for model-provider mappings
      • Completion message for 5-minute aggregation
  • apps/worker/src/worker.ts
    • Replaced info logs with debug for the following events:
      • Deducted credits from an organization
      • Added usage to an API key
      • Marked logs as processed

Rationale

  • Reduces log noise in standard/production environments while preserving the ability to enable verbose logging if needed via debug level.
  • Keeps error reporting intact (errors still logged at error level).

Test plan

  • Run the worker and verify that the verbose info-level logs are no longer emitted by default; debug-level logs should appear only when the logging level is set to debug.
  • Confirm that critical errors still surface via logger.error and the core workflow behavior is unaffected.
  • Ensure that operational metrics and data processing paths are unchanged; only log verbosity is affected.
  • Update any local or CI tests that assert log messages to reflect new debug-level logging for these events if applicable.

🌿 Generated by Terry


ℹ️ Tag @terragon-labs to ask questions and address PR feedback

📎 Task: https://www.terragonlabs.com/task/d9ce4ce2-b8a9-4804-8963-86687d385f8f

Summary by CodeRabbit

  • Chores
    • Adjusted internal logging verbosity levels to reduce operational message output without affecting functionality.

✏️ Tip: You can customize this high-level summary in your review settings.

…o for routine logs

Changed various logger.info calls to logger.debug in worker and stats-calculator services to reduce verbosity of routine operational log messages and better reflect their importance level.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
@github-actions github-actions Bot changed the title Switch worker and stats logs to debug level chore(logging): reduce log noise Dec 1, 2025
@coderabbitai

coderabbitai Bot commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Log verbosity adjustments in worker services: several info-level log statements are downgraded to debug level in stats-calculator and worker modules. No control flow or data model changes; purely logging configuration adjustments.

Changes

Cohort / File(s) Summary
Stats Calculator Logging
apps/worker/src/services/stats-calculator.ts
Replaced multiple info-level log statements with debug-level logs across minutely history calculation and 5-minute aggregated statistics calculation, including start messages, per-minute recording updates, and finalization messages.
Worker Batch Processing Logging
apps/worker/src/worker.ts
Downgraded three logger.info calls to logger.debug in batchProcessLogs function for organization credit deduction, API key usage tracking, and log processing completion.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Verify that downgrading these log statements to debug level does not obscure critical operational events that should remain at info level
  • Confirm that the log level changes align with organizational logging standards and observability requirements

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(logging): reduce log noise' clearly and concisely describes the main change: converting info-level logs to debug-level logs to reduce verbosity in the worker and stats services.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch terragon/debug-loglevel-llmgateway-worker-ceveun

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/worker/src/services/stats-calculator.ts (1)

596-599: Aggregated stats logging downgrade is reasonable; consider keeping a single info summary (optional)

Changing the “starting 5‑minute aggregation”, “updated statistics for N providers/models/mappings”, and “completed successfully” logs to debug significantly quiets periodic noise and keeps error visibility intact. This is acceptable given the PR objectives.

If ops still wants lightweight confirmation that the aggregation loop is alive in production logs, you might optionally retain a single coarse logger.info per run (for example, only the final “completed” line) and keep the detailed counts at debug. Not required, but could help with quick sanity checks without turning on full debug.

Also applies to: 655-657, 711-712, 785-790

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e30142 and c8d397b.

📒 Files selected for processing (2)
  • apps/worker/src/services/stats-calculator.ts (6 hunks)
  • apps/worker/src/worker.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Always use top-level import, never use require or dynamic imports
No unnecessary code comments

Files:

  • apps/worker/src/worker.ts
  • apps/worker/src/services/stats-calculator.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use cookies for user-settings which are not saved in the database to ensure SSR works

**/*.{ts,tsx,js,jsx}: Always use tabs for indentation
Always use top-level import, never use require or dynamic imports
Avoid unnecessary code comments

Files:

  • apps/worker/src/worker.ts
  • apps/worker/src/services/stats-calculator.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use Drizzle ORM with latest object syntax for database operations
For database reads: Use db().query.<table>.findMany() or db().query.<table>.findFirst()

Never use any or as any in TypeScript code unless absolutely necessary

Files:

  • apps/worker/src/worker.ts
  • apps/worker/src/services/stats-calculator.ts
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

For database reads, use db().query.<table>.findMany() or db().query.<table>.findFirst() with Drizzle ORM

Files:

  • apps/worker/src/worker.ts
  • apps/worker/src/services/stats-calculator.ts
🧠 Learnings (1)
📚 Learning: 2025-08-04T21:46:14.112Z
Learnt from: mowdl
Repo: theopenco/llmgateway PR: 572
File: apps/gateway/src/worker.ts:292-298
Timestamp: 2025-08-04T21:46:14.112Z
Learning: In the LLMGateway system, API key usage should be tracked for all keys regardless of project billing mode. This dual tracking approach allows credit deduction for non-"api-keys" mode projects while maintaining comprehensive usage statistics across all API keys for monitoring and analytics purposes.

Applied to files:

  • apps/worker/src/worker.ts
🧬 Code graph analysis (2)
apps/worker/src/worker.ts (1)
packages/logger/src/index.ts (1)
  • logger (181-181)
apps/worker/src/services/stats-calculator.ts (1)
packages/logger/src/index.ts (1)
  • logger (181-181)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build / run
  • GitHub Check: test / run
  • GitHub Check: lint / run
  • GitHub Check: autofix
🔇 Additional comments (2)
apps/worker/src/services/stats-calculator.ts (1)

550-565: Minutely history logs moved to debug are consistent with reduced-noise intent

The start and per‑minute summary logs in calculateMinutelyHistory being downgraded to logger.debug match the goal of avoiding high‑frequency info spam, while errors remain at error. There’s no change to the actual history computation or DB writes, so runtime behavior is preserved.

apps/worker/src/worker.ts (1)

646-678: Log level downgrade in batchProcessLogs is correct and behavior-preserving

Downgrading the per-organization credit deduction (line 657), per-API-key usage (line 709), and "marked logs as processed" (line 721) messages from info to debug is appropriate. The accounting logic remains unchanged—credits are still deducted, API key usage is still tracked, and referral earnings are still calculated. A batch-level info log at line 564 preserves observability for the overall operation. No tests or alerts in the codebase depend on the downgraded log messages.

@steebchen
steebchen added this pull request to the merge queue Dec 31, 2025
Merged via the queue into main with commit 2663b98 Dec 31, 2025
8 checks passed
@steebchen
steebchen deleted the terragon/debug-loglevel-llmgateway-worker-ceveun branch December 31, 2025 15:45
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