- /** Number of sessions currently enabling the wildcard "*" event */
- private final AtomicInteger enabledWildcards = new AtomicInteger(0);
+ /**
+ * Lock protecting accesses to the {@link #enabledPatterns} and
+ * {@link #enabledEventNamesCache} maps.
+ */
+ private final Lock enabledEventNamesLock = new ReentrantLock();
+
+ /**
+ * The application contexts currently enabled in the tracing sessions.
+ *
+ * It is first indexed by context retriever, then by context name. This
+ * allows to efficiently query all the contexts for a given retriever.
+ *
+ * Works similarly as {@link #enabledEvents}, but for app contexts (and with
+ * an extra degree of indexing).
+ *
+ * TODO Could be changed to a Guava Table once/if we start using it.
+ */
+ private final Map<String, Map<String, Integer>> enabledAppContexts = new ConcurrentHashMap<String, Map<String, Integer>>();