Skip to content

Commit

Permalink
Improve metric names
Browse files Browse the repository at this point in the history
  • Loading branch information
awaescher committed May 15, 2024
1 parent 337ef02 commit 7ecc3fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions MaxPower/HostedServices/ExporterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace MaxPower.HostedServices;

public class ExporterService(MaxSettings maxSettings, IEnumerable<InverterConfiguration> inverters, IMaxTalkClient maxTalkClient, ILogger<ExporterService> 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<InverterConfiguration> Inverters { get; } = inverters ?? throw new ArgumentNullException(nameof(inverters));
Expand Down
2 changes: 2 additions & 0 deletions MaxPower/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public static void Main(string[] args)
var maxSettings = builder.Configuration.GetSection("MaxSettings").Get<MaxSettings>() ?? new MaxSettings();
var inverters = builder.Configuration.GetSection("Inverters").Get<InverterConfiguration[]>() ?? [];

Log.Logger.Information($"Found {(inverters.Length == 1 ? "1 inverter" : $"{inverters.Length} inverters")} to process.");

builder.Services.AddSingleton(maxSettings);
builder.Services.AddSingleton<IEnumerable<InverterConfiguration>>(inverters);

Expand Down

0 comments on commit 7ecc3fd

Please sign in to comment.