Skip to content

Commit f1389cc

Browse files
committed
Merge branch 'main' into utf8-formattable
2 parents 0ecb06d + b995ebc commit f1389cc

16 files changed

+395
-43
lines changed

StackExchange.Redis.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1313
Directory.Build.props = Directory.Build.props
1414
Directory.Build.targets = Directory.Build.targets
1515
Directory.Packages.props = Directory.Packages.props
16+
tests\RedisConfigs\docker-compose.yml = tests\RedisConfigs\docker-compose.yml
1617
global.json = global.json
1718
NuGet.Config = NuGet.Config
1819
README.md = README.md
1920
docs\ReleaseNotes.md = docs\ReleaseNotes.md
2021
Shared.ruleset = Shared.ruleset
2122
version.json = version.json
22-
tests\RedisConfigs\docker-compose.yml = tests\RedisConfigs\docker-compose.yml
2323
EndProjectSection
2424
EndProject
2525
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RedisConfigs", "RedisConfigs", "{96E891CD-2ED7-4293-A7AB-4C6F5D8D2B05}"
@@ -120,6 +120,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTestBaseline", "test
120120
EndProject
121121
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "docs", "docs\docs.csproj", "{1DC43E76-5372-4C7F-A433-0602273E87FC}"
122122
EndProject
123+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StackExchange.Redis.Benchmarks", "tests\StackExchange.Redis.Benchmarks\StackExchange.Redis.Benchmarks.csproj", "{59889284-FFEE-82E7-94CB-3B43E87DA6CF}"
124+
EndProject
123125
Global
124126
GlobalSection(SolutionConfigurationPlatforms) = preSolution
125127
Debug|Any CPU = Debug|Any CPU
@@ -174,6 +176,10 @@ Global
174176
{1DC43E76-5372-4C7F-A433-0602273E87FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
175177
{1DC43E76-5372-4C7F-A433-0602273E87FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
176178
{1DC43E76-5372-4C7F-A433-0602273E87FC}.Release|Any CPU.Build.0 = Release|Any CPU
179+
{59889284-FFEE-82E7-94CB-3B43E87DA6CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
180+
{59889284-FFEE-82E7-94CB-3B43E87DA6CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
181+
{59889284-FFEE-82E7-94CB-3B43E87DA6CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
182+
{59889284-FFEE-82E7-94CB-3B43E87DA6CF}.Release|Any CPU.Build.0 = Release|Any CPU
177183
EndGlobalSection
178184
GlobalSection(SolutionProperties) = preSolution
179185
HideSolutionNode = FALSE
@@ -195,6 +201,7 @@ Global
195201
{A9F81DA3-DA82-423E-A5DD-B11C37548E06} = {96E891CD-2ED7-4293-A7AB-4C6F5D8D2B05}
196202
{A0F89B8B-32A3-4C28-8F1B-ADE343F16137} = {73A5C363-CA1F-44C4-9A9B-EF791A76BA6A}
197203
{69A0ACF2-DF1F-4F49-B554-F732DCA938A3} = {73A5C363-CA1F-44C4-9A9B-EF791A76BA6A}
204+
{59889284-FFEE-82E7-94CB-3B43E87DA6CF} = {73A5C363-CA1F-44C4-9A9B-EF791A76BA6A}
198205
EndGlobalSection
199206
GlobalSection(ExtensibilityGlobals) = postSolution
200207
SolutionGuid = {193AA352-6748-47C1-A5FC-C9AA6B5F000B}

src/StackExchange.Redis/ConnectionMultiplexer.Sentinel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ internal void SwitchPrimary(EndPoint? switchBlame, ConnectionMultiplexer connect
396396
var logger = Logger.With(writer);
397397
if (connection.RawConfig.ServiceName is not string serviceName)
398398
{
399-
logger?.LogInformation("Service name not defined.");
399+
logger?.LogInformationServiceNameNotDefined();
400400
return;
401401
}
402402

src/StackExchange.Redis/ConnectionMultiplexer.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,14 +1335,16 @@ internal void GetStatus(ILogger? log)
13351335
if (log == null) return;
13361336

13371337
var tmp = GetServerSnapshot();
1338-
log?.LogInformation("Endpoint Summary:");
1338+
log.LogInformationEndpointSummaryHeader();
13391339
foreach (var server in tmp)
13401340
{
1341-
log?.LogInformation(" " + server.Summary());
1342-
log?.LogInformation(" " + server.GetCounters().ToString());
1343-
log?.LogInformation(" " + server.GetProfile());
1341+
log.LogInformationServerSummary(server.Summary(), server.GetCounters(), server.GetProfile());
13441342
}
1345-
log?.LogInformation($"Sync timeouts: {Interlocked.Read(ref syncTimeouts)}; async timeouts: {Interlocked.Read(ref asyncTimeouts)}; fire and forget: {Interlocked.Read(ref fireAndForgets)}; last heartbeat: {LastHeartbeatSecondsAgo}s ago");
1343+
log.LogInformationTimeoutsSummary(
1344+
Interlocked.Read(ref syncTimeouts),
1345+
Interlocked.Read(ref asyncTimeouts),
1346+
Interlocked.Read(ref fireAndForgets),
1347+
LastHeartbeatSecondsAgo);
13461348
}
13471349

13481350
private void ActivateAllServers(ILogger? log)

src/StackExchange.Redis/EndPointCollection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ internal async Task ResolveEndPointsAsync(ConnectionMultiplexer multiplexer, ILo
209209
}
210210
else
211211
{
212-
log?.LogInformation($"Using DNS to resolve '{dns.Host}'...");
212+
log?.LogInformationUsingDnsToResolve(dns.Host);
213213
var ips = await Dns.GetHostAddressesAsync(dns.Host).ObserveErrors().ForAwait();
214214
if (ips.Length == 1)
215215
{
216216
ip = ips[0];
217-
log?.LogInformation($"'{dns.Host}' => {ip}");
217+
log?.LogInformationDnsResolutionResult(dns.Host, ip);
218218
cache[dns.Host] = ip;
219219
this[i] = new IPEndPoint(ip, dns.Port);
220220
}
@@ -223,7 +223,7 @@ internal async Task ResolveEndPointsAsync(ConnectionMultiplexer multiplexer, ILo
223223
catch (Exception ex)
224224
{
225225
multiplexer.OnInternalError(ex);
226-
log?.LogError(ex, ex.Message);
226+
log?.LogErrorDnsResolution(ex, ex.Message);
227227
}
228228
}
229229
}

src/StackExchange.Redis/LoggerExtensions.cs

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,4 +488,225 @@ internal static void LogWithThreadPoolStats(this ILogger? log, string message)
488488
EventId = 70,
489489
Message = "{Server}: Flushing outbound buffer")]
490490
internal static partial void LogInformationFlushingOutboundBuffer(this ILogger logger, ServerEndPointLogValue server);
491+
492+
// ResultProcessor logging methods
493+
[LoggerMessage(
494+
Level = LogLevel.Information,
495+
EventId = 71,
496+
Message = "Response from {BridgeName} / {CommandAndKey}: {Result}")]
497+
internal static partial void LogInformationResponse(this ILogger logger, string? bridgeName, string commandAndKey, RawResult result);
498+
499+
[LoggerMessage(
500+
Level = LogLevel.Information,
501+
EventId = 72,
502+
Message = "{Server}: Auto-configured role: replica")]
503+
internal static partial void LogInformationAutoConfiguredRoleReplica(this ILogger logger, ServerEndPointLogValue server);
504+
505+
[LoggerMessage(
506+
Level = LogLevel.Information,
507+
EventId = 73,
508+
Message = "{Server}: Auto-configured (CLIENT) connection-id: {ConnectionId}")]
509+
internal static partial void LogInformationAutoConfiguredClientConnectionId(this ILogger logger, ServerEndPointLogValue server, long connectionId);
510+
511+
[LoggerMessage(
512+
Level = LogLevel.Information,
513+
EventId = 74,
514+
Message = "{Server}: Auto-configured (INFO) role: {Role}")]
515+
internal static partial void LogInformationAutoConfiguredInfoRole(this ILogger logger, ServerEndPointLogValue server, string role);
516+
517+
[LoggerMessage(
518+
Level = LogLevel.Information,
519+
EventId = 75,
520+
Message = "{Server}: Auto-configured (INFO) version: {Version}")]
521+
internal static partial void LogInformationAutoConfiguredInfoVersion(this ILogger logger, ServerEndPointLogValue server, Version version);
522+
523+
[LoggerMessage(
524+
Level = LogLevel.Information,
525+
EventId = 76,
526+
Message = "{Server}: Auto-configured (INFO) server-type: {ServerType}")]
527+
internal static partial void LogInformationAutoConfiguredInfoServerType(this ILogger logger, ServerEndPointLogValue server, ServerType serverType);
528+
529+
[LoggerMessage(
530+
Level = LogLevel.Information,
531+
EventId = 77,
532+
Message = "{Server}: Auto-configured (SENTINEL) server-type: sentinel")]
533+
internal static partial void LogInformationAutoConfiguredSentinelServerType(this ILogger logger, ServerEndPointLogValue server);
534+
535+
[LoggerMessage(
536+
Level = LogLevel.Information,
537+
EventId = 78,
538+
Message = "{Server}: Auto-configured (CONFIG) timeout: {TimeoutSeconds}s")]
539+
internal static partial void LogInformationAutoConfiguredConfigTimeout(this ILogger logger, ServerEndPointLogValue server, int timeoutSeconds);
540+
541+
[LoggerMessage(
542+
Level = LogLevel.Information,
543+
EventId = 79,
544+
Message = "{Server}: Auto-configured (CONFIG) databases: {DatabaseCount}")]
545+
internal static partial void LogInformationAutoConfiguredConfigDatabases(this ILogger logger, ServerEndPointLogValue server, int databaseCount);
546+
547+
[LoggerMessage(
548+
Level = LogLevel.Information,
549+
EventId = 81,
550+
Message = "{Server}: Auto-configured (CONFIG) read-only replica: {ReadOnlyReplica}")]
551+
internal static partial void LogInformationAutoConfiguredConfigReadOnlyReplica(this ILogger logger, ServerEndPointLogValue server, bool readOnlyReplica);
552+
553+
[LoggerMessage(
554+
Level = LogLevel.Information,
555+
EventId = 82,
556+
Message = "{Server}: Auto-configured (HELLO) server-version: {Version}")]
557+
internal static partial void LogInformationAutoConfiguredHelloServerVersion(this ILogger logger, ServerEndPointLogValue server, Version version);
558+
559+
[LoggerMessage(
560+
Level = LogLevel.Information,
561+
EventId = 83,
562+
Message = "{Server}: Auto-configured (HELLO) protocol: {Protocol}")]
563+
internal static partial void LogInformationAutoConfiguredHelloProtocol(this ILogger logger, ServerEndPointLogValue server, RedisProtocol protocol);
564+
565+
[LoggerMessage(
566+
Level = LogLevel.Information,
567+
EventId = 84,
568+
Message = "{Server}: Auto-configured (HELLO) connection-id: {ConnectionId}")]
569+
internal static partial void LogInformationAutoConfiguredHelloConnectionId(this ILogger logger, ServerEndPointLogValue server, long connectionId);
570+
571+
[LoggerMessage(
572+
Level = LogLevel.Information,
573+
EventId = 85,
574+
Message = "{Server}: Auto-configured (HELLO) server-type: {ServerType}")]
575+
internal static partial void LogInformationAutoConfiguredHelloServerType(this ILogger logger, ServerEndPointLogValue server, ServerType serverType);
576+
577+
[LoggerMessage(
578+
Level = LogLevel.Information,
579+
EventId = 86,
580+
Message = "{Server}: Auto-configured (HELLO) role: {Role}")]
581+
internal static partial void LogInformationAutoConfiguredHelloRole(this ILogger logger, ServerEndPointLogValue server, string role);
582+
583+
// PhysicalBridge logging methods
584+
[LoggerMessage(
585+
Level = LogLevel.Information,
586+
EventId = 87,
587+
Message = "{EndPoint}: OnEstablishingAsync complete")]
588+
internal static partial void LogInformationOnEstablishingComplete(this ILogger logger, EndPointLogValue endPoint);
589+
590+
[LoggerMessage(
591+
Level = LogLevel.Information,
592+
EventId = 88,
593+
Message = "{ErrorMessage}")]
594+
internal static partial void LogInformationConnectionFailureRequested(this ILogger logger, Exception exception, string errorMessage);
595+
596+
[LoggerMessage(
597+
Level = LogLevel.Error,
598+
EventId = 89,
599+
Message = "{ErrorMessage}")]
600+
internal static partial void LogErrorConnectionIssue(this ILogger logger, Exception exception, string errorMessage);
601+
602+
[LoggerMessage(
603+
Level = LogLevel.Warning,
604+
EventId = 90,
605+
Message = "Dead socket detected, no reads in {LastReadSecondsAgo} seconds with {TimeoutCount} timeouts, issuing disconnect")]
606+
internal static partial void LogWarningDeadSocketDetected(this ILogger logger, long lastReadSecondsAgo, long timeoutCount);
607+
608+
[LoggerMessage(
609+
Level = LogLevel.Information,
610+
EventId = 91,
611+
Message = "Resurrecting {Bridge} (retry: {RetryCount})")]
612+
internal static partial void LogInformationResurrecting(this ILogger logger, PhysicalBridge bridge, long retryCount);
613+
614+
[LoggerMessage(
615+
Level = LogLevel.Information,
616+
EventId = 92,
617+
Message = "{BridgeName}: Connecting...")]
618+
internal static partial void LogInformationConnecting(this ILogger logger, string bridgeName);
619+
620+
[LoggerMessage(
621+
Level = LogLevel.Error,
622+
EventId = 93,
623+
Message = "{BridgeName}: Connect failed: {ErrorMessage}")]
624+
internal static partial void LogErrorConnectFailed(this ILogger logger, Exception exception, string bridgeName, string errorMessage);
625+
626+
// PhysicalConnection logging methods
627+
[LoggerMessage(
628+
Level = LogLevel.Error,
629+
EventId = 94,
630+
Message = "No endpoint")]
631+
internal static partial void LogErrorNoEndpoint(this ILogger logger, Exception exception);
632+
633+
[LoggerMessage(
634+
Level = LogLevel.Information,
635+
EventId = 95,
636+
Message = "{EndPoint}: BeginConnectAsync")]
637+
internal static partial void LogInformationBeginConnectAsync(this ILogger logger, EndPointLogValue endPoint);
638+
639+
[LoggerMessage(
640+
Level = LogLevel.Information,
641+
EventId = 96,
642+
Message = "{EndPoint}: Starting read")]
643+
internal static partial void LogInformationStartingRead(this ILogger logger, EndPointLogValue endPoint);
644+
645+
[LoggerMessage(
646+
Level = LogLevel.Error,
647+
EventId = 97,
648+
Message = "{EndPoint}: (socket shutdown)")]
649+
internal static partial void LogErrorSocketShutdown(this ILogger logger, Exception exception, EndPointLogValue endPoint);
650+
651+
[LoggerMessage(
652+
Level = LogLevel.Information,
653+
EventId = 98,
654+
Message = "Configuring TLS")]
655+
internal static partial void LogInformationConfiguringTLS(this ILogger logger);
656+
657+
[LoggerMessage(
658+
Level = LogLevel.Information,
659+
EventId = 99,
660+
Message = "TLS connection established successfully using protocol: {SslProtocol}")]
661+
internal static partial void LogInformationTLSConnectionEstablished(this ILogger logger, System.Security.Authentication.SslProtocols sslProtocol);
662+
663+
[LoggerMessage(
664+
Level = LogLevel.Information,
665+
EventId = 100,
666+
Message = "{BridgeName}: Connected")]
667+
internal static partial void LogInformationConnected(this ILogger logger, string bridgeName);
668+
669+
// ConnectionMultiplexer GetStatus logging methods
670+
[LoggerMessage(
671+
Level = LogLevel.Information,
672+
EventId = 101,
673+
Message = "Endpoint Summary:")]
674+
internal static partial void LogInformationEndpointSummaryHeader(this ILogger logger);
675+
676+
[LoggerMessage(
677+
Level = LogLevel.Information,
678+
EventId = 102,
679+
Message = "Server summary: {ServerSummary}, counters: {ServerCounters}, profile: {ServerProfile}")]
680+
internal static partial void LogInformationServerSummary(this ILogger logger, string serverSummary, ServerCounters serverCounters, string serverProfile);
681+
682+
[LoggerMessage(
683+
Level = LogLevel.Information,
684+
EventId = 105,
685+
Message = "Sync timeouts: {SyncTimeouts}; async timeouts: {AsyncTimeouts}; fire and forget: {FireAndForgets}; last heartbeat: {LastHeartbeatSecondsAgo}s ago")]
686+
internal static partial void LogInformationTimeoutsSummary(this ILogger logger, long syncTimeouts, long asyncTimeouts, long fireAndForgets, long lastHeartbeatSecondsAgo);
687+
688+
// EndPointCollection logging methods
689+
[LoggerMessage(
690+
Level = LogLevel.Information,
691+
EventId = 106,
692+
Message = "Using DNS to resolve '{DnsHost}'...")]
693+
internal static partial void LogInformationUsingDnsToResolve(this ILogger logger, string dnsHost);
694+
695+
[LoggerMessage(
696+
Level = LogLevel.Information,
697+
EventId = 107,
698+
Message = "'{DnsHost}' => {IpAddress}")]
699+
internal static partial void LogInformationDnsResolutionResult(this ILogger logger, string dnsHost, IPAddress ipAddress);
700+
701+
[LoggerMessage(
702+
Level = LogLevel.Error,
703+
EventId = 108,
704+
Message = "{ErrorMessage}")]
705+
internal static partial void LogErrorDnsResolution(this ILogger logger, Exception exception, string errorMessage);
706+
707+
[LoggerMessage(
708+
Level = LogLevel.Information,
709+
EventId = 109,
710+
Message = "Service name not defined.")]
711+
internal static partial void LogInformationServiceNameNotDefined(this ILogger logger);
491712
}

0 commit comments

Comments
 (0)