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.

Ability to disable ConnectionId and RequestId + RequestPath scopes

See original GitHub issue

We use scopes to identify log entries as coming from a certain tenant, this is a critical part of our diagnostic ability.

Scopes have various performance downsides but due to the value they provide we really wouldn’t want to disable them completely. We also add all scopes to our json logger going to cloud logging and the smaller these messages can be the better, there is a direct financial cost attached to ingestion of larger than need be messages over time.

However, and this is the issue, in the framework there exist a few scope pushes that have limited or no value for us and can’t be turned off without also turning off important log messages.

ConnectionId is not relevant to us, but we can’t turn it off because all of it is enabled under category Microsoft.AspNetCore.Server.Kestrel which also contains important log messages like reaching connection limits.

RequestId is really not relevant anymore (at least to us) with SpanId and TraceId being integrated by default but we can’t turn it off RequestPath is occasionaly useful but we could just as well emit it ourselves.

Our minimal scopes would ideally look like:

Would it be possible to provide knob(s) to disable these kestrel scopes somewhere, like in KestrelServerOptions? (not sure where RequestId + RequestPath comes from)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tjmcdonoughcommented, Mar 31, 2023

You can exclude scopes by configuring ActivityTrackingOptions when initialising the logging service.

builder.Services.AddLogging(options =>
{
    options.Configure(c => c.ActivityTrackingOptions = ActivityTrackingOptions.None);
});
0reactions
markm77commented, Mar 18, 2023

Yes, agree with this. I just tried to add OpenTelemetry context to JSON console logging in an ASP.NET Core 6 project.

Using the “IncludeScopes” formatter option I get the below scopes on a log , when all I really want is the TraceId/SpanId for correlation purposes.

"Scopes": [
    {
      "Message": "SpanId:7d01d402b9b9fda5, TraceId:ebd21c67aaf93cc221a6ea2ecc416a24",
      "SpanId": "7d01d402b9b9fda5",
      "TraceId": "ebd21c67aaf93cc221a6ea2ecc416a24"
    },
    {
      "Message": "ConnectionId:0HMP7SSS89CFI",
      "ConnectionId": "0HMP7SSS89CFI"
    },
    {
      "Message": "RequestPath:/x/y RequestId:0HMP7SSS89CFI:00000002",
      "RequestId": "0HMP7SSS89CFI:00000002",
      "RequestPath": "/x/y"
    },
    {
      "Message": "XXX.PostAsync (YYY)",
      "ActionId": "0e04439b-492e-4a1c-aea8-7131c3f64482",
      "ActionName": "XXX.PostAsync (YYY)"
    }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scoped logging using Microsoft Logger with Serilog in .Net ...
The below read will let you know, how to enable scoped logging using Microsoft ILogger (with or without serilog) in a .Net core...
Read more >
Improvements in .NET Core 3.0 for troubleshooting and ...
Let's explore distributed tracing in .NET Core 3.0 and improvements recently made. First, we'll see how two “out of the box” ASP.NET Core...
Read more >
How to remove properties from log entries in ASP.Net Core
RequestId ; RequestPath. I presume they are being added by the ASP.Net Core logging framework. How can I get rid of them?
Read more >
apigatewayv2 - Amazon Web Services - Go SDK
RequestID returns the service's response RequestID for request. ... You can't update or delete // a managed API by using API Gateway.
Read more >
Writing logs to Elasticsearch with Fluentd using Serilog in ...
In this post, I describe how to customise the output of the Serilog Console sink so that you can pipe your console output...
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