Skip to content

CertificateManagerEventSource Has Incorrectly Authored Events #29541

Open
@brianrob

Description

@brianrob

CertificateManagerEventSource has some events that are incorrectly authored. ListCertificatesStart (https://github.com/dotnet/aspnetcore/blob/main/src/Shared/CertificateGeneration/CertificateManager.cs#L782) is one such example:

            [Event(1, Level = EventLevel.Verbose)]
            public void ListCertificatesStart(StoreLocation location, StoreName storeName)
            {
                if (IsEnabled())
                {
                    WriteEvent(1, $"Listing certificates from {location}\\{storeName}");
                }
            }

There are two arguments to the method, both of which are enums, but the call to WriteEvent only takes one payload argument of type string. When a tool attempts to decode the event, or anEventListener dispatches the event, it will treat the event as if it has two enums as payloads, even though the data payload does not match. The way to fix this is to make sure that the arguments to WriteEvent match the arguments to the event method itself.

Another example is CreateDevelopmentCertificateEnd (https://github.com/dotnet/aspnetcore/blob/main/src/Shared/CertificateGeneration/CertificateManager.cs#L861), which takes no arguments, but passes a string to WriteEvent. In cases like this, the event name should describe the context around when the event is logged, which I believe it does. The string that gets passed to WriteEvent will not be seen by an event consumer, but is allocated and logged into the file.

In general, any usage of string constants or string interpolation inside of an event method is incorrect. Context should either come from the event name itself or from the arguments, but don't feel required to make the strings "super clean" - it's more important to make the logging paths as low cost as possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-very-fewThis issue impacts very few customersarea-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIbugThis issue describes a behavior which is not expected - a bug.feature-devcertshelp candidateIndicates that the issues may be a good fit for community to help with. Requires work from eng. teaminvestigateseverity-nice-to-haveThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions