Skip to content

feat: adds logging to retry logic in provider-proxy#1741

Merged
stalniy merged 1 commit intomainfrom
feat/provider-proxy-retry-logging
Jul 25, 2025
Merged

feat: adds logging to retry logic in provider-proxy#1741
stalniy merged 1 commit intomainfrom
feat/provider-proxy-retry-logging

Conversation

@stalniy
Copy link
Contributor

@stalniy stalniy commented Jul 25, 2025

Why

Probably this is a blind spot which is reported by OTEL but we don't have logs for. Eventually I will suppress metrics collection for this section but first need to prove that this is the blind spot we were looking for

Summary by CodeRabbit

  • New Features

    • Enhanced retry operations with structured logging, providing more detailed information about retry attempts and failures.
  • Bug Fixes

    • Improved reliability and traceability during network retries by integrating logging into relevant service and utility functions.

@stalniy stalniy requested a review from a team as a code owner July 25, 2025 17:07
@stalniy stalniy requested a review from Copilot July 25, 2025 17:07
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 25, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes introduce structured logging to the HTTP retry mechanism used throughout the provider proxy service. A logger instance is conditionally created and passed through the service container, injected into the ProviderService, and propagated to the retry utility. The retry logic now emits log events at various stages of execution, enhancing observability during retries.

Changes

File(s) Change Summary
apps/provider-proxy/src/container.ts Instantiates appLogger before ProviderService and injects it into the service and container.
apps/provider-proxy/src/routes/proxyProviderRequest.ts Passes appLogger from the container to the httpRetry options in proxyProviderRequest.
apps/provider-proxy/src/services/ProviderService/ProviderService.ts Updates ProviderService constructor to accept optional logger and passes it to httpRetry.
apps/provider-proxy/src/utils/retry.ts Extends httpRetry and retryWithBackoff to accept optional logger; adds structured logging at retry events.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant Container
    participant ProviderService
    participant httpRetry
    participant Logger

    App->>Container: Initialize (with NODE_ENV)
    Container->>Logger: Create appLogger (if test)
    Container->>ProviderService: Instantiate (pass appLogger)
    ProviderService->>httpRetry: Call with logger option
    httpRetry->>Logger: Log attempt (if logger present)
    httpRetry->>ProviderService: Execute callback
    alt Retry needed
        httpRetry->>Logger: Log retry event
        httpRetry->>httpRetry: Retry with backoff (pass logger)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

In the warren where retries hop,
Now logs will leap and never stop.
Each attempt, a gentle thump—
Warnings, info, in a clump!
With every log, we see the track,
Of bunnies bouncing safely back.
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-25T17_37_23_237Z-debug-0.log


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d4881a1 and cb5ba22.

📒 Files selected for processing (4)
  • apps/provider-proxy/src/container.ts (1 hunks)
  • apps/provider-proxy/src/routes/proxyProviderRequest.ts (1 hunks)
  • apps/provider-proxy/src/services/ProviderService/ProviderService.ts (3 hunks)
  • apps/provider-proxy/src/utils/retry.ts (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/provider-proxy-retry-logging

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.32%. Comparing base (d4881a1) to head (cb5ba22).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1741      +/-   ##
==========================================
- Coverage   72.46%   72.32%   -0.14%     
==========================================
  Files         627      622       -5     
  Lines       14867    14696     -171     
  Branches     2583     2568      -15     
==========================================
- Hits        10773    10629     -144     
+ Misses       3772     3744      -28     
- Partials      322      323       +1     
Flag Coverage Δ *Carryforward flag
api 80.16% <ø> (ø) Carriedforward from d4881a1
deploy-web 58.12% <ø> (ø) Carriedforward from d4881a1
log-collector ?
notifications 87.25% <ø> (ø) Carriedforward from d4881a1
provider-console 80.95% <ø> (ø) Carriedforward from d4881a1
provider-proxy 85.00% <100.00%> (+0.16%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
apps/provider-proxy/src/container.ts 100.00% <100.00%> (ø)
.../provider-proxy/src/routes/proxyProviderRequest.ts 93.47% <ø> (ø)
...xy/src/services/ProviderService/ProviderService.ts 95.23% <100.00%> (+0.23%) ⬆️
apps/provider-proxy/src/utils/retry.ts 96.29% <100.00%> (+0.64%) ⬆️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stalniy stalniy force-pushed the feat/provider-proxy-retry-logging branch from d3440a7 to cb5ba22 Compare July 25, 2025 17:15
@stalniy stalniy requested a review from Copilot July 25, 2025 17:22
Copy link

Copilot AI left a comment

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 adds comprehensive logging to the retry logic in the provider-proxy application to improve observability and debugging capabilities. The changes enable tracking of retry attempts, failures, and callback execution patterns.

  • Adds optional logger parameter to retry utilities and services
  • Implements structured logging for retry attempts and failures
  • Updates dependency injection to provide logger instances throughout the application

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
apps/provider-proxy/src/utils/retry.ts Adds logging support to retry functions with structured log events
apps/provider-proxy/src/services/ProviderService/ProviderService.ts Updates constructor to accept logger and passes it to retry calls
apps/provider-proxy/src/routes/proxyProviderRequest.ts Adds logger to retry options in proxy request handling
apps/provider-proxy/src/container.ts Reorganizes logger creation to provide app logger to ProviderService

@stalniy stalniy merged commit e604524 into main Jul 25, 2025
61 checks passed
@stalniy stalniy deleted the feat/provider-proxy-retry-logging branch July 25, 2025 17: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.

2 participants

Comments