Skip to content
Jon Wagner edited this page Mar 6, 2014 · 2 revisions

EventKeywords

EventKeywords let you specify groups of events. For example, you may classify your events as IO, Compression, DataAccess, etc. It helps with analysis, as well as optimizing logging performance by enabling/disabling logging at a keyword level.

AutoKeywords

You can also have ESP generate keywords for you. You can set it globally with:

EventSourceImplementer.ForceAutoKeywords = true

You can set it on an individual event source with:

[EventSourceImplementation(AutoKeywords=true)]

Windows only allows 44 user keywords on an EventSource, and will throw an exception if you try to add more. So, when generating Keywords, ESP will fold names using the following rules:

  • Fold XXX, BeginXXX, EndXXX, and XXXAsync into a Keyword for XXX.
  • Ignore any Keywords past the 44th Keywords.

Getting the Value of AutoKeywords

If you need to programmatically access the value of a keyword, you can use:

EventKeywords kw = EventSourceImplementer.GetKeywordValue<T>(methodName);

Too Many Keywords?

If you end up with too many Keywords, you will have to specify them yourself. You can do this by adding Event attributes to your methods (or by adding an EventAttributeProvider).

[EventSourceImplementation(Keywords=typeof(BeerKeywords))]
public interface IBeerRepository
{
	[Event(Keywords=BeerKeywords.Beer)]
	void BeerAdded(Beer beer);

	[Event(Keywords=BeerKeywords.Beer)]
	void BeerRemoved(Beer beer);

	[Event(Keywords=BeerKeywords.Glass)]
	void GlassAdded(Glass glass);

	[Event(Keywords=BeerKeywords.Glass)]
	void GlassRemoved(Glass glass);
}