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

[refactor] Refactor jptrace/attributes_tests.go for readability #6786

Merged
merged 6 commits into from
Feb 28, 2025

Conversation

mahadzaryab1
Copy link
Collaborator

Description of the changes

How was this change tested?

  • CI

Checklist

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @mahadzaryab1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request refactors the jptrace/attributes.go file by introducing a new helper method AttributesToStringMap and modifying the existing AttributesToMap method. It also updates the tests to reflect these changes. The primary goal is to address leftover comments from a previous pull request, specifically #6785.

Highlights

  • New Helper Method: Introduces AttributesToStringMap in internal/jptrace/attributes.go to convert pcommon.Map attributes to a map[string]string.
  • Modified AttributesToMap: Updates AttributesToMap in internal/jptrace/attributes.go to convert pcommon.Map attributes to a map[string]any.
  • Test Refactoring: Refactors tests in internal/jptrace/attributes_test.go to accommodate the new AttributesToStringMap method and the updated AttributesToMap method.
  • Integration Adjustment: Adjusts the call to the attributes conversion in cmd/jaeger/internal/integration/trace_reader.go to use the new AttributesToStringMap method.
  • Storage API Adjustment: Adjusts the call to the attributes conversion in internal/storage/v2/api/tracestore/reader.go to use the new AttributesToStringMap method.

Changelog

Click here to see the changelog
  • cmd/jaeger/internal/integration/trace_reader.go
    • Replaces AttributesToMap with AttributesToStringMap on line 124.
  • internal/jptrace/attributes.go
    • Introduces AttributesToStringMap function converting pcommon.Map to map[string]string (lines 21-27).
    • Modifies AttributesToMap function converting pcommon.Map to map[string]any (lines 30-36).
  • internal/jptrace/attributes_test.go
    • Renames TestAttributesToMap to TestAttributesToStringMap (line 13).
    • Adds a new TestAttributesToMap to test the new implementation of the function (lines 63-107).
    • Updates TestMapToAttributes to assert equality with AttributesToStringMap (line 135).
  • internal/storage/v2/api/tracestore/reader.go
    • Replaces AttributesToMap with AttributesToStringMap on line 111.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Did you know?

The OpenTelemetry project, which provides the pcommon library used in this PR, is the second most active project in the Cloud Native Computing Foundation (CNCF) after Kubernetes.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a new helper method AttributesToMap to jptrace/attributes.go and refactors the tests. The changes look good overall, but there are a few minor suggestions for improvement.

Summary of Findings

Merge Readiness

The code changes are well-structured and the tests are comprehensive. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. I believe this pull request is ready to be merged after addressing the comments.

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.04%. Comparing base (06cc410) to head (91c3c56).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6786   +/-   ##
=======================================
  Coverage   96.03%   96.04%           
=======================================
  Files         364      364           
  Lines       20690    20690           
=======================================
+ Hits        19870    19872    +2     
+ Misses        626      624    -2     
  Partials      194      194           
Flag Coverage Δ
badger_v1 9.81% <55.55%> (ø)
badger_v2 1.89% <44.44%> (ø)
cassandra-4.x-v1-manual 14.86% <55.55%> (ø)
cassandra-4.x-v2-auto 1.88% <44.44%> (ø)
cassandra-4.x-v2-manual 1.88% <44.44%> (ø)
cassandra-5.x-v1-manual 14.86% <55.55%> (ø)
cassandra-5.x-v2-auto 1.88% <44.44%> (ø)
cassandra-5.x-v2-manual 1.88% <44.44%> (ø)
elasticsearch-6.x-v1 19.19% <55.55%> (ø)
elasticsearch-7.x-v1 19.27% <55.55%> (ø)
elasticsearch-8.x-v1 19.44% <55.55%> (ø)
elasticsearch-8.x-v2 1.89% <44.44%> (ø)
grpc_v1 10.86% <55.55%> (ø)
grpc_v2 7.86% <44.44%> (ø)
kafka-3.x-v1 10.11% <0.00%> (ø)
kafka-3.x-v2 1.89% <44.44%> (ø)
memory_v2 1.89% <44.44%> (ø)
opensearch-1.x-v1 19.32% <55.55%> (ø)
opensearch-2.x-v1 19.32% <55.55%> (ø)
opensearch-2.x-v2 1.89% <44.44%> (ø)
tailsampling-processor 0.48% <0.00%> (ø)
unittests 94.93% <100.00%> (+<0.01%) ⬆️

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.

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
@mahadzaryab1 mahadzaryab1 changed the title [refactor] Add new helper method to jptrace/attributes.go and refactor tests [refactor] Refactor jptrace/attributes_tests.go for readability Feb 28, 2025
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
@mahadzaryab1 mahadzaryab1 added this pull request to the merge queue Feb 28, 2025
Merged via the queue into jaegertracing:main with commit a15552f Feb 28, 2025
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants