Skip to content

Commit

Permalink
[#23557] Remove empty CatCacheIdMisses_End metric
Browse files Browse the repository at this point in the history
Summary:
`PgPrometheusMetricsHandler` is treating `CatCacheMisses_End` in the `statementType` enum as a metric and publishes these empty metric names:

```
_count{metric_id="yb.ysqlserver",metric_type="server",exported_instance="yb-15-kfranz-catcache-chart-1-n1"} 0 1723844460867
_sum{metric_id="yb.ysqlserver",metric_type="server",exported_instance="yb-15-kfranz-catcache-chart-1-n1"} 0 1723844460867
```

This revision fixes that behavior, removing the empty metrics.

Test Plan:
```
./yb_build.sh --cxx-test pgwrapper_pg_libpq-test --gtest_filter PgLibPqTest.CatalogCacheIdMissMetricsTest
```

Reviewers: myang

Reviewed By: myang

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D37372
  • Loading branch information
kai-franz committed Aug 20, 2024
1 parent 67147d2 commit 6daf129
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/postgres/yb-extensions/yb_pg_metrics/yb_pg_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ typedef enum statementType
CatCacheIdMisses_76,
CatCacheIdMisses_77,
CatCacheIdMisses_78,
CatCacheIdMisses_End,
CatCacheIdMisses_End = CatCacheIdMisses_78,
kMaxStatementType
} statementType;
int num_entries = kMaxStatementType;
Expand Down Expand Up @@ -278,7 +278,7 @@ set_metric_names(void)
strcpy(ybpgm_table[Transaction].name, YSQL_METRIC_PREFIX "Transactions");
strcpy(ybpgm_table[AggregatePushdown].name, YSQL_METRIC_PREFIX "AggregatePushdowns");
strcpy(ybpgm_table[CatCacheMisses].name, YSQL_METRIC_PREFIX "CatalogCacheMisses");
for (int i = CatCacheIdMisses_Start; i < CatCacheIdMisses_End; ++i)
for (int i = CatCacheIdMisses_Start; i <= CatCacheIdMisses_End; ++i)
{
int cache_id = i - CatCacheIdMisses_Start;
char index_name[NAMEDATALEN + 16];
Expand Down Expand Up @@ -623,7 +623,7 @@ _PG_init(void)

prev_ProcessUtility = ProcessUtility_hook;
ProcessUtility_hook = ybpgm_ProcessUtility;
static_assert(SysCacheSize == CatCacheIdMisses_End - CatCacheIdMisses_Start,
static_assert(SysCacheSize == CatCacheIdMisses_End - CatCacheIdMisses_Start + 1,
"Wrong catalog cache number");
}

Expand Down Expand Up @@ -783,7 +783,7 @@ ybpgm_ExecutorEnd(QueryDesc *queryDesc)
*/
ybpgm_StoreCount(CatCacheMisses, 0, total_delta);
if (total_delta > 0)
for (int i = CatCacheIdMisses_Start; i < CatCacheIdMisses_End; ++i)
for (int i = CatCacheIdMisses_Start; i <= CatCacheIdMisses_End; ++i)
{
int j = i - CatCacheIdMisses_Start;
ybpgm_StoreCount(i, 0, current_cache_id_misses[j] - last_cache_id_misses_val[j]);
Expand Down

0 comments on commit 6daf129

Please sign in to comment.