Skip to content

Commit 18e30b9

Browse files
committed
Merge branch 'main' into fix/56331
2 parents d8d2d2f + d301328 commit 18e30b9

File tree

11 files changed

+247
-222
lines changed

11 files changed

+247
-222
lines changed

eng/Version.Details.xml

Lines changed: 144 additions & 144 deletions
Large diffs are not rendered by default.

eng/Versions.props

Lines changed: 72 additions & 72 deletions
Large diffs are not rendered by default.

src/Hosting/Hosting/src/Internal/HostingMetrics.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public HostingMetrics(IMeterFactory meterFactory)
2929
_requestDuration = _meter.CreateHistogram<double>(
3030
"http.server.request.duration",
3131
unit: "s",
32-
description: "Duration of HTTP server requests.");
32+
description: "Duration of HTTP server requests.",
33+
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = MetricsConstants.ShortSecondsBucketBoundaries });
3334
}
3435

3536
// Note: Calling code checks whether counter is enabled.

src/Hosting/Hosting/src/Microsoft.AspNetCore.Hosting.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<Compile Include="$(SharedSourceRoot)ErrorPage\**\*.cs" />
1818
<Compile Include="$(SharedSourceRoot)StaticWebAssets\**\*.cs" LinkBase="StaticWebAssets" />
1919
<Compile Include="$(SharedSourceRoot)Metrics\MetricsExtensions.cs" />
20+
<Compile Include="$(SharedSourceRoot)Metrics\MetricsConstants.cs" />
2021
</ItemGroup>
2122

2223
<ItemGroup>

src/Middleware/RateLimiting/src/Microsoft.AspNetCore.RateLimiting.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<Reference Include="System.Threading.RateLimiting" />
1919

2020
<Compile Include="$(SharedSourceRoot)ValueStopwatch\*.cs" />
21+
<Compile Include="$(SharedSourceRoot)Metrics\MetricsConstants.cs" />
2122
</ItemGroup>
2223

2324
<ItemGroup>

src/Middleware/RateLimiting/src/RateLimitingMetrics.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Diagnostics;
55
using System.Diagnostics.Metrics;
66
using System.Runtime.CompilerServices;
7+
using Microsoft.AspNetCore.Http;
78

89
namespace Microsoft.AspNetCore.RateLimiting;
910

@@ -30,7 +31,8 @@ public RateLimitingMetrics(IMeterFactory meterFactory)
3031
_requestLeaseDurationCounter = _meter.CreateHistogram<double>(
3132
"aspnetcore.rate_limiting.request_lease.duration",
3233
unit: "s",
33-
description: "The duration of rate limiting leases held by HTTP requests on the server.");
34+
description: "The duration of rate limiting leases held by HTTP requests on the server.",
35+
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = MetricsConstants.ShortSecondsBucketBoundaries });
3436

3537
_queuedRequestsCounter = _meter.CreateUpDownCounter<long>(
3638
"aspnetcore.rate_limiting.queued_requests",
@@ -40,7 +42,8 @@ public RateLimitingMetrics(IMeterFactory meterFactory)
4042
_queuedRequestDurationCounter = _meter.CreateHistogram<double>(
4143
"aspnetcore.rate_limiting.request.time_in_queue",
4244
unit: "s",
43-
description: "The duration of HTTP requests in a queue, waiting to acquire a rate limiting lease.");
45+
description: "The duration of HTTP requests in a queue, waiting to acquire a rate limiting lease.",
46+
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = MetricsConstants.ShortSecondsBucketBoundaries });
4447

4548
_requestsCounter = _meter.CreateCounter<long>(
4649
"aspnetcore.rate_limiting.requests",

src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelMetrics.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Runtime.CompilerServices;
1010
using System.Security.Authentication;
1111
using Microsoft.AspNetCore.Connections;
12+
using Microsoft.AspNetCore.Http;
1213

1314
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
1415

@@ -43,7 +44,8 @@ public KestrelMetrics(IMeterFactory meterFactory)
4344
_connectionDuration = _meter.CreateHistogram<double>(
4445
"kestrel.connection.duration",
4546
unit: "s",
46-
description: "The duration of connections on the server.");
47+
description: "The duration of connections on the server.",
48+
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = MetricsConstants.LongSecondsBucketBoundaries });
4749

4850
_rejectedConnectionsCounter = _meter.CreateCounter<long>(
4951
"kestrel.rejected_connections",
@@ -68,7 +70,8 @@ public KestrelMetrics(IMeterFactory meterFactory)
6870
_tlsHandshakeDuration = _meter.CreateHistogram<double>(
6971
"kestrel.tls_handshake.duration",
7072
unit: "s",
71-
description: "The duration of TLS handshakes on the server.");
73+
description: "The duration of TLS handshakes on the server.",
74+
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = MetricsConstants.ShortSecondsBucketBoundaries });
7275

7376
_activeTlsHandshakesCounter = _meter.CreateUpDownCounter<long>(
7477
"kestrel.active_tls_handshakes",

src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<Compile Include="$(SharedSourceRoot)CancellationTokenSourcePool.cs" />
3333
<Compile Include="$(SharedSourceRoot)Debugger\DictionaryItemDebugView.cs" LinkBase="Shared" />
3434
<Compile Include="$(SharedSourceRoot)Debugger\StringValuesDictionaryDebugView.cs" LinkBase="Shared" />
35+
<Compile Include="$(SharedSourceRoot)Metrics\MetricsConstants.cs" LinkBase="Shared" />
3536
<Compile Include="$(RepoRoot)src\Shared\TaskToApm.cs" Link="Internal\TaskToApm.cs" />
3637
</ItemGroup>
3738

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.Http;
5+
6+
internal static class MetricsConstants
7+
{
8+
// Follows boundaries from http.server.request.duration/http.client.request.duration
9+
public static readonly IReadOnlyList<double> ShortSecondsBucketBoundaries = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10];
10+
11+
// Not based on a standard. Larger bucket sizes for longer lasting operations, e.g. HTTP connection duration. See https://github.com/open-telemetry/semantic-conventions/issues/336
12+
public static readonly IReadOnlyList<double> LongSecondsBucketBoundaries = [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 30, 60, 120, 300];
13+
}

src/SignalR/common/Http.Connections/src/Internal/HttpConnectionsMetrics.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public HttpConnectionsMetrics(IMeterFactory meterFactory)
3333
_connectionDuration = _meter.CreateHistogram<double>(
3434
"signalr.server.connection.duration",
3535
unit: "s",
36-
description: "The duration of connections on the server.");
36+
description: "The duration of connections on the server.",
37+
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = MetricsConstants.LongSecondsBucketBoundaries });
3738

3839
_currentConnectionsCounter = _meter.CreateUpDownCounter<long>(
3940
"signalr.server.active_connections",

src/SignalR/common/Http.Connections/src/Microsoft.AspNetCore.Http.Connections.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<Compile Include="$(SharedSourceRoot)WebEncoders\**\*.cs" />
2626
<Compile Include="$(SharedSourceRoot)ValueTaskExtensions\**\*.cs" />
2727
<Compile Include="$(SharedSourceRoot)NonCapturingTimer\*.cs" />
28+
<Compile Include="$(SharedSourceRoot)Metrics\MetricsConstants.cs" />
2829
<Compile Include="$(SharedSourceRoot)ThrowHelpers\ArgumentNullThrowHelper.cs" LinkBase="Shared" />
2930
<Compile Include="$(SharedSourceRoot)ThrowHelpers\ArgumentOutOfRangeThrowHelper.cs" LinkBase="Shared" />
3031
<Compile Include="$(SharedSourceRoot)CallerArgument\CallerArgumentExpressionAttribute.cs" LinkBase="Shared" />

0 commit comments

Comments
 (0)