Beispiel #1
0
 public ApplicationProfilerSetup(
     IEnumerable <IProfiler <ApplicationGCProfilingContext> > gcProfilers,
     IEnumerable <IProfiler <ApplicationThreadingProfilingContext> > threadingprofilers,
     IOptionAccessor <ApplicationProfilingOptions> optionAccessor, IInternalLogger logger = null)
 {
     _profilingOptions   = optionAccessor.Value;
     _logger             = logger;
     _gcProfilers        = gcProfilers ?? throw new ArgumentNullException(nameof(gcProfilers));
     _threadingprofilers = threadingprofilers ?? throw new ArgumentNullException(nameof(threadingprofilers));
     _interval           = _profilingOptions.Interval.HasValue && _profilingOptions.Interval.Value > 0 ? _profilingOptions.Interval.Value : _defaultInterval;
 }
        public static ApmComponentOptions AddApplicationProfiler(this ApmComponentOptions apmComponent, Action <ApplicationProfilingOptions> configure)
        {
            if (apmComponent == null)
            {
                throw new ArgumentNullException(nameof(apmComponent));
            }
            var options = new ApplicationProfilingOptions();

            configure?.Invoke(options);
            apmComponent.Services.AddType <IOptionAccessor <ApplicationProfilingOptions>, ApplicationProfilingOptions>(Lifetime.Singleton);
            apmComponent.Services.AddType <IProfilerSetup, ApplicationProfilerSetup>(Lifetime.Singleton);
            apmComponent.Services.AddType <IProfiler <ApplicationGCProfilingContext>, ApplicationGCProfiler>(Lifetime.Singleton);
            apmComponent.Services.AddType <IProfiler <ApplicationThreadingProfilingContext>, ApplicationThreadingProfiler>(Lifetime.Singleton);
            return(apmComponent);
        }