[Proof of Concept] Azure Monitor - Refactoring the EventSource #16061
[Proof of Concept] Azure Monitor - Refactoring the EventSource #16061rajkumar-rangaraj merged 4 commits intoAzure:masterfrom
Conversation
|
|
||
| [NonEvent] | ||
| public void SdkVersionCreateFailed(Exception ex) | ||
| public void Write(string name, object value) |
There was a problem hiding this comment.
For context, this is being used like so:
AzureMonitorTraceExporterEventSource.Log.Write($"FailedToExport{EventLevelSuffix.Error}", ex.LogAsyncException());
This is a cool idea, but I'm not a fan of this approach.
Mainly because this requires string parsing, manipulation inside the EventSource to determine the EventLevel detail.
The event level detail was known at compile time and I think this step can be avoided.
Plus, this assumes that the period ('.') won't be used as punctuation in the message itself.
I would propose either,
- call the correct method directly
- or pass an enum into this method and switch on the enum. (this avoids the string parsing).
There was a problem hiding this comment.
This is an inspiration from DiagnosticSource class, StartActivity and StopActivity
Ref: https://github.com/dotnet/runtime/blob/6072e4d3a7a2a1493f514cdf4be75a3d56580e84/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceActivity.cs#L30
I'm using a very simple string parser in EventSource, where execution should be fast with no data allocation.
There was a problem hiding this comment.
I think the solution used by DiagnosticSource isn't valid here.
DiagnosticSource is communicating across applications and can't share any managed types, therefore it's storing all the data into that string.
In our example, our project can call this method directly and pass in an Enum, which would avoid the string parsing completely.
There was a problem hiding this comment.
Additionally, because of LastIndexOf('.') this method will break the first time someone tries to write one or more sentences into this error message (using a period as punctuation). This limitation isn't referenced in the summary for this method. :(
There was a problem hiding this comment.
I merged the changes, will create a new PR to address it.
…#16061) * Changed eventsource * Check for IsEnabled * Fine tune * Fine tune
Continuation of #14781
TODO