Skip to content

Commit 1bc07c8

Browse files
XiztTejas Kulkarni
andauthored
Added metrics for transaction commands received and executed successfully. (#1310)
* Add metrics for transaction commands received and executed * counting number of failures * missed update. * Removed NullSessionMetrics struct and IMetrics interface. * bumped version --------- Co-authored-by: Tejas Kulkarni <[email protected]>
1 parent dcbf742 commit 1bc07c8

File tree

5 files changed

+50
-101
lines changed

5 files changed

+50
-101
lines changed

Version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<!-- VersionPrefix property for builds and packages -->
33
<PropertyGroup>
4-
<VersionPrefix>1.0.78</VersionPrefix>
4+
<VersionPrefix>1.0.79</VersionPrefix>
55
</PropertyGroup>
66
</Project>

libs/server/Custom/CustomRespCommands.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ private bool TryTransactionProc(byte id, CustomTransactionProcedure proc, int st
2525

2626
LatencyMetrics?.Start(LatencyMetricsType.TX_PROC_LAT);
2727

28+
29+
sessionMetrics?.incr_total_transaction_commands_received();
30+
2831
var procInput = new CustomProcedureInput(ref parseState, startIdx: startIdx, respVersion: respProtocolVersion);
2932
if (txnManager.RunTransactionProc(id, ref procInput, proc, ref output))
3033
{
@@ -37,6 +40,7 @@ private bool TryTransactionProc(byte id, CustomTransactionProcedure proc, int st
3740
}
3841
else
3942
{
43+
sessionMetrics?.incr_total_transaction_execution_failed();
4044
// Write output to wire
4145
if (output.MemoryOwner != null)
4246
SendAndReset(output.MemoryOwner, output.Length);

libs/server/Metrics/GarnetSessionMetrics.cs

Lines changed: 42 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,6 @@
55

66
namespace Garnet.server
77
{
8-
internal struct NullGarnetSessionMetrics : IMetrics
9-
{
10-
public void Add(IMetrics metrics) { }
11-
12-
public void Reset() { }
13-
14-
public void incr_total_net_input_bytes(ulong bytes) { }
15-
16-
public ulong get_total_net_input_bytes() => 0;
17-
18-
public void incr_total_net_output_bytes(ulong bytes) { }
19-
20-
public ulong get_total_net_output_bytes() => 0;
21-
22-
public void incr_total_commands_processed(ulong cmds) { }
23-
24-
public ulong get_total_commands_processed() => 0;
25-
26-
public void incr_total_pending(ulong count = 1) { }
27-
28-
public ulong get_total_pending() => 0;
29-
30-
public void incr_total_found(ulong count = 1) { }
31-
32-
public ulong get_total_found() => 0;
33-
34-
public void incr_total_notfound(ulong count = 1) { }
35-
36-
public ulong get_total_notfound() => 0;
37-
38-
public void incr_total_cluster_commands_processed(ulong count = 1) { }
39-
40-
public ulong get_total_cluster_commands_processed() => 0;
41-
42-
public void add_total_write_commands_processed(ulong count) { }
43-
44-
public void incr_total_write_commands_processed(byte cmd) { }
45-
46-
public ulong get_total_write_commands_processed() => 0;
47-
48-
public void add_total_read_commands_processed(ulong count) { }
49-
50-
public void incr_total_read_commands_processed(byte cmd) { }
51-
52-
public ulong get_total_read_commands_processed() => 0;
53-
54-
public static void incr_total_number_resp_server_session_exceptions(ulong count) { }
55-
56-
public static ulong get_total_number_resp_server_session_exceptions() => 0;
57-
}
58-
598
/// <summary>
609
/// Performance Metrics Emitted from ServerSessionBase
6110
/// </summary>
@@ -106,11 +55,21 @@ public class GarnetSessionMetrics
10655
/// </summary>
10756
public ulong total_read_commands_processed;
10857

58+
/// <summary>
59+
/// Keep track of transaction commands received.
60+
/// </summary>
61+
public ulong total_transactions_commands_received;
62+
10963
/// <summary>
11064
/// Keep track of total number of exceptions triggered in try consume for all resp server sessions
11165
/// </summary>
11266
public ulong total_number_resp_server_session_exceptions;
11367

68+
/// <summary>
69+
/// Keep track of total number of transactions that were executed successfully.
70+
/// </summary>
71+
public ulong total_transaction_commands_execution_failed;
72+
11473
/// <summary>
11574
/// GarnetSessionMetrics constructor
11675
/// </summary>
@@ -133,6 +92,8 @@ internal void Add(GarnetSessionMetrics add)
13392

13493
add_total_write_commands_processed(add.get_total_write_commands_processed());
13594
add_total_read_commands_processed(add.get_total_read_commands_processed());
95+
incr_total_transaction_commands_received(add.get_total_transaction_commands_received());
96+
incr_total_transaction_execution_failed(add.get_total_transaction_commands_execution_failed());
13697

13798
incr_total_number_resp_server_session_exceptions(add.get_total_number_resp_server_session_exceptions());
13899
}
@@ -151,6 +112,8 @@ internal void Reset()
151112
total_cluster_commands_processed = 0;
152113
total_write_commands_processed = 0;
153114
total_read_commands_processed = 0;
115+
total_transactions_commands_received = 0;
116+
total_transaction_commands_execution_failed = 0;
154117
total_number_resp_server_session_exceptions = 0;
155118
}
156119

@@ -266,13 +229,41 @@ internal void Reset()
266229
[MethodImpl(MethodImplOptions.AggressiveInlining)]
267230
public void add_total_read_commands_processed(ulong count) => total_read_commands_processed += count;
268231

232+
/// <summary>
233+
/// Increment total_transactions_commands_received
234+
/// </summary>
235+
/// <param name="count"></param>
236+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
237+
public void incr_total_transaction_commands_received(ulong count = 1) => total_transactions_commands_received += count;
238+
239+
/// <summary>
240+
/// Increment total_transaction_commands_execution_failed
241+
/// </summary>
242+
/// <param name="count"></param>
243+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
244+
public void incr_total_transaction_execution_failed(ulong count = 1) => total_transaction_commands_execution_failed += count;
245+
269246
/// <summary>
270247
/// Get total_read_commands_processed
271248
/// </summary>
272249
/// <returns></returns>
273250
[MethodImpl(MethodImplOptions.AggressiveInlining)]
274251
public ulong get_total_read_commands_processed() => total_read_commands_processed;
275252

253+
/// <summary>
254+
/// Get total_transactions_commands_received
255+
/// </summary>
256+
/// <returns></returns>
257+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
258+
public ulong get_total_transaction_commands_received() => total_transactions_commands_received;
259+
260+
/// <summary>
261+
/// Get total_transaction_commands_execution_failed
262+
/// </summary>
263+
/// <returns></returns>
264+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
265+
public ulong get_total_transaction_commands_execution_failed() => total_transaction_commands_execution_failed;
266+
276267
/// <summary>
277268
/// Increment total_number_resp_server_session_exceptions
278269
/// </summary>

libs/server/Metrics/IMetrics.cs

Lines changed: 0 additions & 48 deletions
This file was deleted.

libs/server/Metrics/Info/GarnetInfoMetrics.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ private void PopulateStatsInfo(StoreWrapper storeWrapper)
206206
new("total_cluster_commands_processed", metricsDisabled ? "0" : globalMetrics.globalSessionMetrics.get_total_cluster_commands_processed().ToString()),
207207
new("total_write_commands_processed", metricsDisabled ? "0" : globalMetrics.globalSessionMetrics.get_total_write_commands_processed().ToString()),
208208
new("total_read_commands_processed", metricsDisabled ? "0" : globalMetrics.globalSessionMetrics.get_total_read_commands_processed().ToString()),
209-
new("total_number_resp_server_session_exceptions", metricsDisabled ? "0" : globalMetrics.globalSessionMetrics.get_total_number_resp_server_session_exceptions().ToString())
209+
new("total_number_resp_server_session_exceptions", metricsDisabled ? "0" : globalMetrics.globalSessionMetrics.get_total_number_resp_server_session_exceptions().ToString()),
210+
new("total_transaction_commands_received", metricsDisabled ? "0" : globalMetrics.globalSessionMetrics.get_total_transaction_commands_received().ToString()),
211+
new("total_transaction_commands_execution_failed", metricsDisabled ? "0" : globalMetrics.globalSessionMetrics.get_total_transaction_commands_execution_failed().ToString()),
210212
];
211213

212214
if (clusterEnabled)

0 commit comments

Comments
 (0)