private void CommitDispatchConfiguration() { Debug.Assert(Monitor.IsEntered(m_dispatchControlLock)); // Ensure that the dispatch task is stopped. // This is a no-op if the task is already stopped. StopDispatchTask(); // Stop tracing. // This is a no-op if it's already disabled. EventPipeInternal.Disable(m_sessionID); // Check to see if tracing should be enabled. if (m_subscriptions.Count <= 0) { return; } // Determine the keywords and level that should be used based on the set of enabled EventListeners. EventKeywords aggregatedKeywords = EventKeywords.None; EventLevel highestLevel = EventLevel.LogAlways; foreach (EventListenerSubscription subscription in m_subscriptions.Values) { aggregatedKeywords |= subscription.MatchAnyKeywords; highestLevel = (subscription.Level > highestLevel) ? subscription.Level : highestLevel; } // Enable the EventPipe session. EventPipeProviderConfiguration[] providerConfiguration = new EventPipeProviderConfiguration[] { new EventPipeProviderConfiguration(RuntimeEventSource.EventSourceName, (ulong)aggregatedKeywords, (uint)highestLevel, null) }; m_sessionID = EventPipeInternal.Enable(null, 1024, 1, providerConfiguration, 1, 0); Debug.Assert(m_sessionID != 0); // Get the session information that is required to properly dispatch events. EventPipeSessionInfo sessionInfo; unsafe { if (!EventPipeInternal.GetSessionInfo(m_sessionID, &sessionInfo)) { Debug.Assert(false, "GetSessionInfo returned false."); } } m_syncTimeUtc = DateTime.FromFileTimeUtc(sessionInfo.StartTimeAsUTCFileTime); m_syncTimeQPC = sessionInfo.StartTimeStamp; m_timeQPCFrequency = sessionInfo.TimeStampFrequency; // Start the dispatch task. StartDispatchTask(); }
private void CommitDispatchConfiguration() { // Ensure that the dispatch task is stopped. // This is a no-op if the task is already stopped. StopDispatchTask(); // Stop tracing. // This is a no-op if it's already disabled. EventPipeInternal.Disable(); // Check to see if tracing should be enabled. if (m_subscriptions.Count <= 0) { return; } // Start collecting events. EventKeywords aggregatedKeywords = EventKeywords.None; EventLevel highestLevel = EventLevel.LogAlways; foreach (EventListenerSubscription subscription in m_subscriptions.Values) { aggregatedKeywords |= subscription.MatchAnyKeywords; highestLevel = (subscription.Level > highestLevel) ? subscription.Level : highestLevel; } EventPipeProviderConfiguration[] providerConfiguration = new EventPipeProviderConfiguration[] { new EventPipeProviderConfiguration(RuntimeEventSource.EventSourceName, (ulong)aggregatedKeywords, (uint)highestLevel) }; EventPipeInternal.Enable(null, 1024, 1, providerConfiguration, 1); // Start the dispatch task. StartDispatchTask(); }
internal static void Disable() { EventPipeInternal.Disable(s_sessionID); }
internal static void Disable() { EventPipeInternal.Disable(); }