Beispiel #1
0
        /// <exception cref="ArgumentNullException"><paramref name="configuration"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="logger"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="processorService"/> is <see langword="null" />.</exception>
        public CompletedSessionsProcessorQueue([NotNull] IProfilerConfiguration configuration,
                                               [NotNull] IProfilerLogger logger,
                                               [NotNull] ICompletedSessionProcessorService processorService)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (processorService == null)
            {
                throw new ArgumentNullException(nameof(processorService));
            }

            this.configuration    = configuration;
            this.processorService = processorService;
            this.logger           = logger;

            this.dataToProcess           = new BlockingCollection <ProfileSession>(this.configuration.ResultsBufferSize);
            this.cancellationTokenSource = new CancellationTokenSource();
        }
Beispiel #2
0
        public static IProfilerConfiguration UseSerilogTraceWriter(this IProfilerConfiguration settings,
                                                                   Action <ISerilogTraceWriterSettings> configure)
        {
            var serilogTraceWriterSettings = new SerilogTraceWriterSettings();

            configure(serilogTraceWriterSettings);
            settings.CreateTraceWriter = () => new SerilogTraceWriter(serilogTraceWriterSettings);
            return(settings);
        }
Beispiel #3
0
        public CustomFactory(IProfilerConfiguration settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            _createTimeMeasure  = settings.CreateTimeMeasure ?? (() => new StopwatchTimeMeasure());
            _createTraceWriter  = settings.CreateTraceWriter ?? (() => DummyTraceWriter.Instance);
            _createReportWriter = settings.CreateReportWriter ?? (() => DummyReportWriter.Instance);
        }
Beispiel #4
0
 public Profiler([NotNull] IProfilerConfiguration configuration,
                 [NotNull] ICurrentSessionProvider currentSession,
                 [NotNull] IProfilerLogger logger,
                 [NotNull] ICompletedSessionsProcessorQueue completedSessionsProcessorQueue,
                 [NotNull] IProfilerEventsHandler eventsHandler)
 {
     this.Configuration  = configuration ?? throw new ArgumentNullException(nameof(configuration));
     this.currentSession = currentSession ?? throw new ArgumentNullException(nameof(currentSession));
     this.logger         = logger ?? throw new ArgumentNullException(nameof(logger));
     this.completedSessionsProcessorQueue = completedSessionsProcessorQueue ?? throw new ArgumentNullException(nameof(completedSessionsProcessorQueue));
     this.eventsHandler = eventsHandler ?? throw new ArgumentNullException(nameof(eventsHandler));
 }
        public CompletedSessionProcessorService([NotNull] IProfilerConfiguration configuration,
                                                [NotNull] IProfilerResultsStorage resultsStorage,
                                                [NotNull] ICompletedSessionProcessingFilter completedSessionFilter)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (resultsStorage == null)
            {
                throw new ArgumentNullException(nameof(resultsStorage));
            }

            if (completedSessionFilter == null)
            {
                throw new ArgumentNullException(nameof(completedSessionFilter));
            }

            this.configuration          = configuration;
            this.resultsStorage         = resultsStorage;
            this.completedSessionFilter = completedSessionFilter;
        }
Beispiel #6
0
 public static IProfilerConfiguration UseInsiderReportWriter(this IProfilerConfiguration settings, IInsider insider)
 {
     settings.CreateReportWriter = () => new InsiderReportWriter(insider);
     return(settings);
 }
 public static IProfiler CreateProfiler(this IProfilerConfiguration settings)
 {
     return(new Profiler(new CustomFactory(settings)));
 }
 public static IProfilerConfiguration UseDebugTraceWriter(this IProfilerConfiguration settings) => settings
 .UseTraceWriter(create: () => DebugTraceWriter.Instance);
 public static IProfilerConfiguration UseDummyReportWriter(this IProfilerConfiguration settings) => settings
 .UseReportWriter(create: () => DummyReportWriter.Instance);
 public static IProfilerConfiguration UseStopwatchTimeMeasure(this IProfilerConfiguration settings) => settings
 .UseTimeMeasure(create: () => new StopwatchTimeMeasure());
 public static IProfilerConfiguration UseReportWriter(this IProfilerConfiguration settings, Func <IReportWriter> create)
 {
     settings.CreateReportWriter = create;
     return(settings);
 }
 public static IProfilerConfiguration UseTimeMeasure(this IProfilerConfiguration settings, Func <ITimeMeasure> create)
 {
     settings.CreateTimeMeasure = create;
     return(settings);
 }
 public static IProfilerConfiguration UseConsoleReportWriter(this IProfilerConfiguration settings) => settings
 .UseReportWriter(create: () => new ConsoleReportWriter());