diff --git a/pkg/ccl/serverccl/adminccl/tenant_admin_test.go b/pkg/ccl/serverccl/adminccl/tenant_admin_test.go index 70b2d93e1c4a..22e33a6d946b 100644 --- a/pkg/ccl/serverccl/adminccl/tenant_admin_test.go +++ b/pkg/ccl/serverccl/adminccl/tenant_admin_test.go @@ -48,6 +48,19 @@ func TestTenantAdminAPI(t *testing.T) { t.Run("tenant_unimplemented", func(t *testing.T) { testUnimplementedRPCs(ctx, t, testHelper) }) + + t.Run("tenant_metricmetadata", func(t *testing.T) { + testMetricMetadataRPC(ctx, t, testHelper) + }) +} + +func testMetricMetadataRPC(ctx context.Context, t *testing.T, helper serverccl.TenantTestHelper) { + http := helper.TestCluster().TenantAdminHTTPClient(t, 1) + defer http.Close() + + metricMetadataResp := serverpb.MetricMetadataResponse{} + http.GetJSON("/_admin/v1/metricmetadata", &metricMetadataResp) + require.NotEmpty(t, metricMetadataResp.Metadata) } func testUnimplementedRPCs(ctx context.Context, t *testing.T, helper serverccl.TenantTestHelper) { diff --git a/pkg/server/status/recorder.go b/pkg/server/status/recorder.go index 920303cfcf82..d324adfcbf48 100644 --- a/pkg/server/status/recorder.go +++ b/pkg/server/status/recorder.go @@ -359,13 +359,17 @@ func (mr *MetricsRecorder) GetMetricsMetadata() map[string]metric.Metadata { // Get a random storeID. var sID roachpb.StoreID + storeFound := false for storeID := range mr.mu.storeRegistries { sID = storeID + storeFound = true break } // Get metric metadata from that store because all stores have the same metadata. - mr.mu.storeRegistries[sID].WriteMetricsMetadata(metrics) + if storeFound { + mr.mu.storeRegistries[sID].WriteMetricsMetadata(metrics) + } return metrics }