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

User/saweb/listen for kestrel events #55

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

webbsk
Copy link

@webbsk webbsk commented May 19, 2021

I think this PR requires work but I'm open to feedback! I am using this in my own work and I would be interested in improvements you suggest.

namespace Prometheus.DotNetRuntime.Tests.IntegrationTests
{
//[TestFixture]
//internal class Given_Contention_Events_Are_Enabled_For_Kestrel_Stats
Copy link
Author

Choose a reason for hiding this comment

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

I feel like this should have tests but I'm not sure how to write them here.

Copy link
Owner

Choose a reason for hiding this comment

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

The way I've approached integration testing is to invoke some behaviour in the runtime (e.g. allocate some memory, content a lock) and make sure I can observe the relevant change in the metrics.

I'd suggest running a web server and issuing traffic against it, verifying that the expected metrics change.

Copy link
Owner

@djluck djluck left a comment

Choose a reason for hiding this comment

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

@webbsk thanks for submitting this PR! I've had a quick glance over it but due to it's size, it might take a bit of time to give it a proper review. However the functionality you're adding looks very useful, I'll get back to you with a full review when I can.

@@ -2,13 +2,16 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>8</LangVersion>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
Copy link
Owner

Choose a reason for hiding this comment

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

Neat, was not aware of these properties!

@@ -0,0 +1,1222 @@
#!/usr/bin/env bash
Copy link
Owner

Choose a reason for hiding this comment

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

What's the purpose of this script?

**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
Copy link
Owner

Choose a reason for hiding this comment

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

Nice, thanks!

COPY . .
RUN dotnet publish "examples/AspNetCoreExample" -c Release -o /app
WORKDIR "/src/examples/AspNetCoreExample"
RUN dotnet build "AspNetCoreExample.csproj" -c Release -o /app/build
Copy link
Owner

Choose a reason for hiding this comment

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

There should be no need for an explicit restore or build- publish does all these things implicitly.

@@ -0,0 +1,13 @@
# FROM mcr.microsoft.com/dotnet/core/sdk:3.1.201 AS build
Copy link
Owner

Choose a reason for hiding this comment

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

We should delete this if it's no longer in use. I haven't yet checked out your branch but I still do want to support building the docker image via docker-compose up.


namespace Prometheus.DotNetRuntime.EventListening.Parsers
{
public class KestrelEventParser : IEventParser<KestrelEventParser>, KestrelEventParser.Events.Info
Copy link
Owner

Choose a reason for hiding this comment

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

I can see you went through a fair bit of effort to write this class (the event parsers are by far the most tedious part to write) so firstly, thankyou- you did a good job.

However, it seems that most if not all of the information you're pulling out here could be extracted using event counters. Event counters are definitely prefered for any event that is going to be high-frequency and pretty much required on .NET 3.1 to avoid a nasty CPU leak.

It seems asp.net core 3.1 has the following event counter sources available to it:

OnEventCommand is the method to look at in each class- it will initialize the counters and specifying the name of the counter. Using this name we can subscribe to counters (see RuntimeEventParser as an example).

@@ -69,9 +69,9 @@ public static class Events
{
public interface CountersV3_0 : ICounterEvents
{
event Action<MeanCounterValue> ThreadPoolThreadCount;
event Action<MeanCounterValue> ConnectionCount;
Copy link
Owner

Choose a reason for hiding this comment

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

You've definitely broken the tests with this change- each event source should have it's own class defined. You may be able to group all the ASP.NET counters together as I guess users would commonly want to enable them all simultaneously.

Copy link
Owner

@djluck djluck left a comment

Choose a reason for hiding this comment

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

I've left some feedback for you. There's some fairly large asks in here so feel free to ignore this, I was eventually planning to add support for these counters in and I could definitely build on this MR. If you're still keen, have a look and shoot me any questions you might have.

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