diff --git a/CodexNetDeployer/CodexNodeStarter.cs b/CodexNetDeployer/CodexNodeStarter.cs index 7c33892..2896ea7 100644 --- a/CodexNetDeployer/CodexNodeStarter.cs +++ b/CodexNetDeployer/CodexNodeStarter.cs @@ -20,7 +20,7 @@ namespace CodexNetDeployer this.workflowCreator = workflowCreator; this.lifecycle = lifecycle; this.gethResult = gethResult; - this.validatorsLeft = numberOfValidators; + validatorsLeft = numberOfValidators; } public RunningContainer? Start(int i) diff --git a/CodexNetDeployer/Configuration.cs b/CodexNetDeployer/Configuration.cs index d58e233..4d4c735 100644 --- a/CodexNetDeployer/Configuration.cs +++ b/CodexNetDeployer/Configuration.cs @@ -46,6 +46,9 @@ namespace CodexNetDeployer [Uniform("max-duration", "md", "MAXDURATION", true, "Maximum duration in seconds for contracts which will be accepted.")] public int MaxDuration { get; set; } + [Uniform("record-metrics", "rm", "RECORDMETRICS", false, "If true, metrics will be collected for all Codex nodes.")] + public bool RecordMetrics { get; set; } = false; + public TestRunnerLocation RunnerLocation { get; set; } = TestRunnerLocation.InternalToCluster; public List Validate() diff --git a/CodexNetDeployer/Deployer.cs b/CodexNetDeployer/Deployer.cs index b4efd3f..64e46aa 100644 --- a/CodexNetDeployer/Deployer.cs +++ b/CodexNetDeployer/Deployer.cs @@ -27,6 +27,7 @@ namespace CodexNetDeployer // We trick the Geth companion node into unlocking all of its accounts, by saying we want to start 999 codex nodes. var setup = new CodexSetup(999, config.CodexLogLevel); setup.WithStorageQuota(config.StorageQuota!.Value.MB()).EnableMarketplace(0.TestTokens()); + setup.MetricsEnabled = config.RecordMetrics; Log("Creating Geth instance and deploying contracts..."); var gethStarter = new GethStarter(lifecycle, workflowCreator); @@ -46,6 +47,11 @@ namespace CodexNetDeployer if (container != null) codexContainers.Add(container); } + if (setup.MetricsEnabled) + { + StartMetricsService(lifecycle, setup, codexContainers); + } + return new CodexDeployment(gethResults, codexContainers.ToArray(), CreateMetadata()); } @@ -75,6 +81,13 @@ namespace CodexNetDeployer return (workflowCreator, lifecycle); } + private void StartMetricsService(TestLifecycle lifecycle, CodexSetup setup, List codexContainers) + { + Log("Starting metrics service..."); + var runningContainers = new RunningContainers(null!, null!, codexContainers.ToArray()); + lifecycle.PrometheusStarter.CollectMetricsFor(setup, runningContainers); + } + private string? GetKubeConfig(string kubeConfigFile) { if (string.IsNullOrEmpty(kubeConfigFile) || kubeConfigFile.ToLowerInvariant() == "null") return null;