-
-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathDbInterceptionIntegration.cs
More file actions
30 lines (26 loc) · 885 Bytes
/
DbInterceptionIntegration.cs
File metadata and controls
30 lines (26 loc) · 885 Bytes
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
namespace Sentry.EntityFramework;
internal class DbInterceptionIntegration : ISdkIntegration, ISentryTracingIntegration
{
// Internal for testing.
internal IDbInterceptor? SqlInterceptor { get; private set; }
internal const string SampleRateDisabledMessage = "EF performance won't be collected because TracesSampleRate is set to 0.";
public void Register(IHub hub, SentryOptions options)
{
if (!options.IsPerformanceMonitoringEnabled)
{
options.DiagnosticLogger?.LogInfo(SampleRateDisabledMessage);
}
else
{
SqlInterceptor = new SentryQueryPerformanceListener(hub, options);
DbInterception.Add(SqlInterceptor);
}
}
public void Unregister()
{
if (SqlInterceptor is { } interceptor)
{
DbInterception.Remove(interceptor);
}
}
}