-
-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathSentryMetricEmitter.Counter.cs
More file actions
74 lines (69 loc) · 4.41 KB
/
Copy pathSentryMetricEmitter.Counter.cs
File metadata and controls
74 lines (69 loc) · 4.41 KB
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
namespace Sentry;
public abstract partial class SentryMetricEmitter
{
/// <summary>
/// Increment a counter.
/// </summary>
/// <param name="name">The name of the metric.</param>
/// <param name="value">The value of the metric.</param>
/// <typeparam name="T">The numeric type of the metric.</typeparam>
/// <remarks>Supported numeric value types for <typeparamref name="T"/> are <see langword="byte"/>, <see langword="short"/>, <see langword="int"/>, <see langword="long"/>, <see langword="float"/>, and <see langword="double"/>.</remarks>
public void EmitCounter<T>(string name, T value) where T : struct
{
CaptureMetric(SentryMetricType.Counter, name, value, null, [], null);
}
/// <summary>
/// Increment a counter.
/// </summary>
/// <param name="name">The name of the metric.</param>
/// <param name="value">The value of the metric.</param>
/// <param name="scope">The scope to capture the metric with.</param>
/// <typeparam name="T">The numeric type of the metric.</typeparam>
/// <remarks>Supported numeric value types for <typeparamref name="T"/> are <see langword="byte"/>, <see langword="short"/>, <see langword="int"/>, <see langword="long"/>, <see langword="float"/>, and <see langword="double"/>.</remarks>
public void EmitCounter<T>(string name, T value, Scope? scope) where T : struct
{
CaptureMetric(SentryMetricType.Counter, name, value, null, [], scope);
}
/// <summary>
/// Increment a counter.
/// </summary>
/// <param name="name">The name of the metric.</param>
/// <param name="value">The value of the metric.</param>
/// <param name="attributes">A dictionary of attributes (key-value pairs with type information).</param>
/// <param name="scope">The scope to capture the metric with.</param>
/// <typeparam name="T">The numeric type of the metric.</typeparam>
/// <remarks>Supported numeric value types for <typeparamref name="T"/> are <see langword="byte"/>, <see langword="short"/>, <see langword="int"/>, <see langword="long"/>, <see langword="float"/>, and <see langword="double"/>.</remarks>
public void EmitCounter<T>(string name, T value, IEnumerable<KeyValuePair<string, object>>? attributes, Scope? scope = null) where T : struct
{
CaptureMetric(SentryMetricType.Counter, name, value, null, attributes, scope);
}
/// <summary>
/// Increment a counter.
/// </summary>
/// <param name="name">The name of the metric.</param>
/// <param name="value">The value of the metric.</param>
/// <param name="attributes">A dictionary of attributes (key-value pairs with type information).</param>
/// <param name="scope">The scope to capture the metric with.</param>
/// <typeparam name="T">The numeric type of the metric.</typeparam>
/// <remarks>Supported numeric value types for <typeparamref name="T"/> are <see langword="byte"/>, <see langword="short"/>, <see langword="int"/>, <see langword="long"/>, <see langword="float"/>, and <see langword="double"/>.</remarks>
public void EmitCounter<T>(string name, T value, ReadOnlySpan<KeyValuePair<string, object>> attributes, Scope? scope = null) where T : struct
{
CaptureMetric(SentryMetricType.Counter, name, value, null, attributes, scope);
}
#if NET6_0_OR_GREATER
/// <summary>
/// Increment a counter.
/// </summary>
/// <param name="name">The name of the metric.</param>
/// <param name="value">The value of the metric.</param>
/// <param name="attributes">A dictionary of attributes (key-value pairs with type information).</param>
/// <param name="scope">The scope to capture the metric with.</param>
/// <typeparam name="T">The numeric type of the metric.</typeparam>
/// <remarks>Supported numeric value types for <typeparamref name="T"/> are <see langword="byte"/>, <see langword="short"/>, <see langword="int"/>, <see langword="long"/>, <see langword="float"/>, and <see langword="double"/>.</remarks>
[SuppressMessage("Roslynator", "RCS1242:Do not pass non-read-only struct by read-only reference", Justification = $"Ensure that only readonly instance members of {nameof(TagList)} are invoked, to avoid a defensive copy created by the compiler.")]
public void EmitCounter<T>(string name, T value, in TagList attributes, Scope? scope = null) where T : struct
{
CaptureMetric(SentryMetricType.Counter, name, value, null, in attributes, scope);
}
#endif
}