Skip to content

Developers can employ EventSource APIs when publishing for AOT targets to be able to use .NET tracing capabilities #43390

Open

Description

@mjsabby

EventSource is a common logging abstraction in .NET but it uses reflection to generate the schema for an EventSource definition. The source generator would do this at build time and make using EventSources reflection free.

Activity

  1. MichalStrehovsky commented on Oct 14, 2020

    @MichalStrehovsky
    Member

    EventSource used to have a hookup point for this that was used in .NET Native. It looked like this:

    internal virtual void GetMetadata(out Guid eventSourceGuid, out string eventSourceName, out EventMetadata[] eventData, out byte[] manifestBytes)
    {
    //
    // In ProjectN subclasses need to override this method, and return the data from their EventSourceAttribute and EventAttribute annotations.
    // On other architectures it is a no-op.
    //
    // eventDescriptors needs to contain one EventDescriptor for each event; the event's ID should be the same as its index in this array.
    // manifestBytes is a UTF-8 encoding of the ETW manifest for the type.
    //
    // This will be implemented by an IL rewriter, so we can't make this method abstract or the initial build of the subclass would fail.
    //
    eventSourceGuid = Guid.Empty;
    eventSourceName = null;
    eventData = null;
    manifestBytes = null;
    return;
    }

    It was nuked in the meantime (latest sources don't have it anymore).

  2. removed
    untriagedNew issue has not been triaged by the area owner
    on Oct 14, 2020
  3. added this to the 6.0.0 milestone on Oct 14, 2020
  4. added
    User StoryA single user-facing feature. Can be grouped under an epic.
    on Nov 9, 2020
  5. 7sharp9 commented on Nov 17, 2020

    @7sharp9

    How would this be consumed by non C# languages?

  6. changed the title [-]Feature Proposal: Reflection-free EventSource* using Roslyn Source Generators[/-] [+]Developers can leverage EventSource API when publishing for AOT targets[/+] on Nov 27, 2020
  7. changed the title [-]Developers can leverage EventSource API when publishing for AOT targets[/-] [+]Developers can employ EventSource APIs when publishing for AOT targets to be able to use .NET tracing capabilities[/+] on Nov 27, 2020
  8. 6 remaining items

  9. benaadams commented on Mar 10, 2021

    @benaadams
    Member

    A whole lot of startup going into generating EventSource manifests and Guids etc for a standardish ASP.NET Core app with ApplicationInsights, e.g. this is https://themesof.net/

    image

    Couldn't fit it all on one screen, here's the rest

    image

  10. benaadams commented on Mar 10, 2021

    @benaadams
    Member

    For https://themesof.net/ looks like 27 EventSources are created on startup, most of them probably just to check .Log.IsEnabled() and get false back... 😅

    With any not in System.Private.CoreLib.dll doing reflection to get the Guid to use

    image

  11. iSazonov commented on Mar 10, 2021

    @iSazonov
    Contributor

    It is an issue for PowerShell startup too.

  12. modified the milestones: 6.0.0, 7.0.0 on Jun 21, 2021
  13. modified the milestones: 7.0.0, 8.0.0 on Jun 28, 2022
  14. tommcdon commented on Jul 23, 2023

    @tommcdon
    Member

    @LakshanF @davmason do you know of any unresolved issues related to using EventSource on NativeAOT?

  15. LakshanF commented on Jul 23, 2023

    @LakshanF
    Contributor

    Any payload that uses complex data types in EventSource, that in turn depends on unbound reflection for serialization, will be problematic for NativeAOT applications (primarily due to trimming). The long-term solution is to use a source generator for such cases. These scenarios would cause both Roslyn analyzer (when the application project file indicate intention to use NativeAOT) and ILCompiler to generate warnings, and developers should not ignore these warnings.

    All Framework EventSource providers should work without problems, as well as payloads with primitive data types.

  16. modified the milestones: 8.0.0, 9.0.0 on Jul 24, 2023
  17. modified the milestones: 9.0.0, Future on Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions