Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,15 @@ namespace Microsoft.Data.Common

internal static class ActivityCorrelator
{
internal class ActivityId
internal sealed class ActivityId
{
internal Guid Id { get; private set; }
internal uint Sequence { get; private set; }
internal readonly Guid Id;
internal readonly uint Sequence;

internal ActivityId()
internal ActivityId(uint sequence)
{
this.Id = Guid.NewGuid();
this.Sequence = 0; // the first event will start 1
}

// copy-constructor
internal ActivityId(ActivityId activity)
{
this.Id = activity.Id;
this.Sequence = activity.Sequence;
}

internal void Increment()
{
unchecked
{
++this.Sequence;
}
this.Sequence = sequence;
}

public override string ToString()
Expand All @@ -61,10 +46,9 @@ internal static ActivityId Current
{
if (t_tlsActivity == null)
{
t_tlsActivity = new ActivityId();
t_tlsActivity = new ActivityId(1);
}

return new ActivityId(t_tlsActivity);
return t_tlsActivity;
}
}

Expand All @@ -74,14 +58,9 @@ internal static ActivityId Current
/// <returns>ActivityId</returns>
internal static ActivityId Next()
{
if (t_tlsActivity == null)
{
t_tlsActivity = new ActivityId();
}

t_tlsActivity.Increment();
t_tlsActivity = new ActivityId( (t_tlsActivity?.Sequence ?? 0) + 1);

return new ActivityId(t_tlsActivity);
return t_tlsActivity;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,10 @@ internal void Deactivate(bool connectionIsDoomed)
{
// Called when the connection that owns us is deactivated.
SqlClientEventSource.Log.AdvanceTrace("<sc.TdsParser.Deactivate|ADV> {0}# deactivating", ObjectID);
SqlClientEventSource.Log.StateDumpEvent("<sc.TdsParser.Deactivate|STATE> {0}# {1}", ObjectID, TraceString());
if (SqlClientEventSource.Log.IsStateDumpEnabled())
{
SqlClientEventSource.Log.StateDumpEvent("<sc.TdsParser.Deactivate|STATE> {0}# {1}", ObjectID, TraceString());
}

if (MARSOn)
{
Expand Down Expand Up @@ -12631,13 +12634,13 @@ private bool TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsParserStateObjec
;
internal string TraceString()
{
return String.Format(/*IFormatProvider*/ null,
return string.Format(/*IFormatProvider*/ null,
StateTraceFormatString,
null == _physicalStateObj,
null == _pMarsPhysicalConObj,
null == _physicalStateObj ? bool.TrueString : bool.FalseString,
null == _pMarsPhysicalConObj ? bool.TrueString : bool.FalseString,
_state,
_server,
_fResetConnection,
_fResetConnection ? bool.TrueString : bool.FalseString,
null == _defaultCollation ? "(null)" : _defaultCollation.TraceString(),
_defaultCodePage,
_defaultLCID,
Expand All @@ -12649,17 +12652,17 @@ internal string TraceString()
_retainedTransactionId,
_nonTransactedOpenResultCount,
null == _connHandler ? "(null)" : _connHandler.ObjectID.ToString((IFormatProvider)null),
_fMARS,
_fMARS ? bool.TrueString : bool.FalseString,
null == _sessionPool ? "(null)" : _sessionPool.TraceString(),
_isYukon,
_isYukon ? bool.TrueString : bool.FalseString,
null == _sniSpnBuffer ? "(null)" : _sniSpnBuffer.Length.ToString((IFormatProvider)null),
_physicalStateObj != null ? "(null)" : _physicalStateObj.ErrorCount.ToString((IFormatProvider)null),
_physicalStateObj != null ? "(null)" : _physicalStateObj.WarningCount.ToString((IFormatProvider)null),
_physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionErrorCount.ToString((IFormatProvider)null),
_physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionWarningCount.ToString((IFormatProvider)null),
null == _statistics,
_statisticsIsInTransaction,
_fPreserveTransaction,
null == _statistics ? bool.TrueString : bool.FalseString,
_statisticsIsInTransaction ? bool.TrueString : bool.FalseString,
_fPreserveTransaction ? bool.TrueString : bool.FalseString,
null == _connHandler ? "(null)" : _connHandler.ConnectionOptions.MultiSubnetFailover.ToString((IFormatProvider)null));
}

Expand Down