74 instantiations of KestrelMetrics
InMemory.FunctionalTests (60)
BadHttpRequestTests.cs (7)
171}, new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) 240await using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)))) 262await using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)))) 346await using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) { DiagnosticSource = diagListener })) 393await using (var server = new TestServer(context => context.Request.Body.DrainAsync(default), new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) { DiagnosticSource = diagListener })) 459await using (var server = new TestServer(context => context.Request.Body.DrainAsync(default), new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) { DiagnosticSource = diagListener })) 534await using (var server = new TestServer(context => context.Request.Body.DrainAsync(default), new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) { DiagnosticSource = diagListener }))
ChunkedRequestTests.cs (1)
858var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory));
ConnectionLimitTests.cs (2)
228var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(meterFactory ?? new TestMeterFactory())); 235var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(meterFactory ?? new TestMeterFactory()));
ConnectionMiddlewareTests.cs (1)
161var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory));
Http2\TlsTests.cs (1)
49new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)),
HttpsConnectionMiddlewareTests.cs (3)
45.AddSingleton(new KestrelMetrics(new TestMeterFactory())) 1480return new HttpsConnectionMiddleware(context => Task.CompletedTask, options, httpProtocols, loggerFactory, new KestrelMetrics(new TestMeterFactory())); 1485return new HttpsConnectionMiddleware(context => Task.CompletedTask, options, httpProtocols, new KestrelMetrics(new TestMeterFactory()));
HttpsTests.cs (1)
42.AddSingleton(new KestrelMetrics(new TestMeterFactory()))
KeepAliveTimeoutTests.cs (6)
30var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 62var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 95var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 140var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 185var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 210var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory));
KestrelMetricsTests.cs (14)
65var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 124var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 167var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 209var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) 274var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) 344var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 398var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 458var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 500var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 543new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) 612var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) 690new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)), 779new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)), 858new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)),
MaxRequestBodySizeTests.cs (2)
135new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) { ServerOptions = { Limits = { MaxRequestBodySize = maxRequestBodySize } } })) 384new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) { ServerOptions = { Limits = { MaxRequestBodySize = 0 } } }))
MaxRequestLineSizeTests.cs (1)
85return new TestServer(async httpContext => await httpContext.Response.WriteAsync("hello, world"), new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(meterFactory))
RequestBodyTimeoutTests.cs (3)
26var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 102var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 156var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory));
RequestHeaderLimitsTests.cs (1)
175var kestrelMetrics = meterFactory != null ? new KestrelMetrics(meterFactory) : null;
RequestHeadersTimeoutTests.cs (4)
29var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 58var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 96var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 123var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory));
RequestTests.cs (2)
1159var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 2261var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory));
ResponseTests.cs (9)
147var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 693}, new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)))) 952var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) 996var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 2608var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 2811var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 2864var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 2909var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 3008var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory));
src\Servers\Kestrel\shared\test\TestContextFactory.cs (1)
42Metrics = new KestrelMetrics(new TestMeterFactory())
src\Servers\Kestrel\shared\test\TestServiceContext.cs (1)
27metrics ??= new KestrelMetrics(new TestMeterFactory());
Microsoft.AspNetCore.Server.Kestrel.Core (1)
KestrelServer.cs (1)
40new KestrelMetrics(new DummyMeterFactory()),
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (4)
KestrelServerTests.cs (2)
38.AddSingleton(new KestrelMetrics(new TestMeterFactory())) 313metrics ?? new KestrelMetrics(new TestMeterFactory()),
src\Servers\Kestrel\shared\test\TestContextFactory.cs (1)
42Metrics = new KestrelMetrics(new TestMeterFactory())
src\Servers\Kestrel\shared\test\TestServiceContext.cs (1)
27metrics ??= new KestrelMetrics(new TestMeterFactory());
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (1)
src\Servers\Kestrel\shared\test\TestContextFactory.cs (1)
42Metrics = new KestrelMetrics(new TestMeterFactory())
Microsoft.AspNetCore.Server.Kestrel.Tests (1)
KestrelConfigurationLoaderTests.cs (1)
30.AddSingleton(new KestrelMetrics(new TestMeterFactory()))
Sockets.BindTests (1)
src\Servers\Kestrel\shared\test\TestServiceContext.cs (1)
27metrics ??= new KestrelMetrics(new TestMeterFactory());
Sockets.FunctionalTests (6)
src\Servers\Kestrel\shared\test\TestServiceContext.cs (1)
27metrics ??= new KestrelMetrics(new TestMeterFactory());
src\Servers\Kestrel\test\FunctionalTests\ResponseTests.cs (5)
206var testServiceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 434var testServiceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); 508var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) 763var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) 1026var testContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory))
94 references to KestrelMetrics
InMemory.FunctionalTests (32)
ConnectionLimitTests.cs (2)
158m.Tags.TryGetValue(KestrelMetrics.ErrorTypeAttributeName, out var value); 166Assert.Equal(10, connectionErrors.Single(e => e.Key == KestrelMetrics.GetErrorType(ConnectionEndReason.MaxConcurrentConnectionsExceeded)).Count());
ConnectionMiddlewareTests.cs (1)
175Assert.Equal(typeof(InvalidOperationException).FullName, m.Tags[KestrelMetrics.ErrorTypeAttributeName]);
Http2\Http2StreamTests.cs (1)
3781Assert.False(ConnectionTags.ContainsKey(KestrelMetrics.ErrorTypeAttributeName), "Non-error reason shouldn't be added to error.type");
KestrelMetricsTests.cs (21)
36var hasValue = KestrelMetrics.TryGetErrorType(reason, out var value); 96AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http11); 198AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http11, error: KestrelMetrics.GetErrorType(ConnectionEndReason.InvalidBodyReaderState)); 262AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http11); 313AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http11, error: KestrelMetrics.GetErrorType(ConnectionEndReason.AppShutdownTimeout)); 384AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http11); 427AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http11, error: KestrelMetrics.GetErrorType(ConnectionEndReason.AbortedByApp)); 514Assert.Collection(connectionDuration.GetMeasurementSnapshot(), m => AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http11)); 601Assert.Collection(connectionDuration.GetMeasurementSnapshot(), m => AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http2)); 663Assert.Collection(connectionDuration.GetMeasurementSnapshot(), m => AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http2, error: KestrelMetrics.GetErrorType(ConnectionEndReason.AppShutdownTimeout))); 739Assert.Collection(connectionDuration.GetMeasurementSnapshot(), m => AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http2, "1.2")); 744m => AssertRequestCount(m, 1, KestrelMetrics.Http2), 745m => AssertRequestCount(m, -1, KestrelMetrics.Http2), 746m => AssertRequestCount(m, 1, KestrelMetrics.Http2), 747m => AssertRequestCount(m, -1, KestrelMetrics.Http2)); 832Assert.Collection(connectionDuration.GetMeasurementSnapshot(), m => AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http2)); 906AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", httpVersion: null, tlsProtocolVersion: null, error: KestrelMetrics.GetErrorType(ConnectionEndReason.TlsHandshakeFailed));
RequestHeaderLimitsTests.cs (1)
175var kestrelMetrics = meterFactory != null ? new KestrelMetrics(meterFactory) : null;
src\Servers\Kestrel\shared\test\MetricsAssert.cs (4)
14Assert.Equal(KestrelMetrics.GetErrorType(expectedReason), errorType); 19Equal(expectedReason, (string) tags[KestrelMetrics.ErrorTypeAttributeName]); 24if (tags.TryGetValue(KestrelMetrics.ErrorTypeAttributeName, out var error)) 26Assert.Fail($"Tag collection contains {KestrelMetrics.ErrorTypeAttributeName} with value {error}.");
src\Servers\Kestrel\shared\test\TestServiceContext.cs (2)
23public TestServiceContext(ILoggerFactory loggerFactory = null, KestrelTrace kestrelTrace = null, bool disableHttp1LineFeedTerminators = true, KestrelMetrics metrics = null) 51private void Initialize(ILoggerFactory loggerFactory, KestrelTrace kestrelTrace, bool disableHttp1LineFeedTerminators, KestrelMetrics metrics)
Microsoft.AspNetCore.Server.Kestrel (1)
WebHostBuilderKestrelExtensions.cs (1)
87services.AddSingleton<KestrelMetrics>();
Microsoft.AspNetCore.Server.Kestrel.Core (45)
Internal\ConnectionDispatcher.cs (1)
25private KestrelMetrics Metrics => _serviceContext.Metrics;
Internal\Http\Http1ChunkedEncodingMessageBody.cs (1)
140KestrelMetrics.AddConnectionEndReason(_context.MetricsContext, ConnectionEndReason.UnexpectedEndOfRequestContent);
Internal\Http\Http1Connection.cs (9)
142KestrelMetrics.AddConnectionEndReason(MetricsContext, reason); 154KestrelMetrics.AddConnectionEndReason(MetricsContext, ConnectionEndReason.RequestHeadersTimeout); 162KestrelMetrics.AddConnectionEndReason(MetricsContext, ConnectionEndReason.MinRequestBodyDataRate); 624KestrelMetrics.AddConnectionEndReason(MetricsContext, ConnectionEndReason.InvalidRequestHeaders); 635KestrelMetrics.AddConnectionEndReason(MetricsContext, ConnectionEndReason.InvalidRequestHeaders); 668KestrelMetrics.AddConnectionEndReason(MetricsContext, ConnectionEndReason.InvalidRequestHeaders); 677KestrelMetrics.AddConnectionEndReason(MetricsContext, ConnectionEndReason.InvalidRequestHeaders); 743KestrelMetrics.AddConnectionEndReason(MetricsContext, ConnectionEndReason.OtherError); 842KestrelMetrics.AddConnectionEndReason(MetricsContext, reason);
Internal\Http\Http1MessageBody.cs (2)
210KestrelMetrics.AddConnectionEndReason(context.MetricsContext, ConnectionEndReason.InvalidRequestHeaders); 231KestrelMetrics.AddConnectionEndReason(_context.MetricsContext, ConnectionEndReason.UnexpectedEndOfRequestContent);
Internal\Http\Http1OutputProducer.cs (1)
476KestrelMetrics.AddConnectionEndReason(_connectionMetricsContext, reason);
Internal\Http2\Http2Connection.cs (2)
239KestrelMetrics.AddConnectionEndReason(_metricsContext, reason); 1344_context.ServiceContext.Metrics.RequestQueuedStart(_metricsContext, KestrelMetrics.Http2);
Internal\Http2\Http2StreamOfT.cs (1)
24ServiceContext.Metrics.RequestQueuedStop(MetricsContext, KestrelMetrics.Http2);
Internal\Http3\Http3Connection.cs (2)
190KestrelMetrics.AddConnectionEndReason(MetricsContext, reason); 618_context.ServiceContext.Metrics.RequestQueuedStart(MetricsContext, KestrelMetrics.Http3);
Internal\Http3\Http3StreamOfT.cs (1)
23ServiceContext.Metrics.RequestQueuedStop(MetricsContext, KestrelMetrics.Http3);
Internal\HttpConnection.cs (4)
72AddMetricsHttpProtocolTag(KestrelMetrics.Http11); 80AddMetricsHttpProtocolTag(KestrelMetrics.Http2); 85AddMetricsHttpProtocolTag(KestrelMetrics.Http3); 131KestrelMetrics.AddConnectionEndReason(connectionMetricsTagsFeature, connectionEndReason);
Internal\Infrastructure\KestrelConnectionOfT.cs (1)
33private KestrelMetrics Metrics => _serviceContext.Metrics;
Internal\Infrastructure\TransportConnectionManager.cs (1)
81KestrelMetrics.AddConnectionEndReason(
Internal\KestrelServerImpl.cs (4)
43KestrelMetrics metrics, 77private static ServiceContext CreateServiceContext(IOptions<KestrelServerOptions> options, ILoggerFactory loggerFactory, DiagnosticSource? diagnosticSource, KestrelMetrics metrics, 432private static ConnectionDelegate EnforceConnectionLimit(ConnectionDelegate innerDelegate, long? connectionLimit, KestrelTrace trace, KestrelMetrics metrics) 442private static MultiplexedConnectionDelegate EnforceConnectionLimit(MultiplexedConnectionDelegate innerDelegate, long? connectionLimit, KestrelTrace trace, KestrelMetrics metrics)
Internal\ServiceContext.cs (1)
36public KestrelMetrics Metrics { get; set; } = default!;
ListenOptionsHttpsExtensions.cs (4)
195var metrics = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService<KestrelMetrics>(); 258var metrics = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService<KestrelMetrics>();
Middleware\ConnectionLimitMiddleware.cs (3)
16private readonly KestrelMetrics _metrics; 18public ConnectionLimitMiddleware(Func<T, Task> next, long connectionLimit, KestrelTrace trace, KestrelMetrics metrics) 24internal ConnectionLimitMiddleware(Func<T, Task> next, ResourceCounter concurrentConnectionCounter, KestrelTrace trace, KestrelMetrics metrics)
Middleware\HttpsConnectionMiddleware.cs (7)
39private readonly KestrelMetrics _metrics; 57public HttpsConnectionMiddleware(ConnectionDelegate next, HttpsConnectionAdapterOptions options, HttpProtocols httpProtocols, KestrelMetrics metrics) 62public HttpsConnectionMiddleware(ConnectionDelegate next, HttpsConnectionAdapterOptions options, HttpProtocols httpProtocols, ILoggerFactory loggerFactory, KestrelMetrics metrics) 130KestrelMetrics metrics) 220if (KestrelMetrics.TryGetHandshakeProtocol(sslStream.SslProtocol, out var protocolName, out var protocolVersion)) 252static void RecordHandshakeFailed(KestrelMetrics metrics, long startTimestamp, long currentTimestamp, ConnectionMetricsContext metricsContext, IConnectionMetricsTagsFeature? metricsTagsFeature, Exception ex) 257KestrelMetrics.AddConnectionEndReason(metricsTagsFeature, ConnectionEndReason.TlsHandshakeFailed);
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (7)
KestrelServerTests.cs (1)
295KestrelMetrics metrics = null)
src\Servers\Kestrel\shared\test\MetricsAssert.cs (4)
14Assert.Equal(KestrelMetrics.GetErrorType(expectedReason), errorType); 19Equal(expectedReason, (string) tags[KestrelMetrics.ErrorTypeAttributeName]); 24if (tags.TryGetValue(KestrelMetrics.ErrorTypeAttributeName, out var error)) 26Assert.Fail($"Tag collection contains {KestrelMetrics.ErrorTypeAttributeName} with value {error}.");
src\Servers\Kestrel\shared\test\TestServiceContext.cs (2)
23public TestServiceContext(ILoggerFactory loggerFactory = null, KestrelTrace kestrelTrace = null, bool disableHttp1LineFeedTerminators = true, KestrelMetrics metrics = null) 51private void Initialize(ILoggerFactory loggerFactory, KestrelTrace kestrelTrace, bool disableHttp1LineFeedTerminators, KestrelMetrics metrics)
Microsoft.AspNetCore.Server.Kestrel.Tests (1)
WebHostBuilderKestrelExtensionsTests.cs (1)
120Assert.IsType<KestrelMetrics>(server.ServiceContext.Metrics);
Sockets.BindTests (2)
src\Servers\Kestrel\shared\test\TestServiceContext.cs (2)
23public TestServiceContext(ILoggerFactory loggerFactory = null, KestrelTrace kestrelTrace = null, bool disableHttp1LineFeedTerminators = true, KestrelMetrics metrics = null) 51private void Initialize(ILoggerFactory loggerFactory, KestrelTrace kestrelTrace, bool disableHttp1LineFeedTerminators, KestrelMetrics metrics)
Sockets.FunctionalTests (6)
src\Servers\Kestrel\shared\test\MetricsAssert.cs (4)
14Assert.Equal(KestrelMetrics.GetErrorType(expectedReason), errorType); 19Equal(expectedReason, (string) tags[KestrelMetrics.ErrorTypeAttributeName]); 24if (tags.TryGetValue(KestrelMetrics.ErrorTypeAttributeName, out var error)) 26Assert.Fail($"Tag collection contains {KestrelMetrics.ErrorTypeAttributeName} with value {error}.");
src\Servers\Kestrel\shared\test\TestServiceContext.cs (2)
23public TestServiceContext(ILoggerFactory loggerFactory = null, KestrelTrace kestrelTrace = null, bool disableHttp1LineFeedTerminators = true, KestrelMetrics metrics = null) 51private void Initialize(ILoggerFactory loggerFactory, KestrelTrace kestrelTrace, bool disableHttp1LineFeedTerminators, KestrelMetrics metrics)