Skip to content

[Unified Waterfall] Add support for coloring OTel spans with the 'kind' field #230836

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

iblancof
Copy link
Contributor

@iblancof iblancof commented Aug 6, 2025

Summary

Closes #228239

This PR improves the waterfall UI for non-processed OTel data in traces that belong to a single service by adding support for the kind field to determine item coloring. When there are multiple services, the legend and coloring continue to be based on service.name.

For APM / processed OTel, if an item in the waterfall doesn’t have a span.type or span.subtype, we normally use the service.name in the legend, because transactions can miss these fields. However, for non-processed OTel tracing, every span always includes a kind field, so there’s no need to fall back to service.name in this case.

Before After
Screenshot 2025-08-06 at 18 11 35 Screenshot 2025-08-06 at 16 15 29

How to test

FROM traces* | STATS 
    service_count = count_distinct(service.name), 
    kind_count = count_distinct(kind)
  BY trace.id | WHERE service_count ==  1 AND kind_count > 1
  • Copy the trace.id of any resulting trace and run another query to fetch any document with that trace.id
  • Open document flyout
  • Open full screen waterfall from the Overview tab
  • The trace should display a different color for each kind present in the trace

@iblancof iblancof self-assigned this Aug 6, 2025
@iblancof iblancof requested a review from a team as a code owner August 6, 2025 16:14
@iblancof iblancof added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team v9.2.0 labels Aug 6, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

Comment on lines 25 to 26
spanType?: string;
kind?: string;
Copy link
Contributor

@cauemarcondes cauemarcondes Aug 6, 2025

Choose a reason for hiding this comment

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

I was wondering if it would be possible to not have these two fields in the unified waterfall interface. By having both fields the waterfall now "knows" between otel and apm documents differences.

Do you think we could join these two fields in one? Maybe keeping only kind becasue it's an otel field. We'd then color the waterfal based on the service.name or the kind (that could be both spanType (APM docs) or kind (Otel docs)).

Copy link
Contributor

Choose a reason for hiding this comment

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

These fields mean two different things. There is a proposal to add something more like span.type to OpenTelemetry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for raising this!

I was thinking about this before starting the work, I even considered just adding kind to the spanType to avoid making too many changes. But then I thought OTel users would probably prefer to see the data shown and named the way it really is.

That said, you’re right, the Waterfall shouldn’t really care where the data comes from. It should just build the UI based on the data it gets.

When we worked on the span failure/error display, we first handled it differently depending on the data source, but in the end we made it generic enough so the Waterfall didn’t need to know about that, it all came down to how we passed the data in.

I’ll be doing some changes to keep the Waterfall simple in the same way.

The only thing I’d like to keep is showing “Kind” or “Type” as the legend title, depending on what we’re showing. Using the same label for different things across APM and OTel could be confusing.

Copy link
Contributor Author

@iblancof iblancof Aug 8, 2025

Choose a reason for hiding this comment

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

@cauemarcondes details about the changed approach explained here.

@iblancof
Copy link
Contributor Author

iblancof commented Aug 8, 2025

After this comment, I decided to go with a simpler approach and just use a type property in the TraceItem to match the legend with the row/item coloring.

To ensure the APM behavior hasn’t been negatively impacted, here are a few different use cases:

Data source Single service Multi service
APM/processed OTEL Screenshot 2025-08-08 at 12 37 52 Screenshot 2025-08-08 at 12 48 07
Non-processed OTel Screenshot 2025-08-08 at 12 44 21 Screenshot 2025-08-08 at 12 38 18

Regarding the legend title, I decided to keep just the "Type" label to avoid overcomplicating the logic. That said, if anyone strongly disagrees, I'm happy to revisit the solution and explore a dynamic alternative. However, that would likely require introducing a different kind of configuration for the legend, rather than relying on this new single type property.

Changes done in acf82c4

@iblancof iblancof requested a review from cauemarcondes August 8, 2025 11:04
@elasticmachine
Copy link
Contributor

💔 Build Failed

Failed CI Steps

History

cc @iblancof

Copy link
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM][Unified waterfall] Add support for Span Kind in waterfall legend (OTel only)
4 participants