2023-09-13 09:12:18 +02:00
|
|
|
|
using Core;
|
2023-11-12 10:07:23 +01:00
|
|
|
|
using KubernetesWorkflow.Types;
|
2023-09-13 11:25:08 +02:00
|
|
|
|
using Logging;
|
2023-09-13 09:12:18 +02:00
|
|
|
|
|
|
|
|
|
namespace MetricsPlugin
|
|
|
|
|
{
|
|
|
|
|
public static class CoreInterfaceExtensions
|
|
|
|
|
{
|
2023-11-07 11:17:20 +01:00
|
|
|
|
public static RunningContainers DeployMetricsCollector(this CoreInterface ci, params IHasMetricsScrapeTarget[] scrapeTargets)
|
2023-09-19 11:51:59 +02:00
|
|
|
|
{
|
2023-09-20 09:16:57 +02:00
|
|
|
|
return Plugin(ci).DeployMetricsCollector(scrapeTargets.Select(t => t.MetricsScrapeTarget).ToArray());
|
2023-09-19 11:51:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 11:17:20 +01:00
|
|
|
|
public static RunningContainers DeployMetricsCollector(this CoreInterface ci, params IMetricsScrapeTarget[] scrapeTargets)
|
2023-09-13 09:12:18 +02:00
|
|
|
|
{
|
2023-09-20 09:16:57 +02:00
|
|
|
|
return Plugin(ci).DeployMetricsCollector(scrapeTargets);
|
2023-09-13 11:25:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 11:17:20 +01:00
|
|
|
|
public static IMetricsAccess WrapMetricsCollector(this CoreInterface ci, RunningContainers metricsContainer, IHasMetricsScrapeTarget scrapeTarget)
|
2023-09-26 14:32:28 +02:00
|
|
|
|
{
|
|
|
|
|
return ci.WrapMetricsCollector(metricsContainer, scrapeTarget.MetricsScrapeTarget);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 11:17:20 +01:00
|
|
|
|
public static IMetricsAccess WrapMetricsCollector(this CoreInterface ci, RunningContainers metricsContainer, IMetricsScrapeTarget scrapeTarget)
|
2023-09-13 11:25:08 +02:00
|
|
|
|
{
|
2023-09-20 09:16:57 +02:00
|
|
|
|
return Plugin(ci).WrapMetricsCollectorDeployment(metricsContainer, scrapeTarget);
|
2023-09-13 11:25:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-19 11:51:59 +02:00
|
|
|
|
public static IMetricsAccess[] GetMetricsFor(this CoreInterface ci, params IHasManyMetricScrapeTargets[] manyScrapeTargets)
|
2023-09-13 11:59:21 +02:00
|
|
|
|
{
|
|
|
|
|
return ci.GetMetricsFor(manyScrapeTargets.SelectMany(t => t.ScrapeTargets).ToArray());
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-19 11:51:59 +02:00
|
|
|
|
public static IMetricsAccess[] GetMetricsFor(this CoreInterface ci, params IHasMetricsScrapeTarget[] scrapeTargets)
|
|
|
|
|
{
|
|
|
|
|
return ci.GetMetricsFor(scrapeTargets.Select(t => t.MetricsScrapeTarget).ToArray());
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 11:25:08 +02:00
|
|
|
|
public static IMetricsAccess[] GetMetricsFor(this CoreInterface ci, params IMetricsScrapeTarget[] scrapeTargets)
|
|
|
|
|
{
|
2023-09-20 09:16:57 +02:00
|
|
|
|
var rc = ci.DeployMetricsCollector(scrapeTargets);
|
|
|
|
|
return scrapeTargets.Select(t => ci.WrapMetricsCollector(rc, t)).ToArray();
|
2023-09-13 11:25:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static LogFile? DownloadAllMetrics(this CoreInterface ci, IMetricsAccess metricsAccess, string targetName)
|
|
|
|
|
{
|
|
|
|
|
return Plugin(ci).DownloadAllMetrics(metricsAccess, targetName);
|
2023-09-13 09:12:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static MetricsPlugin Plugin(CoreInterface ci)
|
|
|
|
|
{
|
|
|
|
|
return ci.GetPlugin<MetricsPlugin>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|