Skip to content

feat(metrics): add UpDownCounter to Buffered Metrics and RuntimeMetricMeter#2007

Merged
mjameswh merged 5 commits intotemporalio:mainfrom
gibbonjj:add_updowncounter_to_buffered_metrics
Apr 20, 2026
Merged

feat(metrics): add UpDownCounter to Buffered Metrics and RuntimeMetricMeter#2007
mjameswh merged 5 commits intotemporalio:mainfrom
gibbonjj:add_updowncounter_to_buffered_metrics

Conversation

@gibbonjj
Copy link
Copy Markdown
Contributor

@gibbonjj gibbonjj commented Apr 12, 2026

Summary

  • Adds the UpDownCounter metric instrument type (supports signed values) to the buffered metrics pipeline and RuntimeMetricMeter
  • Updates sdk-core submodule to pick up UpDownCounter support (temporalio/sdk-core#1180)
  • Enables otel feature on temporalio-common (required by sdk-core update)
  • Does not expose UpDownCounter on workflow or activity context meters — that will be a follow-up PR

This is step 1+2 of the breakdown from the previous PR review:

  1. Add support for UpDownCounter to Buffered Metrics
  2. Add support for UpDownCounter to RuntimeMetricMeter

Changes

  • packages/common/src/metrics.tsMetricUpDownCounter interface, MetricKind union, NoopMetricMeter, composed tags wrapper
  • packages/core-bridge/src/metrics.rs — Rust UpDownCounter struct, NAPI create/add functions, buffered metric SignedDelta + UpDownCounter handling
  • packages/core-bridge/ts/native.ts — native TS declarations, BufferedMetricKind update
  • packages/worker/src/runtime-metrics.tsRuntimeMetricUpDownCounter class, createUpDownCounter on meter
  • packages/test/src/test-runtime-buffered-metrics.ts — buffered metrics test with UpDownCounter including negative values

@gibbonjj gibbonjj requested a review from a team as a code owner April 12, 2026 01:11
@gibbonjj
Copy link
Copy Markdown
Contributor Author

@mjameswh here's the pr separating parts 1 and 2 out of #1980

…imeMetricMeter

Add the UpDownCounter metric instrument type, which supports adding
signed values (positive or negative), to the buffered metrics pipeline
and RuntimeMetricMeter. This does not yet expose UpDownCounter on
workflow or activity context meters.

- Update sdk-core submodule to pick up UpDownCounter support
- Add MetricUpDownCounter interface and update MetricKind type
- Add UpDownCounter NAPI bridge (Rust struct, create/add functions)
- Handle SignedDelta and UpDownCounter in buffered metric conversion
- Add RuntimeMetricUpDownCounter class
- Add NoopMetricMeter and composed tags support for UpDownCounter
- Add buffered metrics test covering UpDownCounter including negative values
- Enable otel feature on temporalio-common (required by sdk-core update)
@gibbonjj gibbonjj force-pushed the add_updowncounter_to_buffered_metrics branch from c0413df to 69118e3 Compare April 12, 2026 01:39
Comment thread packages/core-bridge/src/metrics.rs Outdated
Comment thread packages/core-bridge/ts/native.ts Outdated
Comment thread packages/core-bridge/Cargo.toml
Comment thread packages/core-bridge/src/metrics.rs Outdated
Comment thread packages/common/src/metrics.ts Outdated
Comment thread packages/common/src/metrics.ts Outdated
Comment thread packages/common/src/metrics.ts
Comment thread packages/worker/src/runtime-metrics.ts Outdated
@mjameswh
Copy link
Copy Markdown
Contributor

Thanks a lot @gibbonjj for bearing with me. Splitting your original PR definitely makes easier.

I flagged a few minor details to be fixed, they should all be straightforward to apply.

…buffered_metrics

# Conflicts:
#	packages/core-bridge/Cargo.lock
- Use #[derive(TryIntoJs)] on MetricKind enum (the derive macro
  produces 'up-down-counter' automatically), and rename the TS
  kind string from 'up_down_counter' to 'up-down-counter' to match
- Reorder newMetricUpDownCounter export and createUpDownCounter
  method to group with their respective creation siblings
- Add FIXME on MetricMeterWithComposedTags.createUpDownCounter
  guard noting it can go once up-down-counter support is complete
@gibbonjj
Copy link
Copy Markdown
Contributor Author

Thanks a lot @gibbonjj for bearing with me. Splitting your original PR definitely makes easier.

I flagged a few minor details to be fixed, they should all be straightforward to apply.

Thanks! addressed all of your comments 😄

@mjameswh
Copy link
Copy Markdown
Contributor

Awesome! Thanks @gibbonjj!

@mjameswh
Copy link
Copy Markdown
Contributor

There was a bug in the TryIntoJS derive macro. I just fixed it.

@mjameswh mjameswh merged commit 6aed8bd into temporalio:main Apr 20, 2026
50 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants