add emitMetric global fn#231
Merged
Merged
Conversation
5402424 to
03f110a
Compare
nolag
reviewed
Apr 28, 2026
| } | ||
|
|
||
| emitMetric(payload: Uint8Array): boolean { | ||
| return hostBindings.emitMetric(payload) >= 0 |
Contributor
There was a problem hiding this comment.
Do we want to instead have the host return an error message we can throw? The magnitude of the negative number usually indicates how long that message is.
That said, metrics are usually async. When do we expect this to return false? Should we instead just make it void?
Author
There was a problem hiding this comment.
the host returns negative on validation or rate limit errors
https://github.com/smartcontractkit/chainlink-common/blob/b1fd6cbfea8000121d85902f59fff4bfe0cef26f/pkg/workflows/wasm/host/execution.go#L188
and since all the errors are -1 I just converted this to boolean
nolag
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://smartcontract-it.atlassian.net/browse/DF-23782
Add emitMetric host function and runtime.emitMetric(...) SDK API
Javy plugin
TypeScript SDK
workflows.v2.WorkflowUserMetricby adding the proto to buf.gen.yaml.emitMetric(payload: Uint8Array): booleanto the internal RuntimeHelpers interface and implemented it for both the WASM runtime (hostBindings.emitMetric) and the test runtime (captures payloads on TestWriter).runtime.emitMetric(name, value, 'counter' | 'gauge', labels?)