Skip to content

(Minor Improvement) Guard TelemetryClient.Flush to not throw NullReference Exception #755

@MichaCo

Description

@MichaCo

Hi,
today I ran into an odd behavior that on app shutdown of my ASP.NET Core service, one part of the application (the Serilog Sink) tries to Flush before it disposes.
But at that point in time, this.configuration.TelemetryChannel in TelemetryClient is already null.

And that causes Flush to throw a hard NullReference Exception Code line 589

see serilog-contrib/serilog-sinks-applicationinsights#46

Could you just elvis the expression or at least null check it?

Thanks,
Michael

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions