jonwagner / EventSourceProxy

EventSourceProxy (ESP) is the easiest way to add scalable Event Tracing for Windows (ETW) logging to your .NET program
Other
97 stars 20 forks source link

Do not generate _Completed and _Faulted events when not using a Tracing Proxy #11

Closed jonwagner closed 10 years ago

jonwagner commented 10 years ago

When ESP generates an EventSource, for each method x, it also generates x_Completed and x_Faulted events. These methods are intended to be used for TracingProxy, so should not be emitted if not creating a proxy.

jonwagner commented 10 years ago

This one is a dilemma. Right now, ESP always generates the extra events on interfaces, so you can always do:

var log = EventSourceImplementer.GetEventSource<ISource>();
var proxy = new TracingProxy<ISource>(foo);

The proxy binds to the extra events on the log, since they are always there. You can only define a logger once. If we don't always put them there, then the behavior will depend upon whether the logger is created first or the proxy. That would be bad.

One option would be to generate them on interfaces, but not on abstract EventSource classes (since they would never be needed). I'm not sure if that would be confusing.

jonwagner commented 10 years ago

The latest code no longer generates complement methods (Completed/Faulted) when implementing a class derived from EventSource. (v2.0.1 and later)

I'll keep thinking on this for a bit.

mot256 commented 10 years ago

My suggestion, if you still need to generate the the extra _Completed and _Faulted events for interfaces it to use event IDs from the other side of the integer spectrum (i.e. use IDs counted back from int.Max) or give the user the ability to specify specific IDs for those events (thus letting the user consciously know what IDs are used for what).

jonwagner commented 10 years ago

I tried Int32.Max, but the EventSource class does this:

_somevariable = new int [MAX(EventID)];

Boom! OutOfMemoryException.

So I'm leaning toward disabling it for EventSource-derived classes (it's not needed), and maybe giving an option to turn it off. Or perhaps leaving it off, and letting people turn it on.

Or more magic. I'm good at magic.

Thanks for the feedback.

jonwagner commented 10 years ago

I'm going with:

  1. Default behavior is ImplementComplementMethods if type is not a subclass of EventSource. This handles most of the cases and most people can just ignore this completely.
  2. Added EventSourceImplementationAttribute.ImplementComplementMethods property.

This is in v2.0.1

ailn commented 10 years ago

Jon, ImplementComplementMethods is nullable and the VS 2013 compiler does not allow to set a value for it: Error 1 'ImplementComplementMethods' is not a valid named attribute argument because it is not a valid attribute parameter type

jonwagner commented 10 years ago

I fixed this in 2.0.2. Hang on...