-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
- Add strict validation for span fields (traceID, spanID, operationNa… #2677
base: main
Are you sure you want to change the base?
Conversation
…me, etc) - Add process object validation to ensure serviceName exists - Improve validation of process references in spans - Handle both Jaeger and OTLP trace formats
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @rohitlohar45, 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 addresses issue #6517 by adding strict validation for span fields, improving error handling, and supporting OpenTelemetry span JSON format uploads. The changes include converting OTel spans to OTLP format during processing and handling different trace format types (Jaeger, OTLP, and single OTel spans). The changes primarily affect the readJsonFile.tsx
file in the jaeger-ui
package.
Highlights
- OTel Span Support: Adds support for uploading OpenTelemetry span JSON format and converts them to OTLP format for processing.
- Strict Validation: Improves validation for span and process properties to ensure data integrity.
- Error Handling: Adds proper error handling for invalid JSON formats, providing better feedback in the client UI.
- Trace Format Handling: Handles different trace format types, including Jaeger, OTLP, and single OTel spans.
Changelog
Click here to see the changelog
- packages/jaeger-ui/src/utils/readJsonFile.tsx
- Added
validateSpan
function to validate span fields (traceID, spanID, operationName, startTime, duration, processID). Lines 33-43 - Added
validateProcess
function to validate process properties (serviceName). Lines 45-51 - Added
isOTelSpan
function to check if an object is an OpenTelemetry span based on the presence ofcontext.trace_id
andcontext.span_id
. Lines 54-62 - Added
convertOTelSpanToOTLP
function to convert an OTel span to OTLP format. Lines 65-97 - Added
validateJaegerTrace
function to validate Jaeger trace format, including support for OTel spans and resourceSpans. Lines 100-120 - Added
validateSingleTrace
function to validate a single Jaeger trace, checking for traceID, spans, and processes. Lines 122-139 - Improved error handling when parsing JSON, providing a more informative error message. Line 156
- Added validation for Jaeger and OTLP trace formats, rejecting invalid formats. Line 162
- Conversion of OTel spans to OTLP format when detected. Line 167
- Updated error message when converting traces to Jaeger format. Line 185
- Added
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 term 'telemetry' originates from the Greek roots 'tele' (remote) and 'metron' (measure).
Footnotes
-
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. ↩
There was a problem hiding this 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 validation for span fields and adds support for OpenTelemetry span JSON format upload, converting them to OTLP format during processing. It also improves error handling for invalid JSON formats and handles different trace format types. Overall, the changes seem well-structured and address the issue mentioned in the PR description. However, there are a few areas where improvements can be made to enhance code clarity and maintainability.
Merge Readiness
The changes introduced by this pull request enhance the application's ability to handle various trace formats and improve data validation. While the code appears functional, addressing the suggestions related to error message clarity and code structure would further improve the quality and maintainability of the codebase. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. Given the absence of CRITICAL or HIGH severity issues, the pull request is a good candidate for merging once the feedback is addressed.
this was the only change required per the issue. The UI already handles different input formats. |
@yurishkuro Thank you for the clarification. I've adjusted my implementation to focus specifically on the error handling for invalid JSON formats as you mentioned. The revised code now properly handles the error case that was causing the "Cannot read properties of undefined (reading 'map')" exception. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I don't see why we need these changes. The code can already recognize valid formats, that part requires no changes. What is the root cause of the issue when invalid format is uploaded?
@yurishkuro When loadJsonDone() attempts to parse this data, it tries to map over a property that is not present in this structure with properties (probably looking for a structure that has a In my fix I added verification to catch this particular instance and reject with an appropriate error message rather than allowing the not supported format to be send to loadJsonDone(). This avoids the runtime error while not changing the existing format handling for correct inputs. |
None of the so-called validations are validating the whole structure, so there can be an issue deeper in the structure which may still throw exception somewhere. The objective of the ticket was to ensure that such exceptions are still caught and displayed on the screen, not let it hang with a spinner. |
So do I need to check for that recursively? Because for for large trace files, deep validation might impact performance. |
We don't need to validate anything, we need to catch exceptions and display them. |
Understood, I added the try catch block to catch the exceptions if any in the loadJsonDone function, it worked and was displaying the error for non supported JSON |
@yurishkuro any issues with the changes? |
Here's a fixed version of the PR description:
Which problem is this PR solving?
Description of the changes
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:npm run lint
andnpm run test