Skip to content

Commit 0ff7bdd

Browse files
author
Liudmila Molkova
authored
When Activity stack is too deep, do not write Id to error message (#43)
When Activity step is too deep, do not write Id to error message
1 parent a7d5d69 commit 0ff7bdd

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/Microsoft.AspNet.TelemetryCorrelation/ActivityHelper.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ public static bool StopAspNetActivity(Activity activity, IDictionary contextItem
9090
// in case it would ever be possible to have cycles in the Activity stack.
9191
if (iteration++ == MaxActivityStackSize)
9292
{
93-
AspNetTelemetryCorrelationEventSource.Log.ActivityStackIsTooDeep(currentActivity.Id, currentActivity.OperationName);
93+
// this is for internal error reporting
94+
AspNetTelemetryCorrelationEventSource.Log.ActivityStackIsTooDeepError();
95+
96+
// this is for debugging
97+
AspNetTelemetryCorrelationEventSource.Log.ActivityStackIsTooDeepDetails(currentActivity.Id, currentActivity.OperationName);
9498
activity.Stop();
9599
return false;
96100
}

src/Microsoft.AspNet.TelemetryCorrelation/AspNetTelemetryCorrelationEventSource.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public void FinishedActivityIsDetected(string id, string name)
5353
WriteEvent(6, id, name);
5454
}
5555

56-
[Event(7, Message = "Activity stack is too deep, Current Id: '{0}', Name: '{1}'", Level = EventLevel.Error)]
57-
public void ActivityStackIsTooDeep(string id, string name)
56+
[Event(7, Message = "System.Diagnostics.Activity stack is too deep. This is a code authoring error, Activity will not be stopped.", Level = EventLevel.Error)]
57+
public void ActivityStackIsTooDeepError()
5858
{
59-
WriteEvent(7, id, name);
59+
WriteEvent(7);
6060
}
6161

6262
[Event(8, Message = "Activity restored, Id='{0}'", Level = EventLevel.Informational)]
@@ -70,6 +70,12 @@ public void OnExecuteRequestStepInvokationError(string error)
7070
{
7171
WriteEvent(9, error);
7272
}
73+
74+
[Event(10, Message = "System.Diagnostics.Activity stack is too deep. Current Id: '{0}', Name: '{1}'", Level = EventLevel.Warning)]
75+
public void ActivityStackIsTooDeepDetails(string id, string name)
76+
{
77+
WriteEvent(10, id, name);
78+
}
7379
}
7480
}
7581
#pragma warning restore SA1600 // Elements must be documented

0 commit comments

Comments
 (0)