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

feat: add correlate span logs in traces waterfall chart #605

Open
wants to merge 3 commits into
base: v2
Choose a base branch
from

Conversation

LYHuang
Copy link

@LYHuang LYHuang commented Feb 10, 2025

  • Add correlate span logs in traces waterfall chart
  • SeverityText: warn will display as color yellow
  • Some functions refactor
  • Support both log tab and trace tab

Log Tab:
Screenshot 2025-02-10 at 8 58 40 AM

Trace Tab:
image

Ref: hdx-1181

Copy link

changeset-bot bot commented Feb 10, 2025

🦋 Changeset detected

Latest commit: a868d77

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hyperdx/common-utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

- Support searching coorelate span log in trace windows

Ref: hdx-1181
@LYHuang LYHuang force-pushed the mh/hdx-1181-correlate-logs-for-traces branch from e8fc4a9 to 7c2c758 Compare February 11, 2025 20:13
packages/app/src/components/DBTraceWaterfallChart.tsx Outdated Show resolved Hide resolved
packages/app/src/components/DBTraceWaterfallChart.tsx Outdated Show resolved Hide resolved
@@ -202,7 +204,14 @@ export default function DBTracePanel({
<Text size="sm" c="dark.2" my="sm">
Span Details
Copy link
Contributor

Choose a reason for hiding this comment

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

This should reflect the correct event type name

Copy link
Author

Choose a reason for hiding this comment

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

Not sure which part you mean, do you mean Span Details?

packages/app/src/components/DBTracePanel.tsx Outdated Show resolved Hide resolved
@@ -56,7 +57,7 @@ export default function DBTracePanel({

const [traceRowWhere, setTraceRowWhere] = useQueryState(
'traceRowWhere',
Copy link
Contributor

Choose a reason for hiding this comment

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

not a huge fan of overloading this query param, esp if the rowWhere is for a log but put in the "traceRowWhere" - the naming wouldn't make sense.

I think it might be better to introduce another query param for logRowWhere? We could rename this query param but it'd technically be a breaking change (technically this schema change is already a breaking change, URLs are supposed to be stable in our app).

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I agree with you we should not overload traceRowWhere, it should only return trace relate param, however I think it is a little too overcomplicate to make two queryState for returning focus param.

I think I will change the name to spanRowWhere, it makes more sense since span can be log or trace.

packages/app/src/components/DBTraceWaterfallChart.tsx Outdated Show resolved Hide resolved
@@ -73,6 +73,7 @@ export const SelectListSchema = z.array(DerivedColumnSchema).or(z.string());
export const SortSpecificationSchema = z.intersection(
RootValueExpressionSchema,
z.object({
valueExpression: z.string().optional(),
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to add this?

Copy link
Author

Choose a reason for hiding this comment

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

It get mentioned in lint error,
usually ordering will need to mention column, example:

orderBy: [
        {
          valueExpression: config.timestampValueExpression,
          ordering: 'ASC',
        },
      ],

I am fine to revert this, because I don't think I need order query anymore(data need to sort after fetching anyway).

// If there's no parent defined, or if the parent doesn't exist, we're a root
(result.ParentSpanId === '' || !spanIds.has(result.ParentSpanId))
) {
const isRootNode =
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this can be a lot more readable if we do the direct boolean expression which I believe is:

const isRootNode = HyperDXEventType === 'span' && type !== SourceKind.Log && !nodeParentSpanId;

Copy link
Author

Choose a reason for hiding this comment

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

oh cool, good call on this. Also since I am removing HyperDXEventType, this will become:

// root if is trace event and has no parent
  const isRootNode = type === SourceKind.Trace && !nodeParentSpanId;

packages/app/src/components/DBTraceWaterfallChart.tsx Outdated Show resolved Hide resolved
if (type === SourceKind.Log) logSpanCount += 1;

// log have dupelicate span id, tag it with -log-couunt
const nodeSpanId =
Copy link
Contributor

Choose a reason for hiding this comment

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

is this id used anywhere? is it effectively just random and never used further?

Copy link
Author

Choose a reason for hiding this comment

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

It uses as ref key to get node, it only use for trace event. And for log event, I add -log-count to prevent it overwrite trace event node.

And the reason is, in trace table, all spanId is unique, but in log table, spanId can be duplicate and it is a reference to trace event(more like parentSpanId).

@LYHuang LYHuang requested a review from MikeShi42 February 13, 2025 18:13
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