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

trace [SLT-330] #3264

Merged
merged 6 commits into from
Oct 10, 2024
Merged

trace [SLT-330] #3264

merged 6 commits into from
Oct 10, 2024

Conversation

trajan0x
Copy link
Contributor

@trajan0x trajan0x commented Oct 10, 2024

[goreleaser]

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

    • Enhanced tracing functionality added to the request processing, improving observability.
    • New transaction attributes included for better tracing insights.
  • Documentation

    • Added a comment indicating future support for tracing in the Request interface.

[goreleaser]
@github-actions github-actions bot added go Pull requests that update Go code size/xs labels Oct 10, 2024
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 15.38462% with 11 lines in your changes missing coverage. Please review.

Project coverage is 30.68453%. Comparing base (648088c) to head (0b2dc8e).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...s/omnirpc/modules/receiptsbackup/receiptsbackup.go 0.00000% 8 Missing ⚠️
ethergo/util/attributes.go 40.00000% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #3264         +/-   ##
===================================================
+ Coverage   24.97972%   30.68453%   +5.70480%     
===================================================
  Files            340         447        +107     
  Lines          22190       29787       +7597     
  Branches          82          82                 
===================================================
+ Hits            5543        9140       +3597     
- Misses         16081       19797       +3716     
- Partials         566         850        +284     
Flag Coverage Δ
cctp-relayer 31.97848% <ø> (ø)
ethergo 47.27896% <40.00000%> (?)
omnirpc 32.66914% <0.00000%> (-0.12157%) ⬇️
opbot 0.48870% <ø> (ø)
promexporter 6.81642% <ø> (ø)
rfq 24.61876% <ø> (+0.09874%) ⬆️
scribe 18.24614% <ø> (ø)
tools 30.55118% <ø> (ø)

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

cloudflare-workers-and-pages bot commented Oct 10, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0b2dc8e
Status: ✅  Deploy successful!
Preview URL: https://4cda0d15.sanguine-fe.pages.dev
Branch Preview URL: https://fix-track-issue.sanguine-fe.pages.dev

View logs

Copy link
Contributor

coderabbitai bot commented Oct 10, 2024

Walkthrough

The changes in this pull request introduce a new constant txRawAttr in the attributes.go file to enhance transaction attribute handling. The TxToAttributes function is modified to include the raw binary representation of transactions. Additionally, the processRequest method in receiptsbackup.go is updated to include tracing functionality, logging events related to request and response bodies. A comment indicating future tracing requirements is added to the Request interface in client.go. The overall structure and functionality of the affected components remain unchanged.

Changes

File Path Change Summary
ethergo/util/attributes.go Added constant txRawAttr and modified TxToAttributes function to include marshaled transaction attributes.
ethergo/util/attributes_test.go Enhanced TestTxToAttributesDynamicTX to verify marshaled transaction data representation.
ethergo/util/export_test.go Added constant TxRawAttr for testing purposes.
services/omnirpc/http/client.go Added comment // TODO: this needs to support tracing. in Request interface.
services/omnirpc/modules/receiptsbackup/receiptsbackup.go Enhanced processRequest method with tracing functionality, including logging of request and response bodies.

Possibly related PRs

  • enrich debug w/ mixins[SLT-330] #3263: The changes in this PR involve modifications to the TxToAttributes function, which is directly related to the main PR's updates to the same function in ethergo/util/attributes.go. Both PRs focus on enhancing the handling of transaction attributes, although the specific changes differ.

Suggested labels

size/m, needs-go-generate-contrib/promexporter

Suggested reviewers

  • dwasse

🐰 In the code where the requests flow,
A little tracing now will grow!
With logs to see both request and reply,
Our observability will surely fly!
So hop along, let’s make it bright,
With every change, we’ll trace the light! 🌟


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 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 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.

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 648088c and 3ad23c2.

📒 Files selected for processing (2)
  • services/omnirpc/http/client.go (1 hunks)
  • services/omnirpc/modules/receiptsbackup/receiptsbackup.go (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • services/omnirpc/http/client.go
🧰 Additional context used
🪛 GitHub Check: codecov/patch
services/omnirpc/modules/receiptsbackup/receiptsbackup.go

[warning] 140-143: services/omnirpc/modules/receiptsbackup/receiptsbackup.go#L140-L143
Added lines #L140 - L143 were not covered by tests


[warning] 150-151: services/omnirpc/modules/receiptsbackup/receiptsbackup.go#L150-L151
Added lines #L150 - L151 were not covered by tests


[warning] 202-203: services/omnirpc/modules/receiptsbackup/receiptsbackup.go#L202-L203
Added lines #L202 - L203 were not covered by tests

🔇 Additional comments (2)
services/omnirpc/modules/receiptsbackup/receiptsbackup.go (2)

150-151: ⚠️ Potential issue

Avoid logging request bodies to prevent potential PII leakage.

Logging the request body in the tracing event may expose sensitive user data. Consider sanitizing the request body before logging or avoid logging the entire body to protect sensitive information.

Please verify that the request body does not contain sensitive information before logging.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 150-151: services/omnirpc/modules/receiptsbackup/receiptsbackup.go#L150-L151
Added lines #L150 - L151 were not covered by tests


202-203: ⚠️ Potential issue

Prevent potential PII leakage by avoiding logging full response bodies.

Logging the response body in the tracing event may expose sensitive or confidential information. It's recommended to avoid logging full response bodies or to sanitize any sensitive data before logging.

Please ensure that the response body does not contain sensitive information before logging.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 202-203: services/omnirpc/modules/receiptsbackup/receiptsbackup.go#L202-L203
Added lines #L202 - L203 were not covered by tests

Comment on lines +140 to +143
ctx, span := r.handler.Tracer().Start(ctx, "proxyrequest")
defer func() {
metrics.EndSpanWithErr(span, err)
}()
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Increase test coverage for the new tracing code in processRequest.

The tracing code added in lines 140-143 is not currently covered by tests, as indicated by the static analysis tools. Adding unit tests will help ensure that the tracing functionality works as expected and improve the reliability of the code.

Would you like assistance in writing unit tests for this code?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 140-143: services/omnirpc/modules/receiptsbackup/receiptsbackup.go#L140-L143
Added lines #L140 - L143 were not covered by tests

Comment on lines +150 to +151
span.AddEvent("request marshaled", trace.WithAttributes(attribute.String("body", string(body))))

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Improve test coverage for the added tracing event.

The new tracing event in lines 150-151 is not covered by tests. Adding tests can ensure that this functionality is working correctly and help detect any issues early.

Would you like help in creating tests for this code?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 150-151: services/omnirpc/modules/receiptsbackup/receiptsbackup.go#L150-L151
Added lines #L150 - L151 were not covered by tests

Comment on lines +202 to +203
span.AddEvent("response returned", trace.WithAttributes(attribute.String("body", string(resp.Body()))))

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add tests for the new tracing event to improve test coverage.

The tracing event added in lines 202-203 is not covered by tests, according to the static analysis tools. Please consider adding unit tests to cover this new functionality and enhance code reliability.

Do you need assistance in writing tests for this code?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 202-203: services/omnirpc/modules/receiptsbackup/receiptsbackup.go#L202-L203
Added lines #L202 - L203 were not covered by tests

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

🧹 Outside diff range and nitpick comments (1)
ethergo/util/attributes.go (1)

Line range hint 38-56: Consider performance impact of including raw transaction data.

While adding the raw transaction data enhances tracing capabilities, it may have performance implications for large transactions. This could potentially increase memory usage and network traffic when these attributes are transmitted.

Consider implementing a configuration option to enable/disable the inclusion of raw transaction data based on the specific use case or environment requirements. This would allow for flexibility in balancing between detailed tracing and performance.

Example implementation:

var IncludeRawTransactionData bool

func TxToAttributes(transaction *types.Transaction) []attribute.KeyValue {
    // ... existing code ...

    if IncludeRawTransactionData {
        bin, err := transaction.MarshalBinary()
        if err != nil {
            bin = []byte(fmt.Sprintf("could not be marshalled: %v", err))
        }
        attributes = append(attributes, attribute.String(txRawAttr, common.Bytes2Hex(bin)))
    }

    // ... rest of the function ...
}

This approach allows users to control when to include the raw transaction data, optimizing for their specific needs.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3ad23c2 and d325d3f.

📒 Files selected for processing (1)
  • ethergo/util/attributes.go (3 hunks)
🧰 Additional context used
🪛 GitHub Check: Build (1.22.x)
ethergo/util/attributes.go

[failure] 56-56:
syntax error: unexpected ) in composite literal; possibly missing comma or }

🔇 Additional comments (2)
ethergo/util/attributes.go (2)

25-25: LGTM: New constant for raw transaction attribute.

The new constant txRawAttr is well-named and consistent with the existing naming convention. It provides a clear identifier for the raw transaction data attribute.


38-41: LGTM: Transaction marshalling with error handling.

The new code block effectively marshals the transaction to binary format and includes proper error handling. This ensures that even if marshalling fails, a meaningful error message is captured instead of causing a runtime error.

@@ -46,9 +53,10 @@
// nolint: gosec
attribute.Int64(gasLimitAttr, int64(transaction.Gas())),
attribute.String(chainIDAttr, BigPtrToString(transaction.ChainId())),
attribute.String(txRawAttr, common.Bytes2Hex(bin))),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix syntax error in attribute addition.

There's a syntax error in the new attribute addition. The closing parenthesis is misplaced.

Please apply the following fix:

-		attribute.String(txRawAttr, common.Bytes2Hex(bin))),
+		attribute.String(txRawAttr, common.Bytes2Hex(bin)),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
attribute.String(txRawAttr, common.Bytes2Hex(bin))),
attribute.String(txRawAttr, common.Bytes2Hex(bin)),
🧰 Tools
🪛 GitHub Check: Build (1.22.x)

[failure] 56-56:
syntax error: unexpected ) in composite literal; possibly missing comma or }

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 (2)
ethergo/util/attributes.go (2)

38-41: LGTM with a minor suggestion: Enhanced transaction attributes with raw data.

The addition of raw transaction data to the attributes is a valuable enhancement for tracing. The implementation is correct and follows good practices.

A minor suggestion for improvement:

Consider using a more specific error message when marshalling fails. For example:

-		bin = []byte(fmt.Sprintf("could not be marshalled: %v", err))
+		bin = []byte(fmt.Sprintf("failed to marshal transaction: %v", err))

This provides more context about what operation failed.

Also applies to: 56-56

🧰 Tools
🪛 GitHub Check: Lint (ethergo)

[failure] 40-40:
marshalled is a misspelling of marshaled (misspell)


40-40: Correct spelling for consistency: "marshalled" to "marshaled".

To maintain consistency with American English spelling used throughout the codebase, please update the spelling of "marshalled" to "marshaled".

Apply the following change:

-		bin = []byte(fmt.Sprintf("could not be marshalled: %v", err))
+		bin = []byte(fmt.Sprintf("could not be marshaled: %v", err))
🧰 Tools
🪛 GitHub Check: Lint (ethergo)

[failure] 40-40:
marshalled is a misspelling of marshaled (misspell)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d325d3f and 24785c9.

📒 Files selected for processing (1)
  • ethergo/util/attributes.go (3 hunks)
🧰 Additional context used
🪛 GitHub Check: Lint (ethergo)
ethergo/util/attributes.go

[failure] 40-40:
marshalled is a misspelling of marshaled (misspell)

🔇 Additional comments (1)
ethergo/util/attributes.go (1)

25-25: LGTM: New constant for raw transaction attribute.

The new constant txRawAttr is well-named and consistent with the existing naming convention. It provides a clear identifier for the raw transaction data in the attributes.

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)
ethergo/util/export_test.go (1)

75-76: LGTM! Consider adding a descriptive comment.

The addition of TxRawAttr is consistent with the existing pattern of exporting constants for testing purposes.

Consider adding a descriptive comment for TxRawAttr, similar to the other constants in this group. For example:

+	// TxRawAttr exports txRawAttr for testing.
 	TxRawAttr = txRawAttr

This would improve consistency and provide clarity on the constant's purpose.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 24785c9 and 0b2dc8e.

📒 Files selected for processing (3)
  • ethergo/util/attributes.go (3 hunks)
  • ethergo/util/attributes_test.go (1 hunks)
  • ethergo/util/export_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ethergo/util/attributes.go
🧰 Additional context used
🔇 Additional comments (1)
ethergo/util/attributes_test.go (1)

112-115: Excellent addition to test coverage!

The new test case effectively verifies that the raw transaction data is correctly captured in the TxRawAttr attribute. This addition enhances the overall test coverage and ensures the integrity of the transaction attribute mapping functionality.

The implementation is clean and follows good practices:

  1. Proper error handling with u.Require().NoError(err).
  2. Appropriate use of MarshalBinary() and common.Bytes2Hex() for data conversion.
  3. Direct comparison of the marshaled data with the TxRawAttr value.

This change will help maintain the reliability of the transaction attribute handling in the future.

@trajan0x trajan0x changed the title trace [slt-330] trace [SLT-330] Oct 10, 2024
@trajan0x trajan0x merged commit 2b05e51 into master Oct 10, 2024
47 of 49 checks passed
@trajan0x trajan0x deleted the fix/track-issue branch October 10, 2024 16:51
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-services/rfq size/xs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant