-
-
Notifications
You must be signed in to change notification settings - Fork 203
/
ISpanData.cs
78 lines (67 loc) · 2.67 KB
/
ISpanData.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
using Sentry.Protocol;
namespace Sentry;
/// <summary>
/// Immutable data belonging to a span.
/// </summary>
public interface ISpanData : ITraceContext, IHasTags, IHasExtra
{
/// <summary>
/// Start timestamp.
/// </summary>
DateTimeOffset StartTimestamp { get; }
/// <summary>
/// End timestamp.
/// </summary>
DateTimeOffset? EndTimestamp { get; }
/// <summary>
/// Whether the span is finished.
/// </summary>
bool IsFinished { get; }
/// <summary>
/// Get Sentry trace header.
/// </summary>
SentryTraceHeader GetTraceHeader();
/// <summary>
/// The measurements that have been set on the transaction.
/// </summary>
IReadOnlyDictionary<string, Measurement> Measurements { get; }
/// <summary>
/// Sets a measurement on the transaction.
/// </summary>
/// <param name="name">The name of the measurement.</param>
/// <param name="measurement">The measurement.</param>
void SetMeasurement(string name, Measurement measurement);
}
/// <summary>
/// Extensions for <see cref="ISpanData"/>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static class SpanDataExtensions
{
/// <summary>
/// Sets a measurement on the transaction.
/// </summary>
/// <param name="spanData">The transaction.</param>
/// <param name="name">The name of the measurement.</param>
/// <param name="value">The value of the measurement.</param>
/// <param name="unit">The optional unit of the measurement.</param>
public static void SetMeasurement(this ISpanData spanData, string name, int value,
MeasurementUnit unit = default) =>
spanData.SetMeasurement(name, new Measurement(value, unit));
/// <inheritdoc cref="SetMeasurement(Sentry.ISpanData,string,int,Sentry.MeasurementUnit)" />
public static void SetMeasurement(this ISpanData spanData, string name, long value,
MeasurementUnit unit = default) =>
spanData.SetMeasurement(name, new Measurement(value, unit));
/// <inheritdoc cref="SetMeasurement(Sentry.ISpanData,string,int,Sentry.MeasurementUnit)" />
#if !__MOBILE__
// ulong parameter is not CLS compliant
[CLSCompliant(false)]
#endif
public static void SetMeasurement(this ISpanData spanData, string name, ulong value,
MeasurementUnit unit = default) =>
spanData.SetMeasurement(name, new Measurement(value, unit));
/// <inheritdoc cref="SetMeasurement(Sentry.ISpanData,string,int,Sentry.MeasurementUnit)" />
public static void SetMeasurement(this ISpanData spanData, string name, double value,
MeasurementUnit unit = default) =>
spanData.SetMeasurement(name, new Measurement(value, unit));
}