This repository was archived by the owner on Dec 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 872
/
Copy pathRedisStats.cs
168 lines (151 loc) · 6.5 KB
/
RedisStats.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
using System.Collections.Generic;
using System.Threading;
namespace ServiceStack.Redis
{
public static class RedisStats
{
/// <summary>
/// Total number of commands sent
/// </summary>
public static long TotalCommandsSent
{
get { return Interlocked.Read(ref RedisState.TotalCommandsSent); }
}
/// <summary>
/// Number of times the Redis Client Managers have FailoverTo() either by sentinel or manually
/// </summary>
public static long TotalFailovers
{
get { return Interlocked.Read(ref RedisState.TotalFailovers); }
}
/// <summary>
/// Number of times a Client was deactivated from the pool, either by FailoverTo() or exceptions on client
/// </summary>
public static long TotalDeactivatedClients
{
get { return Interlocked.Read(ref RedisState.TotalDeactivatedClients); }
}
/// <summary>
/// Number of times connecting to a Sentinel has failed
/// </summary>
public static long TotalFailedSentinelWorkers
{
get { return Interlocked.Read(ref RedisState.TotalFailedSentinelWorkers); }
}
/// <summary>
/// Number of times we've forced Sentinel to failover to another master due to
/// consecutive errors beyond sentinel.WaitBeforeForcingMasterFailover
/// </summary>
public static long TotalForcedMasterFailovers
{
get { return Interlocked.Read(ref RedisState.TotalForcedMasterFailovers); }
}
/// <summary>
/// Number of times a connecting to a reported Master wasn't actually a Master
/// </summary>
public static long TotalInvalidMasters
{
get { return Interlocked.Read(ref RedisState.TotalInvalidMasters); }
}
/// <summary>
/// Number of times no Masters could be found in any of the configured hosts
/// </summary>
public static long TotalNoMastersFound
{
get { return Interlocked.Read(ref RedisState.TotalNoMastersFound); }
}
/// <summary>
/// Number of Redis Client instances created with RedisConfig.ClientFactory
/// </summary>
public static long TotalClientsCreated
{
get { return Interlocked.Read(ref RedisState.TotalClientsCreated); }
}
/// <summary>
/// Number of times a Redis Client was created outside of pool, either due to overflow or reserved slot was overridden
/// </summary>
public static long TotalClientsCreatedOutsidePool
{
get { return Interlocked.Read(ref RedisState.TotalClientsCreatedOutsidePool); }
}
/// <summary>
/// Number of times Redis Sentinel reported a Subjective Down (sdown)
/// </summary>
public static long TotalSubjectiveServersDown
{
get { return Interlocked.Read(ref RedisState.TotalSubjectiveServersDown); }
}
/// <summary>
/// Number of times Redis Sentinel reported an Objective Down (sdown)
/// </summary>
public static long TotalObjectiveServersDown
{
get { return Interlocked.Read(ref RedisState.TotalObjectiveServersDown); }
}
/// <summary>
/// Number of times a Redis Request was retried due to Socket or Retryable exception
/// </summary>
public static long TotalRetryCount
{
get { return Interlocked.Read(ref RedisState.TotalRetryCount); }
}
/// <summary>
/// Number of times a Request succeeded after it was retried
/// </summary>
public static long TotalRetrySuccess
{
get { return Interlocked.Read(ref RedisState.TotalRetrySuccess); }
}
/// <summary>
/// Number of times a Retry Request failed after exceeding RetryTimeout
/// </summary>
public static long TotalRetryTimedout
{
get { return Interlocked.Read(ref RedisState.TotalRetryTimedout); }
}
/// <summary>
/// Total number of deactivated clients that are pending being disposed
/// </summary>
public static long TotalPendingDeactivatedClients
{
get { return RedisState.DeactivatedClients.Count; }
}
public static void Reset()
{
Interlocked.Exchange(ref RedisState.TotalFailovers, 0);
Interlocked.Exchange(ref RedisState.TotalDeactivatedClients, 0);
Interlocked.Exchange(ref RedisState.TotalFailedSentinelWorkers, 0);
Interlocked.Exchange(ref RedisState.TotalForcedMasterFailovers, 0);
Interlocked.Exchange(ref RedisState.TotalInvalidMasters, 0);
Interlocked.Exchange(ref RedisState.TotalNoMastersFound, 0);
Interlocked.Exchange(ref RedisState.TotalClientsCreated, 0);
Interlocked.Exchange(ref RedisState.TotalClientsCreatedOutsidePool, 0);
Interlocked.Exchange(ref RedisState.TotalSubjectiveServersDown, 0);
Interlocked.Exchange(ref RedisState.TotalObjectiveServersDown, 0);
Interlocked.Exchange(ref RedisState.TotalRetryCount, 0);
Interlocked.Exchange(ref RedisState.TotalRetrySuccess, 0);
Interlocked.Exchange(ref RedisState.TotalRetryTimedout, 0);
}
public static Dictionary<string, long> ToDictionary()
{
return new Dictionary<string, long>
{
{"TotalCommandsSent", TotalCommandsSent},
{"TotalFailovers", TotalFailovers},
{"TotalDeactivatedClients", TotalDeactivatedClients},
{"TotalFailedSentinelWorkers", TotalFailedSentinelWorkers},
{"TotalForcedMasterFailovers", TotalForcedMasterFailovers},
{"TotalInvalidMasters", TotalInvalidMasters},
{"TotalNoMastersFound", TotalNoMastersFound},
{"TotalClientsCreated", TotalClientsCreated},
{"TotalClientsCreatedOutsidePool", TotalClientsCreatedOutsidePool},
{"TotalSubjectiveServersDown", TotalSubjectiveServersDown},
{"TotalObjectiveServersDown", TotalObjectiveServersDown},
{"TotalPendingDeactivatedClients", TotalPendingDeactivatedClients },
{"TotalRetryCount", TotalRetryCount },
{"TotalRetrySuccess", TotalRetrySuccess },
{"TotalRetryTimedout", TotalRetryTimedout },
};
}
}
}