Ejemplo n.º 1
0
        /// <summary>
        /// Add Info actuator endpoint to OWIN Pipeline
        /// </summary>
        /// <param name="builder">OWIN <see cref="IAppBuilder" /></param>
        /// <param name="config"><see cref="IConfiguration"/> of application for configuring info endpoint</param>
        /// <param name="contributors">IInfo Contributors to collect into from</param>
        /// <param name="loggerFactory">For logging within the middleware</param>
        /// <returns>OWIN <see cref="IAppBuilder" /> with Info Endpoint added</returns>
        public static IAppBuilder UseInfoActuator(this IAppBuilder builder, IConfiguration config, IList <IInfoContributor> contributors, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

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

            var mgmtOptions = ManagementOptions.Get(config);
            var options     = new InfoEndpointOptions(config);

            foreach (var mgmt in mgmtOptions)
            {
                mgmt.EndpointOptions.Add(options);
            }

            var endpoint = new InfoEndpoint(options, contributors, loggerFactory?.CreateLogger <InfoEndpoint>());
            var logger   = loggerFactory?.CreateLogger <EndpointOwinMiddleware <Dictionary <string, object> > >();

            return(builder.Use <EndpointOwinMiddleware <Dictionary <string, object> > >(endpoint, mgmtOptions, new List <HttpMethod> {
                HttpMethod.Get
            }, true, logger));
        }
Ejemplo n.º 2
0
        private static IAppBuilder UseTraceActuatorComponents(this IAppBuilder builder, IConfiguration config, ITraceRepository traceRepository, ILoggerFactory loggerFactory)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            ITraceOptions options = new TraceEndpointOptions(config);

            var mgmtOptions = ManagementOptions.Get(config);

            foreach (var mgmt in mgmtOptions)
            {
                mgmt.EndpointOptions.Add(options);
            }

            traceRepository = traceRepository ?? new TraceDiagnosticObserver(options, loggerFactory?.CreateLogger <TraceDiagnosticObserver>());
            DiagnosticsManager.Instance.Observers.Add((IDiagnosticObserver)traceRepository);
            var endpoint = new TraceEndpoint(options, traceRepository, loggerFactory?.CreateLogger <TraceEndpoint>());
            var logger   = loggerFactory?.CreateLogger <TraceEndpointOwinMiddleware>();

            return(builder.Use <TraceEndpointOwinMiddleware>(endpoint, mgmtOptions, logger));
        }
        /// <summary>
        /// Add Loggers actuator endpoint to OWIN Pipeline
        /// </summary>
        /// <param name="builder">OWIN <see cref="IAppBuilder" /></param>
        /// <param name="config"><see cref="IConfiguration"/> of application for configuring loggers endpoint</param>
        /// <param name="loggerProvider">Provider of loggers to report on and configure</param>
        /// <param name="loggerFactory">For logging within the middleware</param>
        /// <returns>OWIN <see cref="IAppBuilder" /> with Loggers Endpoint added</returns>
        public static IAppBuilder UseLoggersActuator(this IAppBuilder builder, IConfiguration config, ILoggerProvider loggerProvider, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

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

            var options     = new LoggersEndpointOptions(config);
            var mgmtOptions = ManagementOptions.Get(config);

            foreach (var mgmt in mgmtOptions)
            {
                mgmt.EndpointOptions.Add(options);
            }

            var endpoint = new LoggersEndpoint(options, loggerProvider as IDynamicLoggerProvider, loggerFactory?.CreateLogger <LoggersEndpoint>());
            var logger   = loggerFactory?.CreateLogger <LoggersEndpointOwinMiddleware>();

            return(builder.Use <LoggersEndpointOwinMiddleware>(endpoint, mgmtOptions, logger));
        }
        /// <summary>
        /// Add Cloud Foundry actuator to OWIN Pipeline
        /// </summary>
        /// <param name="builder">Your OWIN <see cref="IAppBuilder"/></param>
        /// <param name="config">Your application's <see cref="IConfiguration"/></param>
        /// <param name="loggerFactory"><see cref="ILoggerFactory"/> for logging within the middleware</param>
        /// <returns>Your OWIN <see cref="IAppBuilder"/> with Cloud Foundry actuator attached</returns>
        public static IAppBuilder UseHypermediaActuator(this IAppBuilder builder, IConfiguration config, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            IActuatorHypermediaOptions options;

            options = new HypermediaEndpointOptions(config);
            var mgmtOptions = ManagementOptions.Get(config);
            var mgmt        = mgmtOptions.OfType <ActuatorManagementOptions>().Single();

            mgmt.EndpointOptions.Add(options);

            var endpoint = new ActuatorEndpoint(options, mgmtOptions, loggerFactory?.CreateLogger <ActuatorEndpoint>());
            var logger   = loggerFactory?.CreateLogger <ActuatorHypermediaEndpointOwinMiddleware>();

            return(builder.Use <ActuatorHypermediaEndpointOwinMiddleware>(endpoint, mgmtOptions, logger));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Add Route Mappings actuator endpoint to OWIN Pipeline
        /// </summary>
        /// <param name="builder">OWIN <see cref="IAppBuilder" /></param>
        /// <param name="config"><see cref="IConfiguration"/> of application for configuring refresh endpoint</param>
        /// <param name="apiExplorer">An <see cref="ApiExplorer"/> for iterating routes and their metadata</param>
        /// <param name="loggerFactory">For logging within the middleware</param>
        /// <returns>OWIN <see cref="IAppBuilder" /> with Refresh Endpoint added</returns>
        public static IAppBuilder UseMappingActuator(this IAppBuilder builder, IConfiguration config, IApiExplorer apiExplorer, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

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

            IMappingsOptions options = new MappingsEndpointOptions(config);
            var mgmtOptions          = ManagementOptions.Get(config);

            foreach (var mgmt in mgmtOptions)
            {
                mgmt.EndpointOptions.Add(options);
            }

            var logger = loggerFactory?.CreateLogger <EndpointOwinMiddleware <IList <string> > >();

            return(builder.Use <MappingsEndpointOwinMiddleware>(options, mgmtOptions, apiExplorer, loggerFactory?.CreateLogger <MappingsEndpointOwinMiddleware>()));
        }
        /// <summary>
        /// Add Environment middleware to OWIN Pipeline
        /// </summary>
        /// <param name="builder">OWIN <see cref="IAppBuilder" /></param>
        /// <param name="config"><see cref="IConfiguration"/> of application for configuring env endpoint and inclusion in response</param>
        /// <param name="hostingEnvironment"><see cref="IHostingEnvironment"/> of the application</param>
        /// <param name="loggerFactory">For logging within the middleware</param>
        /// <returns>OWIN <see cref="IAppBuilder" /> with Env Endpoint added</returns>
        public static IAppBuilder UseEnvActuator(this IAppBuilder builder, IConfiguration config, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

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

            IEnvOptions options     = new EnvEndpointOptions(config);
            var         mgmtOptions = ManagementOptions.Get(config);

            foreach (var mgmt in mgmtOptions)
            {
                if (!mgmt.EndpointOptions.Contains(options))
                {
                    mgmt.EndpointOptions.Add(options);
                }
            }

            var endpoint = new EnvEndpoint(options, config, hostingEnvironment, loggerFactory?.CreateLogger <EnvEndpoint>());
            var logger   = loggerFactory?.CreateLogger <EndpointOwinMiddleware <EnvironmentDescriptor> >();

            return(builder.Use <EndpointOwinMiddleware <EnvironmentDescriptor> >(endpoint, mgmtOptions, new List <HttpMethod> {
                HttpMethod.Get
            }, true, logger));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Add Cloud Foundry actuator to OWIN Pipeline
        /// </summary>
        /// <param name="builder">Your OWIN <see cref="IAppBuilder"/></param>
        /// <param name="config">Your application's <see cref="IConfiguration"/></param>
        /// <param name="mgmtOptions">Shared management options</param>
        /// <param name="loggerFactory"><see cref="ILoggerFactory"/> for logging within the middleware</param>
        /// <returns>Your OWIN <see cref="IAppBuilder"/> with Cloud Foundry actuator attached</returns>
        public static IAppBuilder UseCloudFoundryActuator(this IAppBuilder builder, IConfiguration config, IEnumerable <IManagementOptions> mgmtOptions, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            if (mgmtOptions == null)
            {
                mgmtOptions = ManagementOptions.Get(config);
            }

            var cloudFoundryOptions = new CloudFoundryEndpointOptions(config);
            var mgmt = mgmtOptions.OfType <CloudFoundryManagementOptions>().Single();

            mgmt.EndpointOptions.Add(cloudFoundryOptions);

            var endpoint = new CloudFoundryEndpoint(cloudFoundryOptions, mgmtOptions, loggerFactory?.CreateLogger <CloudFoundryEndpoint>());
            var logger   = loggerFactory?.CreateLogger <CloudFoundryEndpointOwinMiddleware>();

            return(builder.Use <CloudFoundryEndpointOwinMiddleware>(endpoint, mgmtOptions, logger));
        }
        /// <summary>
        /// Add Thread Dump actuator endpoint to OWIN Pipeline
        /// </summary>
        /// <param name="builder">OWIN <see cref="IAppBuilder" /></param>
        /// <param name="config"><see cref="IConfiguration"/> of application for configuring thread dump endpoint</param>
        /// <param name="loggerFactory">For logging within the middleware</param>
        /// <param name="version">MediaTypeVersion for endpoint response</param>
        /// <returns>OWIN <see cref="IAppBuilder" /> with Thread Dump Endpoint added</returns>
        public static IAppBuilder UseThreadDumpActuator(this IAppBuilder builder, IConfiguration config, ILoggerFactory loggerFactory, MediaTypeVersion version)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            var options = new ThreadDumpEndpointOptions(config);

            if (version == MediaTypeVersion.V2 && options.Id == "dump")
            {
                options.Id = "threaddump";
            }

            var mgmtOptions = ManagementOptions.Get(config);

            foreach (var mgmt in mgmtOptions)
            {
                mgmt.EndpointOptions.Add(options);
            }

            var threadDumper = new ThreadDumper(options, loggerFactory?.CreateLogger <ThreadDumper>());

            return(builder.UseThreadDumpActuator(options, threadDumper, loggerFactory, version));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Add Http Request Trace actuator endpoint to OWIN Pipeline
        /// </summary>
        /// <param name="builder">OWIN <see cref="IAppBuilder" /></param>
        /// <param name="config"><see cref="IConfiguration"/> of application for configuring thread dump endpoint</param>
        /// <param name="traceRepository">repository to put traces in</param>
        /// <param name="loggerFactory">For logging within the middleware</param>
        /// <returns>OWIN <see cref="IAppBuilder" /> with Trace Endpoint added</returns>
        public static IAppBuilder UseHttpTraceActuator(this IAppBuilder builder, IConfiguration config, IHttpTraceRepository traceRepository, ILoggerFactory loggerFactory)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            ITraceOptions options = new HttpTraceEndpointOptions(config);

            var mgmtOptions = ManagementOptions.Get(config);

            foreach (var mgmt in mgmtOptions)
            {
                mgmt.EndpointOptions.Add(options);
            }

            traceRepository = traceRepository ?? new HttpTraceDiagnosticObserver(options, loggerFactory?.CreateLogger <HttpTraceDiagnosticObserver>());
            DiagnosticsManager.Instance.Observers.Add((IDiagnosticObserver)traceRepository);
            var endpoint = new HttpTraceEndpoint(options, traceRepository, loggerFactory?.CreateLogger <HttpTraceEndpoint>());
            var logger   = loggerFactory?.CreateLogger <EndpointOwinMiddleware <HttpTraceEndpoint, HttpTraceResult> >();

            return(builder.Use <EndpointOwinMiddleware <HttpTraceResult> >(endpoint, mgmtOptions, new List <HttpMethod> {
                HttpMethod.Get
            }, true, logger));
        }
        /// <summary>
        /// Add (Config) Refresh actuator endpoint to OWIN Pipeline
        /// </summary>
        /// <param name="builder">OWIN <see cref="IAppBuilder" /></param>
        /// <param name="config"><see cref="IConfiguration"/> of application for configuring refresh endpoint</param>
        /// <param name="loggerFactory">For logging within the middleware</param>
        /// <returns>OWIN <see cref="IAppBuilder" /> with Refresh Endpoint added</returns>
        public static IAppBuilder UseRefreshActuator(this IAppBuilder builder, IConfiguration config, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            IRefreshOptions options     = new RefreshEndpointOptions(config);
            var             mgmtOptions = ManagementOptions.Get(config);

            foreach (var mgmt in mgmtOptions)
            {
                mgmt.EndpointOptions.Add(options);
            }

            var endpoint = new RefreshEndpoint(options, config, loggerFactory?.CreateLogger <RefreshEndpoint>());
            var logger   = loggerFactory?.CreateLogger <EndpointOwinMiddleware <IList <string> > >();

            return(builder.Use <EndpointOwinMiddleware <IList <string> > >(endpoint, mgmtOptions, new List <HttpMethod> {
                HttpMethod.Get
            }, true, logger));
        }
        private static IAppBuilder UseThreadDumpV2Components(IAppBuilder builder, IThreadDumpOptions options, IThreadDumper threadDumper, ILoggerFactory loggerFactory)
        {
            var endpoint    = new ThreadDumpEndpoint_v2(options, threadDumper, loggerFactory?.CreateLogger <ThreadDumpEndpoint_v2>());
            var logger      = loggerFactory?.CreateLogger <EndpointOwinMiddleware <ThreadDumpResult> >();
            var mgmtOptions = ManagementOptions.Get();

            return(builder.Use <EndpointOwinMiddleware <ThreadDumpResult> >(endpoint, mgmtOptions, new List <HttpMethod> {
                HttpMethod.Get
            }, true, logger));
        }
        /// <summary>
        /// Adds OWIN Middleware for providing Heap Dumps to OWIN pipeline
        /// </summary>
        /// <param name="builder">Your <see cref="IAppBuilder"/></param>
        /// <param name="options"><see cref="IHeapDumpOptions"/> to configure the endpoint</param>
        /// <param name="heapDumper"><see cref="HeapDumper"/> or other implementer of <see cref="IHeapDumper"/> for retrieving a heap dump</param>
        /// <param name="loggerFactory"><see cref="ILoggerFactory"/> for logging inside the middleware and its components</param>
        /// <returns>Your <see cref="IAppBuilder"/> with Heap Dump middleware attached</returns>
        public static IAppBuilder UseHeapDumpActuator(this IAppBuilder builder, IHeapDumpOptions options, IHeapDumper heapDumper, ILoggerFactory loggerFactory = null)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

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

            var endpoint = new HeapDumpEndpoint(options, heapDumper, loggerFactory?.CreateLogger <HeapDumpEndpoint>());
            var logger   = loggerFactory?.CreateLogger <HeapDumpEndpointOwinMiddleware>();

            return(builder.Use <HeapDumpEndpointOwinMiddleware>(endpoint, ManagementOptions.Get(), logger));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Add Metrics actuator endpoint to OWIN Pipeline
        /// </summary>
        /// <param name="builder">OWIN <see cref="IAppBuilder" /></param>
        /// <param name="config"><see cref="IConfiguration"/> of application for configuring metrics endpoint</param>
        /// <param name="stats">Class for recording statistics - See also: <seealso cref="OpenCensusStats"/></param>
        /// <param name="tags">Class using for recording statistics</param>
        /// <param name="loggerFactory">For logging within the middleware</param>
        /// <returns>OWIN <see cref="IAppBuilder" /> with Metrics Endpoint added</returns>
        public static IAppBuilder UseMetricsActuator(this IAppBuilder builder, IConfiguration config, IStats stats, ITags tags, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

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

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

            IMetricsOptions options     = new MetricsEndpointOptions(config);
            var             mgmtOptions = ManagementOptions.Get(config);

            foreach (var mgmt in mgmtOptions)
            {
                mgmt.EndpointOptions.Add(options);
            }

            var hostObserver = new OwinHostingObserver(options, stats, tags, loggerFactory?.CreateLogger <OwinHostingObserver>());
            var clrObserver  = new CLRRuntimeObserver(options, stats, tags, loggerFactory?.CreateLogger <CLRRuntimeObserver>());

            DiagnosticsManager.Instance.Observers.Add(hostObserver);
            DiagnosticsManager.Instance.Observers.Add(clrObserver);

            var clrSource = new CLRRuntimeSource();

            DiagnosticsManager.Instance.Sources.Add(clrSource);

            var endpoint = new MetricsEndpoint(options, stats, loggerFactory?.CreateLogger <MetricsEndpoint>());
            var logger   = loggerFactory?.CreateLogger <MetricsEndpointOwinMiddleware>();

            return(builder.Use <MetricsEndpointOwinMiddleware>(endpoint, mgmtOptions, logger));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Add Cloud Foundry security to actuator requests in the OWIN Pipeline
        /// </summary>
        /// <param name="builder">Your OWIN <see cref="IAppBuilder"/></param>
        /// <param name="config">Your application's <see cref="IConfiguration"/></param>
        /// <param name="loggerFactory"><see cref="ILoggerFactory"/> for logging within the middleware</param>
        /// <returns>Your OWIN <see cref="IAppBuilder"/> with Cloud Foundry request security and CORS configured</returns>
        public static IAppBuilder UseCloudFoundrySecurityMiddleware(this IAppBuilder builder, IConfiguration config, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new System.ArgumentNullException(nameof(builder));
            }

            if (config == null)
            {
                throw new System.ArgumentNullException(nameof(config));
            }

            var mgmtOptions         = ManagementOptions.Get(config);
            var cloudFoundryOptions = new CloudFoundryEndpointOptions(config);
            var logger = loggerFactory?.CreateLogger <CloudFoundrySecurityOwinMiddleware>();

            return(builder.Use <CloudFoundrySecurityOwinMiddleware>(cloudFoundryOptions, mgmtOptions, logger));
        }
        /// <summary>
        /// Add HealthCheck actuator endpoint to OWIN Pipeline
        /// </summary>
        /// <param name="builder">OWIN <see cref="IAppBuilder" /></param>
        /// <param name="config"><see cref="IConfiguration"/> of application for configuring health endpoint</param>
        /// <param name="loggerFactory">For logging within the middleware</param>
        /// <returns>OWIN <see cref="IAppBuilder" /> with Health Endpoint added</returns>
        public static IAppBuilder UseHealthActuator(this IAppBuilder builder, IConfiguration config, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            var mgmtOptions = ManagementOptions.Get(config);
            var options     = new HealthEndpointOptions(config);

            foreach (var mgmt in mgmtOptions)
            {
                mgmt.EndpointOptions.Add(options);
            }

            return(builder.UseHealthActuator(options, new DefaultHealthAggregator(), loggerFactory));
        }
        /// <summary>
        /// Add HealthCheck middleware to OWIN Pipeline
        /// </summary>
        /// <param name="builder">OWIN <see cref="IAppBuilder" /></param>
        /// <param name="options"><see cref="IHealthOptions"/> for configuring Health endpoint</param>
        /// <param name="aggregator"><see cref="IHealthAggregator"/> for determining how to report aggregate health of the application</param>
        /// <param name="contributors">A list of <see cref="IHealthContributor"/> to monitor for determining application health</param>
        /// <param name="loggerFactory">For logging within the middleware</param>
        /// <returns>OWIN <see cref="IAppBuilder" /> with Health Endpoint added</returns>
        public static IAppBuilder UseHealthActuator(this IAppBuilder builder, IHealthOptions options, IHealthAggregator aggregator, IEnumerable <IHealthContributor> contributors, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

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

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

            var mgmtOptions = ManagementOptions.Get();

            foreach (var mgmt in mgmtOptions)
            {
                if (!mgmt.EndpointOptions.Contains(options))
                {
                    mgmt.EndpointOptions.Add(options);
                }
            }

            var endpoint = new HealthEndpoint(options, aggregator, contributors, loggerFactory?.CreateLogger <HealthEndpoint>());
            var logger   = loggerFactory?.CreateLogger <HealthEndpointOwinMiddleware>();

            return(builder.Use <HealthEndpointOwinMiddleware>(endpoint, mgmtOptions, logger));
        }
        /// <summary>
        /// Adds actuator endpoint providing Heap Dumps to OWIN pipeline
        /// </summary>
        /// <param name="builder">Your <see cref="IAppBuilder"/></param>
        /// <param name="config"><see cref="IConfiguration"/> for configuring the endpoint</param>
        /// <param name="applicationPathOnDisk">Provide the path to the app directory if heap dumps are failing due to access restrictions</param>
        /// <param name="loggerFactory"><see cref="ILoggerFactory"/> for logging inside the middleware and its components</param>
        /// <returns>Your <see cref="IAppBuilder"/> with Heap Dump middleware attached</returns>
        public static IAppBuilder UseHeapDumpActuator(this IAppBuilder builder, IConfiguration config, string applicationPathOnDisk = null, ILoggerFactory loggerFactory = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            IHeapDumpOptions options = new HeapDumpEndpointOptions(config);
            var mgmtOptions          = ManagementOptions.Get(config);

            foreach (var mgmt in mgmtOptions)
            {
                mgmt.EndpointOptions.Add(options);
            }

            var heapDumper = new HeapDumper(options, applicationPathOnDisk, loggerFactory?.CreateLogger <HeapDumper>());

            return(builder.UseHeapDumpActuator(options, heapDumper, loggerFactory));
        }