You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Formulas are not structured the way queries are, they are not "programmable".
In terms of the language of formulas we have already captured it fully (to the best of my knowledge) via the grammar and the type definitions in libddog.metrics, so there aren't any unknowns here. We will now turn these types into a dsl so that formulas can be written like so:
query_all_reqs=Query(
metric=Metric(name="aws.elb.request_count"),
agg=Aggregation(func=AggFunc.SUM),
name="reqs_all", # this name no longer matters
)
reqs_all=query_all_reqs.identifier(name='reqs_all')
Formula(text=100* (reqs_5xx/reqs_all))
Here, reqs_5xx and reqs_all are plain variables in Python instead. I'm unsure if we can support arithmetic expressions in natural syntax as shown, or whether we will need a custom representation for them like so:
Formula(text=Mul(100, (Div(reqs_5xx, reqs_all)))
Another approach would be to wrap Python literals instead and have these classes support the binary operators we need to support:
Formula(text=Int(100) * (reqs_5xx/reqs_all))
As part of this issue we should:
Implement the dsl for formulas
Add exhaustive unit tests for formulas
Make sure validation on formulas is user friendly (not just a naked assert)
Officially decouple the query dsl from the formula dsl, such that they have no common subclass. From now on we will treat these as separate languages.
Clean up all the types related to formulas in libddog.metrics and remove the ones that aren't actually useful.
Update the integration tests using formulas to use the dsl instead (textual formulas won't be supported anymore, anyway).
The text was updated successfully, but these errors were encountered:
At the moment we treat formulas as text strings even though we have a dsl for queries:
This is unfortunate, because it means:
reqs_all
attached to theQuery
has to matchreqs_all
in the formula text),100 * not_a_func(reqs_all)
In terms of the language of formulas we have already captured it fully (to the best of my knowledge) via the grammar and the type definitions in
libddog.metrics
, so there aren't any unknowns here. We will now turn these types into a dsl so that formulas can be written like so:Here,
reqs_5xx
andreqs_all
are plain variables in Python instead. I'm unsure if we can support arithmetic expressions in natural syntax as shown, or whether we will need a custom representation for them like so:Another approach would be to wrap Python literals instead and have these classes support the binary operators we need to support:
As part of this issue we should:
assert
)libddog.metrics
and remove the ones that aren't actually useful.The text was updated successfully, but these errors were encountered: