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.

Aligning diagnostic with Microsoft guidelines

See original GitHub issue

I started to check how to bring the new diagnostics features related to System.Diagnostics. Current iteration looks good but I found a couple of things that might need to be improved.

Diagnostic source scope

MassTransit only works with a single diagnostic source, normally coming from LogContext.Cache.Default. However, the guidelines advise the following:

DO - create new DiagnosticListener for specific Activity type to allow filtering by activity. E.g Incoming and Outgoing Http Requests should be different DiagnosticListeners. Follow DiagnosticSource User Guide to pick a name. (source)

Naming for diagnostic sources and activities

Related to the previous topic, all diagnostic messages are coming from one source that has a name MassTransit, which becomes hard to manage if a user needs, for example, only trace consumer lifecycle.

Another thing is that operation names are not related to the diagnostic source name. Everywhere I look, all operation names are, as a rule, prefixed with the diagnostic source name:

https://github.com/aspnet/AspNetCore/blob/5b2f3fb5f7f24ac3e91c5150a55cc411b2b36b76/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs#L18 https://github.com/elastic/apm-agent-dotnet/blob/master/src/Elastic.Apm.AspNetCore/DiagnosticListener/AspNetCoreDiagnosticListener.cs#L31 https://github.com/aspnet/EntityFrameworkCore/blob/f386095005e46ea3aa4d677e4439cdac113dbfb1/src/EFCore.Relational/Internal/RelationalDiagnostics.cs#L12

Does it make sense?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:51 (50 by maintainers)

github_iconTop GitHub Comments

1reaction
phatboygcommented, Jan 30, 2020

The only trick the HTTP handler has is that it needs to be added to the pipeline, so it can force propagation that way. And turn it off by not including the handler in the pipeline. Anyway, I added the ability to turn it off via AppContext or environment variable (yes, basically cut and paste from their code).

1reaction
phatboygcommented, Jan 30, 2020

That makes sense, a lot of sense actually. I put the ability to control in just now via AppContext or environment variable. Not sure what else is left to wrap it up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Functions diagnostics Overview
Start Azure Functions diagnostics · Navigate to your function app in the Azure portal. · Select Diagnose and solve problems to open Azure ......
Read more >
NET documentation C# Coding Conventions
Style guidelines · Use four spaces for indentation. · Align code consistently to improve readability. · Limit lines to 65 characters to enhance ......
Read more >
Security best practices for your Azure assets
Best practice: Align the top levels of management groups with segmentation strategy to provide a point for control and policy consistency ...
Read more >
Microsoft Azure Well-Architected Framework
Both services are free to all Azure users and align to the five pillars of the ... Best practices: Monitoring and diagnostics guidance....
Read more >
Guidance and best practices - Azure Backup
Discover the best practices and guidance for backing up cloud and on-premises workload to the cloud.
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