Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NameResolutionTelemetry.cs
Go to the documentation of this file.
6
7namespace System.Net;
8
9[EventSource(Name = "System.Net.NameResolution")]
10internal sealed class NameResolutionTelemetry : EventSource
11{
12 public static readonly NameResolutionTelemetry Log = new NameResolutionTelemetry();
13
15
17
19
20 private long _lookupsRequested;
21
22 private long _currentLookups;
23
25 {
26 if (command.Command != EventCommand.Enable)
27 {
28 return;
29 }
30 if (_lookupsRequestedCounter == null)
31 {
32 _lookupsRequestedCounter = new PollingCounter("dns-lookups-requested", this, () => Interlocked.Read(ref _lookupsRequested))
33 {
34 DisplayName = "DNS Lookups Requested"
35 };
36 }
37 if (_currentLookupsCounter == null)
38 {
39 _currentLookupsCounter = new PollingCounter("current-dns-lookups", this, () => Interlocked.Read(ref _currentLookups))
40 {
41 DisplayName = "Current DNS Lookups"
42 };
43 }
44 if (_lookupsDuration == null)
45 {
46 _lookupsDuration = new EventCounter("dns-lookups-duration", this)
47 {
48 DisplayName = "Average DNS Lookup Duration",
49 DisplayUnits = "ms"
50 };
51 }
52 }
53
54 [Event(1, Level = EventLevel.Informational)]
56 {
58 }
59
60 [Event(2, Level = EventLevel.Informational)]
61 private void ResolutionStop()
62 {
63 WriteEvent(2);
64 }
65
66 [Event(3, Level = EventLevel.Informational)]
67 private void ResolutionFailed()
68 {
69 WriteEvent(3);
70 }
71
72 [NonEvent]
89
90 [NonEvent]
92 {
93 if (!stopwatch.IsActive)
94 {
95 return;
96 }
98 _lookupsDuration.WriteMetric(stopwatch.GetElapsedTime().TotalMilliseconds);
99 if (IsEnabled(EventLevel.Informational, EventKeywords.None))
100 {
101 if (!successful)
102 {
104 }
106 }
107 }
108}
unsafe void WriteEvent(int eventId)
void AfterResolution(ValueStopwatch stopwatch, bool successful)
static readonly NameResolutionTelemetry Log
override void OnEventCommand(EventCommandEventArgs command)
void ResolutionStart(string hostNameOrAddress)
ValueStopwatch BeforeResolution(object hostNameOrAddress)
static int Decrement(ref int location)
static long Read(ref long location)
static int Increment(ref int location)
static Microsoft.Extensions.Internal.ValueStopwatch StartNew()