Пример #1
0
        /// <summary>
        ///     Creates new profile session.
        ///     If there was already session started - throws an exception.<br />
        ///     Any exceptions this method throws are swallowed and logged to <see cref="IProfilerLogger"/>.
        /// </summary>
        public ProfileSession Start(IDictionary <string, object> additionalSessionData = null)
        {
            try
            {
                if (!this.Configuration.Enabled)
                {
                    return(null);
                }

                if (this.currentSession.Get() != null)
                {
                    throw new SessionAlreadyStartedProfilingException();
                }

                var session = new ProfileSession(this, this.logger);

                if (additionalSessionData != null)
                {
                    session.AddData(additionalSessionData);
                }

                this.currentSession.Set(session);

                return(session);
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex);
                return(null);
            }
        }
Пример #2
0
        private void StopSession(IDictionary <string, object> additionalSessionData, ProfileSession session)
        {
            if (additionalSessionData != null)
            {
                session.AddData(additionalSessionData);
            }

            this.completedSessionsProcessorQueue.Add(session);

            try
            {
                this.eventsHandler.OnSessionEnded(session);
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex);
            }
        }