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

Fix: Deep clone trace data for consistency #2571

Merged

Conversation

Zen-cronic
Copy link
Contributor

@Zen-cronic Zen-cronic commented Jan 9, 2025

Resolves #2483

Description of the changes

  • deep cloned the trace data before passing it to @pyroscope/flamegraph

How was this change tested?

  • npm run test
  • visual comparison with this traces data trace.zip:

Timeline view:

timeline

Flamegraph view:

flamegraph

Navigating back and forth between flamegraph and timeline views no longer show inconsistent data

Checklist

@Zen-cronic Zen-cronic requested a review from a team as a code owner January 9, 2025 15:25
@Zen-cronic Zen-cronic requested review from joe-elliott and removed request for a team January 9, 2025 15:25
@@ -13,12 +13,14 @@
// limitations under the License.
import React from 'react';
import { FlamegraphRenderer, convertJaegerTraceToProfile } from '@pyroscope/flamegraph';
import _cloneDeep from 'lodash/cloneDeep';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

An alternative is to use the global structuredClone method, but it's still not supported in jsdom. The workaround would be:

// in TracePage/TraceFlamegraph/index.test.js
beforeAll(() => {
  global.structuredClone = jest.fn((obj) => JSON.parse(JSON.stringify(obj)));

});

afterAll(() => {
  structuredCloneSpy.mockRestore();
});

But we already have lodash installed, so might as well use it

@Zen-cronic Zen-cronic changed the title Fix: Deep clone trace data Fix: Deep clone trace data for consistency Jan 9, 2025
@yurishkuro
Copy link
Member

does it actually resolve the original issue? Seems like a partial solution (a good one, to keep the trace unchanged).

@Zen-cronic
Copy link
Contributor Author

does it actually resolve the original issue? Seems like a partial solution (a good one, to keep the trace unchanged).

Yep, b/c now me-java-rpgle-std::SELECT postgres.MU24020F in the timeline view is 8.17s, which is ≈ 0.14 min in the flamegraph.
likewise, me-java-rpgle-std::CHAIN Execution is 10.57ms, displayed as <0.01 min in the flamegraph.

These values don't change no matter how many times we switch views.

@yurishkuro yurishkuro added the changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements label Jan 9, 2025
@yurishkuro yurishkuro enabled auto-merge (squash) January 9, 2025 17:45
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.63%. Comparing base (843bf69) to head (8085e88).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2571   +/-   ##
=======================================
  Coverage   96.63%   96.63%           
=======================================
  Files         255      255           
  Lines        7731     7731           
  Branches     2012     1997   -15     
=======================================
  Hits         7471     7471           
  Misses        260      260           

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

Zen-cronic and others added 2 commits January 9, 2025 18:26
Signed-off-by: Kaung Zin Hein <kaungzinhein113@gmail.com>
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Signed-off-by: Kaung Zin Hein <83657429+Zen-cronic@users.noreply.github.com>
auto-merge was automatically disabled January 9, 2025 23:26

Head branch was pushed to by a user without write access

@Zen-cronic Zen-cronic force-pushed the fix/inconsistent-data-view branch from 348f1d2 to 8085e88 Compare January 9, 2025 23:26
@yurishkuro yurishkuro enabled auto-merge (squash) January 9, 2025 23:28
@yurishkuro yurishkuro merged commit 8f4cad7 into jaegertracing:main Jan 9, 2025
8 checks passed
@yurishkuro
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Inconsistent Data Displayed in Flamegraph
2 participants