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

[rfq] add withdraw tracing #2929

Merged
merged 3 commits into from
Jul 28, 2024
Merged

[rfq] add withdraw tracing #2929

merged 3 commits into from
Jul 28, 2024

Conversation

trajan0x
Copy link
Contributor

@trajan0x trajan0x commented Jul 28, 2024

Description

adds rfq tracing

Summary by CodeRabbit

  • New Features

    • Added a new field for tracking additional numeric data in date results, enhancing data representation capabilities.
  • Improvements

    • Introduced performance metrics tracking within the API, improving monitoring and optimization potential.
    • Enhanced error handling in the withdrawal command with retry logic and clearer error messaging.
  • Bug Fixes

    • Fixed variable capture issues in concurrent executions, ensuring reliability in task handling within the batch processing function.

[goreleaser]
Copy link
Contributor

coderabbitai bot commented Jul 28, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The recent changes enhance the codebase by introducing new features and improving existing functionalities. Key updates include the addition of a Linea field to the DateResultByChain struct for better data representation, modifications to OpenTelemetry dependencies for direct usage, and enhancements in the API's performance tracking. These updates facilitate improved monitoring, integration of metrics, and clearer error handling, ultimately leading to a more robust application.

Changes

Files Change Summary
contrib/promexporter/.../models.gen.go Added a Linea field to the DateResultByChain struct for enhanced data representation.
contrib/screener-api/go.mod Added go.opentelemetry.io/otel/metric v1.28.0 as a direct dependency, removing it from indirect requirements, indicating direct usage in the module.
services/rfq/relayer/.../handler.go, services/rfq/relayer/.../server.go Updated Handler struct to include a new metrics.Handler, enhancing performance tracking and modifying instantiation parameters in the server.
services/rfq/relayer/cmd/commands.go Enhanced error handling in the withdrawCommand by adding retry logic and improving clarity of error messages.
contrib/promexporter/.../util.go Modified batchCalls to capture the task variable in a closure, improving concurrent execution reliability.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant Handler
    participant Metrics

    Client->>Server: Send API Request
    Server->>Handler: Handle Request
    Handler->>Metrics: Start Metrics Trace
    Metrics-->>Handler: Trace Context
    Handler->>Server: Process Request
    Server->>Client: Return Response
Loading

🐇 "In the code where rabbits hop,
New fields and metrics never stop!
With each change, we bloom and grow,
Tracking performance, putting on a show!
Let's celebrate, with joy and cheer,
For every update brings us near!" 🥕✨


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>.
    • 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 show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

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

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

The pull request introduces RFQ tracing capabilities, enhancing observability and debugging for the Withdraw function.

  • Tracing in Withdraw Function: services/rfq/relayer/relapi/handler.go now includes tracing spans for the Withdraw function.
  • Handler Initialization: services/rfq/relayer/relapi/server.go modifies NewHandler to accept an additional handler parameter for tracing.
  • Dependency Update: contrib/screener-api/go.mod moves go.opentelemetry.io/otel/metric to direct dependencies.
  • New Field Addition: contrib/promexporter/internal/gql/explorer/models.gen.go adds Linea field to DateResultByChain struct for tracking.

4 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

codecov bot commented Jul 28, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 25.35241%. Comparing base (683fb3e) to head (6fd53de).

Files Patch % Lines
services/rfq/relayer/relapi/handler.go 78.57143% 2 Missing and 1 partial ⚠️
contrib/promexporter/exporters/util.go 0.00000% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2929         +/-   ##
===================================================
+ Coverage   25.33491%   25.35241%   +0.01749%     
===================================================
  Files            790         790                 
  Lines          56732       56752         +20     
  Branches          80          80                 
===================================================
+ Hits           14373       14388         +15     
- Misses         40873       40876          +3     
- Partials        1486        1488          +2     
Flag Coverage Δ
cctp-relayer 31.97848% <ø> (ø)
opbot 0.48900% <ø> (ø)
promexporter 7.66551% <0.00000%> (-0.00668%) ⬇️
rfq 24.77036% <80.00000%> (+0.06649%) ⬆️
screener-api 30.19802% <ø> (+0.90509%) ⬆️

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.

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, codebase verification and nitpick comments (1)
services/rfq/relayer/relapi/server.go (1)

115-115: Mismatch in NewHandler function signature.

The NewHandler function in services/rfq/relayer/relapi/handler.go does not include the handler argument, while the call in services/rfq/relayer/relapi/server.go does. This indicates a potential mismatch in the function signature. Please update the NewHandler function to include the handler argument and ensure all calls to this function pass the correct arguments.

  • services/rfq/relayer/relapi/handler.go: Update NewHandler function signature.
  • Verify all calls to NewHandler to ensure they pass the correct arguments.
Analysis chain

Verify the integration of the new handler argument.

The NewHandler function now requires an additional handler argument. Ensure that this change is reflected correctly throughout the codebase and that the handler is properly initialized and used.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the new handler argument in the codebase.

# Test: Search for the `NewHandler` function calls. Expect: All occurrences reflect the new signature.
rg --type go -A 5 $'NewHandler'

Length of output: 2032

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 683fb3e and c847221.

Files selected for processing (4)
  • contrib/promexporter/internal/gql/explorer/models.gen.go (1 hunks)
  • contrib/screener-api/go.mod (2 hunks)
  • services/rfq/relayer/relapi/handler.go (6 hunks)
  • services/rfq/relayer/relapi/server.go (1 hunks)
Additional comments not posted (5)
contrib/screener-api/go.mod (1)

30-30: Verify the dependency change.

The go.opentelemetry.io/otel/metric dependency is now a direct requirement. Ensure that this change is correctly reflected in the codebase and that the dependency is used appropriately.

Verification successful

Verified the dependency change.

The go.opentelemetry.io/otel/metric dependency is now a direct requirement and is used appropriately across multiple files in the codebase.

  • services/scribe/service/scribe.go
  • services/scribe/service/indexer/indexer.go
  • services/scribe/service/chain.go
  • services/explorer/api/server.go
  • services/rfq/relayer/service/otel.go
  • services/rfq/relayer/quoter/quoter.go
  • services/rfq/relayer/inventory/manager.go
  • services/omnirpc/chainmanager/manager.go
  • services/rfq/api/rest/server.go
  • services/rfq/guard/service/otel.go
  • ethergo/submitter/metrics.go
  • ethergo/listener/otel.go
  • core/metrics/null.go
  • core/metrics/meter_test.go
  • core/metrics/meter.go
  • core/metrics/metrics.go
  • core/metrics/instrumentation/otelginmetrics/otelrecorder.go
  • core/metrics/base.go
  • contrib/screener-api/screener/screener.go
  • contrib/promexporter/exporters/otel.go
  • contrib/opbot/botmd/middleware.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `go.opentelemetry.io/otel/metric` dependency in the codebase.

# Test: Search for the usage of the `metric` package. Expect: The package is used directly in the codebase.
rg --type go $'go.opentelemetry.io/otel/metric'

Length of output: 1705

services/rfq/relayer/relapi/handler.go (3)

26-26: Verify the integration of the new field in the Handler struct.

The Handler struct now includes a metrics.Handler field. Ensure that this field is correctly initialized and used within the struct.

Verification successful

The metrics field is correctly integrated and used within the Handler struct.

  • The metrics field is initialized in the NewHandler function.
  • The metrics field is used within the Handler struct methods.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the `metrics.Handler` field in the `Handler` struct.

# Test: Search for the usage of the `metrics` field in the `Handler` struct. Expect: The field is used appropriately within the struct.
rg --type go -A 5 $'metrics metrics.Handler' services/rfq/relayer/relapi/handler.go

Length of output: 84


Script:

#!/bin/bash
# Description: Verify the integration of the `metrics.Handler` field in the `Handler` struct.

# Test: Search for any usage of the `metrics` field in the `Handler` struct. Expect: The field is used appropriately within the struct.
rg --type go 'metrics' services/rfq/relayer/relapi/handler.go

Length of output: 427


34-36: Verify the integration of the new parameter in the NewHandler function.

The NewHandler function now accepts a metricsHandler parameter. Ensure that this parameter is correctly passed and used within the function.

Verification successful

Verify the usage of the metrics field within the Handler struct.

The metricsHelper parameter is assigned to the metrics field of the Handler struct. Ensure that this field is used appropriately within the Handler struct.


Verified: The metricsHelper parameter is correctly integrated and used within the Handler struct.

The metricsHelper parameter is assigned to the metrics field and is used appropriately for tracing operations within the Handler struct.

  • ctx, span := h.metrics.Tracer().Start(c, "withdraw")
  • metrics.EndSpanWithErr(span, err)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the `metricsHandler` parameter in the `NewHandler` function.

# Test: Search for the usage of the `metricsHandler` parameter in the `NewHandler` function. Expect: The parameter is used appropriately within the function.
rg --type go -A 5 $'metricsHelper metrics.Handler' services/rfq/relayer/relapi/handler.go

Length of output: 414


Script:

#!/bin/bash
# Description: Verify the usage of the `metrics` field within the `Handler` struct.

# Test: Search for the usage of the `metrics` field within the `Handler` struct. Expect: The field is used appropriately within the struct.
rg --type go 'metrics' services/rfq/relayer/relapi/handler.go

Length of output: 427


184-188: Verify the integration of tracing functionality in the Withdraw method.

The Withdraw method now includes tracing functionality using the metrics instance. Ensure that the tracing is correctly integrated and does not introduce any issues.

contrib/promexporter/internal/gql/explorer/models.gen.go (1)

106-106: LGTM! The addition of the Linea field is consistent with the existing structure.

The new field Linea is correctly added as a pointer to a float64 and includes the appropriate JSON tag.

[goreleaser]
Copy link

cloudflare-workers-and-pages bot commented Jul 28, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 46bd17d
Status:⚡️  Build in progress...

View logs

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The pull request introduces RFQ tracing capabilities, enhancing observability and debugging for the Withdraw function.

  • Tracing in Withdraw Function: services/rfq/relayer/relapi/handler.go now includes tracing spans for the Withdraw function.
  • Handler Initialization: services/rfq/relayer/relapi/server.go modifies NewHandler to accept an additional handler parameter for tracing.
  • Dependency Update: contrib/screener-api/go.mod moves go.opentelemetry.io/otel/metric to direct dependencies.
  • New Field Addition: contrib/promexporter/internal/gql/explorer/models.gen.go adds Linea field to DateResultByChain struct for tracking.
  • Goroutine Variable Capture Fix: contrib/promexporter/exporters/util.go captures the loop variable task within the goroutine to avoid potential issues with variable scoping.

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c847221 and 6fd53de.

Files selected for processing (1)
  • contrib/promexporter/exporters/util.go (1 hunks)
Additional context used
GitHub Check: codecov/patch
contrib/promexporter/exporters/util.go

[warning] 94-94: contrib/promexporter/exporters/util.go#L94
Added line #L94 was not covered by tests

Additional comments not posted (1)
contrib/promexporter/exporters/util.go (1)

94-94: LGTM! Ensure test coverage for the new line.

The change to capture the task variable in a closure is correct and necessary to prevent concurrency issues. However, the new line is not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 94-94: contrib/promexporter/exporters/util.go#L94
Added line #L94 was not covered by tests

@trajan0x trajan0x merged commit f6f2226 into master Jul 28, 2024
10 of 11 checks passed
@trajan0x trajan0x deleted the fix/rfq-update branch July 28, 2024 16:55
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The pull request introduces a retry mechanism for withdrawal transaction hash retrieval and fixes an error reference in the RFQ relayer service.

  • Retry Mechanism: Added a retry mechanism with a 1-minute max duration for withdrawal transaction hash retrieval in services/rfq/relayer/cmd/commands.go.
  • Error Reference Fix: Corrected the reference to errClient in error messages in services/rfq/relayer/cmd/commands.go.

These changes aim to improve the reliability of the withdrawal process. Ensure thorough testing of the retry mechanism to handle edge cases effectively.

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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 size/xs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant