Skip to content

Commit 3651f47

Browse files
committed
chore: revert unification of metrics server param
1 parent 830e8c1 commit 3651f47

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

.github/actions/c-chain-reexecution-benchmark/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ runs:
9595
LABELS=${{ env.LABELS }} \
9696
BENCHMARK_OUTPUT_FILE=${{ env.BENCHMARK_OUTPUT_FILE }} \
9797
RUNNER_NAME=${{ inputs.runner_name }} \
98+
METRICS_SERVER_ENABLED=true \
9899
METRICS_COLLECTOR_ENABLED=true
99100
prometheus_url: ${{ inputs.prometheus-url }}
100101
prometheus_push_url: ${{ inputs.prometheus-push-url }}

Taskfile.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ tasks:
207207
END_BLOCK: '{{.END_BLOCK}}'
208208
LABELS: '{{.LABELS | default ""}}'
209209
BENCHMARK_OUTPUT_FILE: '{{.BENCHMARK_OUTPUT_FILE | default ""}}'
210+
METRICS_SERVER_ENABLED: '{{.METRICS_SERVER_ENABLED | default "false"}}'
210211
METRICS_SERVER_PORT: '{{.METRICS_SERVER_PORT}}'
211212
METRICS_COLLECTOR_ENABLED: '{{.METRICS_COLLECTOR_ENABLED | default "false"}}'
212213
cmd: |
@@ -218,6 +219,7 @@ tasks:
218219
END_BLOCK={{.END_BLOCK}} \
219220
LABELS={{.LABELS}} \
220221
BENCHMARK_OUTPUT_FILE={{.BENCHMARK_OUTPUT_FILE}} \
222+
METRICS_SERVER_ENABLED={{.METRICS_SERVER_ENABLED}} \
221223
METRICS_SERVER_PORT={{.METRICS_SERVER_PORT}} \
222224
METRICS_COLLECTOR_ENABLED={{.METRICS_COLLECTOR_ENABLED}} \
223225
bash -x ./scripts/benchmark_cchain_range.sh
@@ -234,6 +236,7 @@ tasks:
234236
END_BLOCK: '{{.END_BLOCK | default "250000"}}'
235237
LABELS: '{{.LABELS | default ""}}'
236238
BENCHMARK_OUTPUT_FILE: '{{.BENCHMARK_OUTPUT_FILE | default ""}}'
239+
METRICS_SERVER_ENABLED: '{{.METRICS_SERVER_ENABLED | default "false"}}'
237240
METRICS_SERVER_PORT: '{{.METRICS_SERVER_PORT}}'
238241
METRICS_COLLECTOR_ENABLED: '{{.METRICS_COLLECTOR_ENABLED | default "false"}}'
239242
cmds:
@@ -252,6 +255,7 @@ tasks:
252255
END_BLOCK: '{{.END_BLOCK}}'
253256
LABELS: '{{.LABELS}}'
254257
BENCHMARK_OUTPUT_FILE: '{{.BENCHMARK_OUTPUT_FILE}}'
258+
METRICS_SERVER_ENABLED: '{{.METRICS_SERVER_ENABLED}}'
255259
METRICS_SERVER_PORT: '{{.METRICS_SERVER_PORT}}'
256260
METRICS_COLLECTOR_ENABLED: '{{.METRICS_COLLECTOR_ENABLED}}'
257261

scripts/benchmark_cchain_range.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set -euo pipefail
1010
# END_BLOCK: The ending block height (inclusive).
1111
# LABELS (optional): Comma-separated key=value pairs for metric labels.
1212
# BENCHMARK_OUTPUT_FILE (optional): If set, benchmark output is also written to this file.
13+
# METRICS_SERVER_ENABLED (optional): If set, enables the metrics server.
1314
# METRICS_SERVER_PORT (optional): If set, determines the port the metrics server will listen to.
1415
# METRICS_COLLECTOR_ENABLED (optional): If set, enables the metrics collector.
1516

@@ -27,6 +28,7 @@ cmd="go test -timeout=0 -v -benchtime=1x -bench=BenchmarkReexecuteRange -run=^$
2728
--start-block=\"${START_BLOCK}\" \
2829
--end-block=\"${END_BLOCK}\" \
2930
${LABELS:+--labels=\"${LABELS}\"} \
31+
${METRICS_SERVER_ENABLED:+--metrics-server-enabled=\"${METRICS_SERVER_ENABLED}\"} \
3032
${METRICS_SERVER_PORT:+--metrics-server-port=\"${METRICS_SERVER_PORT}\"} \
3133
${METRICS_COLLECTOR_ENABLED:+--metrics-collector-enabled=\"${METRICS_COLLECTOR_ENABLED}\"}"
3234

tests/reexecute/c/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ export AWS_REGION=us-east-2
4444

4545
If running locally, metrics collection can be customized via the following parameters:
4646

47-
- `METRICS_SERVER_PORT`: if set, starts a Prometheus server exporting VM metrics and sets the port the server will listen to.
48-
- `METRICS_COLLECTOR_ENABLED`: starts a Prometheus collector. If `METRICS_SERVER_PORT` is not set, enabling the collector implicitly sets `METRICS_SERVER_PORT` to `0`.
47+
- `METRICS_SERVER_ENABLED`: starts a Prometheus server exporting VM metrics.
48+
- `METRICS_SERVER_PORT`: if set, determines the port the Prometheus server will listen to (set to `0` by default).
49+
- `METRICS_COLLECTOR_ENABLED`: starts a Prometheus collector. If `METRICS_SERVER_ENABLED` is not set, enabling the collector implicitly sets `METRICS_SERVER_ENABLED` to `true`.
4950

5051
When utilizing the metrics collector feature, follow the instructions in the e2e [README](../../e2e/README.md#monitoring) to set the required Prometheus environment variables.
5152

52-
Running the re-execution test in CI will always set `METRICS_COLLECTOR_ENABLED=true`.
53+
Running the re-execution test in CI will always set `METRICS_SERVER_ENABLED=true` and `METRICS_COLLECTOR_ENABLED=true`.
5354

5455
## Quick Start
5556

@@ -237,7 +238,7 @@ The `CONFIG` parameter currently only supports pre-defined configs and not passi
237238

238239
The C-Chain benchmarks export VM metrics to the same Grafana instance as AvalancheGo CI: https://grafana-poc.avax-dev.network/.
239240

240-
To export metrics for a local run, simply set the Taskfile variable `METRICS_COLLECTOR_ENABLED=true` either via environment variable or passing it at the command line.
241+
To export metrics for a local run, simply set the Taskfile variables `METRICS_SERVER_ENABLED=true` and `METRICS_COLLECTOR_ENABLED=true` either via environment variable or passing it at the command line.
241242

242243
You can view granular C-Chain processing metrics with the label attached to this job (job="c-chain-reexecution") [here](https://grafana-poc.avax-dev.network/d/Gl1I20mnk/c-chain?orgId=1&from=now-5m&to=now&timezone=browser&var-datasource=P1809F7CD0C75ACF3&var-filter=job%7C%3D%7Cc-chain-reexecution&var-chain=C&refresh=10s).
243244

tests/reexecute/c/vm_reexecute_test.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ var (
6363
executionTimeout time.Duration
6464
labelsArg string
6565

66-
metricsServerPort *uint64
66+
metricsServerEnabledArg bool
67+
metricsServerPortArg uint64
6768
metricsCollectorEnabledArg bool
6869

6970
networkUUID string = uuid.NewString()
@@ -104,16 +105,8 @@ func TestMain(m *testing.M) {
104105
flag.IntVar(&chanSizeArg, "chan-size", 100, "Size of the channel to use for block processing.")
105106
flag.DurationVar(&executionTimeout, "execution-timeout", 0, "Benchmark execution timeout. After this timeout has elapsed, terminate the benchmark without error. If 0, no timeout is applied.")
106107

107-
flag.Func("metrics-server-port", "Starts a metrics server and sets the port it will listen to", func(s string) error {
108-
port, err := strconv.ParseUint(s, 10, 64)
109-
if err != nil {
110-
return err
111-
}
112-
113-
metricsServerPort = new(uint64)
114-
*metricsServerPort = port
115-
return nil
116-
})
108+
flag.BoolVar(&metricsServerEnabledArg, "metrics-server-enabled", false, "Whether to enable the metrics server.")
109+
flag.Uint64Var(&metricsServerPortArg, "metrics-server-port", 0, "The port the metrics server will listen to.")
117110
flag.BoolVar(&metricsCollectorEnabledArg, "metrics-collector-enabled", false, "Whether to enable the metrics collector (if true, then metrics-server-enabled must be true as well).")
118111
flag.StringVar(&labelsArg, "labels", "", "Comma separated KV list of metric labels to attach to all exported metrics. Ex. \"owner=tim,runner=snoopy\"")
119112

@@ -128,8 +121,8 @@ func TestMain(m *testing.M) {
128121

129122
flag.Parse()
130123

131-
if metricsCollectorEnabledArg && metricsServerPort == nil {
132-
metricsServerPort = new(uint64)
124+
if metricsCollectorEnabledArg {
125+
metricsServerEnabledArg = true
133126
}
134127

135128
customLabels, err := parseCustomLabels(labelsArg)
@@ -165,7 +158,8 @@ func BenchmarkReexecuteRange(b *testing.B) {
165158
startBlockArg,
166159
endBlockArg,
167160
chanSizeArg,
168-
metricsServerPort,
161+
metricsServerEnabledArg,
162+
metricsServerPortArg,
169163
metricsCollectorEnabledArg,
170164
)
171165
})
@@ -179,7 +173,8 @@ func benchmarkReexecuteRange(
179173
startBlock uint64,
180174
endBlock uint64,
181175
chanSize int,
182-
metricsPort *uint64,
176+
metricsServerEnabled bool,
177+
metricsPort uint64,
183178
metricsCollectorEnabled bool,
184179
) {
185180
r := require.New(b)
@@ -199,8 +194,8 @@ func benchmarkReexecuteRange(
199194

200195
log := tests.NewDefaultLogger("c-chain-reexecution")
201196

202-
if metricsPort != nil {
203-
serverAddr := startServer(b, log, prefixGatherer, *metricsPort)
197+
if metricsServerEnabled {
198+
serverAddr := startServer(b, log, prefixGatherer, metricsPort)
204199

205200
if metricsCollectorEnabled {
206201
startCollector(b, log, "c-chain-reexecution", labels, serverAddr)

0 commit comments

Comments
 (0)