-
Notifications
You must be signed in to change notification settings - Fork 874
Expand file tree
/
Copy pathNpgsqlSqlEventSource.cs
More file actions
28 lines (20 loc) · 1.02 KB
/
NpgsqlSqlEventSource.cs
File metadata and controls
28 lines (20 loc) · 1.02 KB
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
using System.Diagnostics.Tracing;
namespace Npgsql;
sealed class NpgsqlSqlEventSource : EventSource
{
public static readonly NpgsqlSqlEventSource Log = new();
const string EventSourceName = "Npgsql.Sql";
const int CommandStartId = 3;
const int CommandStopId = 4;
internal NpgsqlSqlEventSource() : base(EventSourceName) {}
// NOTE
// - The 'Start' and 'Stop' suffixes on the following event names have special meaning in EventSource. They
// enable creating 'activities'.
// For more information, take a look at the following blog post:
// https://blogs.msdn.microsoft.com/vancem/2015/09/14/exploring-eventsource-activity-correlation-and-causation-features/
// - A stop event's event id must be next one after its start event.
[Event(CommandStartId, Level = EventLevel.Informational)]
public void CommandStart(string sql) => WriteEvent(CommandStartId, sql);
[Event(CommandStopId, Level = EventLevel.Informational)]
public void CommandStop() => WriteEvent(CommandStopId);
}