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(studio): Quick fix for trace rendering bug #9120

Merged
merged 2 commits into from
Sep 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/studio/web/src/Pages/Explore/TraceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ function TraceListComponent({ traces }: { traces: any[] }) {
)
}

const bigIntMin = (...args: bigint[]) => args.reduce((m, e) => (e < m ? e : m))

export default function TraceList() {
const [{ tracesFilter: searchFilter }] = useContext(SearchFilterContext)

Expand All @@ -134,10 +136,8 @@ export default function TraceList() {
},
})

const sortedTraces = data?.rows?.sort((a: any, b: any) => {
const bigIntMin = (...args: bigint[]) =>
args.reduce((m, e) => (e < m ? e : m))

const traces: any[] = data?.rows !== undefined ? [...data.rows] : []
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, but let's see later if we can do sorting in the service/view/queries perhaps? Maybe a sort option?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah agreed

traces.sort((a: any, b: any) => {
const aStart = bigIntMin(...a.spans.map((span: any) => span.startNano))
const bStart = bigIntMin(...b.spans.map((span: any) => span.startNano))
return aStart > bStart ? -1 : bStart > aStart ? 1 : 0
Expand All @@ -150,7 +150,7 @@ export default function TraceList() {
<div className="sm:flex-auto">
<div className="text-base font-semibold leading-6 text-slate-100 px-4 pt-2 pb-2 bg-rich-black rounded-md flex justify-between">
<div>OpenTelemetry Traces</div>
<div>{data?.rows?.length && `(${data.rows.length})`}</div>
<div>{traces.length && `(${traces.length})`}</div>
</div>
</div>
</div>
Expand All @@ -164,7 +164,7 @@ export default function TraceList() {
<LoadingSpinner />
</div>
) : (
<TraceListComponent traces={sortedTraces} />
<TraceListComponent traces={traces} />
)}
</div>
</div>
Expand Down
Loading