grafana/k6 · error
failed to register GRPC module metrics
Error message
failed to register GRPC module metrics: %w
What it means
Raised in the grpc RootModule's NewModuleInstance when registerMetrics fails against the metric registry — a metric name collision or registry error at module instantiation. This is thrown as a script runtime exception via common.Throw, not returned.
Solutions
- Check for custom or extension metrics conflicting with the built-in grpc metric names (grpc_req_duration etc.)
- Report as a k6 bug if no conflicting metric registration exists
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/grpc/grpc.go:47 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/b1ca338afd1cf4f0.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/grpc/grpc.go:47
}
)
var (
_ modules.Module = &RootModule{}
_ modules.Instance = &ModuleInstance{}
)
// New returns a pointer to a new RootModule instance.
func New() *RootModule {
return &RootModule{}
}
// NewModuleInstance implements the modules.Module interface to return
// a new instance for each VU.
func (r *RootModule) NewModuleInstance(vu modules.VU) modules.Instance {
metrics, err := registerMetrics(vu.InitEnv().Registry)
if err != nil {
common.Throw(vu.Runtime(), fmt.Errorf("failed to register GRPC module metrics: %w", err))
}
mi := &ModuleInstance{
vu: vu,
exports: make(map[string]any),
metrics: metrics,
}
mi.exports["Client"] = mi.NewClient
mi.defineConstants()
mi.exports["Stream"] = mi.stream
return mi
}
// NewClient is the JS constructor for the grpc Client.
func (mi *ModuleInstance) NewClient(_ sobek.ConstructorCall) *sobek.Object {
rt := mi.vu.Runtime()View on GitHub (pinned to 01ffac6f24)