Repository navigation
Decide if duplicate EventNames in LoggerMessage is appropriate #46072
Description
We have a couple cases caught by the new LoggerMessage analyzer in dotnet/runtime#64667.
Two duplicates here: InvokeDotNetMethodException and InvokeDotNetMethodSuccess
aspnetcore/src/Components/Server/src/Circuits/RemoteJSRuntime.cs
Lines 199 to 209 in 334da01
| [LoggerMessage(2, LogLevel.Debug, "There was an error invoking the static method '[{AssemblyName}]::{MethodIdentifier}' with callback id '{CallbackId}'.", EventName = "InvokeDotNetMethodException")] | |
| private static partial void InvokeStaticDotNetMethodException(ILogger logger, string assemblyName, string methodIdentifier, string? callbackId, Exception exception); | |
| [LoggerMessage(4, LogLevel.Debug, "There was an error invoking the instance method '{MethodIdentifier}' on reference '{DotNetObjectReference}' with callback id '{CallbackId}'.", EventName = "InvokeDotNetMethodException")] | |
| private static partial void InvokeInstanceDotNetMethodException(ILogger logger, string methodIdentifier, long dotNetObjectReference, string? callbackId, Exception exception); | |
| [LoggerMessage(3, LogLevel.Debug, "Invocation of '[{AssemblyName}]::{MethodIdentifier}' with callback id '{CallbackId}' completed successfully.", EventName = "InvokeDotNetMethodSuccess")] | |
| private static partial void InvokeStaticDotNetMethodSuccess(ILogger<RemoteJSRuntime> logger, string assemblyName, string methodIdentifier, string? callbackId); | |
| [LoggerMessage(5, LogLevel.Debug, "Invocation of '{MethodIdentifier}' on reference '{DotNetObjectReference}' with callback id '{CallbackId}' completed successfully.", EventName = "InvokeDotNetMethodSuccess")] | |
| private static partial void InvokeInstanceDotNetMethodSuccess(ILogger<RemoteJSRuntime> logger, string methodIdentifier, long dotNetObjectReference, string? callbackId); |
And a duplicate LocationChangeFailed between:
aspnetcore/src/Components/Server/src/Circuits/CircuitHost.cs
Lines 761 to 762 in 334da01
| [LoggerMessage(210, LogLevel.Debug, "Location change to '{URI}' in circuit '{CircuitId}' failed.", EventName = "LocationChangeFailed")] | |
| public static partial void LocationChangeFailed(ILogger logger, string uri, CircuitId circuitId, Exception exception); |
aspnetcore/src/Components/Server/src/Circuits/CircuitHost.cs
Lines 812 to 813 in 334da01
| [LoggerMessage(219, LogLevel.Error, "Location change to '{URI}' in circuit '{CircuitId}' failed.", EventName = "LocationChangeFailed")] | |
| public static partial void LocationChangeFailedInCircuit(ILogger logger, string uri, CircuitId circuitId, Exception exception); |
I've suppressed these warnings in #46055 for now. But we should make a conscious decision if we really want/need these EventNames to be the same, or if we should change them. My understanding is changing them is technically a breaking change, so we should be sure that they need changing if we do.
Activity
javiercn commentedon Jan 13, 2023
@eerhardt thanks for raising this up.
I believe this is a copy/paste type of error. We should change the event names to be unique
javiercn commentedon Jan 13, 2023
We probably want the name to be
InvokeInstanceDotNetMethodSuccessJamesNK commentedon Jan 14, 2023
@javiercn What is going on with
LocationChangeFailedandLocationChangeFailedInCircuit? The log messages are identical apart from the logging level.The easy fix is changing
LocationChangeFailedInCircuit's log name toLocationChangeFailedInCircuit, but what was the idea behind adding it? Why identical logs but different levels?JamesNK commentedon Jan 14, 2023
InvokeInstanceDotNetMethodExceptionandInvokeStaticDotNetMethodExceptionInvokeInstanceDotNetMethodSuccessandInvokeStaticDotNetMethodSuccessJamesNK commentedon Jan 14, 2023
By the way, logging ID and name changes are considered breaking changes and should be added at https://github.com/aspnet/Announcements and friends. e.g. https://github.com/aspnet/Announcements
e.g. aspnet/Announcements#447
eerhardt commentedon Jan 17, 2023
Note that in #46055, @SteveSandersonMS and I updated the event names that were obviously wrong. We should include them as well in any announcement of event name changes:
ExpirationExpiresExceeded=>NotModifiedIfNoneMatchStarConnected=>NotConnectedFailedToReconnectToCircuit=>ReconnectionSucceededBeginInvokeDotNetFailed=>BeginInvokeDotNetStaticFailed(to align withBeginInvokeDotNetStatic)shiladitya-mukerji-22 commentedon Mar 17, 2023
Hey @javiercn, is this issue still open? If yes I would like to work on it.
javiercn commentedon Mar 17, 2023
@shiladitya-mukerji-22 Yes, if nobody yet has addressed the issue, I think we would accept a change for this.
shiladitya-mukerji-22 commentedon Mar 17, 2023
@javiercn Under the task it shows that no one has been assigned yet. So, could you please assign the task to me.
javiercn commentedon Mar 17, 2023
@shiladitya-mukerji-22 go for it.
shiladitya-mukerji-22 commentedon Mar 17, 2023
@javiercn Thank you.