示例#1
0
        /// <summary>
        /// Logs the scope end to ULS
        /// </summary>
        private void LogEnd(IMachineInformation machineInformation)
        {
            if (!IsSuccessful.HasValue)
            {
                ULSLogging.LogTraceTag(0x238174e3 /* tag_96xt9 */, Categories.TimingGeneral, Levels.Warning,
                                       "Result not set for scope {0}. Considered as SystemError", Name);

                Result             = TimedScopeResult.SystemError;
                FailureDescription = InternalFailureDescription.UnknownResultAsSystemError;
            }

            CorrelationData scopeData = ConstructCorrelationDataEntries(machineInformation);

            ScopeLogger.LogScopeEnd(this, scopeData);

            ReplayEventConfigurator.ConfigureReplayEventsOnScopeEnd(this);
        }
示例#2
0
        /// <summary>
        /// Start the timed scope
        /// </summary>
        public void Start()
        {
            if (IsDisposed)
            {
                ULSLogging.LogTraceTag(0x238174dd /* tag_96xt3 */, Categories.TimingGeneral, Levels.Error,
                                       "Attempting to start scope '{0}' that has already been disposed.", Name);
                return;
            }

            if (IsScopeActive)
            {
                ULSLogging.LogTraceTag(0x238174de /* tag_96xt4 */, Categories.TimingGeneral, Levels.Error,
                                       "Attempting to start scope '{0}' that has already been started.", Name);
                return;
            }

            string metaDataCopy = MetaData;
            string subTypeCopy  = SubType;

            CorrelationData currentCorrelation = CorrelationData;

            TimedScopeData     = currentCorrelation.Clone() ?? new CorrelationData();
            RunningTransaction = TransactionMonitor.RunningTransaction(TimedScopeData);

            if (!string.IsNullOrWhiteSpace(metaDataCopy) && string.IsNullOrWhiteSpace(MetaData))
            {
                MetaData = metaDataCopy;
            }

            if (!string.IsNullOrWhiteSpace(subTypeCopy) && string.IsNullOrWhiteSpace(SubType))
            {
                SubType = subTypeCopy;
            }

            // differentiate scope name when running under a test transaction
            if (IsTransaction)
            {
                NameSuffix = string.Concat(NameSuffix, "::Trx", RunningTransaction.ToString(CultureInfo.InvariantCulture));
            }

            // differentiate special scopes
            if (TimedScopeData.IsFallbackCall)
            {
                NameSuffix = string.Concat(NameSuffix, "::Fallback");
            }

            // differentiate scope name for inner (proxied) calls
            if (TimedScopeData.CallDepth > 0)
            {
                NameSuffix = string.Concat(NameSuffix, "::Depth", TimedScopeData.CallDepth.ToString(CultureInfo.InvariantCulture));

                if (currentCorrelation != null)
                {
                    // reset call depth so any inner scopes are reported as layer 0 again
                    currentCorrelation.CallDepth = 0;
                }
            }

            Parent        = TimedScopeStackManager.Scopes?.Peek();
            IsRoot        = Parent == null && TimedScopeData.CallDepth == 0;
            StartTick     = Stopwatch.GetTimestamp();
            IsScopeActive = true;
            ScopeLogger.LogScopeStart(this);

            PerfDiagnostics = new PerfDiagnostics(Parent != null ? Parent.PerfDiagnostics : null);
            PerfDiagnostics.Start();
        }