-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Log KestrelServerOptions when tracing is enabled #34680
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
Conversation
- Dump configured values in a dictionary and emit an event with the pairs
|
EventSource only allows primitive values afaik. If you want to use eventsource then could could log each name/value in a separate call. Alternatively, DiagnosticSource supports passing a dictionary. |
|
@noahfalk did some testing and a dictionary worked the other day. But maybe only in narrow cases. I'll likely use JSON if tho doesn't work |
- Added listen options - Added IsDevCertLoaded property - Mored RegisterOptions to the end of StartAsync
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
I'm a little worried about the options going out of sync with the event. Assuming we use this pattern of adding Serialize method everywhere maybe have an analyzer to detect that? But besides that, looks good to me 👍🏾 |
|
IsDevCertLoaded is internal, do we want to log it? |
Code reviewz! But a valid concern. We can add a comment to the file but yeah, an analyzer could probably detect it.
Seems useful for debugging. |
|
I should probably add a test |
| [NonEvent] | ||
| public void Configuration(KestrelServerOptions options) | ||
| { | ||
| var bufferWriter = new ArrayBufferWriter<byte>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an equivalent of checking log level here? Only want to write JSON if Informational and above events are being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This:
aspnetcore/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelEventSource.cs
Line 63 in e470d40
| if (IsEnabled(EventLevel.Informational, EventKeywords.None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is checked in AddServerOptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Configuration event is invoked from OnEventCommand and that path ideally would also test the level. If that level test was here it would make it easy to have it enforced uniformly. Currently Configuration() is also a public API so any other code could become a new caller in the future.
Do we want to log the addresses configured by the |
|
I do but it feels weird to put it on the object. Maybe it's fine? |
| Assert.Equal(Guid.Empty, connectionStop.RelatedActivityId); | ||
|
|
||
| Assert.Equal(eventIndex, events.Count); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your choice in deciding how much you care, but if you want to you could write a unit test that deserializes the serialized JSON to see if the value round trips. Another option would be reflecting over all property names to confirm that they match the names observed in the JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will write a test that JSON deserializes
noahfalk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: James Newton-King <[email protected]>
Dumped out OptionsInUse (seems to work well). |
{ "AllowSynchronousIO": false, "AddServerHeader": true, "AllowAlternateSchemes": false, "AllowResponseHeaderCompression": true, "EnableAltSvc": false, "IsDevCertLoaded": true, "RequestHeaderEncodingSelector": "default", "ResponseHeaderEncodingSelector": "default", "Limits": { "KeepAliveTimeout": "00:02:10", "MaxConcurrentConnections": null, "MaxConcurrentUpgradedConnections": null, "MaxRequestBodySize": 30000000, "MaxRequestBufferSize": 1048576, "MaxRequestHeaderCount": 100, "MaxRequestHeadersTotalSize": 32768, "MaxRequestLineSize": 8192, "MaxResponseBufferSize": 65536, "MinRequestBodyDataRate": "Bytes per second: 240, Grace Period: 00:00:05", "MinResponseDataRate": "Bytes per second: 240, Grace Period: 00:00:05", "RequestHeadersTimeout": "00:00:30", "Http2": { "MaxStreamsPerConnection": 100, "HeaderTableSize": 4096, "MaxFrameSize": 16384, "MaxRequestHeaderFieldSize": 16384, "InitialConnectionWindowSize": 131072, "InitialStreamWindowSize": 98304, "KeepAlivePingDelay": "10675199.02:48:05.4775807", "KeepAlivePingTimeout": "00:00:20" }, "Http3": { "HeaderTableSize": 0, "MaxRequestHeaderFieldSize": 16384 } }, "ListenOptions": [ { "Address": "https://127.0.0.1:7030", "IsTls": true, "Protocols": "Http1AndHttp2" }, { "Address": "https://[::1]:7030", "IsTls": true, "Protocols": "Http1AndHttp2" }, { "Address": "http://127.0.0.1:5030", "IsTls": false, "Protocols": "Http1AndHttp2" }, { "Address": "http://[::1]:5030", "IsTls": false, "Protocols": "Http1AndHttp2" } ] }The payload size is event source and LOH safe so >= 2K and 4K (with more listen options).
Contributes to #34578