Exemple #1
0
        public static void UseHeapDumpActuator(IConfiguration configuration, IHeapDumper heapDumper = null, ILoggerFactory loggerFactory = null)
        {
            var options = new HeapDumpOptions(configuration);

            heapDumper = heapDumper ?? new HeapDumper(options);
            var ep      = new HeapDumpEndpoint(options, heapDumper, CreateLogger <HeapDumpEndpoint>(loggerFactory));
            var handler = new HeapDumpHandler(ep, SecurityService, CreateLogger <HeapDumpHandler>(loggerFactory));

            ConfiguredHandlers.Add(handler);
        }
Exemple #2
0
        public HeapDumpEndpoint(IHeapDumpOptions options, IHeapDumper heapDumper, ILogger <HeapDumpEndpoint> logger = null)
            : base(options)
        {
            if (heapDumper == null)
            {
                throw new ArgumentNullException(nameof(heapDumper));
            }

            _heapDumper = heapDumper;
            _logger     = 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));
        }