Skip to content

feat(runtime): add support for buffered metrics#1922

Open
mjameswh wants to merge 8 commits intomainfrom
buffered-metrics
Open

feat(runtime): add support for buffered metrics#1922
mjameswh wants to merge 8 commits intomainfrom
buffered-metrics

Conversation

@mjameswh
Copy link
Contributor

@mjameswh mjameswh commented Feb 4, 2026

What was changed

@mjameswh mjameswh requested a review from a team as a code owner February 4, 2026 02:55
@mjameswh mjameswh requested a review from Copilot February 4, 2026 15:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds experimental support for buffered metrics, allowing metrics emitted by the Core SDK to be exported through a language-side exporter. This provides an alternative to the existing Prometheus and OpenTelemetry exporters by buffering metric events in memory and exposing them via the Runtime.retrieveBufferedMetrics() method.

Changes:

  • Added BufferedMetricsExporter configuration option with buffer size and duration unit settings
  • Implemented Runtime.retrieveBufferedMetrics() method to drain buffered metric updates
  • Extended metric interfaces with kind and valueType properties for runtime type information

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/workflow/src/metrics.ts Added kind and valueType properties to workflow metric implementations
packages/worker/src/runtime.ts Added retrieveBufferedMetrics() method and updated imports
packages/worker/src/runtime-options.ts Added BufferedMetricsExporter configuration type and compilation logic
packages/worker/src/runtime-metrics.ts Added BufferedMetricUpdate interface and kind/valueType properties to runtime metrics
packages/test/src/test-runtime-otel.ts New test file for OTEL metrics export functionality
packages/test/src/test-runtime-buffered-metrics.ts New test file for buffered metrics functionality
packages/test/src/test-otel.ts Refactored by moving OTEL test helpers to dedicated test file
packages/core-bridge/ts/native.ts Added native types for buffered metrics support
packages/core-bridge/src/runtime.rs Implemented buffered metrics buffer management in Rust runtime
packages/core-bridge/src/metrics.rs Implemented buffered metrics collection and conversion logic
packages/core-bridge/src/helpers/try_into_js.rs Added MemoizedHandle and OptionAsUndefined helper types
packages/core-bridge/bridge-macros/src/derive_tryintojs.rs Enhanced macro to support enum-to-string conversions
packages/common/src/metrics.ts Refactored metric types and added kind/valueType properties

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Clippy lint suggestions seem sensible.

res.write(
// This is a raw gRPC response, of length 0
Buffer.from([
new Uint8Array([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason for this change other than general Buffer -> Uint8Array migration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, that usage of Buffer was showing as an error in my editor, even though that was building fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjameswh mjameswh requested a review from Copilot February 4, 2026 19:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 18 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

packages/worker/src/runtime-metrics.ts:1

  • The documentation appears to be cut off mid-sentence at line 364. The sentence starting with 'Note that the SDK may miss deduplication opportunities' is incomplete.
import {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mjameswh mjameswh requested a review from Copilot February 4, 2026 21:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 18 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

[Feature Request] Forward Core's metrics to TypeScript-land

2 participants