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

TraceQL: Support select() on multiple scopes #4311

Open
farcaller opened this issue Oct 29, 2024 · 7 comments
Open

TraceQL: Support select() on multiple scopes #4311

farcaller opened this issue Oct 29, 2024 · 7 comments
Labels
enhancement New feature or request keepalive Label to exempt Issues / PRs from stale workflow traceql

Comments

@farcaller
Copy link

Why is this needed:

select() allows you to visualize the attributes of the span, making them easier to visually compare. However, it's not possible to select anything from parent scopes if the final selected span doesn't provide enough context.

What would you like to be added:

Consider the following traces:

<span name="hello" sender="alice">
  <span name="world" message="hello world" />
</span>

You can select all the world spans within helloes and add the column for message via { span:name = "hello" } >> { span:name = "world" } | select(span.message), however you can't add the sender of the parent span to vizualisation.

I don't know how the syntax for this should look like. My naive expectation is that { span:name = "hello" } | select(span.sender) >> { span:name = "world" } | select(span.message) would create a table with both sender and message columns.

Who is this feature for?

This is useful when you're analyzing the issue stretching across several nested spans, you narrowed it down to the specific parent-child spans and want to see the attributes in play.

@adrapereira adrapereira transferred this issue from grafana/grafana Nov 11, 2024
@adrapereira
Copy link

Moved to https://github.com/grafana/tempo since this is a TraceQL feature request.

@mapno
Copy link
Member

mapno commented Nov 13, 2024

Hi @farcaller. Have you tried using union structural operators? It returns the matching spans of both selectors.

@joe-elliott
Copy link
Member

I really like this idea. The ability to select (or even just reference) the attributes from other spans. The original TraceQL design actually included this with the concept of parent:

{ parent.foo = "bar" }

but we've struggled to build it into the language due to storage level issues. I would not give up hope tho! I want this as well, but it is definitely not a current focus of the team.

@joe-elliott joe-elliott added enhancement New feature or request keepalive Label to exempt Issues / PRs from stale workflow traceql labels Nov 15, 2024
@farcaller
Copy link
Author

Hi @farcaller. Have you tried using union structural operators? It returns the matching spans of both selectors.

I don't think that's semantically the same. The result is both spans and I can |select() the fields from both but now I'm human-parsing the output to match the lines. I'd rather have the machine do the job for me 😄

@joe-elliott
Copy link
Member

I don't think that's semantically the same. The result is both spans and I can |select() the fields from both but now I'm human-parsing the output to match the lines. I'd rather have the machine do the job for me 😄

Agreed. I was going to suggest experimenting with using Grafana tables and transformations to link the two up, but while you can select(span:id) you can't select(span:parentID). we should add that to the language.

@joe-elliott
Copy link
Member

It just occurred to me that you can do this with the nested set values. I know we're in super hacky territory here. I acknowledge this isn't a "real" solution but it would be interesting to see how well it would work. A parent span can be identified if nestedSetLeft = nestedSetParent

In this screenshot you can see the queried span has two children.

Image

@mdisibio
Copy link
Contributor

Agree it would be awesome to have more capabilities in this area of selecting/organizing output. The original idea of selecting on multiple spanset filters I'm thinking hits up against more limits in the language other than the parsing. Spanset operators returns the right-hand-side, so a query like {A} | select(...) >> {B} | select(...) would never return spans from {A} anyways. Therefore select()ing, even if it worked, wouldn't be available to display in the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request keepalive Label to exempt Issues / PRs from stale workflow traceql
Projects
None yet
Development

No branches or pull requests

5 participants