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

Add JSON Folding Support in Logs #1724

Merged
merged 2 commits into from
Aug 24, 2023

Conversation

prathamesh-mutkure
Copy link
Contributor

Which problem is this PR solving?

Resolves #1415

Description of the changes

  • I've added react-json-view-lite to render json in tree view
  • The old jsonMarkup.js file has been removed
  • The styling has been matched to old design

How was this change tested?

  • The test cases passed
  • The old and new approaches followed same design

Before -

Screenshot 2023-08-23 at 1 11 03 PM

Now -

Screenshot 2023-08-23 at 1 11 30 PM

Checklist

Signed-off-by: Prathamesh Mutkure <pmutkure009@gmail.com>
content = (
<JsonView
data={parsed}
shouldInitiallyExpand={allExpanded}
Copy link
Member

@yurishkuro yurishkuro Aug 23, 2023

Choose a reason for hiding this comment

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

could this be conditional on the size of the output, e.g. if the JSON object has more than 10 keys then don't start in expanded form.

Also, please post a screenshot of how it looks in the collapsed at the root form.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's how it looks when collapsed at the root

Screenshot 2023-08-24 at 12 55 08 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The JSON tree will now only expand if it has 10 or less keys, nested objects will remain collapsed otherwise

Signed-off-by: Prathamesh Mutkure <pmutkure009@gmail.com>
@codecov
Copy link

codecov bot commented Aug 24, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.02% ⚠️

Comparison is base (a01f444) 96.01% compared to head (b501f0f) 96.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1724      +/-   ##
==========================================
- Coverage   96.01%   96.00%   -0.02%     
==========================================
  Files         241      240       -1     
  Lines        7562     7514      -48     
  Branches     1987     1974      -13     
==========================================
- Hits         7261     7214      -47     
+ Misses        301      300       -1     
Files Changed Coverage Δ
.../TraceTimelineViewer/SpanDetail/KeyValuesTable.tsx 97.77% <100.00%> (-0.05%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yurishkuro yurishkuro merged commit 252c08c into jaegertracing:main Aug 24, 2023
8 checks passed
@@ -79,7 +71,28 @@ function formatValue(key: string, value: any) {
} else if (Array.isArray(parsed) && shouldDisplayAsStringList(key)) {
content = stringListMarkup(parsed);
} else {
content = _jsonMarkup(parsed);
const shouldJsonTreeExpand = Object.keys(parsed).length <= 10;
Copy link
Member

Choose a reason for hiding this comment

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

I think this is good as a first approximation, but the right solution would be estimating the total height to be >10, not just the number of first-level children.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I guess we could work on some algorithm, It could be something like 1 property = 8 px, and then we could just go on calculating the height of the first X elements (recursively) and then decide to expand or collapse the tree

This task could be included in the upcoming LFX term

nullValue: 'json-markup-null',
undefinedValue: 'json-markup-undefined',
expander: 'json-markup-expander',
basicChildStyle: 'json-markup-child',
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't look like a desirable outcome:

image

Copy link
Member

Choose a reason for hiding this comment

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

please elaborate

Copy link
Contributor

Choose a reason for hiding this comment

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

I made #2168

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.

[Feature]: log json folding
3 participants