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

feat(opbot): experimental logger #3132

Merged
merged 3 commits into from
Sep 16, 2024
Merged

feat(opbot): experimental logger #3132

merged 3 commits into from
Sep 16, 2024

Conversation

golangisfun123
Copy link
Collaborator

@golangisfun123 golangisfun123 commented Sep 16, 2024

Description
A clear and concise description of the features you're adding in this pull request.

Additional context
Add any other context about the problem you're solving.

Metadata

  • Fixes #[Link to Issue]

Summary by CodeRabbit

  • New Features

    • Introduced a new logging mechanism for improved monitoring and debugging within the bot.
    • Enhanced error logging for transaction searches and quote request fetching.
  • Improvements

    • Increased retry attempts from 3 to 5 and extended maximum attempt time from 15 to 30 seconds for quote request fetching.
  • Dependency Updates

    • Added a new dependency for enhanced observability with OpenTelemetry logging.

@golangisfun123 golangisfun123 changed the title feat(opbot): experimental logger to debug txhash by nonce feat(opbot): experimental logger Sep 16, 2024
Copy link
Contributor

coderabbitai bot commented Sep 16, 2024

Walkthrough

The changes introduce a new logging mechanism to the Bot structure in botmd.go, integrating an experimentalLogger for enhanced logging capabilities. The NewBot function is updated to initialize this logger. Additionally, error logging is improved in the traceCommand and rfqRefund functions, with adjustments to the retry logic in rfqRefund to allow more attempts and longer wait times. A new dependency on otelzap is added in go.mod, enhancing the project's observability.

Changes

Files Change Summary
contrib/opbot/botmd/botmd.go Added logger experimentalLogger.ExperimentalLogger to Bot struct; modified NewBot for logger initialization.
contrib/opbot/botmd/commands.go Enhanced error logging in traceCommand and rfqRefund; adjusted retry logic in rfqRefund (increased attempts and time).
contrib/opbot/go.mod Added github.com/uptrace/opentelemetry-go-extra/otelzap v0.3.1 dependency; removed indirect requirement for otelzap.

Possibly related PRs

  • feat(promexporter): add some tracing #3114: The changes in this PR enhance error handling and introduce tracing capabilities, which are conceptually related to the improved logging mechanisms introduced in the main PR, as both aim to enhance observability and debugging within the application.

Suggested labels

go, size/xs

Poem

In the meadow where the bunnies hop,
A logger's added, no need to stop!
With retries aplenty and errors in sight,
Our bot's now ready to take flight!
Hooray for changes, let’s give a cheer,
For better logs and less bunny fear! 🐇✨


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 generate interesting stats about this repository and render them as a table.
    -- @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.

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.

@github-actions github-actions bot added go Pull requests that update Go code size/xs labels Sep 16, 2024
Copy link

cloudflare-workers-and-pages bot commented Sep 16, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3d7c677
Status: ✅  Deploy successful!
Preview URL: https://b1630fbc.sanguine-fe.pages.dev
Branch Preview URL: https://log-errors.sanguine-fe.pages.dev

View logs

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: 0

Outside diff range and nitpick comments (1)
contrib/opbot/botmd/commands.go (1)

343-356: Justify the chosen retry values.

Increasing the retry attempts and maximum attempt time can make the process more resilient to transient failures, which is a good improvement.

However, please provide a justification for the specific values chosen (5 attempts and 30 seconds). This will help in understanding the reasoning behind these values and ensure that they are suitable for the given use case.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7ffafac and 3d7c677.

Files selected for processing (3)
  • contrib/opbot/botmd/botmd.go (2 hunks)
  • contrib/opbot/botmd/commands.go (3 hunks)
  • contrib/opbot/go.mod (1 hunks)
Additional comments not posted (8)
contrib/opbot/botmd/botmd.go (4)

14-14: LGTM!

The import statement for the experimental logger looks good. The alias and package path are appropriate.


20-20: Looks good! The otelzap import will enable OpenTelemetry instrumentation for Zap logging.

The otelzap package is an extension that allows emitting OpenTelemetry traces and metrics from the Zap logging library. This aligns with the PR objective of introducing an experimental logger for debugging purposes.

By leveraging otelzap, the bot will gain the ability to correlate logs with traces and metrics, enabling better observability and debugging capabilities.


35-35: The logger field addition and initialization look good!

The Bot struct now includes an ExperimentalLogger field, which is initialized in the NewBot function using the following steps:

  1. A new zap.Logger instance is created using experimentalLogger.MakeZapLogger().
  2. The zap.Logger is wrapped with otelzap.New() to enable OpenTelemetry instrumentation.
  3. The wrapped logger is then converted to a sugared logger using .Sugar().
  4. Finally, the sugared logger is wrapped again using experimentalLogger.MakeWrappedSugaredLogger() to create the final ExperimentalLogger instance.

This initialization process ensures that the bot's logger is properly set up with the experimental logging capabilities and OpenTelemetry instrumentation.

Also applies to: 48-48


41-43: This code segment is part of the logger initialization process that was already covered in the previous review comment. No further analysis is needed.

contrib/opbot/botmd/commands.go (3)

85-85: LGTM!

The error logging is appropriate and helps in diagnosing issues when searching for a transaction fails. The log message provides relevant context about the failure.


294-294: LGTM!

The error logging is appropriate and helps in diagnosing issues when fetching a quote request fails. The log message provides relevant context about the failure.


359-359: LGTM!

The error logging is appropriate and helps in diagnosing issues when fetching a quote request fails after retries. The log message provides relevant context about the failure.

contrib/opbot/go.mod (1)

31-31: LGTM!

The addition of the github.com/uptrace/opentelemetry-go-extra/otelzap dependency in the require section is a good practice, as it explicitly declares the direct usage of this package in the project. The chosen version v0.3.1 also seems to be a stable release.

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

Attention: Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Project coverage is 37.95807%. Comparing base (265aff4) to head (3d7c677).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
contrib/opbot/botmd/commands.go 0.00000% 10 Missing ⚠️
contrib/opbot/botmd/botmd.go 0.00000% 4 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #3132         +/-   ##
===================================================
+ Coverage   36.66888%   37.95807%   +1.28918%     
===================================================
  Files            443         418         -25     
  Lines          25643       24232       -1411     
  Branches         119          82         -37     
===================================================
- Hits            9403        9198        -205     
+ Misses         15498       14295       -1203     
+ Partials         742         739          -3     
Flag Coverage Δ
opbot 0.48960% <0.00000%> (-0.00302%) ⬇️
promexporter ?
solidity ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@trajan0x trajan0x merged commit 377a7fa into master Sep 16, 2024
28 of 29 checks passed
@trajan0x trajan0x deleted the log-errors branch September 16, 2024 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code needs-go-generate-contrib/opbot size/xs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants