From 7ecc3fd7389eaf754b56c179397fdb9d47f64dbb Mon Sep 17 00:00:00 2001 From: awaescher Date: Wed, 15 May 2024 17:15:31 +0200 Subject: [PATCH] Improve metric names --- MaxPower/HostedServices/ExporterService.cs | 8 ++++---- MaxPower/Program.cs | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/MaxPower/HostedServices/ExporterService.cs b/MaxPower/HostedServices/ExporterService.cs index 66bde99..15d7fe6 100644 --- a/MaxPower/HostedServices/ExporterService.cs +++ b/MaxPower/HostedServices/ExporterService.cs @@ -5,10 +5,10 @@ namespace MaxPower.HostedServices; public class ExporterService(MaxSettings maxSettings, IEnumerable inverters, IMaxTalkClient maxTalkClient, ILogger logger) : BackgroundService { - private Counter _energyDay = Metrics.CreateCounter("EnergyDay", "The amount of energy created this day in kWh", ["ip", "id"]); - private Counter _energyMonth = Metrics.CreateCounter("EnergyMonth", "The amount of energy created this month in kWh", ["ip", "id"]); - private Counter _energyYear = Metrics.CreateCounter("EnergyYear", "The amount of energy created this year in kWh", ["ip", "id"]); - private Counter _energyTotal = Metrics.CreateCounter("EnergyTotal", "The amount of energy created in total in kWh", ["ip", "id"]); + private Counter _energyDay = Metrics.CreateCounter("maxpower_energy_day", "The amount of energy created today in kWh", ["ip", "id"]); + private Counter _energyMonth = Metrics.CreateCounter("maxpower_energy_month", "The amount of energy created this month in kWh", ["ip", "id"]); + private Counter _energyYear = Metrics.CreateCounter("maxpower_energy_year", "The amount of energy created this year in kWh", ["ip", "id"]); + private Counter _energyTotal = Metrics.CreateCounter("maxpower_energy_total", "The amount of energy created in total in kWh", ["ip", "id"]); public MaxSettings MaxSettings { get; } = maxSettings ?? throw new ArgumentNullException(nameof(maxSettings)); public IEnumerable Inverters { get; } = inverters ?? throw new ArgumentNullException(nameof(inverters)); diff --git a/MaxPower/Program.cs b/MaxPower/Program.cs index 030cdc1..ede0e5b 100644 --- a/MaxPower/Program.cs +++ b/MaxPower/Program.cs @@ -22,6 +22,8 @@ public static void Main(string[] args) var maxSettings = builder.Configuration.GetSection("MaxSettings").Get() ?? new MaxSettings(); var inverters = builder.Configuration.GetSection("Inverters").Get() ?? []; + Log.Logger.Information($"Found {(inverters.Length == 1 ? "1 inverter" : $"{inverters.Length} inverters")} to process."); + builder.Services.AddSingleton(maxSettings); builder.Services.AddSingleton>(inverters);