Skip to content

EventSourceInternal.IsEnabled behaves inconsistently. #746

@macrogreg

Description

@macrogreg

TelemetryClient.Track(ITelemetry telemetry) invokes RichPayloadEventSource.Log.Process(telemetry) after completing the telemetry chain. That method performs checks such as:
if (!this.EventSourceInternal.IsEnabled(EventLevel.Verbose, Keywords.Metrics)) { . . . }.

When running unit tests in VS, that call to EventSourceInternal.IsEnabled(EventLevel.Verbose, Keywords.Metrics) always returns true when running under debugger. However, when running without a debugger, that call behaves inconsistently: When executing a single unit test, it always returns false. When running multiple unit tests in VS, that method sometimes returns true and sometimes false. As a results, Sanitize() is sometimes invoked for the telemetry item, and sometimes not. This breaks tests that rely on a specific state of the telemetry item (either sanitized or not). It will also affect any telemetry items potentially stored in a channel cache.

Please make this behavior predictable.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions