-
Notifications
You must be signed in to change notification settings - Fork 87
/
Statistics.cs
89 lines (70 loc) · 1.94 KB
/
Statistics.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
using System.Threading;
namespace zipkin4net.Tracers.Zipkin
{
/// <summary>
/// Some statistics about the tracing
/// </summary>
public interface IStatistics
{
/// <summary>
/// Number of record processed by the tracer
/// </summary>
long RecordProcessed { get; }
/// <summary>
/// Number of span sent
/// </summary>
long SpanSent { get; }
/// <summary>
/// Total number of bytes of the sent spans
/// </summary>
long SpanSentTotalBytes { get; }
/// <summary>
/// Number of span sent after staying
/// too much time without being completed
/// </summary>
long SpanFlushed { get; }
void UpdateRecordProcessed();
void UpdateSpanSent();
void UpdateSpanFlushed();
void UpdateSpanSentBytes(int bytesSent);
}
public class Statistics : IStatistics
{
private long _recordProcessed;
private long _spanSent;
private long _spanFlushed;
private long _spanSentTotalBytes;
public long RecordProcessed
{
get { return _recordProcessed; }
}
public long SpanSent
{
get { return _spanSent; }
}
public long SpanFlushed
{
get { return _spanFlushed; }
}
public long SpanSentTotalBytes
{
get { return _spanSentTotalBytes; }
}
public void UpdateRecordProcessed()
{
Interlocked.Increment(ref _recordProcessed);
}
public void UpdateSpanSent()
{
Interlocked.Increment(ref _spanSent);
}
public void UpdateSpanFlushed()
{
Interlocked.Increment(ref _spanFlushed);
}
public void UpdateSpanSentBytes(int bytesSent)
{
Interlocked.Add(ref _spanSentTotalBytes, bytesSent);
}
}
}