Skip to content

Commit

Permalink
INFO field for modules (#408)
Browse files Browse the repository at this point in the history
* INFO field for modules

* nit; add help message

---------

Co-authored-by: vazois <vazois@microsoft.com>
  • Loading branch information
badrishc and vazois authored May 22, 2024
1 parent 9656bf5 commit 95149fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions libs/common/Metrics/InfoMetricsType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public enum InfoMetricsType : byte
/// Database related stats
/// </summary>
KEYSPACE,
/// <summary>
/// Modules info
/// </summary>
MODULES,
}

/// <summary>
Expand Down
9 changes: 7 additions & 2 deletions libs/server/Metrics/Info/GarnetInfoMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,16 @@ public static string GetSectionHeader(InfoMetricsType infoType)
InfoMetricsType.PERSISTENCE => "Persistence",
InfoMetricsType.CLIENTS => "Clients",
InfoMetricsType.KEYSPACE => "Keyspace",
InfoMetricsType.MODULES => "Modules",
_ => "Default",
};
}

private static string GetSectionRespInfo(InfoMetricsType infoType, MetricsItem[] info)
{
if (info == null)
return "";
var section = $"# {GetSectionHeader(infoType)}\r\n";
if (info == null)
return section;

// For some metrics we have a multi-string in the value and no name, so don't print a stray leading ':'.
if (string.IsNullOrEmpty(info[0].Name))
Expand Down Expand Up @@ -350,6 +351,8 @@ public string GetRespInfo(InfoMetricsType section, StoreWrapper storeWrapper)
case InfoMetricsType.KEYSPACE:
PopulateKeyspaceInfo(storeWrapper);
return GetSectionRespInfo(InfoMetricsType.KEYSPACE, keyspaceInfo);
case InfoMetricsType.MODULES:
return GetSectionRespInfo(section, null);
default:
return "";
}
Expand Down Expand Up @@ -417,6 +420,8 @@ private MetricsItem[] GetMetricInternal(InfoMetricsType section, StoreWrapper st
case InfoMetricsType.KEYSPACE:
PopulateKeyspaceInfo(storeWrapper);
return keyspaceInfo;
case InfoMetricsType.MODULES:
return null;
default:
return null;
}
Expand Down
4 changes: 4 additions & 0 deletions libs/server/Metrics/Info/InfoHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public static List<string> GetInfoTypeHelpMessage()
$"{nameof(InfoMetricsType.OBJECTSTOREHASHTABLE)}: Hash table distribution info for object store (expensive, not returned by default).",
$"{nameof(InfoMetricsType.STOREREVIV)}: Revivification info for deleted records in main store (not returned by default).",
$"{nameof(InfoMetricsType.OBJECTSTOREREVIV)}: Record revivification info for deleted records in object store (not returned by default).",
$"{nameof(InfoMetricsType.PERSISTENCE)}: Persistence related information (i.e. Checkpoint and AOF).",
$"{nameof(InfoMetricsType.CLIENTS)}: Information related to client connections.",
$"{nameof(InfoMetricsType.KEYSPACE)}: Database related statistics.",
$"{nameof(InfoMetricsType.MODULES)}: Information related to loaded modules.",
$"{nameof(ALL)}: Return all informational sections.",
$"{nameof(HELP)}: Print this help message.",
$"{nameof(RESET)}: Reset stats.",
Expand Down

0 comments on commit 95149fa

Please sign in to comment.