Esempio n. 1
0
        public static void UpdateFilter(ref ActivityFilter filterList, EventSource source, int perEventSourceSessionId, string startEvents)
        {
            ActivityFilter.DisableFilter(ref filterList, source);
            if (string.IsNullOrEmpty(startEvents))
            {
                return;
            }
            string str1 = startEvents;

            char[] chArray = new char[1] {
                ' '
            };
            foreach (string str2 in str1.Split(chArray))
            {
                int result1 = 1;
                int result2 = -1;
                int length  = str2.IndexOf(':');
                if (length < 0)
                {
                    source.ReportOutOfBandMessage("ERROR: Invalid ActivitySamplingStartEvent specification: " + str2, false);
                }
                else
                {
                    string s = str2.Substring(length + 1);
                    if (!int.TryParse(s, out result1))
                    {
                        source.ReportOutOfBandMessage("ERROR: Invalid sampling frequency specification: " + s, false);
                    }
                    else
                    {
                        string str3 = str2.Substring(0, length);
                        if (!int.TryParse(str3, out result2))
                        {
                            result2 = -1;
                            for (int index = 0; index < source.m_eventData.Length; ++index)
                            {
                                EventSource.EventMetadata[] eventMetadataArray = source.m_eventData;
                                if (eventMetadataArray[index].Name != null && eventMetadataArray[index].Name.Length == str3.Length && string.Compare(eventMetadataArray[index].Name, str3, StringComparison.OrdinalIgnoreCase) == 0)
                                {
                                    result2 = eventMetadataArray[index].Descriptor.EventId;
                                    break;
                                }
                            }
                        }
                        if (result2 < 0 || result2 >= source.m_eventData.Length)
                        {
                            source.ReportOutOfBandMessage("ERROR: Invalid eventId specification: " + str3, false);
                        }
                        else
                        {
                            ActivityFilter.EnableFilter(ref filterList, source, perEventSourceSessionId, result2, result1);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 // Token: 0x0600342C RID: 13356 RVA: 0x000C9DD0 File Offset: 0x000C7FD0
 public static void UpdateFilter(ref ActivityFilter filterList, EventSource source, int perEventSourceSessionId, string startEvents)
 {
     ActivityFilter.DisableFilter(ref filterList, source);
     if (!string.IsNullOrEmpty(startEvents))
     {
         foreach (string text in startEvents.Split(new char[]
         {
             ' '
         }))
         {
             int samplingFreq = 1;
             int num          = -1;
             int num2         = text.IndexOf(':');
             if (num2 < 0)
             {
                 source.ReportOutOfBandMessage("ERROR: Invalid ActivitySamplingStartEvent specification: " + text, false);
             }
             else
             {
                 string text2 = text.Substring(num2 + 1);
                 if (!int.TryParse(text2, out samplingFreq))
                 {
                     source.ReportOutOfBandMessage("ERROR: Invalid sampling frequency specification: " + text2, false);
                 }
                 else
                 {
                     text = text.Substring(0, num2);
                     if (!int.TryParse(text, out num))
                     {
                         num = -1;
                         for (int j = 0; j < source.m_eventData.Length; j++)
                         {
                             EventSource.EventMetadata[] eventData = source.m_eventData;
                             if (eventData[j].Name != null && eventData[j].Name.Length == text.Length && string.Compare(eventData[j].Name, text, StringComparison.OrdinalIgnoreCase) == 0)
                             {
                                 num = eventData[j].Descriptor.EventId;
                                 break;
                             }
                         }
                     }
                     if (num < 0 || num >= source.m_eventData.Length)
                     {
                         source.ReportOutOfBandMessage("ERROR: Invalid eventId specification: " + text, false);
                     }
                     else
                     {
                         ActivityFilter.EnableFilter(ref filterList, source, perEventSourceSessionId, num, samplingFreq);
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Currently this has "override" semantics. We first disable all filters
        /// associated with 'source', and next we add new filters for each entry in the 
        /// string 'startEvents'. participateInSampling specifies whether non-startEvents 
        /// always trigger or only trigger when current activity is 'active'.
        /// </summary>
        public static void UpdateFilter(
                                    ref ActivityFilter filterList, 
                                    EventSource source, 
                                    int perEventSourceSessionId,
                                    string startEvents)
        {
            Contract.Assert(Monitor.IsEntered(EventListener.EventListenersLock));

            // first remove all filters associated with 'source'
            DisableFilter(ref filterList, source);

            if (!string.IsNullOrEmpty(startEvents))
            {
                // ActivitySamplingStartEvents is a space-separated list of Event:Frequency pairs.
                // The Event may be specified by name or by ID. Errors in parsing such a pair 
                // result in the error being reported to the listeners, and the pair being ignored.
                // E.g. "CustomActivityStart:1000 12:10" specifies that for event CustomActivityStart
                // we should initiate activity tracing once every 1000 events, *and* for event ID 12
                // we should initiate activity tracing once every 10 events.
                string[] activityFilterStrings = startEvents.Split(' ');

                for (int i = 0; i < activityFilterStrings.Length; ++i)
                {
                    string activityFilterString = activityFilterStrings[i];
                    int sampleFreq = 1;
                    int eventId = -1;
                    int colonIdx = activityFilterString.IndexOf(':');
                    if (colonIdx < 0)
                    {
                        source.ReportOutOfBandMessage("ERROR: Invalid ActivitySamplingStartEvent specification: " + 
                            activityFilterString, false);
                        // ignore failure...
                        continue;
                    }
                    string sFreq = activityFilterString.Substring(colonIdx + 1);
                    if (!int.TryParse(sFreq, out sampleFreq))
                    {
                        source.ReportOutOfBandMessage("ERROR: Invalid sampling frequency specification: " + sFreq, false);
                        continue;
                    }
                    activityFilterString = activityFilterString.Substring(0, colonIdx);
                    if (!int.TryParse(activityFilterString, out eventId))
                    {
                        // reset eventId
                        eventId = -1;
                        // see if it's an event name
                        for (int j = 0; j < source.m_eventData.Length; j++)
                        {
                            EventSource.EventMetadata[] ed = source.m_eventData;
                            if (ed[j].Name != null && ed[j].Name.Length == activityFilterString.Length &&
                                string.Compare(ed[j].Name, activityFilterString, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                eventId = ed[j].Descriptor.EventId;
                                break;
                            }
                        }
                    }
                    if (eventId < 0 || eventId >= source.m_eventData.Length)
                    {
                        source.ReportOutOfBandMessage("ERROR: Invalid eventId specification: " + activityFilterString, false);
                        continue;
                    }
                    EnableFilter(ref filterList, source, perEventSourceSessionId, eventId, sampleFreq);
                }
            }
        }