Skip to content

EventSource.GetGuid can differ from EventSource.Guid #1360

Closed
dotnet/dotnet-api-docs
#5209

Description

@noahfalk

If you write an EventSource that specifies a name dynamically in the constructor but does not provide the name statically in an EventSource attribute then GetGuid(Type) and the Guid property will compute different values. The GetGuid(Type) return value no longer correlates to the GUID used to register the EventSource with ETW. Although it is intended that users will provide the EventSourceAttribute in this scenario nothing enforces that they do so.

I don't see any obvious way to change the API design to mitigate this issue without also introducing the potential for compat problems, but at minimum we should make the requirements clear in the docs, such as where GetGuid() is described and on the constructors that take a string name.

Activity

  1. added
    documentation
    on Jan 7, 2020
  2. added this to the 5.0 milestone on Jan 7, 2020
  3. added
    untriaged
    on Jan 7, 2020
  4. noahfalk commented on Jan 7, 2020

    @noahfalk
    MemberAuthor

    Adding repro case:

    using System;
    using System.Diagnostics.Tracing;
     
    namespace GuidProblemRepro
    {
        class Program
        {
            static int Main(string[] args)
            {
                Console.WriteLine("Hello World!");
     
                MyEventSource mes = new MyEventSource();
     
                Console.WriteLine( "                                        mes.Guid: {0}", mes.Guid );
                Console.WriteLine( "MyEventSource.GetGuid( typeof( MyEventSource ) ): {0}", MyEventSource.GetGuid( typeof( MyEventSource ) ) );
     
                return 0;
            }
     
     
            private class MyEventSource : EventSource
            {
                public MyEventSource()
                    : base( "Microsoft.Blah.WhateverEventSource",
                            EventSourceSettings.EtwSelfDescribingEventFormat | EventSourceSettings.ThrowOnEventWriteErrors )
                {
                }
     
                [Event( 1 )]
                public void WriteMessage( string msg )
                {
                    WriteEvent( 1, msg );
                }
            } // end class MyEventSource
        }
    }
    
  5. removed
    untriaged
    on Feb 24, 2020
  6. added
    tracking
    on Jul 8, 2020
  7. modified the milestones: 5.0.0, 6.0.0 on Jul 8, 2020
  8. removed
    tracking
    on Dec 10, 2020
  9. tommcdon commented on Dec 10, 2020

    @tommcdon
    Member

    FYI @sywhang as this is a documentation issue

  10. self-assigned this
    on Jan 6, 2021
  11. ghost locked as resolved and limited conversation to collaborators on Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-Tracing-coreclrdocumentation

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions