When querying traces, you can use special prefixes to search for attributes across different spans within a trace. Two important prefixes are any. and anyX. (where X can be 1, 2, or 3).

Using the any. prefix

The any. prefix matches attributes within the same span. For example, the query:

WHERE any.attr1 = val1 AND any.attr2 = val2

This will find traces that have a single span containing both attributes (attr1=val1 AND attr2=val2).

Using the anyX. prefix

The anyX. prefix (where X can be 1, 2, or 3) allows you to match attributes across different spans within the same trace. For example:

WHERE any1.attr1 = val1 AND any2.attr2 = val2

This will find traces where:

  • One span has attr1=val1

  • Another span has attr2=val2

Example

Here's a practical example of using anyX. prefixes:

name = EnsureQueryWithQueryer AND 
any1.name = translate_read_request AND 
any2.name = QueriesHandler.RunQueryWebSocket

Performance trace visualization showing multiple spans including EnsureQueryWithQueryer, translate_read_request, and QueriesHandler.RunQueryWebSocket

Important notes

  • Multiple conditions using the same anyX. prefix (e.g., any1.attr1 and any1.attr2) will apply to the same span
  • You can use up to three different anyX. prefixes (any1, any2, any3) in a query, and there is no ordering implied by these numbers

    For more examples and advanced usage patterns of any. and anyX. prefixes, see our trace query examples documentation.