setting up for metrics
This commit is contained in:
parent
7e7414d491
commit
d900416d7c
@ -23,8 +23,8 @@ namespace CodexPlugin
|
||||
{
|
||||
Image = GetDockerImage();
|
||||
|
||||
Resources.Requests = new ContainerResourceSet(milliCPUs: 1000, memory: 6.GB());
|
||||
Resources.Limits = new ContainerResourceSet(milliCPUs: 4000, memory: 12.GB());
|
||||
//Resources.Requests = new ContainerResourceSet(milliCPUs: 1000, memory: 6.GB());
|
||||
//Resources.Limits = new ContainerResourceSet(milliCPUs: 4000, memory: 12.GB());
|
||||
}
|
||||
|
||||
protected override void InitializeRecipe(StartupConfig startupConfig)
|
||||
|
@ -7,10 +7,12 @@ namespace CodexPlugin
|
||||
public class CodexStarter
|
||||
{
|
||||
private readonly IPluginTools pluginTools;
|
||||
private readonly ILog log;
|
||||
|
||||
public CodexStarter(IPluginTools pluginTools)
|
||||
{
|
||||
this.pluginTools = pluginTools;
|
||||
log = new LogPrefixer(pluginTools.GetLog(), "(CodexStarter) ");
|
||||
}
|
||||
|
||||
public RunningContainers[] BringOnline(CodexSetup codexSetup)
|
||||
@ -118,7 +120,7 @@ namespace CodexPlugin
|
||||
|
||||
try
|
||||
{
|
||||
Stopwatch.Measure(pluginTools.GetLog(), "(CodexStarter) EnsureOnline", group.EnsureOnline); // log prefixer plz
|
||||
Stopwatch.Measure(log, "EnsureOnline", group.EnsureOnline);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -131,7 +133,7 @@ namespace CodexPlugin
|
||||
|
||||
private void CodexNodesNotOnline(RunningContainers[] runningContainers)
|
||||
{
|
||||
pluginTools.GetLog().Log("Codex nodes failed to start");
|
||||
Log("Codex nodes failed to start");
|
||||
// todo:
|
||||
//foreach (var container in runningContainers.Containers()) lifecycle.DownloadLog(container);
|
||||
}
|
||||
@ -148,7 +150,7 @@ namespace CodexPlugin
|
||||
|
||||
private void Log(string message)
|
||||
{
|
||||
pluginTools.GetLog().Log($"(CodexStarter) {message}");
|
||||
log.Log(message);
|
||||
}
|
||||
|
||||
//private void StopCrashWatcher(RunningContainers containers)
|
||||
|
@ -1,42 +0,0 @@
|
||||
using Logging;
|
||||
|
||||
namespace DistTestCore
|
||||
{
|
||||
public class BaseStarter
|
||||
{
|
||||
protected readonly TestLifecycle lifecycle;
|
||||
private Stopwatch? stopwatch;
|
||||
|
||||
public BaseStarter(TestLifecycle lifecycle)
|
||||
{
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
protected void LogStart(string msg)
|
||||
{
|
||||
Log(msg);
|
||||
stopwatch = Stopwatch.Begin(lifecycle.Log, GetClassName());
|
||||
}
|
||||
|
||||
protected void LogEnd(string msg)
|
||||
{
|
||||
stopwatch!.End(msg);
|
||||
stopwatch = null;
|
||||
}
|
||||
|
||||
protected void Log(string msg)
|
||||
{
|
||||
lifecycle.Log.Log($"{GetClassName()} {msg}");
|
||||
}
|
||||
|
||||
protected void Debug(string msg)
|
||||
{
|
||||
lifecycle.Log.Debug($"{GetClassName()} {msg}", 1);
|
||||
}
|
||||
|
||||
private string GetClassName()
|
||||
{
|
||||
return $"({GetType().Name})";
|
||||
}
|
||||
}
|
||||
}
|
34
Logging/LogPrefixer.cs
Normal file
34
Logging/LogPrefixer.cs
Normal file
@ -0,0 +1,34 @@
|
||||
namespace Logging
|
||||
{
|
||||
public class LogPrefixer : ILog
|
||||
{
|
||||
private readonly ILog backingLog;
|
||||
private readonly string prefix;
|
||||
|
||||
public LogPrefixer(ILog backingLog, string prefix)
|
||||
{
|
||||
this.backingLog = backingLog;
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public LogFile CreateSubfile(string ext = "log")
|
||||
{
|
||||
return backingLog.CreateSubfile(ext);
|
||||
}
|
||||
|
||||
public void Debug(string message = "", int skipFrames = 0)
|
||||
{
|
||||
backingLog.Debug(prefix + message, skipFrames);
|
||||
}
|
||||
|
||||
public void Error(string message)
|
||||
{
|
||||
backingLog.Error(prefix + message);
|
||||
}
|
||||
|
||||
public void Log(string message)
|
||||
{
|
||||
backingLog.Log(prefix + message);
|
||||
}
|
||||
}
|
||||
}
|
18
MetricsPlugin/CoreInterfaceExtensions.cs
Normal file
18
MetricsPlugin/CoreInterfaceExtensions.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Core;
|
||||
using KubernetesWorkflow;
|
||||
|
||||
namespace MetricsPlugin
|
||||
{
|
||||
public static class CoreInterfaceExtensions
|
||||
{
|
||||
public static RunningContainer StartMetricsCollector(this CoreInterface ci, RunningContainers[] scrapeTargets)
|
||||
{
|
||||
return Plugin(ci).StartMetricsCollector(scrapeTargets);
|
||||
}
|
||||
|
||||
private static MetricsPlugin Plugin(CoreInterface ci)
|
||||
{
|
||||
return ci.GetPlugin<MetricsPlugin>();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using KubernetesWorkflow;
|
||||
|
||||
namespace DistTestCore
|
||||
namespace MetricsPlugin
|
||||
{
|
||||
public class GrafanaStarter : BaseStarter
|
||||
{
|
32
MetricsPlugin/MetricsPlugin.cs
Normal file
32
MetricsPlugin/MetricsPlugin.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using Core;
|
||||
using KubernetesWorkflow;
|
||||
using Logging;
|
||||
|
||||
namespace MetricsPlugin
|
||||
{
|
||||
public class MetricsPlugin : IProjectPlugin
|
||||
{
|
||||
|
||||
#region IProjectPlugin Implementation
|
||||
|
||||
public void Announce(ILog log)
|
||||
{
|
||||
log.Log("Hi from the metrics plugin.");
|
||||
}
|
||||
|
||||
public void Initialize(IPluginTools tools)
|
||||
{
|
||||
}
|
||||
|
||||
public void Finalize(ILog log)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public RunningContainer StartMetricsCollector(RunningContainers[] scrapeTargets)
|
||||
{
|
||||
return null!;
|
||||
}
|
||||
}
|
||||
}
|
9
MetricsPlugin/MetricsPlugin.csproj
Normal file
9
MetricsPlugin/MetricsPlugin.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -1,13 +1,16 @@
|
||||
using KubernetesWorkflow;
|
||||
using Core;
|
||||
using KubernetesWorkflow;
|
||||
using System.Text;
|
||||
|
||||
namespace DistTestCore
|
||||
namespace MetricsPlugin
|
||||
{
|
||||
public class PrometheusStarter : BaseStarter
|
||||
public class PrometheusStarter
|
||||
{
|
||||
public PrometheusStarter(TestLifecycle lifecycle)
|
||||
: base(lifecycle)
|
||||
private readonly IPluginTools tools;
|
||||
|
||||
public PrometheusStarter(IPluginTools tools)
|
||||
{
|
||||
this.tools = tools;
|
||||
}
|
||||
|
||||
public RunningContainers CollectMetricsFor(RunningContainers[] containers)
|
Loading…
x
Reference in New Issue
Block a user