Skip to content

Commit 72e7370

Browse files
committed
update reports doc, include WASP fix
1 parent f5e1c5a commit 72e7370

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

book/src/libs/wasp/benchspy/reports/new_executor.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# BenchSpy - Adding a New QueryExecutor
22

3+
# QueryExecutor interface
4+
35
As mentioned earlier, the `StandardReport` supports three different data sources:
46
- `Direct`
57
- `Loki`
@@ -48,4 +50,18 @@ By default, `StandardReport` calculates the test time range automatically by ana
4850

4951
---
5052

51-
With these details in mind, you should have a clear path to implementing your own `QueryExecutor` and integrating it seamlessly with `BenchSpy`'s `StandardReport`.
53+
With these details in mind, you should have a clear path to implementing your own `QueryExecutor` and integrating it seamlessly with `BenchSpy`'s `StandardReport`.
54+
55+
# NamedGenerator interface
56+
57+
Executors that query load generation metrics should also implement this simple interface:
58+
```go
59+
type NamedGenerator interface {
60+
// GeneratorName returns the name of the generator
61+
GeneratorName() string
62+
}
63+
```
64+
65+
It is used primarly, when casting results from `map[string]interface{}` to target type, while splitting them between different generators.
66+
67+
Currently, this interface is implemented by `Direct` and `Loki` exectors, but not by `Prometheus`.

book/src/libs/wasp/benchspy/reports/standard_report.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Both query executors focus on the characteristics of the load generated by `WASP
1818
Predefined metrics for both include:
1919
- Median latency
2020
- 95th percentile latency
21+
- Max latency
2122
- Error rate
2223

2324
**Latency** is the round-trip time from sending a request to receiving a response from the Application Under Test (AUT).
@@ -31,8 +32,10 @@ Predefined metrics for both include:
3132
Prometheus metrics focus on resource consumption by the AUT rather than load generation. These metrics include:
3233
- Median CPU usage
3334
- 95th percentile CPU usage
35+
- Max CPU usage
3436
- Median memory usage
3537
- 95th percentile memory usage
38+
- Max memory usage
3639

3740
Prometheus queries focus on **total** consumption, which combines the usage of the underlying system and your application.
3841

@@ -44,7 +47,7 @@ To use pre-defined metrics, call the `NewStandardReport` method:
4447

4548
```go
4649
report, err := benchspy.NewStandardReport(
47-
"91ee9e3c903d52de12f3d0c1a07ac3c2a6d141fb",
50+
"v1.1.1",
4851
// Query executor types for which standard metrics should be generated
4952
benchspy.WithStandardQueries(
5053
benchspy.StandardQueryExecutor_Prometheus,
@@ -69,7 +72,7 @@ Since `WASP` stores AUT responses in each generator, you can create custom metri
6972
```go
7073
var generator *wasp.Generator
7174

72-
var timeouts = func(responses *wasp.SliceBuffer[wasp.Response]) (float64, error) {
75+
var timeouts = func(responses *wasp.SliceBuffer[*wasp.Response]) (float64, error) {
7376
if len(responses.Data) == 0 {
7477
return 0, nil
7578
}
@@ -104,7 +107,7 @@ var generator *wasp.Generator
104107

105108
lokiQueryExecutor := benchspy.NewLokiQueryExecutor(
106109
map[string]string{
107-
"responses_over_time": fmt.Sprintf("sum(count_over_time({my_label=~\"%s\", test_data_type=~\"responses\", gen_name=~\"%s\"} [1s])) by (node_id, gen_name)", label, gen.Cfg.GenName),
110+
"responses_over_time": fmt.Sprintf("sum(count_over_time({my_label=~\"%s\", test_data_type=~\"responses\", gen_name=~\"%s\"} [5s])) by (node_id, gen_name)", label, gen.Cfg.GenName),
108111
},
109112
generator.Cfg.LokiConfig,
110113
)
@@ -139,7 +142,7 @@ To use custom queries in a `StandardReport`, pass the custom `QueryExecutors` cr
139142

140143
```go
141144
report, err := benchspy.NewStandardReport(
142-
"2d1fa3532656c51991c0212afce5f80d2914e34e",
145+
"v1.2.3",
143146
benchspy.WithQueryExecutors(directExecutor, lokiQueryExecutor, prometheusExecutor),
144147
benchspy.WithGenerators(gen),
145148
)

wasp/benchspy/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type QueryExecutor interface {
4646
}
4747

4848
type NamedGenerator interface {
49+
// GeneratorName returns the name of the generator
4950
GeneratorName() string
5051
}
5152

wasp/wasp.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,6 @@ func (g *Generator) Wait() (interface{}, bool) {
713713
g.dataCancel()
714714
g.dataWaitGroup.Wait()
715715
if g.Cfg.LokiConfig != nil {
716-
// g.dataCancel()
717-
// g.dataWaitGroup.Wait()
718716
g.stopLokiStream()
719717
}
720718
return g.GetData(), g.stats.RunFailed.Load()

0 commit comments

Comments
 (0)