Skip to content

EventSource too restrictive on Transfer events #38223

@mconnew

Description

@mconnew

Description

When using the method EventSource.WriteEventWithRelatedActivityId to emit an event with a related activity id, EventSource has some validation code here which requires the OpCode of the event to be Send, Receive or Start. If this isn't the case, it will emit an EventSoureMessage event with a vague error saying there was a problem while processing that event and optionally throw an exception if configured.

I would expect the event to be correctly emitted with the provided RelatedActivityId. The event I discovered this issue with is the WCF event ClientOperationPrepared. As we are supporting using the same ETW schema as WCF uses in the .Net Framework and there is existing tooling around parsing these events, we are not able to change which OpCode we are using. This particular event has an OpCode of OperationPrepared.

Regression?

This is kind of a regression. On .NET Framework we were calling the ETW api's directly ourselves. To be cross-platform we removed out native calls to ETW and replaced it with EventSource. We are expecting EventSource to provide the same capabilities as we have when calling ETW api's natively and previous fixes have been made to EventSource in the past to achieve this.

Other information

Stack trace from VS debugger

System.Private.CoreLib.dll!System.Diagnostics.Tracing.EventSource.ValidateEventOpcodeForTransfer(ref System.Diagnostics.Tracing.EventSource.EventMetadata eventData, string eventName) Line 2393	C#  
System.Private.CoreLib.dll!System.Diagnostics.Tracing.EventSource.WriteEventVarargs(int eventId, System.Guid* childActivityID, object[] args) Line 1924	C#  
System.Private.CoreLib.dll!System.Diagnostics.Tracing.EventSource.WriteEventWithRelatedActivityId(int eventId, System.Guid relatedActivityId, object[] args) Line 1327	C#  
System.Private.ServiceModel.dll!System.Runtime.WcfEventSource.ClientOperationPrepared(System.Guid relatedActivityId, string Action, string ContractName, string Destination, string HostReference, string AppDomain) Line 329	C#

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions