Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail fast on empty wasmvm cache metric setup #1576

Merged
merged 1 commit into from
Aug 28, 2023
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
3 changes: 3 additions & 0 deletions x/wasm/keeper/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

// NewWasmVMMetricsCollector constructor
func NewWasmVMMetricsCollector(s metricSource) *WasmVMMetricsCollector {
if s == nil {
panic("wasmvm instance must not be nil")

Check warning on line 33 in x/wasm/keeper/metrics.go

View check run for this annotation

Codecov / codecov/patch

x/wasm/keeper/metrics.go#L33

Added line #L33 was not covered by tests
}
return &WasmVMMetricsCollector{
source: s,
CacheHitsDescr: prometheus.NewDesc("wasmvm_cache_hits_total", "Total number of cache hits", []string{"type"}, nil),
Expand Down
10 changes: 10 additions & 0 deletions x/wasm/keeper/options_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"github.com/prometheus/client_golang/prometheus"
"reflect"
"testing"

Expand Down Expand Up @@ -31,6 +32,15 @@ func TestConstructorOptions(t *testing.T) {
assert.IsType(t, &wasmtesting.MockWasmer{}, k.wasmVM)
},
},
"vm cache metrics": {
srcOpt: WithVMCacheMetrics(prometheus.DefaultRegisterer),
verify: func(t *testing.T, k Keeper) {
t.Helper()
registered := prometheus.DefaultRegisterer.Unregister(NewWasmVMMetricsCollector(k.wasmVM))
assert.True(t, registered)
},
isPostOpt: true,
},
"decorate wasmvm": {
srcOpt: WithWasmEngineDecorator(func(old types.WasmerEngine) types.WasmerEngine {
require.IsType(t, &wasmvm.VM{}, old)
Expand Down