shounakmk219 commented on code in PR #18823:
URL: https://github.com/apache/pinot/pull/18823#discussion_r3475343492


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/SegmentStatusChecker.java:
##########
@@ -194,6 +203,31 @@ private void updateTableConfigMetrics(String 
tableNameWithType, TableConfig tabl
     }
     int replication = tableConfig.getReplication();
     _controllerMetrics.setValueOfTableGauge(tableNameWithType, 
ControllerGauge.REPLICATION_FROM_CONFIG, replication);
+
+    updateTenantInfoGauge(tableNameWithType, tableConfig);
+  }
+
+  /**
+   * Emits a {@code tableTenantInfo} gauge keyed by server tenant name so 
Prometheus can extract the tenant as a
+   * label and join it onto other table-scoped metrics.  Always set to {@code 
1}.
+   * The gauge is registered once per unique (table, tenant) pair and only 
re-registered when the tenant changes,
+   * avoiding redundant metric writes on each periodic cycle.
+   * When the tenant changes, the new gauge is registered first to avoid a gap 
window, then the stale gauge is removed.
+   */
+  private void updateTenantInfoGauge(String tableNameWithType, TableConfig 
tableConfig) {
+    TenantConfig tenantConfig = tableConfig.getTenantConfig();
+    String serverTenant =
+        (tenantConfig != null && tenantConfig.getServer() != null) ? 
tenantConfig.getServer()
+            : TagNameUtils.DEFAULT_TENANT_NAME;
+
+    String previousTenant = _tableTenantMap.put(tableNameWithType, 
serverTenant);
+    if (serverTenant.equals(previousTenant)) {
+      return;
+    }
+    _controllerMetrics.setOrUpdateTableGauge(tableNameWithType, serverTenant, 
ControllerGauge.TABLE_TENANT_INFO, 1L);

Review Comment:
   Are we not tracking broker tenant? Also we may need to consider the tiered 
tenants as well. Checkout `TableConfigUtils.isRelevantToTenant` which pulls all 
the relevant tenants for a table. We can build on this util to expose a label 
tenantType (server, broker, tier, etc) on the metric. Wdyt?



-- 
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