This repository has been archived by the owner on Nov 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathReporter.cs
70 lines (60 loc) · 2.37 KB
/
Reporter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using Improbable.OnlineServices.DataModel.Gateway;
using Prometheus;
namespace Gateway
{
public static class Reporter
{
private static Counter _joinCounter;
private static Counter _joinStatusCounter;
private static Counter _cancelJoinCounter;
private static Counter _transactionAbortedCounter;
private static Histogram _spatialClientHistogram;
static Reporter()
{
_joinCounter = Metrics.CreateCounter("i8e_gateway_join_request_total", "Total number of join requests.",
"state");
_joinStatusCounter = Metrics.CreateCounter("i8e_gateway_join_status_request_total",
"Total number of join status requests.", "state");
_cancelJoinCounter = Metrics.CreateCounter("i8e_gateway_cancel_join_request_total",
"Total number of join cancellations.", "state");
_transactionAbortedCounter = Metrics.CreateCounter("i8e_gateway_transaction_aborted_total",
"Total number of transactions aborted", "RPC");
_spatialClientHistogram = Metrics.CreateHistogram("i8e_gateway_spatial_calls_seconds_total",
"Histogram for requests for waiting players.",
buckets: new[] { .001, .005, .01, .05, 0.075, .1, .25, .5, 1, 2, 5, 10 },
labelNames: "method");
}
public static void JoinRequestInc()
{
_joinCounter.Labels("New").Inc();
}
public static void JoinRequestQueuedInc()
{
_joinCounter.Labels("Queued").Inc();
}
public static void JoinStatusInc(MatchState state)
{
_joinStatusCounter.Labels(state.ToString("G")).Inc();
}
public static void JoinStatusNotFoundInc()
{
_joinStatusCounter.Labels("NotFound").Inc();
}
public static void CancelJoinInc()
{
_cancelJoinCounter.Labels("Success").Inc();
}
public static void CancelJoinNotFoundInc()
{
_cancelJoinCounter.Labels("NotFound").Inc();
}
public static void SpatialCallsInc(string method, double sec)
{
_spatialClientHistogram.Labels(method).Observe(sec);
}
public static void TransactionAbortedInc(string rpc)
{
_transactionAbortedCounter.Labels(rpc).Inc();
}
}
}