Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitoring windows service using Metrics.Net #129

Open
rdongur opened this issue May 16, 2016 · 1 comment
Open

Monitoring windows service using Metrics.Net #129

rdongur opened this issue May 16, 2016 · 1 comment

Comments

@rdongur
Copy link

rdongur commented May 16, 2016

Hi,
How do we configure/implement Metrics.Net library for monitoring windows services? We have need to monitor http services and windows services (running in the background) as well. Please let me know if anyone had done this before or have some ideas.

thanks,
Raghu

@SabrinaMH
Copy link

I have some experience hosting Metrics.Net inside a Windows Service (using Topshelf).
In Program.cs I have the following Topshelf specific code:

                var topshelfExitCode = HostFactory.Run(serviceConfiguration =>
                {
                    Log.Logger.Bootstrap(new ConfigurationFromAppConfig());    
                    serviceConfiguration.UseSerilog(Log.Logger);
                    serviceConfiguration.Service<ApiService>(serviceInstance =>
                    {
                        serviceInstance.ConstructUsing(() => new ApiService());

and in ApiService.cs I have

        public void Start()
        {
            try
            { 
                Uri baseAddress = LoadUrl();
                _webApiServer = WebApp.Start<Startup>(url: baseAddress.ToString());
                Metric.Config.WithHttpEndpoint("http://localhost:1337/").WithAllCounters().WithReporting(r => r.WithTextFileReport(@"c:\temp\APIServiceReports.log", TimeSpan.FromSeconds(5)));
            }
            catch (Exception ex)
            {
                ...
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants