Skip to content

chore: consistant otel keys in setAttribute + add genai keys#13

Merged
adivate2021 merged 12 commits into
mainfrom
ahh/0.2.2
Oct 30, 2025
Merged

chore: consistant otel keys in setAttribute + add genai keys#13
adivate2021 merged 12 commits into
mainfrom
ahh/0.2.2

Conversation

@abhishekg999

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @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 judgeval-java SDK by introducing a more consistent and robust mechanism for setting span attributes. It expands the tracing context to include specific attributes for Generative AI operations, allowing for more granular observability of AI-driven workflows. The changes also include general code improvements for clarity and error handling, alongside a minor version increment.

Highlights

  • OpenTelemetry Attribute Consistency: Refactored setAttribute methods in BaseTracer to provide consistent handling for various data types (String, long, double, boolean) and improved null checks, streamlining how attributes are added to spans.
  • Generative AI Tracing Keys: Introduced a new set of OpenTelemetry attribute keys specifically designed for tracing Generative AI operations, covering aspects like prompts, completions, models, and token usage.
  • Code Refactoring and Robustness: Implemented a new private helper method withCurrentSpan to centralize current span access, removed an unused Optional import, and added error handling to the GsonSerializer for more robust object serialization.
  • Version Update: The project version has been updated from 0.2.1 to 0.2.2 in pom.xml.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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

  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.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/main/java/com/judgmentlabs/judgeval/tracer/BaseTracer.java
Comment thread src/main/java/com/judgmentlabs/judgeval/tracer/BaseTracer.java
Comment thread src/main/java/com/judgmentlabs/judgeval/tracer/BaseTracer.java
Comment thread src/main/java/com/judgmentlabs/judgeval/tracer/BaseTracer.java
Comment thread src/main/java/com/judgmentlabs/judgeval/tracer/BaseTracer.java
Comment thread src/main/java/com/judgmentlabs/judgeval/tracer/BaseTracer.java
Comment on lines +365 to +366
Logger.error("Failed to serialize object: " + e.getMessage());
return obj != null ? obj.toString() : null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

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() + "\"}";

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

string is a valid outpuit for a key

@delve-auditor

delve-auditor Bot commented Oct 29, 2025

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to af7122e.

Security Overview
  • 🔎 Scanned files: 54 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-ai followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@abhishekg999

Copy link
Copy Markdown
Collaborator Author

@gemini summarize all the issues

@adivate2021 adivate2021 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm, just look at gemini comments on the non-null key set attribute thing

Comment thread src/main/java/com/judgmentlabs/judgeval/tracer/BaseTracer.java
@abhishekg999

Copy link
Copy Markdown
Collaborator Author

@gemini review

@adivate2021 adivate2021 merged commit 8d83a18 into main Oct 30, 2025
2 checks passed
@adivate2021 adivate2021 deleted the ahh/0.2.2 branch October 30, 2025 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants