Skip to content

Commit

Permalink
fix forced on sni log entries (#1580)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wraith2 authored Apr 29, 2022
1 parent c1edc1a commit 11f6ad0
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,9 @@ internal long TrySNIScopeEnterEvent(string className, [System.Runtime.CompilerSe
{
if (Log.IsSNIScopeEnabled())
{
StringBuilder sb = new StringBuilder(className);
sb.Append(".").Append(memberName).Append(" | SNI | INFO | SCOPE | Entering Scope {0}");
return SNIScopeEnter(sb.ToString());
long scopeId = Interlocked.Increment(ref s_nextSNIScopeId);
WriteEvent(SNIScopeEnterId, $"{className}.{memberName} | SNI | INFO | SCOPE | Entering Scope {scopeId}");
return scopeId;
}
return 0;
}
Expand Down Expand Up @@ -1017,7 +1017,6 @@ internal void BeginExecute(int objectId, string dataSource, string database, str
[Event(EndExecuteEventId, Keywords = Keywords.ExecutionTrace, Task = Tasks.ExecuteCommand, Opcode = EventOpcode.Stop)]
internal void EndExecute(int objectId, int compositestate, int sqlExceptionNumber, string message)
{

WriteEvent(EndExecuteEventId, objectId, compositestate, sqlExceptionNumber, message);
}

Expand Down Expand Up @@ -1130,10 +1129,17 @@ internal static class EventType
private readonly long _scopeId;

public TrySNIEventScope(long scopeID) => _scopeId = scopeID;
public void Dispose() =>
SqlClientEventSource.Log.SNIScopeLeave(string.Format("Exit SNI Scope {0}", _scopeId));
public void Dispose()
{
if (_scopeId == 0)
{
return;
}
SqlClientEventSource.Log.TrySNIScopeLeaveEvent(_scopeId);
}

public static TrySNIEventScope Create(string message) => new TrySNIEventScope(SqlClientEventSource.Log.SNIScopeEnter(message));
public static TrySNIEventScope Create(string className, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "")
=> new TrySNIEventScope(SqlClientEventSource.Log.TrySNIScopeEnterEvent(className, memberName));
}

internal readonly ref struct TryEventScope //: IDisposable
Expand Down

0 comments on commit 11f6ad0

Please sign in to comment.