diff --git a/.github/actions/c-chain-reexecution-benchmark/action.yml b/.github/actions/c-chain-reexecution-benchmark/action.yml index bbe2bc38225d..001ee106e7bb 100644 --- a/.github/actions/c-chain-reexecution-benchmark/action.yml +++ b/.github/actions/c-chain-reexecution-benchmark/action.yml @@ -30,6 +30,10 @@ inputs: description: 'The duration of the AWS role to assume for S3 access.' required: true default: '43200' # 12 hours + prometheus-url: + description: 'The URL of the prometheus instance.' + required: true + default: '' prometheus-push-url: description: 'The push URL of the prometheus instance.' required: true @@ -93,6 +97,7 @@ runs: BENCHMARK_OUTPUT_FILE=${{ env.BENCHMARK_OUTPUT_FILE }} \ RUNNER_NAME=${{ inputs.runner_name }} \ METRICS_ENABLED=true + prometheus_url: ${{ inputs.prometheus-url }} prometheus_push_url: ${{ inputs.prometheus-push-url }} prometheus_username: ${{ inputs.prometheus-username }} prometheus_password: ${{ inputs.prometheus-password }} diff --git a/.github/workflows/c-chain-reexecution-benchmark-container.yml b/.github/workflows/c-chain-reexecution-benchmark-container.yml index fb84b4c95ffa..db12a98ad703 100644 --- a/.github/workflows/c-chain-reexecution-benchmark-container.yml +++ b/.github/workflows/c-chain-reexecution-benchmark-container.yml @@ -105,6 +105,7 @@ jobs: end-block: ${{ matrix.end-block }} block-dir-src: ${{ matrix.block-dir-src }} current-state-dir-src: ${{ matrix.current-state-dir-src }} + prometheus-url: ${{ secrets.PROMETHEUS_URL || '' }} prometheus-push-url: ${{ secrets.PROMETHEUS_PUSH_URL || '' }} prometheus-username: ${{ secrets.PROMETHEUS_USERNAME || '' }} prometheus-password: ${{ secrets.PROMETHEUS_PASSWORD || '' }} diff --git a/.github/workflows/c-chain-reexecution-benchmark-gh-native.yml b/.github/workflows/c-chain-reexecution-benchmark-gh-native.yml index e13d70690c60..174b8f36403b 100644 --- a/.github/workflows/c-chain-reexecution-benchmark-gh-native.yml +++ b/.github/workflows/c-chain-reexecution-benchmark-gh-native.yml @@ -95,6 +95,7 @@ jobs: end-block: ${{ matrix.end-block }} block-dir-src: ${{ matrix.block-dir-src }} current-state-dir-src: ${{ matrix.current-state-dir-src }} + prometheus-url: ${{ secrets.PROMETHEUS_URL || '' }} prometheus-push-url: ${{ secrets.PROMETHEUS_PUSH_URL || '' }} prometheus-username: ${{ secrets.PROMETHEUS_USERNAME || '' }} prometheus-password: ${{ secrets.PROMETHEUS_PASSWORD || '' }} diff --git a/tests/reexecute/c/vm_reexecute_test.go b/tests/reexecute/c/vm_reexecute_test.go index 63b32eb2b80d..9738c1bc38aa 100644 --- a/tests/reexecute/c/vm_reexecute_test.go +++ b/tests/reexecute/c/vm_reexecute_test.go @@ -18,6 +18,7 @@ import ( "time" "github.com/ava-labs/coreth/plugin/factory" + "github.com/google/uuid" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" "go.uber.org/zap" @@ -62,10 +63,12 @@ var ( executionTimeout time.Duration labelsArg string - labels = map[string]string{ + networkUUID string = uuid.NewString() + labels = map[string]string{ "job": "c-chain-reexecution", "is_ephemeral_node": "false", "chain": "C", + "network_uuid": networkUUID, } configKey = "config" @@ -174,7 +177,7 @@ func benchmarkReexecuteRange( r.NoError(prefixGatherer.Register("avalanche_snowman", consensusRegistry)) if metricsEnabled { - collectRegistry(b, "c-chain-reexecution", time.Minute, prefixGatherer, labels) + collectRegistry(b, "c-chain-reexecution", prefixGatherer, labels) } log := tests.NewDefaultLogger("c-chain-reexecution") @@ -541,13 +544,14 @@ func newConsensusMetrics(registry prometheus.Registerer) (*consensusMetrics, err // collectRegistry starts prometheus and collects metrics from the provided gatherer. // Attaches the provided labels + GitHub labels if available to the collected metrics. -func collectRegistry(tb testing.TB, name string, timeout time.Duration, gatherer prometheus.Gatherer, labels map[string]string) { +func collectRegistry(tb testing.TB, name string, gatherer prometheus.Gatherer, labels map[string]string) { r := require.New(tb) - ctx, cancel := context.WithTimeout(context.Background(), timeout) - tb.Cleanup(cancel) + startPromCtx, cancel := context.WithTimeout(context.Background(), tests.DefaultTimeout) + defer cancel() - r.NoError(tmpnet.StartPrometheus(ctx, tests.NewDefaultLogger("prometheus"))) + logger := tests.NewDefaultLogger("prometheus") + r.NoError(tmpnet.StartPrometheus(startPromCtx, logger)) server, err := tests.NewPrometheusServer(gatherer) r.NoError(err) @@ -567,6 +571,10 @@ func collectRegistry(tb testing.TB, name string, timeout time.Duration, gatherer return nil }(), )) + + checkMetricsCtx, cancel := context.WithTimeout(context.Background(), tests.DefaultTimeout) + defer cancel() + r.NoError(tmpnet.CheckMetricsExist(checkMetricsCtx, logger, networkUUID)) }) sdConfigFilePath, err = tmpnet.WritePrometheusSDConfig(name, tmpnet.SDConfig{