Skip to content

NamespaceMetricCapture in Nexus tests#9938

Merged
stephanos merged 6 commits intomainfrom
stephanos/nexus-new-metrics
Apr 14, 2026
Merged

NamespaceMetricCapture in Nexus tests#9938
stephanos merged 6 commits intomainfrom
stephanos/nexus-new-metrics

Conversation

@stephanos
Copy link
Copy Markdown
Contributor

@stephanos stephanos commented Apr 13, 2026

What changed?

Use the new NamespaceMetricCapture etc in Nexus tests.

Why?

Allows to remove a few dedicated cluster options; ie run faster.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

@stephanos stephanos force-pushed the stephanos/nexus-new-metrics branch 3 times, most recently from ed9af24 to 1655e0e Compare April 13, 2026 23:43
env *NexusTestEnv,
url string,
completion nexusrpc.CompleteOperationOptions,
) (map[string][]*metricstest.CapturedRecording, error) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Callers track metrics themselves now because they need to distinguish between namespace vs global

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice! It does look better to have the caller do the metric stuff rather than scattering part of it here

@stephanos stephanos force-pushed the stephanos/nexus-new-metrics branch 2 times, most recently from bfc5322 to da88682 Compare April 13, 2026 23:51
@stephanos stephanos force-pushed the stephanos/nexus-new-metrics branch from da88682 to b8aaae9 Compare April 13, 2026 23:58

func (s *NexusWorkflowTestSuite) sendNexusCompletionRequest(
ctx context.Context,
env *NexusTestEnv,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not needed anymore


s.Run("NamespaceNotFoundNoIdentifier", func(s *NexusWorkflowTestSuite) {
env := s.newNexusWorkflowTestEnv(chasmEnabled)
env := s.newNexusWorkflowTestEnv(chasmEnabled, testcore.WithDedicatedCluster())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added wherever StartGlobalMetricCapture was used

}

func (s *NexusAPIValidationTestSuite) TestNexusStartOperation_WithNamespaceAndTaskQueue_NamespaceNotFound() {
env := newNexusTestEnv(s.T(), false, testcore.WithDedicatedCluster())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not needed as using StartNamespaceMetricCapture

@stephanos stephanos marked this pull request as ready for review April 14, 2026 00:14
@stephanos stephanos requested review from a team as code owners April 14, 2026 00:14
@stephanos stephanos requested a review from long-nt-tran April 14, 2026 00:14

testFn := func(s *NexusApiTestSuite, tc testcase, dispatchOnlyByEndpoint bool) {
env := newNexusTestEnv(s.T(), useTemporalFailures, testcore.WithDedicatedCluster())
env.GetTestCluster().Host().SetOnAuthorize(func(ctx context.Context, c *authorization.Claims, ct *authorization.CallTarget) (authorization.Result, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe a comment around here mentioning we still need dedicated cluster because of these calls (since some other parameterized tests are now done without dedicated cluster thanks to the new metric capture)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍 added

ctx := testcore.NewContext()
capture := env.GetTestCluster().Host().CaptureMetricsHandler().StartCapture()
defer env.GetTestCluster().Host().CaptureMetricsHandler().StopCapture(capture)
capture := env.StartNamespaceMetricCapture().ForNamespace(namespace)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I get the intent is to find the metric tagged w/ the nonexistent namespace, but it seems a bit awkward to create a metric capture for namespace-1 and then immediately filter by namespace-2.

I thought about this a bit, I think we can also do:

  1. StartGlobalMetricCapture() and then later filter by namespace. I think this is fine aside from the panic in metric_capture.go if all metric are namespace-scoped. Maybe not preferable if you want to keep the panic to nudge people to use the right scope of capture
  2. Maybe a StartNamespaceMetricCapture(namespace string) function that allows you to capture from a specific namespace (or namespaces?) at capture start. I think it might read less awkward than starting capture in namespace-1 and then filter by namespace-2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a good call, there's only one use case right now but let's add StartNamespaceMetricCaptureFor to allow passing a custom namespace in (Go doesn't allow method overloading) as that's def clearer.

env *NexusTestEnv,
url string,
completion nexusrpc.CompleteOperationOptions,
) (map[string][]*metricstest.CapturedRecording, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice! It does look better to have the caller do the metric stuff rather than scattering part of it here

@stephanos stephanos enabled auto-merge (squash) April 14, 2026 18:27
@stephanos stephanos merged commit decbba0 into main Apr 14, 2026
67 of 70 checks passed
@stephanos stephanos deleted the stephanos/nexus-new-metrics branch April 14, 2026 20:42
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