spacemonkd commented on code in PR #11243:
URL: https://github.com/apache/ozone/pull/11243#discussion_r4142731322


##########
ozone-ui/packages/om/src/api/metrics.ts:
##########
@@ -0,0 +1,346 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** JMX query for the OM metrics bean (RPC operation counters + object 
counts). */
+export const OM_METRICS_QUERY = 'Hadoop:service=OzoneManager,name=OMMetrics';
+
+/**
+ * Operation categories exposed by `OMMetrics` as `Num<Type><Op>` counters. 
Order
+ * seeds the metric-type dropdown; a type with no activity is disabled there. 
Any
+ * category found in the bean but missing here is still surfaced (appended), 
so a
+ * newly added OM metric type is never silently dropped.
+ */
+export const METRIC_TYPES = [
+  'Get',
+  'Abort',
+  'Add',
+  'Block',
+  'Bucket',
+  'Cancel',
+  'Commit',
+  'Complete',
+  'Create',
+  'Delete',
+  'Expired',
+  'Follower',
+  'Initiate',
+  'Key',
+  'Leader',
+  'Linearizable',
+  'List',
+  'Lookup',
+  'Open',
+  'Put',
+  'Recover',
+  'Remove',
+  'Set',
+  'Snapshot',
+  'Tenant',
+  'Trash',
+  'Volume',
+] as const;
+
+export type MetricType = (typeof METRIC_TYPES)[number];
+
+/** Raw OM metrics JMX bean — dynamic `Num*`/count keys plus string tags. */
+export type OMMetricsBean = Record<string, number | string>;
+
+export type OperationStatus = 'Active' | 'Warning' | 'Inactive';
+
+export interface MetricOperation {
+  key: string;
+  /** Canonical operation label (e.g. `Allocate`, `Commit`, `Delete`). */
+  name: string;
+  /** Successful request count for this operation. */
+  requests: number;
+  /** Failure count for this operation. */
+  failures: number;
+  status: OperationStatus;
+}
+
+export interface MetricTypeData {
+  type: string;
+  /** Total requests: the sum of the requests of the operations shown for this 
type. */
+  totalRequests: number;
+  /** Operations with any activity (requests or failures), busiest first. */
+  operations: MetricOperation[];
+  /** False when the type has no activity at all — its dropdown option is 
greyed out. */
+  enabled: boolean;
+}
+
+export interface MetricsSummary {
+  volumes: number;
+  buckets: number;
+  keys: number;
+  totalCommittedBytes: number;
+}
+
+export interface ParsedOmMetrics {
+  summary: MetricsSummary;
+  byType: Record<string, MetricTypeData>;
+}
+
+/**
+ * Request metric key: `Num<Type><Op>` — two CamelCase segments after `Num`, 
e.g.
+ * `NumKeyCommits` → type `Key`, op `Commits`. Single-word counters such as
+ * `NumKeys`/`NumVolumes` (no `<Op>` segment) intentionally do not match, so 
object
+ * counts are never treated as operations.
+ */
+const REQUEST_KEY_RE = /^Num([A-Z][a-z]+)([A-Z].+)$/;

Review Comment:
   @chihsuan Thanks for the idea. Mostly I wanted to avoid it since adding new 
metrics would need extra changes.
   But looking at longer term stability fixed keys are better than regex 
matching.
   
   I updated the change and added a new catalog to map the metric to the key.
   Could you take another look?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to