question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Traces - Options to customize trace listeners

See original GitHub issue

Adding 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ealsurcommented, May 20, 2022

@RamenTurismo not implemented. The team is working on AI (Application Insights) and Open Telemetry integration, PRs for that are in progress.

1reaction
j82wcommented, Feb 19, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found