Skip to content

Commit 462267a

Browse files
committed
feat(telemetry): ensure deterministic EventSource construction
1 parent 9b3f2a6 commit 462267a

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/HttpUserAgentParser.AspNetCore/Telemetry/HttpUserAgentParserAspNetCoreTelemetry.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public static bool AreMetersEnabled
7373
/// </summary>
7474
public static void Enable()
7575
{
76+
// Force EventSource construction at enable-time so listeners can subscribe deterministically.
77+
// This avoids CI-only timing races where first telemetry events happen before listener attachment.
7678
_ = HttpUserAgentParserAspNetCoreEventSource.Log;
7779
Interlocked.Or(ref s_enabledFlags, EventCountersFlag);
7880
}

src/HttpUserAgentParser.MemoryCache/Telemetry/HttpUserAgentParserMemoryCacheTelemetry.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public static bool IsCacheSizeEnabled
5454
/// </summary>
5555
public static void Enable()
5656
{
57+
// Force EventSource construction at enable-time so listeners can subscribe deterministically.
58+
// This avoids CI-only timing races where first telemetry events happen before listener attachment.
5759
_ = HttpUserAgentParserMemoryCacheEventSource.Log;
5860
Interlocked.Or(ref s_enabledFlags, EventCountersFlag);
5961
}

src/HttpUserAgentParser/Telemetry/HttpUserAgentParserTelemetry.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public static bool IsCacheSizeEnabled
6262
/// </summary>
6363
public static void Enable()
6464
{
65+
// Force EventSource construction at enable-time so listeners can subscribe deterministically.
66+
// This avoids CI-only timing races where first telemetry events happen before listener attachment.
6567
_ = HttpUserAgentParserEventSource.Log;
6668
Interlocked.Or(ref s_enabledFlags, EventCountersFlag);
6769
}

0 commit comments

Comments
 (0)