chore: consistant otel keys in setAttribute + add genai keys#13
Conversation
Summary of ChangesHello @abhishekg999, 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! This pull request significantly enhances the OpenTelemetry tracing capabilities within the Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the setAttribute methods in BaseTracer for consistency and robustness, and adds new OpenTelemetry keys for generative AI. The refactoring introduces a withCurrentSpan helper method to reduce code duplication and replaces Optional-based logic with more direct checks. New overloads for setAttribute are added for primitive types. The JSON serialization is also made more robust with error handling. My review focuses on improving the robustness of the new and modified methods. I've identified a potential data leak and incorrect behavior in the serialization error handling, and a series of potential NullPointerExceptions due to missing null checks for attribute keys. I've provided suggestions to address these issues.
| Logger.error("Failed to serialize object: " + e.getMessage()); | ||
| return obj != null ? obj.toString() : null; |
There was a problem hiding this comment.
In case of a serialization failure, falling back to obj.toString() can be problematic. It might not produce a valid JSON string, and could potentially leak sensitive information if the toString() method is verbose. A safer approach is to return a structured JSON error message. Also, the obj != null check is redundant because the calling setAttribute methods already guard against null values.
Logger.error("Failed to serialize object: " + e.getMessage());
return "{\"error\":\"serialization_failed\",\"type\":\"" + type.getTypeName() + "\"}";There was a problem hiding this comment.
string is a valid outpuit for a key
|
✅ No security or compliance issues detected. Reviewed everything up to af7122e. Security Overview
Detected Code ChangesThe diff is too large to display a summary of code changes. Reply to this PR with |
|
@gemini summarize all the issues |
adivate2021
left a comment
There was a problem hiding this comment.
lgtm, just look at gemini comments on the non-null key set attribute thing
|
@gemini review |
No description provided.