Skip to content

Decide if duplicate EventNames in LoggerMessage is appropriate #46072

Closed

Description

@eerhardt

We have a couple cases caught by the new LoggerMessage analyzer in dotnet/runtime#64667.

Two duplicates here: InvokeDotNetMethodException and InvokeDotNetMethodSuccess

[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:

[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);

[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

  1. javiercn commented on Jan 13, 2023

    @javiercn
    Member

    @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

  2. added
    feature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssembly
    bugThis issue describes a behavior which is not expected - a bug.
    help wantedUp for grabs. We would accept a PR to help resolve this issue
    on Jan 13, 2023
  3. javiercn commented on Jan 13, 2023

    @javiercn
    Member

    We probably want the name to be InvokeInstanceDotNetMethodSuccess

  4. added this to the .NET 8 Planning milestone on Jan 13, 2023
  5. JamesNK commented on Jan 14, 2023

    @JamesNK
    Member

    @javiercn What is going on with LocationChangeFailed and LocationChangeFailedInCircuit? The log messages are identical apart from the logging level.

    The easy fix is changing LocationChangeFailedInCircuit's log name to LocationChangeFailedInCircuit, but what was the idea behind adding it? Why identical logs but different levels?

  6. JamesNK commented on Jan 14, 2023

    @JamesNK
    Member

    We probably want the name to be InvokeInstanceDotNetMethodSuccess

    InvokeInstanceDotNetMethodException and InvokeStaticDotNetMethodException

    InvokeInstanceDotNetMethodSuccess and InvokeStaticDotNetMethodSuccess

  7. JamesNK commented on Jan 14, 2023

    @JamesNK
    Member

    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

  8. eerhardt commented on Jan 17, 2023

    @eerhardt
    MemberAuthor

    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:

    • ResponseCaching: ExpirationExpiresExceeded => NotModifiedIfNoneMatchStar
    • RedisLog: Connected => NotConnected
    • Components CircuitRegistry: FailedToReconnectToCircuit => ReconnectionSucceeded
    • Components CircuitHost: BeginInvokeDotNetFailed => BeginInvokeDotNetStaticFailed (to align with BeginInvokeDotNetStatic)
  9. shiladitya-mukerji-22 commented on Mar 17, 2023

    @shiladitya-mukerji-22
    Contributor

    Hey @javiercn, is this issue still open? If yes I would like to work on it.

  10. javiercn commented on Mar 17, 2023

    @javiercn
    Member

    @shiladitya-mukerji-22 Yes, if nobody yet has addressed the issue, I think we would accept a change for this.

  11. shiladitya-mukerji-22 commented on Mar 17, 2023

    @shiladitya-mukerji-22
    Contributor

    @javiercn Under the task it shows that no one has been assigned yet. So, could you please assign the task to me.

  12. javiercn commented on Mar 17, 2023

    @javiercn
    Member
  13. shiladitya-mukerji-22 commented on Mar 17, 2023

    @shiladitya-mukerji-22
    Contributor

    @javiercn Thank you.

  14. ghost locked as resolved and limited conversation to collaborators on Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssemblygood first issueGood for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions