Skip to content

Commit 0977d86

Browse files
committed
chore: name variable according to project convention
1 parent b456083 commit 0977d86

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

RabbitMQ.AMQP.Client/Impl/MetricsReporter.cs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ internal sealed class MetricsReporter : IMetricsReporter
1515
{
1616
const string Version = "0.1.0";
1717

18-
static readonly Meter Meter;
18+
static readonly Counter<int> s_messagingClientSentMessages;
19+
static readonly Histogram<double> s_messagingClientOperationDuration;
1920

20-
static readonly Counter<int> MessagingClientSentMessages;
21-
static readonly Histogram<double> MessagingClientOperationDuration;
22-
23-
static readonly Counter<int> MessagingClientConsumedMessages;
24-
static readonly Histogram<double> MessagingProcessDuration;
21+
static readonly Counter<int> s_messagingClientConsumedMessages;
22+
static readonly Histogram<double> s_messagingProcessDuration;
2523

2624
readonly KeyValuePair<string, object?>
2725
_messagingOperationSystemTag = new(MessagingSystem, MessagingSystemValue);
@@ -48,27 +46,27 @@ internal sealed class MetricsReporter : IMetricsReporter
4846

4947
static MetricsReporter()
5048
{
51-
Meter = new("RabbitMQ.Amqp", Version);
49+
Meter meter = new("RabbitMQ.Amqp", Version);
5250

53-
MessagingClientSentMessages = Meter.CreateCounter<int>(
51+
s_messagingClientSentMessages = meter.CreateCounter<int>(
5452
"messaging.client.sent.messages",
5553
unit: "{message}",
5654
description:
5755
"Number of messages producer attempted to send to the broker.");
5856

59-
MessagingClientOperationDuration = Meter.CreateHistogram<double>(
57+
s_messagingClientOperationDuration = meter.CreateHistogram<double>(
6058
"messaging.client.operation.duration",
6159
unit: "s",
6260
description:
6361
"Duration of messaging operation initiated by a producer or consumer client.");
6462

65-
MessagingClientConsumedMessages = Meter.CreateCounter<int>(
63+
s_messagingClientConsumedMessages = meter.CreateCounter<int>(
6664
"messaging.client.consumed.messages",
6765
unit: "{message}",
6866
description:
6967
"Number of messages that were delivered to the application. ");
7068

71-
MessagingProcessDuration = Meter.CreateHistogram<double>(
69+
s_messagingProcessDuration = meter.CreateHistogram<double>(
7270
"messaging.process.duration",
7371
unit: "s",
7472
description:
@@ -81,17 +79,17 @@ public void ReportMessageSendSuccess(IMetricsReporter.PublisherContext context,
8179
var serverPort = new KeyValuePair<string, object?>(ServerPort, context.ServerPort);
8280
var destination = new KeyValuePair<string, object?>(MessageDestinationName, context.Destination);
8381

84-
MessagingClientSentMessages.Add(1, serverAddress, serverPort, destination, _messagingOperationSystemTag,
82+
s_messagingClientSentMessages.Add(1, serverAddress, serverPort, destination, _messagingOperationSystemTag,
8583
_sendOperationType, _publishOperationName);
8684
if (startTimestamp > 0)
8785
{
8886
#if NET7_0_OR_GREATER
8987
var duration = Stopwatch.GetElapsedTime(startTimestamp);
9088
#else
9189
var duration =
92-
new TimeSpan((long)((Stopwatch.GetTimestamp() - startTimestamp) * StopWatchTickFrequency));
90+
new TimeSpan((long)((Stopwatch.GetTimestamp() - startTimestamp) * s_stopWatchTickFrequency));
9391
#endif
94-
MessagingClientOperationDuration.Record(duration.TotalSeconds, serverAddress, serverPort, destination,
92+
s_messagingClientOperationDuration.Record(duration.TotalSeconds, serverAddress, serverPort, destination,
9593
_messagingOperationSystemTag, _sendOperationType, _publishOperationName);
9694
}
9795
}
@@ -103,7 +101,7 @@ public void ReportMessageSendFailure(IMetricsReporter.PublisherContext context,
103101
var serverAddress = new KeyValuePair<string, object?>(ServerAddress, context.ServerAddress);
104102
var serverPort = new KeyValuePair<string, object?>(ServerPort, context.ServerPort);
105103
var destination = new KeyValuePair<string, object?>(MessageDestinationName, context.Destination);
106-
MessagingClientSentMessages.Add(1, errorType, serverAddress, serverPort, destination,
104+
s_messagingClientSentMessages.Add(1, errorType, serverAddress, serverPort, destination,
107105
_messagingOperationSystemTag, _sendOperationType, _publishOperationName);
108106

109107
if (startTimestamp > 0)
@@ -112,9 +110,9 @@ public void ReportMessageSendFailure(IMetricsReporter.PublisherContext context,
112110
var duration = Stopwatch.GetElapsedTime(startTimestamp);
113111
#else
114112
var duration =
115-
new TimeSpan((long)((Stopwatch.GetTimestamp() - startTimestamp) * StopWatchTickFrequency));
113+
new TimeSpan((long)((Stopwatch.GetTimestamp() - startTimestamp) * s_stopWatchTickFrequency));
116114
#endif
117-
MessagingClientOperationDuration.Record(duration.TotalSeconds, errorType, serverAddress, serverPort,
115+
s_messagingClientOperationDuration.Record(duration.TotalSeconds, errorType, serverAddress, serverPort,
118116
destination,
119117
_messagingOperationSystemTag, _sendOperationType, _publishOperationName);
120118
}
@@ -125,17 +123,17 @@ public void ReportMessageDeliverSuccess(IMetricsReporter.ConsumerContext context
125123
var serverAddress = new KeyValuePair<string, object?>(ServerAddress, context.ServerAddress);
126124
var serverPort = new KeyValuePair<string, object?>(ServerPort, context.ServerPort);
127125
var destination = new KeyValuePair<string, object?>(MessageDestinationName, context.Destination);
128-
MessagingClientConsumedMessages.Add(1, serverAddress, serverPort, destination, _messagingOperationSystemTag,
126+
s_messagingClientConsumedMessages.Add(1, serverAddress, serverPort, destination, _messagingOperationSystemTag,
129127
_processOperationType, _deliverOperationName);
130128
if (startTimestamp > 0)
131129
{
132130
#if NET7_0_OR_GREATER
133131
var duration = Stopwatch.GetElapsedTime(startTimestamp);
134132
#else
135133
var duration =
136-
new TimeSpan((long)((Stopwatch.GetTimestamp() - startTimestamp) * StopWatchTickFrequency));
134+
new TimeSpan((long)((Stopwatch.GetTimestamp() - startTimestamp) * s_stopWatchTickFrequency));
137135
#endif
138-
MessagingProcessDuration.Record(duration.TotalSeconds, serverAddress, serverPort,
136+
s_messagingProcessDuration.Record(duration.TotalSeconds, serverAddress, serverPort,
139137
destination,
140138
_messagingOperationSystemTag, _sendOperationType, _publishOperationName);
141139
}
@@ -148,7 +146,7 @@ public void ReportMessageDeliverFailure(IMetricsReporter.ConsumerContext context
148146
var serverAddress = new KeyValuePair<string, object?>(ServerAddress, context.ServerAddress);
149147
var serverPort = new KeyValuePair<string, object?>(ServerPort, context.ServerPort);
150148
var destination = new KeyValuePair<string, object?>(MessageDestinationName, context.Destination);
151-
MessagingClientConsumedMessages.Add(1, errorType, serverAddress, serverPort, destination,
149+
s_messagingClientConsumedMessages.Add(1, errorType, serverAddress, serverPort, destination,
152150
_messagingOperationSystemTag,
153151
_processOperationType, _deliverOperationName);
154152
if (startTimestamp > 0)
@@ -157,9 +155,9 @@ public void ReportMessageDeliverFailure(IMetricsReporter.ConsumerContext context
157155
var duration = Stopwatch.GetElapsedTime(startTimestamp);
158156
#else
159157
var duration =
160-
new TimeSpan((long)((Stopwatch.GetTimestamp() - startTimestamp) * StopWatchTickFrequency));
158+
new TimeSpan((long)((Stopwatch.GetTimestamp() - startTimestamp) * s_stopWatchTickFrequency));
161159
#endif
162-
MessagingProcessDuration.Record(duration.TotalSeconds, errorType, serverAddress, serverPort,
160+
s_messagingProcessDuration.Record(duration.TotalSeconds, errorType, serverAddress, serverPort,
163161
destination,
164162
_messagingOperationSystemTag, _sendOperationType, _publishOperationName);
165163
}
@@ -168,7 +166,7 @@ public void ReportMessageDeliverFailure(IMetricsReporter.ConsumerContext context
168166
const long TicksPerMicrosecond = 10;
169167
const long TicksPerMillisecond = TicksPerMicrosecond * 1000;
170168
const long TicksPerSecond = TicksPerMillisecond * 1000; // 10,000,000
171-
static readonly double StopWatchTickFrequency = (double)TicksPerSecond / Stopwatch.Frequency;
169+
static readonly double s_stopWatchTickFrequency = (double)TicksPerSecond / Stopwatch.Frequency;
172170
#endif
173171
}
174172
#else

0 commit comments

Comments
 (0)