Skip to main content

weave.trace_server.interface.query

This file contains the interface definition for the Trace Server Query model. It is heavily inspired by the MongoDB query language, but is a subset of the full MongoDB query language. In particular, we have made the following simplifications:

  • We only support the "aggregation" operators, not the "query" operators. This is purely for simplicity and because the "aggregation" operators are more powerful. The Mongo docs language has evolved over time and the primary query language is column-oriented. However, the more expressive aggregation language can be used for both direct queries, but also for column comparison and calculations. We can add support for the "query" operators in the future if needed.

  • We only support a subset of the operators / shorthand forms for now. We can add more operators in the future as needed.

    • One notable omission here is the lack of support for "$field" as a shorthand for the "getField" operator.
  • We have added a $contains operator which is not in the MongoDB query language. This is a simple substring match operator.


API Overview

Classes


class AndOperation

Pydantic Fields:

  • $and: typing.List[typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation]]

class ContainsOperation

Pydantic Fields:

  • $contains: <class 'ContainsSpec'>

class ContainsSpec

Pydantic Fields:

  • input: typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation]
  • substr: typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation]
  • case_insensitive: typing.Optional[bool]

class ConvertOperation

Pydantic Fields:

  • $convert: <class 'ConvertSpec'>

class ConvertSpec

Pydantic Fields:

  • input: typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation]
  • to: typing.Literal['double', 'string', 'int', 'bool', 'exists']

class EqOperation

Pydantic Fields:

  • $eq: typing.Tuple[typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation], typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation]]

class GetFieldOperator

Pydantic Fields:

  • $getField: <class 'str'>

class GtOperation

Pydantic Fields:

  • $gt: typing.Tuple[typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation], typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation]]

class GteOperation

Pydantic Fields:

  • $gte: typing.Tuple[typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation], typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation]]

class InOperation

Pydantic Fields:

  • $in: typing.Tuple[typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation], list['Operand']]

class LiteralOperation

Pydantic Fields:

  • $literal: typing.Union[str, int, float, bool, dict[str, 'LiteralOperation'], list['LiteralOperation'], NoneType]

class NotOperation

Pydantic Fields:

  • $not: typing.Tuple[typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation]]

class OrOperation

Pydantic Fields:

  • $or: typing.List[typing.Union[LiteralOperation, GetFieldOperator, ConvertOperation, AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation]]

class Query

Pydantic Fields:

  • $expr: typing.Union[AndOperation, OrOperation, NotOperation, EqOperation, GtOperation, GteOperation, InOperation, ContainsOperation]