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

Event source configuration #3

Merged
merged 11 commits into from
Jan 24, 2022
Merged

Event source configuration #3

merged 11 commits into from
Jan 24, 2022

Conversation

twenzel
Copy link

@twenzel twenzel commented Jan 22, 2022

Hi @hananiel,
I think this approach is a better event source configuration making it more flexible and more "explorable" for the developer.

@twenzel
Copy link
Author

twenzel commented Jan 23, 2022

The configuration looks like

using var meterprovider = Sdk.CreateMeterProviderBuilder()
                    .AddEventCounters(options =>
                    {
                        options.AddRuntime().WithAll(); // all from 'System.Runtime'
                        options.AddAspNetCore() // dedicated event counters with optional mapped metric name
                            .WithCurrentRequests("http_requests_in_progress")
                            .WithFailedRequests()
                            .WithRequestRate()
                            .WithTotalRequests("http_requests_received_total");
                        
                        options.AddEventSource("Microsoft-AspNetCore-Server-Kestrel") // add any other event counter
                            .WithCounters("total-connections", "connections-per-second")
                            .With("connections-per-second", "The number of connections per update interval to the web server", MetricType.LongSum);
                    })

this.option = options.AddEventSource(KnownEventSources.SystemRuntime);
}

public ISystemRuntimeBuilder WithCounters(params string[] counterNames)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this approach is great and user friendly but the eventCounters under well known counters are not the only ones. We also need to support ones we do not know about. So it has use types that allow users to add theirs without code changes. Also needs to be configurable from appsettings.json or other IConfiguration sources.

@hananiel hananiel merged commit 0619d33 into hananiel:EventCounterListener Jan 24, 2022
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

Successfully merging this pull request may close these issues.

2 participants