Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Metrics via Prometheus support #4199

Open
wants to merge 139 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
6711eca
Update TargetFrameworks and PackageReferences
Mag-nus Oct 10, 2019
fd98276
FromSql -> FromSqlRaw, ExecuteSqlCommand -> ExecuteSqlRaw
Mag-nus Oct 10, 2019
1dfca52
Client side GroupBy is not supported in EF 3.0
Mag-nus Oct 10, 2019
7f56d9a
Update appveyor.yml
Mag-nus Oct 10, 2019
230dcf6
readme updates
Mag-nus Oct 21, 2019
493f587
Add NoTracking
Mag-nus Oct 22, 2019
e562939
scaffolding notes update
Mag-nus Oct 22, 2019
01c41ef
Revert back to EF Core 2.2
Mag-nus Oct 22, 2019
fed0649
EF Core 2.2.0 -> 2.2.6
Mag-nus Oct 22, 2019
65a5165
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Oct 22, 2019
c428737
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Oct 24, 2019
515657b
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Oct 30, 2019
0925180
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Nov 3, 2019
da247bf
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Nov 4, 2019
8dff9c9
prometheus standalone
Mag-nus Nov 11, 2019
8e36fdf
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Nov 17, 2019
809302a
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Nov 17, 2019
72aba8d
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Nov 17, 2019
4a26580
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Nov 21, 2019
c8a5bc9
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Nov 21, 2019
eee4d52
Update packages (Except EF Core)
Mag-nus Nov 22, 2019
312054a
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Nov 23, 2019
0668538
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Nov 27, 2019
4a30027
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Nov 27, 2019
db021b4
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Dec 2, 2019
4dbc77b
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Dec 2, 2019
5e50630
.net core 3.0 -> 3.1 (LTS)
Mag-nus Dec 4, 2019
ba1097b
Update NuGet packages
Mag-nus Dec 4, 2019
20e16af
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Dec 4, 2019
9d8cb82
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Dec 5, 2019
1464f8e
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Dec 5, 2019
5926523
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Dec 8, 2019
22df473
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Dec 8, 2019
27d8643
Update README.md
Mag-nus Dec 8, 2019
e420b18
Update appveyor.yml to use VS Preview
Mag-nus Dec 9, 2019
ab45be3
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Dec 10, 2019
2a8ecd8
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Dec 10, 2019
f85fb33
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Dec 11, 2019
e93095b
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Dec 11, 2019
1b4630d
Merge remote-tracking branch 'upstream/master' into net-3.0
Mag-nus Dec 14, 2019
796c3a8
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Dec 14, 2019
c10408d
Merge branch 'net-3.0' into prometheus
Mag-nus Dec 16, 2019
644c353
merge in 3.1 branch
Mag-nus Dec 16, 2019
58b13fe
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Dec 16, 2019
1f0c5ea
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Dec 18, 2019
5e748d7
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Jan 1, 2020
37e602a
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Jan 6, 2020
382acc0
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Jan 22, 2020
74611f9
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Feb 1, 2020
06fb42c
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Feb 15, 2020
5a570a2
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Mar 2, 2020
b8108ed
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Mar 5, 2020
d4aaa61
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Mar 21, 2020
a541bcd
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Mar 22, 2020
b4152f1
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Mar 23, 2020
4eadbe3
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Mar 24, 2020
1dd0d53
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Mar 27, 2020
9b1d99c
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Apr 3, 2020
c94323a
Update ACE.Server.csproj
Mag-nus Apr 3, 2020
5ef31a2
Revert "Update ACE.Server.csproj"
Mag-nus Apr 3, 2020
e866c17
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Apr 5, 2020
3b8b309
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Apr 11, 2020
fdedff7
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Apr 11, 2020
01f927b
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Apr 13, 2020
dfb56d7
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Apr 21, 2020
04d399a
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus May 12, 2020
8a7a042
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus May 19, 2020
09ef1f5
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus May 27, 2020
d9a9fb5
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Jun 13, 2020
ca92d24
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Sep 23, 2021
4b1ae6d
update metrics collecting
Mag-nus Sep 23, 2021
e5a725e
more metrics for ACE
Mag-nus Sep 23, 2021
e2330af
more progress
Mag-nus Sep 23, 2021
f9904f8
add gc stats
Mag-nus Sep 23, 2021
6c4b673
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Oct 9, 2021
922a1d3
scope collection
Mag-nus Oct 9, 2021
b2e9a20
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Oct 26, 2021
d65e06f
Update Program_Metrics.cs
Mag-nus Nov 21, 2021
1ba7aad
update nuget packages
Mag-nus Nov 28, 2021
7848ea7
stub code
Mag-nus Nov 28, 2021
4300d40
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Nov 28, 2021
35deaa3
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Nov 29, 2021
664e73e
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Dec 2, 2021
0ef5bbc
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Dec 19, 2021
ca52086
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Dec 24, 2021
b7acde2
compile fix
Mag-nus Dec 26, 2021
57c2b28
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Jan 13, 2022
1b1d5bf
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Jan 16, 2022
b4abd5a
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Jan 23, 2022
d21f38f
Merge remote-tracking branch 'upstream/master' into prometheus
Mag-nus Feb 12, 2022
80a6a47
Merge branch 'master' into protest
LtRipley36706 Mar 29, 2022
9d7e036
Update ACE.Server.csproj
LtRipley36706 Mar 29, 2022
449e382
Update Program_Metrics.cs
LtRipley36706 Mar 31, 2022
dd4ad90
Update Program_Metrics.cs
LtRipley36706 Apr 1, 2022
0d99d19
Update Program.cs
LtRipley36706 Apr 1, 2022
618b50b
Update Program_Metrics.cs
LtRipley36706 Apr 1, 2022
23fd5e9
Update Program_Metrics.cs
LtRipley36706 Apr 2, 2022
481b8ca
Update GuidManager.cs
LtRipley36706 Apr 7, 2022
17aceff
Update HouseManager.cs
LtRipley36706 Apr 7, 2022
8dc3dc0
Update Player_House.cs
LtRipley36706 Apr 7, 2022
521369a
Update Program_Metrics.cs
LtRipley36706 Apr 7, 2022
fb11e9f
Merge branch 'master' into protest
LtRipley36706 Apr 7, 2022
122fe29
Update HouseManager.cs
LtRipley36706 Apr 7, 2022
74dc48f
Update HouseManager.cs
LtRipley36706 Apr 8, 2022
6cbf654
Update Player_House.cs
LtRipley36706 Apr 8, 2022
243560b
Update Program_Metrics.cs
LtRipley36706 Apr 9, 2022
e838cb1
Merge branch 'master' into protest
LtRipley36706 Oct 19, 2022
1aa0a2a
Merge branch 'master' into protest
LtRipley36706 Dec 28, 2022
1625940
Merge branch 'master' into protest
LtRipley36706 Dec 29, 2022
5b0e29d
Merge branch 'master' into protest
LtRipley36706 Mar 30, 2023
37d66ca
Merge branch 'master' into protest
LtRipley36706 Apr 21, 2023
a81e1f0
Merge branch 'master' into protest
LtRipley36706 Aug 10, 2023
f7d0d18
Update ACE.Server.csproj
LtRipley36706 Aug 10, 2023
1243d3c
Update ACE.Server.csproj
LtRipley36706 Aug 10, 2023
5cd7e8b
Merge branch 'master' into protest
LtRipley36706 Aug 12, 2023
3b379a3
Merge branch 'master' into protest
LtRipley36706 Feb 5, 2024
8deb8f1
Update ACE.Server.csproj
LtRipley36706 Feb 5, 2024
a15aad0
Update Program_Metrics.cs
LtRipley36706 Feb 5, 2024
133b000
Add Metrics to Config.js
LtRipley36706 Feb 7, 2024
9934f5e
Update ACE.Server.csproj
LtRipley36706 Feb 7, 2024
afee71f
Update Program.cs
LtRipley36706 Feb 7, 2024
4996e4a
Update Program_Metrics.cs
LtRipley36706 Feb 12, 2024
f0d1bf8
Update ACE.Server.csproj
LtRipley36706 Feb 12, 2024
c3f4632
Merge branch 'master' into metrics
LtRipley36706 Apr 5, 2024
153c85c
Merge branch 'master' into metrics
LtRipley36706 Apr 21, 2024
2851a00
Merge branch 'master' into metrics
LtRipley36706 Apr 25, 2024
a264586
Update ACE.Server.csproj
LtRipley36706 Apr 25, 2024
9d18614
Update Program_Metrics.cs
LtRipley36706 Apr 26, 2024
b692928
Merge branch 'ACEmulator:master' into metrics
LtRipley36706 May 18, 2024
99720f1
Update Program_Metrics.cs
LtRipley36706 May 21, 2024
9c9d7c5
Merge branch 'ACEmulator:master' into metrics
LtRipley36706 Jun 28, 2024
59a4f3f
Merge branch 'ACEmulator:master' into metrics
LtRipley36706 Jul 20, 2024
220a063
Merge branch 'master' into metrics
LtRipley36706 Jul 20, 2024
92f51bc
Update ACE.Server.csproj
LtRipley36706 Jul 20, 2024
cd23012
Merge branch 'ACEmulator:master' into metrics
LtRipley36706 Sep 22, 2024
a864927
Update ACE.Server.csproj
LtRipley36706 Sep 30, 2024
e8efbe8
Merge branch 'ACEmulator:master' into metrics
LtRipley36706 Sep 30, 2024
25ee591
Merge branch 'ACEmulator:master' into metrics
LtRipley36706 Sep 30, 2024
2ae9a9d
Merge branch 'ACEmulator:master' into metrics
LtRipley36706 Oct 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/ACE.Common/MasterConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ public class MasterConfiguration
public OfflineConfiguration Offline { get; set; } = new OfflineConfiguration();

public DDDConfiguration DDD { get; set; } = new DDDConfiguration();

public MetricsConfiguration Metrics { get; set; } = new MetricsConfiguration();
}
}
19 changes: 19 additions & 0 deletions Source/ACE.Common/MetricsConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

namespace ACE.Common
{
public class MetricsConfiguration
{
/// <summary>
/// Allow server to publish Prometheus metrics
/// </summary>
public bool EnableMetricsServer { get; set; } = false;

public string Host { get; set; } = "127.0.0.1";

public int Port { get; set; } = 9200;

public string Url { get; set; } = "metrics/";

public bool UseHTTPs { get; set; } = false;
}
}
2 changes: 2 additions & 0 deletions Source/ACE.Server/ACE.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@
<PackageReference Include="Log4Net.Async.Standard" Version="3.1.0" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.4.0" />
<PackageReference Include="MySqlConnector" Version="2.3.7" />
<PackageReference Include="prometheus-net" Version="8.2.1" />
<PackageReference Include="prometheus-net.DotNetRuntime" Version="4.4.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>

Expand Down
31 changes: 31 additions & 0 deletions Source/ACE.Server/Config.js.docker
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,36 @@
// When retrieving a file list of .sql files in the AutoApplyWorldCustomizations process
// this will cause the file search to retrieve all files recursively from each directory
"RecurseWorldCustomizationPaths": true
},
// This section configures handling of client DAT patching from server's DAT files
"DDD": {
// Allow server to patch client DAT files using server's DAT files via DDDManager
"EnableDATPatching": false,

// Upon server startup, precache all DAT files that would be sent as compressed data
"PrecacheCompressedDATFiles": false
},
// This section configures Prometheus metrics server
"Metrics": {
// Allow server to publish Prometheus metrics
"EnableMetricsServer": false,

// Host, default: 127.0.0.1
// Probably best to leave this as is, and use reverse proxy which can be secured better.
"Host": "127.0.0.1",

// Port, default: 9200
// Probably best to leave this as is, and use reverse proxy which can be secured better.
"Port": 9200,

// Url, default: metrics/
// Probably best to leave this as is, and use reverse proxy which can be secured better.
// If above is default, the full url becomes http://127.0.0.1:9200/metrics/ to access
"Url": "metrics/",

// UseHTTPs, default: false
// Probably best to leave this as is, and use reverse proxy which can be secured better.
// If above is default, the full url becomes https://127.0.0.1:9200/metrics to access
"UseHTTPs": false
}
}
23 changes: 23 additions & 0 deletions Source/ACE.Server/Config.js.example
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,28 @@

// Upon server startup, precache all DAT files that would be sent as compressed data
"PrecacheCompressedDATFiles": false
},
// This section configures Prometheus metrics server
"Metrics": {
// Allow server to publish Prometheus metrics
"EnableMetricsServer": false,

// Host, default: 127.0.0.1
// Probably best to leave this as is, and use reverse proxy which can be secured better.
"Host": "127.0.0.1",

// Port, default: 9200
// Probably best to leave this as is, and use reverse proxy which can be secured better.
"Port": 9200,

// Url, default: metrics/
// Probably best to leave this as is, and use reverse proxy which can be secured better.
// If above is default, the full url becomes http://127.0.0.1:9200/metrics/ to access
"Url": "metrics/",

// UseHTTPs, default: false
// Probably best to leave this as is, and use reverse proxy which can be secured better.
// If above is default, the full url becomes https://127.0.0.1:9200/metrics to access
"UseHTTPs": false
}
}
49 changes: 49 additions & 0 deletions Source/ACE.Server/Managers/GuidManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ public static class GuidManager

private class PlayerGuidAllocator
{
private readonly uint min;
private readonly uint max;
private uint current;
private readonly string name;

public PlayerGuidAllocator(uint min, uint max, string name)
{
this.min = min;
this.max = max;

// Read current value out of ShardDatabase
Expand Down Expand Up @@ -99,13 +101,24 @@ public uint Current()
{
return current;
}

public uint Min()
{
return min;
}

public uint Max()
{
return max;
}
}

/// <summary>
/// On a server with ~500 players, about 10,000,000 dynamic GUID's will be requested every 24hr period.
/// </summary>
private class DynamicGuidAllocator
{
private readonly uint min;
private readonly uint max;
private uint current;
private readonly string name;
Expand All @@ -129,6 +142,7 @@ private class DynamicGuidAllocator

public DynamicGuidAllocator(uint min, uint max, string name, bool unlimitedGaps)
{
this.min = min;
this.max = max;

// Read current value out of ShardDatabase
Expand Down Expand Up @@ -249,6 +263,32 @@ public uint Current()
return current;
}

public uint Min()
{
return min;
}

public uint Max()
{
return max;
}

public int SequenceGapPairsTotal => availableIDs.Count;

public uint SequenceGapTotalAvailable()
{
lock (this)
{
uint total = 0;
foreach (var (start, end) in availableIDs)
total += end - start + 1;

return total;
}
}

public int RecycledGuidsTotal => recycledGuids.Count;

public void Recycle(uint guid)
{
lock (this)
Expand Down Expand Up @@ -352,5 +392,14 @@ public static string GetIdListCommandOutput()

return message;
}

public static uint PlayerMin => playerAlloc?.Min() ?? 0;
public static uint PlayerCurrent => playerAlloc?.Current() ?? 0;
public static uint PlayerMax => playerAlloc?.Max() ?? 0;
public static uint DynamicMin => dynamicAlloc?.Min() ?? 0;
public static uint DynamicCurrent => dynamicAlloc?.Current() ?? 0;
public static uint DynamicMax => dynamicAlloc?.Max() ?? 0;
public static int SequenceGapPairsTotal => dynamicAlloc?.SequenceGapPairsTotal ?? 0;
public static int RecycledGuidsTotal => dynamicAlloc?.RecycledGuidsTotal ?? 0;
}
}
20 changes: 19 additions & 1 deletion Source/ACE.Server/Managers/HouseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public static class HouseManager

public static void Initialize()
{
TotalOwnedHousingByType[HouseType.Apartment] = 0;
TotalOwnedHousingByType[HouseType.Cottage] = 0;
TotalOwnedHousingByType[HouseType.Villa] = 0;
TotalOwnedHousingByType[HouseType.Mansion] = 0;

BuildHouseIdToGuid();

BuildRentQueue();
Expand Down Expand Up @@ -198,6 +203,8 @@ private static void AddRentQueue(IPlayer player, House house)
var playerHouse = new PlayerHouse(player, house);

RentQueue.Add(playerHouse);

TotalOwnedHousingByType[playerHouse.House.HouseType]++;
}

/// <summary>
Expand Down Expand Up @@ -336,6 +343,7 @@ public static void Tick()
while (currentTime > nextEntry.RentDue)
{
RentQueue.Remove(nextEntry);
DecrementTotalOwnedHousingByType(nextEntry.House.HouseType);

ProcessRent(nextEntry);

Expand Down Expand Up @@ -507,6 +515,7 @@ public static void HandleEviction(House house, uint playerGuid, bool multihouse
if (multihouse)
{
RemoveRentQueue(house.Guid.Full);
DecrementTotalOwnedHousingByType(house.HouseType);

player.SaveBiotaToDatabase();

Expand Down Expand Up @@ -621,7 +630,7 @@ private static HouseData GetHouseData(House house)
}

// This function is called from a database callback.
// We must add thread safety to prevent AllegianceManager corruption
// We must add thread safety to prevent HouseManager corruption
public static void HandlePlayerDelete(uint playerGuid)
{
WorldManager.EnqueueAction(new ActionEventDelegate(() => DoHandlePlayerDelete(playerGuid)));
Expand Down Expand Up @@ -654,6 +663,7 @@ private static void DoHandlePlayerDelete(uint playerGuid)
HandleEviction(playerHouse, true);

RemoveRentQueue(house.Guid.Full);
DecrementTotalOwnedHousingByType(house.HouseType);
});
}

Expand Down Expand Up @@ -921,5 +931,13 @@ public static void PayAllRent()
PayRent(house);
}
}

public static int TotalOwnedHousing => RentQueue?.Count ?? 0;

public static Dictionary<HouseType, int> TotalOwnedHousingByType = new Dictionary<HouseType, int>();

public static void IncrementTotalOwnedHousingByType(HouseType houseType) => TotalOwnedHousingByType[houseType]++;

public static void DecrementTotalOwnedHousingByType(HouseType houseType) => TotalOwnedHousingByType[houseType]--;
}
}
10 changes: 10 additions & 0 deletions Source/ACE.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ public static void Main(string[] args)
Environment.Exit(0);
}

if (ConfigManager.Config.Metrics.EnableMetricsServer)
{
log.Info("Initializing Metrics Server...");
InitMetrics();
}
else
log.Info("Metrics Server Disabled...");

log.Info("Initializing ServerManager...");
ServerManager.Initialize();

Expand Down Expand Up @@ -350,6 +358,8 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc

private static void OnProcessExit(object sender, EventArgs e)
{
ShutdownMetrics();

if (!IsRunningInContainer)
{
if (!ServerManager.ShutdownInitiated)
Expand Down
Loading