-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Tools-Resprites
- Loading branch information
Showing
204 changed files
with
303 additions
and
171 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
Content.Server/Administration/Managers/AdminManager.Metrics.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System.Diagnostics.Metrics; | ||
using System.Runtime.InteropServices; | ||
using Content.Server.Afk; | ||
using Robust.Server.DataMetrics; | ||
|
||
namespace Content.Server.Administration.Managers; | ||
|
||
// Handles metrics reporting for active admin count and such. | ||
|
||
public sealed partial class AdminManager | ||
{ | ||
private Dictionary<int, (int active, int afk, int deadminned)>? _adminOnlineCounts; | ||
|
||
private const int SentinelRankId = -1; | ||
|
||
[Dependency] private readonly IMetricsManager _metrics = default!; | ||
[Dependency] private readonly IAfkManager _afkManager = default!; | ||
[Dependency] private readonly IMeterFactory _meterFactory = default!; | ||
|
||
private void InitializeMetrics() | ||
{ | ||
_metrics.UpdateMetrics += MetricsOnUpdateMetrics; | ||
|
||
var meter = _meterFactory.Create("SS14.AdminManager"); | ||
|
||
meter.CreateObservableGauge( | ||
"admins_online_count", | ||
MeasureAdminCount, | ||
null, | ||
"The count of online admins"); | ||
} | ||
|
||
private void MetricsOnUpdateMetrics() | ||
{ | ||
_sawmill.Verbose("Updating metrics"); | ||
|
||
var dict = new Dictionary<int, (int active, int afk, int deadminned)>(); | ||
|
||
foreach (var (session, reg) in _admins) | ||
{ | ||
var rankId = reg.RankId ?? SentinelRankId; | ||
|
||
ref var counts = ref CollectionsMarshal.GetValueRefOrAddDefault(dict, rankId, out _); | ||
|
||
if (reg.Data.Active) | ||
{ | ||
if (_afkManager.IsAfk(session)) | ||
counts.afk += 1; | ||
else | ||
counts.active += 1; | ||
} | ||
else | ||
{ | ||
counts.deadminned += 1; | ||
} | ||
} | ||
|
||
// Neither prometheus-net nor dotnet-counters seem to handle stuff well if we STOP returning measurements. | ||
// i.e. if the last admin with a rank disconnects. | ||
// So if we have EVER reported a rank, always keep reporting it. | ||
if (_adminOnlineCounts != null) | ||
{ | ||
foreach (var rank in _adminOnlineCounts.Keys) | ||
{ | ||
CollectionsMarshal.GetValueRefOrAddDefault(dict, rank, out _); | ||
} | ||
} | ||
|
||
// Make sure "no rank" is always available. Avoid "no data". | ||
CollectionsMarshal.GetValueRefOrAddDefault(dict, SentinelRankId, out _); | ||
|
||
_adminOnlineCounts = dict; | ||
} | ||
|
||
private IEnumerable<Measurement<int>> MeasureAdminCount() | ||
{ | ||
if (_adminOnlineCounts == null) | ||
yield break; | ||
|
||
foreach (var (rank, (active, afk, deadminned)) in _adminOnlineCounts) | ||
{ | ||
yield return new Measurement<int>( | ||
active, | ||
new KeyValuePair<string, object?>("state", "active"), | ||
new KeyValuePair<string, object?>("rank", rank == SentinelRankId ? "none" : rank.ToString())); | ||
|
||
yield return new Measurement<int>( | ||
afk, | ||
new KeyValuePair<string, object?>("state", "afk"), | ||
new KeyValuePair<string, object?>("rank", rank == SentinelRankId ? "none" : rank.ToString())); | ||
|
||
yield return new Measurement<int>( | ||
deadminned, | ||
new KeyValuePair<string, object?>("state", "deadminned"), | ||
new KeyValuePair<string, object?>("rank", rank == SentinelRankId ? "none" : rank.ToString())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+78 Bytes
(130%)
Resources/Textures/Clothing/Ears/Headsets/base.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+44 Bytes
(120%)
Resources/Textures/Clothing/Ears/Headsets/base_syndicate.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/base_syndicate.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+76 Bytes
(120%)
Resources/Textures/Clothing/Ears/Headsets/cargo.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-150 Bytes
(71%)
Resources/Textures/Clothing/Ears/Headsets/cargo.rsi/icon_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-8 Bytes
(97%)
Resources/Textures/Clothing/Ears/Headsets/centcom.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-98 Bytes
(79%)
Resources/Textures/Clothing/Ears/Headsets/centcom.rsi/icon_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/centcom.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+71 Bytes
(120%)
Resources/Textures/Clothing/Ears/Headsets/command.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+72 Bytes
(110%)
Resources/Textures/Clothing/Ears/Headsets/command.rsi/icon_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/command.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+123 Bytes
(140%)
Resources/Textures/Clothing/Ears/Headsets/engineering.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-124 Bytes
(75%)
Resources/Textures/Clothing/Ears/Headsets/engineering.rsi/icon_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/engineering.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-397 Bytes
(50%)
Resources/Textures/Clothing/Ears/Headsets/freelance.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-625 Bytes
(37%)
Resources/Textures/Clothing/Ears/Headsets/freelance.rsi/icon_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/freelance.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+105 Bytes
(140%)
Resources/Textures/Clothing/Ears/Headsets/medical.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-16 Bytes
(97%)
Resources/Textures/Clothing/Ears/Headsets/medical.rsi/icon_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/medical.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+102 Bytes
(130%)
Resources/Textures/Clothing/Ears/Headsets/medicalscience.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/medicalscience.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+73 Bytes
(120%)
Resources/Textures/Clothing/Ears/Headsets/mining.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+28 Bytes
(110%)
Resources/Textures/Clothing/Ears/Headsets/robotics.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/robotics.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+85 Bytes
(130%)
Resources/Textures/Clothing/Ears/Headsets/science.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-137 Bytes
(72%)
Resources/Textures/Clothing/Ears/Headsets/science.rsi/icon_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/science.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+125 Bytes
(140%)
Resources/Textures/Clothing/Ears/Headsets/security.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+115 Bytes
(130%)
Resources/Textures/Clothing/Ears/Headsets/security.rsi/icon_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/security.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+107 Bytes
(130%)
Resources/Textures/Clothing/Ears/Headsets/service.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/service.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+124 Bytes
(140%)
Resources/Textures/Clothing/Ears/Headsets/servicesecurity.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
Resources/Textures/Clothing/Ears/Headsets/servicesecurity.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+30 Bytes
(110%)
Resources/Textures/Clothing/Ears/Headsets/syndicate.rsi/icon_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.