Traces - Options to customize trace listeners
See original GitHub issueAdding options to customize Trace listeners for our traces when running on NET Core environment would be great, and also, to disable all trace listeners (including DefaultTraceListener).
If users want to send traces to a particular sink, in NET Core, today it’s extremely complex. When running in NETFX, this can be achieved by web.config/app.config.
It requires some weird hack like:
Type defaultTrace = Type.GetType("Microsoft.Azure.Cosmos.Core.Trace.DefaultTrace,Microsoft.Azure.Cosmos.Direct");
TraceSource traceSource = (TraceSource)defaultTrace.GetProperty("TraceSource").GetValue(null);
traceSource.Switch.Level = SourceLevels.All;
traceSource.Listeners.Clear();
traceSource.Listeners.Add(... my desired listener);
Ideally, we could expose some config APIs like:
CosmosClientOptions.DiagnosticOptions.DisableTraces
: It would disable all tracing and any machine wide default trace listeners from the SDK trace source.CosmosClientOptions.DiagnosticOptions.AttachTraceListeners(IEnumerable<TraceListener>)
: Would attach the listeners to our trace source programmatically.
For performance reasons, any application that does not want to collect traces can disable them to avoid any lock contention on the default machine-wide tracing.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Create and Initialize Trace Listeners - .NET Framework
Learn how to create and initialize trace listeners by using classes such as System.Diagnostics.DefaultTraceListener in .NET.
Read more >How to: Use TraceSource and Filters with Trace Listeners - ...
Use the TraceSource class and filters with trace listeners in .NET. TraceSource supersedes the static methods of the older Trace and Debug ...
Read more >Tracing in .NET and Implementing Your Own Trace Listeners
In order to use our custom Trace Listener, we only need make some changes in the .config file. Once we are done with...
Read more >How to work with trace listeners in ASP.NET Core 6
To use the custom trace listener, you should register it with the Listeners collection using the following code. var loggerFactory = app.
Read more >Remote Tracing·Building a Custom Trace Listener
Custom trace listeners are manipulated like any other trace listeners. To create one, you must first derive from the TraceListener abstract ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@RamenTurismo not implemented. The team is working on AI (Application Insights) and Open Telemetry integration, PRs for that are in progress.
I think there is some confusion. This is not related to CosmosDiagnostics. This is only referring to the DefaultTrace inside the SDK as part of the .NET framework. CosmosDiagnostic levels will need to be handled separately. I think the naming will need to be clear to avoid confusion.