CRE: Add support for user emitted wf metrics#1924
CRE: Add support for user emitted wf metrics#1924karen-stepanyan wants to merge 3 commits intomainfrom
Conversation
|
| LogLineLimit Setting[config.Size] | ||
| LogEventLimit Setting[int] `unit:"{log}"` | ||
|
|
||
| MetricEnabled Setting[bool] |
|
|
||
| if err := e.module.cfg.MaxMetricPayloadLimiter.Check(e.ctx, config.Size(ptrlen)); err != nil { | ||
| e.module.cfg.Logger.Warnf("metric payload too large: %d bytes - dropping: %s", ptrlen, err) | ||
| return -1 |
There was a problem hiding this comment.
Shouldn't we return a better error code? cc @nolag
d700a9c to
c8f6eec
Compare
There was a problem hiding this comment.
Pull request overview
Adds initial support for user-emitted workflow metrics from WASM (NoDAG) modules, including host-side validation/limits, test coverage, and CRE settings schema/default updates.
Changes:
- Link a new WASM host import (
env.emit_metric) and implement host-side decoding + limit enforcement for user metrics. - Extend host execution plumbing (config +
ExecutionHelper) and add NoDAG tests plus a new WASM test module for metrics. - Add new CRE settings fields and defaults for metric enablement and metric limits (payload/name/labels).
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflows/wasm/host/wasm_nodag_test.go | Adds NoDAG tests for metric emission limits and the disabled behavior. |
| pkg/workflows/wasm/host/test/metric_limits/cmd/main_wasip1.go | Adds a WASI test module that emits several user metrics for limit testing. |
| pkg/workflows/wasm/host/module.go | Adds metric-related config/limiters, extends ExecutionHelper, and links the new emit_metric import. |
| pkg/workflows/wasm/host/mock_execution_helper_test.go | Updates generated mock to include EmitUserMetric. |
| pkg/workflows/wasm/host/internal/rawsdk/helpers_wasip1.go | Adds the raw WASM import declaration for emit_metric. |
| pkg/workflows/wasm/host/execution.go | Implements emitMetric handler (proto decode + limit checks + forwarding). |
| pkg/settings/cresettings/settings.go | Adds metric settings to the schema/types. |
| pkg/settings/cresettings/defaults.toml | Adds default values for metric settings. |
| pkg/settings/cresettings/defaults.json | Adds default values for metric settings. |
| pkg/settings/cresettings/README.md | Documents metric settings in the limits diagram. |
| go.mod | Bumps workflows protos dependency to a version that includes metric protos. |
| go.sum | Updates checksums for the bumped workflows protos dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| EmitUserLog(log string) error | ||
|
|
There was a problem hiding this comment.
ExecutionHelper is an exported interface in a public module (chainlink-common). Adding EmitUserMetric makes this a breaking API change for any downstream implementers. Consider introducing a separate optional interface (e.g., type UserMetricEmitter interface { EmitUserMetric(*wfpb.WorkflowUserMetric) error }) and using a type assertion at call sites, or providing a new wrapper type, to keep backward compatibility.
| EmitUserLog(log string) error | |
| EmitUserLog(log string) error | |
| } | |
| // UserMetricEmitter can be implemented optionally to support emitting user metrics. | |
| type UserMetricEmitter interface { |
https://smartcontract-it.atlassian.net/browse/DF-23780