-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Exporter.Geneva] Add TLDTraceExporter #662
[Exporter.Geneva] Add TLDTraceExporter #662
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #662 +/- ##
==========================================
- Coverage 79.07% 70.77% -8.30%
==========================================
Files 182 187 +5
Lines 5614 6724 +1110
==========================================
+ Hits 4439 4759 +320
- Misses 1175 1965 +790
|
private readonly EventProvider eventProvider; | ||
private static readonly ThreadLocal<EventBuilder> eventBuilder = new(() => new(UncheckedASCIIEncoding.SharedInstance)); | ||
private static readonly ThreadLocal<List<KeyValuePair<string, object>>> keyValuePairs = new(() => new()); | ||
private static readonly ThreadLocal<KeyValuePair<string, object>[]> partCFields = new(() => new KeyValuePair<string, object>[120]); // This is used to temporarily store the PartC fields from tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might lead to IndexOutOfRange
exceptions if there are too many Part C tags. I chose the size as 120 as we cannot exceed 127 fields otherwise the event gets dropped and we have at least around 7 fields from Part A and Part B itself.
|
||
private readonly EventProvider eventProvider; | ||
private static readonly ThreadLocal<EventBuilder> eventBuilder = new(() => new(UncheckedASCIIEncoding.SharedInstance)); | ||
private static readonly ThreadLocal<List<KeyValuePair<string, object>>> keyValuePairs = new(() => new()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used for serializing ActivityLinks and env_properties
. I chose a List
here instead of an array as we don't know how many such fields there could be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the initial capacity? (and what's the reallocation behavior? e.g. would this give OOM?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the initial capacity?
I let it use the default behavior.
(and what's the reallocation behavior? e.g. would this give OOM?)
I understand that this might lead to unbounded memory usage and possibly even lead to OOM in extreme cases but I didn't know if we could enforce some sort of limitation on the number of links or env_properties allowed. It's straightforward for PartC fields as the TLD spec enforces a limit on the number of fields allowed. In this case though, links or env_properties would only count towards one field.
Could we enforce such a limitation? If yes, we could very well use an array and just tell the user that they have too many links or env_properties if they exceed a certain number. If not, I guess we would have to go back to the two iterations approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO for this.
#pragma warning disable CA5350 | ||
#pragma warning disable CA5392 | ||
|
||
internal sealed class EventProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have simply copied the contents of this file here: https://github.com/microsoft/tracelogging/blob/main/etw/cs/traceloggingdynamic/TraceLoggingDynamic.cs
Only additional changes that I made are that I have marked the types internal and internal sealed.
private static readonly string INVALID_SPAN_ID = default(ActivitySpanId).ToHexString(); | ||
|
||
private readonly EventProvider eventProvider; | ||
private static readonly ThreadLocal<EventBuilder> eventBuilder = new(() => new(UncheckedASCIIEncoding.SharedInstance)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which one would be better?
- Having 3 ThreadLocals
- Having a single ThreadLocal which points to a complex struct/object with 3 fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong preference. I suppose there's no performance implications of using one over the other. If the second approach looks more readable, I could make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO for this.
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
Changes
TODOs:
ThreadLocal
instead of multipleList<KeyValuePair<string, object>> keyValuePairs
Setup and usage:
You could us any ETW collection tools such as WPA, PerfView etc. to view the data:
Example with PerfView:
For the connectionString =
"EtwSession=OpenTelemetry;PrivatePreviewEnableTraceLoggingDynamic=true"
, you can run the following command in Command Prompt: