Ejemplo n.º 1
0
 public ActivityInfo(string name, long uniqueId, ActivityTracker.ActivityInfo creator, EventActivityOptions options)
 {
     this.m_name         = name;
     this.m_eventOptions = options;
     this.m_creator      = creator;
     this.m_uniqueId     = uniqueId;
     this.m_level        = creator != null ? creator.m_level + 1 : 0;
     this.CreateActivityPathGuid(out this.m_guid, out this.m_activityPathGuidOffset);
 }
Ejemplo n.º 2
0
            public ActivityInfo(string name, long uniqueId, ActivityInfo creator, EventActivityOptions options)
            {
                m_name         = name;
                m_eventOptions = options;
                m_creator      = creator;
                m_uniqueId     = uniqueId;
                m_level        = creator != null ? creator.m_level + 1 : 0;

                // Create a nice GUID that encodes the chain of activities that started this one.
                CreateActivityPathGuid(out m_guid, out m_activityPathGuidOffset);
            }
Ejemplo n.º 3
0
        /// <summary>
        /// Called on work item begins.  The activity name = providerName + activityName without 'Start' suffix.
        /// It updates CurrentActivityId to track.
        ///
        /// It returns true if the Start should be logged, otherwise (if it is illegal recursion) it return false.
        ///
        /// The start event should use as its activity ID the CurrentActivityId AFTER calling this routine and its
        /// RelatedActivityID the CurrentActivityId BEFORE calling this routine (the creator).
        ///
        /// If activity tracing is not on, then activityId and relatedActivityId are not set
        /// </summary>
        public void OnStart(string providerName, string activityName, int task, ref Guid activityId, ref Guid relatedActivityId, EventActivityOptions options)
        {
            if (m_current == null)        // We are not enabled
            {
                // We  used to rely on the TPL provider turning us on, but that has the disadvantage that you don't get Start-Stop tracking
                // until you use Tasks for the first time (which you may never do).   Thus we change it to pull rather tan push for whether
                // we are enabled.
                if (m_checkedForEnable)
                {
                    return;
                }
                m_checkedForEnable = true;
                if (TplEtwProvider.Log.IsEnabled(EventLevel.Informational, TplEtwProvider.Keywords.TasksFlowActivityIds))
                {
                    Enable();
                }
                if (m_current == null)
                {
                    return;
                }
            }


            Contract.Assert((options & EventActivityOptions.Disable) == 0);

            var currentActivity  = m_current.Value;
            var fullActivityName = NormalizeActivityName(providerName, activityName, task);

            var etwLog = TplEtwProvider.Log;

            if (etwLog.Debug)
            {
                etwLog.DebugFacilityMessage("OnStartEnter", fullActivityName);
                etwLog.DebugFacilityMessage("OnStartEnterActivityState", ActivityInfo.LiveActivities(currentActivity));
            }

            if (currentActivity != null)
            {
                // Stop activity tracking if we reached the maximum allowed depth
                if (currentActivity.m_level >= MAX_ACTIVITY_DEPTH)
                {
                    activityId        = Guid.Empty;
                    relatedActivityId = Guid.Empty;
                    if (etwLog.Debug)
                    {
                        etwLog.DebugFacilityMessage("OnStartRET", "Fail");
                    }
                    return;
                }
                // Check for recursion, and force-stop any activities if the activity already started.
                if ((options & EventActivityOptions.Recursive) == 0)
                {
                    ActivityInfo existingActivity = FindActiveActivity(fullActivityName, currentActivity);
                    if (existingActivity != null)
                    {
                        OnStop(providerName, activityName, task, ref activityId);
                        currentActivity = m_current.Value;
                    }
                }
            }

            // Get a unique ID for this activity.
            long id;

            if (currentActivity == null)
            {
                id = Interlocked.Increment(ref m_nextId);
            }
            else
            {
                id = Interlocked.Increment(ref currentActivity.m_lastChildID);
            }

            // The previous ID is my 'causer' and becomes my related activity ID
            relatedActivityId = EventSource.CurrentThreadActivityId;

            // Add to the list of started but not stopped activities.
            ActivityInfo newActivity = new ActivityInfo(fullActivityName, id, currentActivity, relatedActivityId, options);

            m_current.Value = newActivity;

            // Remember the current ID so we can log it
            activityId = newActivity.ActivityId;

            if (etwLog.Debug)
            {
                etwLog.DebugFacilityMessage("OnStartRetActivityState", ActivityInfo.LiveActivities(newActivity));
                etwLog.DebugFacilityMessage1("OnStartRet", activityId.ToString(), relatedActivityId.ToString());
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called on work item begins.  The activity name = providerName + activityName without 'Start' suffix.
        /// It updates CurrentActivityId to track.   
        /// 
        /// It returns true if the Start should be logged, otherwise (if it is illegal recurision) it return false. 
        /// 
        /// The start event should use as its activity ID the CurrentActivityId AFTER calling this routine and its
        /// RelatedActivityID the CurrentActivityId BEFORE calling this routine (the creator).  
        /// 
        /// If activity tracing is not on, then activityId and relatedActivityId are not set
        /// </summary>
        public void OnStart(string providerName, string activityName, int task, ref Guid activityId, ref Guid relatedActivityId, EventActivityOptions options)
        {
            if (m_current == null)        // We are not enabled
                return;

            Contract.Assert((options & EventActivityOptions.Disable) == 0);

            var currentActivity = m_current.Value;
            var fullActivityName = NormalizeActivityName(providerName, activityName, task);
            
            var etwLog = TplEtwProvider.Log;
            if (etwLog.Debug) 
            {
                etwLog.DebugFacilityMessage("OnStartEnter", fullActivityName);
                etwLog.DebugFacilityMessage("OnStartEnterActivityState", ActivityInfo.LiveActivities(currentActivity));
            }

            if (currentActivity != null)
            {
                // Stop activity tracking if we reached the maximum allowed depth 
                if (currentActivity.m_level >= MAX_ACTIVITY_DEPTH)
                {
                    activityId = Guid.Empty;
                    relatedActivityId = Guid.Empty;
                    if (etwLog.Debug)
                        etwLog.DebugFacilityMessage("OnStartRET", "Fail");
                    return;
                }
                // Check for recursion, and force-stop any activities if the activity already started.
                if ((options & EventActivityOptions.Recursive) == 0)
                {
                    ActivityInfo existingActivity = FindActiveActivity(fullActivityName, currentActivity);
                    if (existingActivity != null)
                    {
                        OnStop(providerName, activityName, task, ref activityId);
                        currentActivity = m_current.Value;
                    }
                }
            }

            // Get a unique ID for this activity.
            long id;
            if (currentActivity == null)
                id = Interlocked.Increment(ref m_nextId);
            else
                id = Interlocked.Increment(ref currentActivity.m_lastChildID);

            // Remember the previous ID so we can log it
            relatedActivityId = currentActivity != null ? currentActivity.ActivityId : Guid.Empty;

            // Add to the list of started but not stopped activities. 
            ActivityInfo newActivity = new ActivityInfo(fullActivityName, id, currentActivity, options);
            m_current.Value = newActivity;

            // Remember the current ID so we can log it 
            activityId = newActivity.ActivityId;

            if (etwLog.Debug) 
            {
                etwLog.DebugFacilityMessage("OnStartRetActivityState", ActivityInfo.LiveActivities(newActivity));
                etwLog.DebugFacilityMessage1("OnStartRet", activityId.ToString(), relatedActivityId.ToString());
            }
        }
Ejemplo n.º 5
0
            public ActivityInfo(string name,  long uniqueId, ActivityInfo creator, EventActivityOptions options)
            {
                m_name = name;
                m_eventOptions = options;
                m_creator = creator;
                m_uniqueId = uniqueId;
                m_level = creator != null ? creator.m_level + 1 : 0;

                // Create a nice GUID that encodes the chain of activities that started this one.
                CreateActivityPathGuid(out m_guid, out m_activityPathGuidOffset);
            }
Ejemplo n.º 6
0
        /// <summary>
        /// Called on work item begins.  The activity name = providerName + activityName without 'Start' suffix.
        /// It updates CurrentActivityId to track.
        ///
        /// It returns true if the Start should be logged, otherwise (if it is illegal recurision) it return false.
        ///
        /// The start event should use as its activity ID the CurrentActivityId AFTER calling this routine and its
        /// RelatedActivityID the CurrentActivityId BEFORE calling this routine (the creator).
        ///
        /// If activity tracing is not on, then activityId and relatedActivityId are not set
        /// </summary>
        public void OnStart(string providerName, string activityName, int task, ref Guid activityId, ref Guid relatedActivityId, EventActivityOptions options)
        {
            if (m_current == null)        // We are not enabled
            {
                return;
            }

            Contract.Assert((options & EventActivityOptions.Disable) == 0);

            var currentActivity  = m_current.Value;
            var fullActivityName = NormalizeActivityName(providerName, activityName, task);

            var etwLog = TplEtwProvider.Log;

            if (etwLog.Debug)
            {
                etwLog.DebugFacilityMessage("OnStartEnter", fullActivityName);
                etwLog.DebugFacilityMessage("OnStartEnterActivityState", ActivityInfo.LiveActivities(currentActivity));
            }

            if (currentActivity != null)
            {
                // Stop activity tracking if we reached the maximum allowed depth
                if (currentActivity.m_level >= MAX_ACTIVITY_DEPTH)
                {
                    activityId        = Guid.Empty;
                    relatedActivityId = Guid.Empty;
                    if (etwLog.Debug)
                    {
                        etwLog.DebugFacilityMessage("OnStartRET", "Fail");
                    }
                    return;
                }
                // Check for recursion, and force-stop any activities if the activity already started.
                if ((options & EventActivityOptions.Recursive) == 0)
                {
                    ActivityInfo existingActivity = FindActiveActivity(fullActivityName, currentActivity);
                    if (existingActivity != null)
                    {
                        //
                        OnStop(providerName, activityName, task, ref activityId);
                        currentActivity = m_current.Value;
                    }
                }
            }

            // Get a unique ID for this activity.
            long id;

            if (currentActivity == null)
            {
                id = Interlocked.Increment(ref m_nextId);
            }
            else
            {
                id = Interlocked.Increment(ref currentActivity.m_lastChildID);
            }

            // Remember the previous ID so we can log it
            relatedActivityId = currentActivity != null ? currentActivity.ActivityId : Guid.Empty;

            // Add to the list of started but not stopped activities.
            ActivityInfo newActivity = new ActivityInfo(fullActivityName, id, currentActivity, options);

            m_current.Value = newActivity;

            // Remember the current ID so we can log it
            activityId = newActivity.ActivityId;

            if (etwLog.Debug)
            {
                etwLog.DebugFacilityMessage("OnStartRetActivityState", ActivityInfo.LiveActivities(newActivity));
                etwLog.DebugFacilityMessage1("OnStartRet", activityId.ToString(), relatedActivityId.ToString());
            }
        }
Ejemplo n.º 7
0
        public void OnStart(string providerName, string activityName, int task, ref Guid activityId, ref Guid relatedActivityId, EventActivityOptions options)
        {
            if (this.m_current == null)
            {
                return;
            }
            ActivityTracker.ActivityInfo activityInfo = this.m_current.Value;
            string         str            = this.NormalizeActivityName(providerName, activityName, task);
            TplEtwProvider tplEtwProvider = TplEtwProvider.Log;

            if (tplEtwProvider.Debug)
            {
                tplEtwProvider.DebugFacilityMessage("OnStartEnter", str);
                tplEtwProvider.DebugFacilityMessage("OnStartEnterActivityState", ActivityTracker.ActivityInfo.LiveActivities(activityInfo));
            }
            if (activityInfo != null)
            {
                if (activityInfo.m_level >= 100)
                {
                    activityId        = Guid.Empty;
                    relatedActivityId = Guid.Empty;
                    if (!tplEtwProvider.Debug)
                    {
                        return;
                    }
                    tplEtwProvider.DebugFacilityMessage("OnStartRET", "Fail");
                    return;
                }
                if ((options & EventActivityOptions.Recursive) == EventActivityOptions.None && this.FindActiveActivity(str, activityInfo) != null)
                {
                    this.OnStop(providerName, activityName, task, ref activityId);
                    activityInfo = this.m_current.Value;
                }
            }
            long uniqueId = activityInfo != null?Interlocked.Increment(ref activityInfo.m_lastChildID) : Interlocked.Increment(ref ActivityTracker.m_nextId);

            relatedActivityId = activityInfo != null ? activityInfo.ActivityId : Guid.Empty;
            ActivityTracker.ActivityInfo list = new ActivityTracker.ActivityInfo(str, uniqueId, activityInfo, options);
            this.m_current.Value = list;
            activityId           = list.ActivityId;
            if (!tplEtwProvider.Debug)
            {
                return;
            }
            tplEtwProvider.DebugFacilityMessage("OnStartRetActivityState", ActivityTracker.ActivityInfo.LiveActivities(list));
            tplEtwProvider.DebugFacilityMessage1("OnStartRet", activityId.ToString(), relatedActivityId.ToString());
        }
 // Token: 0x06006B33 RID: 27443 RVA: 0x00172800 File Offset: 0x00170A00
 public ActivityInfo(string name, long uniqueId, ActivityTracker.ActivityInfo creator, Guid activityIDToRestore, EventActivityOptions options)
 {
     this.m_name                = name;
     this.m_eventOptions        = options;
     this.m_creator             = creator;
     this.m_uniqueId            = uniqueId;
     this.m_level               = ((creator != null) ? (creator.m_level + 1) : 0);
     this.m_activityIdToRestore = activityIDToRestore;
     this.CreateActivityPathGuid(out this.m_guid, out this.m_activityPathGuidOffset);
 }
        // Token: 0x06003319 RID: 13081 RVA: 0x000C22B0 File Offset: 0x000C04B0
        public void OnStart(string providerName, string activityName, int task, ref Guid activityId, ref Guid relatedActivityId, EventActivityOptions options)
        {
            if (this.m_current == null)
            {
                if (this.m_checkedForEnable)
                {
                    return;
                }
                this.m_checkedForEnable = true;
                if (TplEtwProvider.Log.IsEnabled(EventLevel.Informational, (EventKeywords)128L))
                {
                    this.Enable();
                }
                if (this.m_current == null)
                {
                    return;
                }
            }
            ActivityTracker.ActivityInfo value = this.m_current.Value;
            string         text = this.NormalizeActivityName(providerName, activityName, task);
            TplEtwProvider log  = TplEtwProvider.Log;

            if (log.Debug)
            {
                log.DebugFacilityMessage("OnStartEnter", text);
                log.DebugFacilityMessage("OnStartEnterActivityState", ActivityTracker.ActivityInfo.LiveActivities(value));
            }
            if (value != null)
            {
                if (value.m_level >= 100)
                {
                    activityId        = Guid.Empty;
                    relatedActivityId = Guid.Empty;
                    if (log.Debug)
                    {
                        log.DebugFacilityMessage("OnStartRET", "Fail");
                    }
                    return;
                }
                if ((options & EventActivityOptions.Recursive) == EventActivityOptions.None)
                {
                    ActivityTracker.ActivityInfo activityInfo = this.FindActiveActivity(text, value);
                    if (activityInfo != null)
                    {
                        this.OnStop(providerName, activityName, task, ref activityId);
                        value = this.m_current.Value;
                    }
                }
            }
            long uniqueId;

            if (value == null)
            {
                uniqueId = Interlocked.Increment(ref ActivityTracker.m_nextId);
            }
            else
            {
                uniqueId = Interlocked.Increment(ref value.m_lastChildID);
            }
            relatedActivityId = EventSource.CurrentThreadActivityId;
            ActivityTracker.ActivityInfo activityInfo2 = new ActivityTracker.ActivityInfo(text, uniqueId, value, relatedActivityId, options);
            this.m_current.Value = activityInfo2;
            activityId           = activityInfo2.ActivityId;
            if (log.Debug)
            {
                log.DebugFacilityMessage("OnStartRetActivityState", ActivityTracker.ActivityInfo.LiveActivities(activityInfo2));
                log.DebugFacilityMessage1("OnStartRet", activityId.ToString(), relatedActivityId.ToString());
            }
        }