Skip to content
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
2 changes: 1 addition & 1 deletion pkg/workflows/wasm/host/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (e *execution[T]) log(caller *wasmtime.Caller, ptr int32, ptrlen int32) {
}

func (e *execution[T]) emitMetric(caller *wasmtime.Caller, ptr int32, ptrlen int32) int32 {
if !e.module.cfg.EnableUserMetrics {
if err := e.module.cfg.EnableUserMetricsLimiter.AllowErr(e.ctx); err != nil {
Comment thread
karen-stepanyan marked this conversation as resolved.
return -1
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/workflows/wasm/host/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type ModuleConfig struct {
MaxLogCountDONMode uint32
MaxLogCountNodeMode uint32

EnableUserMetrics bool
EnableUserMetricsLimiter limits.GateLimiter
MaxUserMetricPayloadBytes uint32
MaxUserMetricPayloadLimiter limits.BoundLimiter[config.Size] // supersedes MaxUserMetricPayloadBytes if set
Comment thread
karen-stepanyan marked this conversation as resolved.
MaxUserMetricNameLength uint32
Expand Down Expand Up @@ -248,6 +248,10 @@ func NewModule(ctx context.Context, modCfg *ModuleConfig, binary []byte, opts ..

lf := limits.Factory{Logger: modCfg.Logger}

if modCfg.EnableUserMetricsLimiter == nil {
modCfg.EnableUserMetricsLimiter = limits.NewGateLimiter(false)
}

if modCfg.MaxUserMetricPayloadLimiter == nil {
limit := settings.Size(config.Size(modCfg.MaxUserMetricPayloadBytes))
var err error
Expand Down
12 changes: 6 additions & 6 deletions pkg/workflows/wasm/host/wasm_nodag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/capabilities/v2/protoc/pkg/test_capabilities/basictrigger"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/settings/limits"
"github.com/smartcontractkit/chainlink-protos/cre/go/sdk"
wfpb "github.com/smartcontractkit/chainlink-protos/workflows/go/v2"

Expand Down Expand Up @@ -158,9 +159,9 @@ func Test_NoDAG_EmitMetricWithLimits(t *testing.T) {
trigger := &basictrigger.Outputs{CoolOutput: anyTestTriggerValue}
executeRequest := triggerExecuteRequest(t, 0, trigger)
cfg := &ModuleConfig{
Logger: logger.Test(t),
IsUncompressed: true,
EnableUserMetrics: true,
Logger: logger.Test(t),
IsUncompressed: true,
EnableUserMetricsLimiter: limits.NewGateLimiter(true),
MaxUserMetricPayloadBytes: 4096,
MaxUserMetricNameLength: 15,
MaxUserMetricLabelsPerMetric: 10,
Expand Down Expand Up @@ -198,9 +199,8 @@ func Test_NoDAG_EmitMetricDisabled(t *testing.T) {
trigger := &basictrigger.Outputs{CoolOutput: anyTestTriggerValue}
executeRequest := triggerExecuteRequest(t, 0, trigger)
cfg := &ModuleConfig{
Logger: logger.Test(t),
IsUncompressed: true,
EnableUserMetrics: false,
Logger: logger.Test(t),
IsUncompressed: true,
}

binary := createTestBinary(metricLimitsBinaryCmd, metricLimitsBinaryLocation, true, t)
Expand Down
Loading