-
Background: We have frequent DB context leaks. We have started recording ( [Event(2)]
public void ContextName(string name, string createdAt)
{
this.WriteEvent(2, name, createdAt);
}
protected override void OnEventCommand(EventCommandEventArgs command)
{
base.OnEventCommand(command);
if (command.Command == EventCommand.Enable)
{
foreach (var entry in ContextDictionary.Instance.AllContexts)
{
this.ContextName(entry.ContextKey.ToString(), entry.StackTraceAsString);
}
}
} Seeing real tack traces for events is fantastic. So my question: Would it be possible to dump the stack trace as-is with the Event Source? So that I could just press |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I'm not sure I fully understand, so please correct me if I go off in a different direction. There are a couple of ways that you can get stack traces through ETW. One is that each time an event is emitted, you can get the stack trace at the time and place of the event. Or, if for some reason you can't emit an event at the time and place of the stack, you can always use Hope that helps - let me know if I completely missed your question. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. Sorry about being imprecise. What I basically want is: var stack = new StackTrace(); // NO perfview is running. We store the stacktrace somewhere.
// then later on, maybe 15min later we start perfView
EtwFooBar.Log.ContextWasCreatedAt(stack); // ideally we display it no as s string. But using the stack viewer of PerfView I guess that this isn't possible. After all, the recoding of the stacktrace is done by the kernel, right? Anyways, feel free to close this. It was a shot in the dark but I'm pretty sure this isnt possible. I guess I'll stick with a string-payload for the stack. :) Cheers |
Beta Was this translation helpful? Give feedback.
Now I understand - you're right, there isn't a good way to do this with just ETW because the stack that you want has to be captured before ETW tracing starts, and ETW is the thing that would capture the stack.
That said, if what you're really after is PerfView showing the stacks in the stack viewer, this is possible. What you'd do is capture the stack as you do today, and emit it into your own event. Then, you can implement a PerfView plugin that takes your events and builds a
StackSource
. You then surface thatStackSource
through your plugin in your own view.This would give you the same type of behavior as the AnyStacks view. If you're just talking about one stack, this might not be wor…