Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Jul 14, 2024
2 parents 62e786b + 38ae309 commit a4d0b7d
Show file tree
Hide file tree
Showing 3 changed files with 520 additions and 357 deletions.
11 changes: 10 additions & 1 deletion ArchiSteamFarm.OfficialPlugins.Monitoring/MonitoringPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

using System;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Composition;
Expand Down Expand Up @@ -69,6 +70,8 @@ internal sealed class MonitoringPlugin : OfficialPlugin, IDisposable, IOfficialG

private static bool Enabled => ASF.GlobalConfig?.IPC ?? GlobalConfig.DefaultIPC;

private static FrozenSet<Measurement<int>>? PluginMeasurements;

[JsonInclude]
[Required]
public override string Name => nameof(MonitoringPlugin);
Expand Down Expand Up @@ -136,6 +139,12 @@ private void InitializeMeter() {
return;
}

PluginMeasurements = new[] {
new Measurement<int>(PluginsCore.ActivePlugins.Count),
new Measurement<int>(PluginsCore.ActivePlugins.Count(static plugin => plugin is OfficialPlugin), new KeyValuePair<string, object?>(TagNames.PluginType, "official")),
new Measurement<int>(PluginsCore.ActivePlugins.Count(static plugin => plugin is not OfficialPlugin), new KeyValuePair<string, object?>(TagNames.PluginType, "custom"))
}.ToFrozenSet();

Meter = new Meter(MeterName, Version.ToString());

Meter.CreateObservableGauge(
Expand All @@ -158,7 +167,7 @@ private void InitializeMeter() {

Meter.CreateObservableGauge(
$"{MetricNamePrefix}_active_plugins",
static () => PluginsCore.ActivePlugins.Count,
static () => PluginMeasurements,
description: "Number of plugins currently loaded in ASF"
);

Expand Down
1 change: 1 addition & 0 deletions ArchiSteamFarm.OfficialPlugins.Monitoring/TagNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal static class TagNames {
internal const string CurrencyCode = "currency";
internal const string Framework = "framework";
internal const string OS = "operating_system";
internal const string PluginType = "type";
internal const string Runtime = "runtime";
internal const string SteamID = "steamid";
internal const string TradeOfferResult = "result";
Expand Down
Loading

0 comments on commit a4d0b7d

Please sign in to comment.