Skip to content

Commit c6fd3d3

Browse files
committed
Rename current connections counter
1 parent e60211a commit c6fd3d3

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal;
99

1010
internal readonly struct MetricsContext
1111
{
12-
public MetricsContext(bool connectionDurationEnabled, bool currentNegotiatedConnectionsCounterEnabled)
12+
public MetricsContext(bool connectionDurationEnabled, bool currentConnectionsCounterEnabled)
1313
{
1414
ConnectionDurationEnabled = connectionDurationEnabled;
15-
CurrentNegotiatedConnectionsCounterEnabled = currentNegotiatedConnectionsCounterEnabled;
15+
CurrentConnectionsCounterEnabled = currentConnectionsCounterEnabled;
1616
}
1717

1818
public bool ConnectionDurationEnabled { get; }
19-
public bool CurrentNegotiatedConnectionsCounterEnabled { get; }
19+
public bool CurrentConnectionsCounterEnabled { get; }
2020
}
2121

2222
internal sealed class HttpConnectionsMetrics : IDisposable
@@ -25,7 +25,7 @@ internal sealed class HttpConnectionsMetrics : IDisposable
2525

2626
private readonly Meter _meter;
2727
private readonly Histogram<double> _connectionDuration;
28-
private readonly UpDownCounter<long> _currentNegotiatedConnectionsCounter;
28+
private readonly UpDownCounter<long> _currentConnectionsCounter;
2929

3030
public HttpConnectionsMetrics(IMeterFactory meterFactory)
3131
{
@@ -36,9 +36,9 @@ public HttpConnectionsMetrics(IMeterFactory meterFactory)
3636
unit: "s",
3737
description: "The duration of connections on the server.");
3838

39-
_currentNegotiatedConnectionsCounter = _meter.CreateUpDownCounter<long>(
40-
"signalr-http-transport-current-negotiated-connections",
41-
description: "Number of negotiated connections that are currently active on the server.");
39+
_currentConnectionsCounter = _meter.CreateUpDownCounter<long>(
40+
"signalr-http-transport-current-connections",
41+
description: "Number of connections that are currently active on the server.");
4242
}
4343

4444
public void ConnectionStop(in MetricsContext metricsContext, HttpTransportType transportType, HttpConnectionStopStatus status, long startTimestamp, long currentTimestamp)
@@ -57,21 +57,21 @@ public void ConnectionTransportStart(in MetricsContext metricsContext, HttpTrans
5757
Debug.Assert(transportType != HttpTransportType.None);
5858

5959
// Tags must match transport end.
60-
if (metricsContext.CurrentNegotiatedConnectionsCounterEnabled)
60+
if (metricsContext.CurrentConnectionsCounterEnabled)
6161
{
62-
_currentNegotiatedConnectionsCounter.Add(1, new KeyValuePair<string, object?>("transport", transportType.ToString()));
62+
_currentConnectionsCounter.Add(1, new KeyValuePair<string, object?>("transport", transportType.ToString()));
6363
}
6464
}
6565

6666
public void TransportStop(in MetricsContext metricsContext, HttpTransportType transportType)
6767
{
68-
if (metricsContext.CurrentNegotiatedConnectionsCounterEnabled)
68+
if (metricsContext.CurrentConnectionsCounterEnabled)
6969
{
7070
// Tags must match transport start.
7171
// If the transport type is none then the transport was never started for this connection.
7272
if (transportType != HttpTransportType.None)
7373
{
74-
_currentNegotiatedConnectionsCounter.Add(-1, new KeyValuePair<string, object?>("transport", transportType.ToString()));
74+
_currentConnectionsCounter.Add(-1, new KeyValuePair<string, object?>("transport", transportType.ToString()));
7575
}
7676
}
7777
}
@@ -83,6 +83,6 @@ public void Dispose()
8383

8484
public MetricsContext CreateContext()
8585
{
86-
return new MetricsContext(_connectionDuration.Enabled, _currentNegotiatedConnectionsCounter.Enabled);
86+
return new MetricsContext(_connectionDuration.Enabled, _currentConnectionsCounter.Enabled);
8787
}
8888
}

src/SignalR/common/Http.Connections/test/HttpConnectionDispatcherTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ public async Task Metrics()
10911091
{
10921092
var testMeterFactory = new TestMeterFactory();
10931093
using var connectionDuration = new InstrumentRecorder<double>(testMeterFactory, HttpConnectionsMetrics.MeterName, "signalr-http-transport-connection-duration");
1094-
using var currentNegotiatedConnections = new InstrumentRecorder<long>(testMeterFactory, HttpConnectionsMetrics.MeterName, "signalr-http-transport-current-negotiated-connections");
1094+
using var currentConnections = new InstrumentRecorder<long>(testMeterFactory, HttpConnectionsMetrics.MeterName, "signalr-http-transport-current-connections");
10951095

10961096
var metrics = new HttpConnectionsMetrics(testMeterFactory);
10971097
var manager = CreateConnectionManager(LoggerFactory, metrics);
@@ -1119,7 +1119,7 @@ public async Task Metrics()
11191119
Assert.False(exists);
11201120

11211121
Assert.Collection(connectionDuration.GetMeasurements(), m => AssertDuration(m, HttpConnectionStopStatus.NormalClosure, HttpTransportType.LongPolling));
1122-
Assert.Collection(currentNegotiatedConnections.GetMeasurements(), m => AssertTransport(m, 1, HttpTransportType.LongPolling), m => AssertTransport(m, -1, HttpTransportType.LongPolling));
1122+
Assert.Collection(currentConnections.GetMeasurements(), m => AssertTransport(m, 1, HttpTransportType.LongPolling), m => AssertTransport(m, -1, HttpTransportType.LongPolling));
11231123
}
11241124

11251125
static void AssertTransport(Measurement<long> measurement, long expected, HttpTransportType transportType)

0 commit comments

Comments
 (0)