Skip to content

Commit 7fa952a

Browse files
authored
try to get around flaky profiler test (#3225)
1 parent da16803 commit 7fa952a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Sentry.Profiling/SamplingTransactionProfilerFactory.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ internal class SamplingTransactionProfilerFactory : IDisposable, ITransactionPro
88
// We only allow a single profile so let's keep track of the current status.
99
internal int _inProgress = FALSE;
1010

11+
// Whether the session startup took longer than the given timeout.
12+
internal bool StartupTimedOut { get; }
13+
1114
private const int TRUE = 1;
1215
private const int FALSE = 0;
1316

@@ -39,6 +42,7 @@ public SamplingTransactionProfilerFactory(SentryOptions options, TimeSpan startu
3942
if (startupTimeout != TimeSpan.Zero && !_sessionTask.Wait(startupTimeout))
4043
{
4144
options.LogWarning("Profiler session startup took longer then the given timeout {0:c}. Profilling will start once the first event is received.", startupTimeout);
45+
StartupTimedOut = true;
4246
}
4347
}
4448

test/Sentry.Profiling.Tests/SamplingTransactionProfilerTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,13 @@ async Task VerifyAsync(HttpRequestMessage message)
319319
options.TransactionProfilerFactory.Should().BeNull();
320320
using var hub = (SentrySdk.InitHub(options) as Hub)!;
321321
SampleProfilerSession.ThrowOnNextStartupForTests.Should().BeFalse();
322+
323+
if (options.TransactionProfilerFactory is SamplingTransactionProfilerFactory factory)
324+
{
325+
factory.StartupTimedOut.Should().BeTrue();
326+
Skip.If(TestEnvironment.IsGitHubActions, "Session sometimes takes too long to start in CI.");
327+
}
328+
322329
options.TransactionProfilerFactory.Should().BeNull();
323330

324331
var clock = SentryStopwatch.StartNew();

0 commit comments

Comments
 (0)