cs-codex-dist-tests/MetricsPlugin/CoreInterfaceExtensions.cs

41 lines
1.5 KiB
C#
Raw Normal View History

2023-09-13 07:12:18 +00:00
using Core;
using KubernetesWorkflow;
2023-09-13 09:25:08 +00:00
using Logging;
2023-09-13 07:12:18 +00:00
namespace MetricsPlugin
{
public static class CoreInterfaceExtensions
{
2023-09-14 13:30:09 +00:00
public static RunningContainer StartMetricsCollector(this CoreInterface ci, params IMetricsScrapeTarget[] scrapeTargets)
2023-09-13 07:12:18 +00:00
{
2023-09-13 09:25:08 +00:00
return Plugin(ci).StartMetricsCollector(scrapeTargets);
}
2023-09-14 13:30:09 +00:00
public static IMetricsAccess GetMetricsFor(this CoreInterface ci, RunningContainer metricsContainer, IMetricsScrapeTarget scrapeTarget)
2023-09-13 09:25:08 +00:00
{
return Plugin(ci).CreateAccessForTarget(metricsContainer, scrapeTarget);
}
2023-09-13 09:59:21 +00:00
public static IMetricsAccess[] GetMetricsFor(this CoreInterface ci, params IManyMetricScrapeTargets[] manyScrapeTargets)
{
return ci.GetMetricsFor(manyScrapeTargets.SelectMany(t => t.ScrapeTargets).ToArray());
}
2023-09-13 09:25:08 +00:00
public static IMetricsAccess[] GetMetricsFor(this CoreInterface ci, params IMetricsScrapeTarget[] scrapeTargets)
{
var rc = ci.StartMetricsCollector(scrapeTargets);
return scrapeTargets.Select(t => ci.GetMetricsFor(rc, t)).ToArray();
}
public static LogFile? DownloadAllMetrics(this CoreInterface ci, IMetricsAccess metricsAccess, string targetName)
{
return Plugin(ci).DownloadAllMetrics(metricsAccess, targetName);
2023-09-13 07:12:18 +00:00
}
private static MetricsPlugin Plugin(CoreInterface ci)
{
return ci.GetPlugin<MetricsPlugin>();
}
}
}