Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Code comments

Keep code comments succinct. The goal of code comments is to help readability by explaining the current code and/or giving some intuitive reasoning.
This can use an example. Code comments should not include git history, or issue numbers or historical facts.

# Process conventions

- **Keep PRs small and single-purpose.** Split a PR that mixes multiple
Expand Down
4 changes: 4 additions & 0 deletions asap-tools/experiments/README_WORKLOAD_GENERATOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The `generate_workload.py` script creates experiment configs by randomly composi
| **B4** | sum/count_over_time | `sum_over_time(fake_metric_total[15m])` |
| **B5** | rate/increase | `rate(fake_metric_total[15m])` |
| **B6** | nested aggregation | `sum by (label_0) (sum_over_time(fake_metric_total[15m]))` |
| **B7** | aggregate rate | `sum by (label_0) (rate(fake_metric_total[15m]))` or `count by (label_0) (rate(fake_metric_total[15m]))` |
| **B8** | topk over sum | `topk(1, sum by (label_0) (fake_metric_total))`, with `k` of 1, 3, or 5 |
| **B9** | topk over count | `topk(1, count by (label_0) (fake_metric_total))`, with `k` of 1, 3, or 5 |
| **B10** | max_over_time | `max_over_time(fake_metric_total[15m])` |

Each block randomly selects parameters:
- **Quantiles**: 0.5, 0.7, 0.8, 0.9, 0.95, 0.99
Expand Down
54 changes: 53 additions & 1 deletion asap-tools/experiments/generate_workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def get_query_lookback(query: str) -> int:


# ============================================================================
# QUERY BUILDING BLOCKS (B1-B6)
# QUERY BUILDING BLOCKS (B1-B10)
# Each function generates a random query of that type
# ============================================================================

Expand Down Expand Up @@ -198,6 +198,50 @@ def generate_b6_query() -> str:
return f"{outer_agg} by ({label}) ({inner_agg}({metric}[{time_range}]))"


def generate_b7_query() -> str:
"""B7: sum by or count by applied to rate.

Example: sum by (label_0) (rate(fake_metric_total[15m]))
"""
aggregation = random.choice(["sum", "count"])
label = get_aggregation_label()
time_range = get_time_range()
metric = get_metric_name()
return f"{aggregation} by ({label}) (rate({metric}[{time_range}]))"


def generate_b8_query() -> str:
"""B8: topk over sum by aggregation, with k in {1, 3, 5}.

Example: topk(3, sum by (label_0) (fake_metric_total))
"""
k = random.choice([1, 3, 5])
label = get_aggregation_label()
metric = get_metric_name()
return f"topk({k}, sum by ({label}) ({metric}))"


def generate_b9_query() -> str:
"""B9: topk over count by aggregation, with k in {1, 3, 5}.

Example: topk(3, count by (label_0) (fake_metric_total))
"""
k = random.choice([1, 3, 5])
label = get_aggregation_label()
metric = get_metric_name()
return f"topk({k}, count by ({label}) ({metric}))"


def generate_b10_query() -> str:
"""B10: max_over_time query.

Example: max_over_time(fake_metric_total[15m])
"""
time_range = get_time_range()
metric = get_metric_name()
return f"max_over_time({metric}[{time_range}])"


# Map block IDs to generator functions
BLOCK_GENERATORS = {
1: generate_b1_query,
Expand All @@ -206,6 +250,10 @@ def generate_b6_query() -> str:
4: generate_b4_query,
5: generate_b5_query,
6: generate_b6_query,
7: generate_b7_query,
8: generate_b8_query,
9: generate_b9_query,
10: generate_b10_query,
}


Expand Down Expand Up @@ -604,6 +652,10 @@ def main():
B4: sum_over_time / count_over_time
B5: rate / increase
B6: sum by () (sum_over_time / count_over_time)
B7: sum by / count by (rate)
B8: topk(1|3|5, sum by ())
B9: topk(1|3|5, count by ())
B10: max_over_time
""",
)

Expand Down
Loading