Skip to content

Conversation

@yuandrew
Copy link
Contributor

@yuandrew yuandrew commented Dec 2, 2025

What was changed

Add resource_slots_cpu_usage and resource_slots_mem_usage metrics

Why?

Match Core and Java

Checklist

  1. Closes Add resource tuner metrics #2089

  2. How was this tested:
    Added a test

  3. Any docs updates needed?
    Should update https://docs.temporal.io/references/sdk-metrics#resource_slots_cpu_usage to include Go in the list of supported SDKs


Note

Adds resource_slots_cpu_usage and resource_slots_mem_usage gauges and emits them during PID decisions in the resource tuner, with accompanying tests.

  • Metrics:
    • Add constants metrics.ResourceSlotsCPUUsage and metrics.ResourceSlotsMemUsage.
  • Resource Tuner (contrib/resourcetuner):
    • Plumb metrics.Handler into pidDecision and TryReserveSlot to publish usage.
    • Implement publishResourceMetrics to update gauges with percent values.
  • Tests:
    • Update existing tests to pass a metrics handler.
    • Add test TestPidDecisionEmitsUsageMetrics verifying both gauges and values.

Written by Cursor Bugbot for commit 5b7e431. This will update automatically on new commits. Configure here.

@yuandrew yuandrew requested a review from a team as a code owner December 2, 2025 00:56
import (
"context"
"errors"
"go.temporal.io/sdk/internal/common/metrics"
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think we should be using internal in a external package

Copy link
Contributor

Choose a reason for hiding this comment

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

TBH I am surprised this isn't failing a lint error

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.

Add resource tuner metrics

2 participants