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
Activity.Current null in Azure Function when using the latest version of System.Diagnostics.DiagnosticSource #7278
Comments
Hello, Similarly you will experience the same issue if you reference Microsoft.ApplicationInsights.AspNetCore 2.16.0 >= in any of your packages getting "System.Diagnostics.DiagnosticSource" version 5.0.0. br, |
We are also getting this issue. This is a glaring hole in our ability to observe our functions. |
Getting this as well. Any workaround or update? |
I think I've been running into this too, although the behaviour I'm experience is slightly different, especially around Activity.Current being null in code vs in the debug windows / tooltips. For example, the screenshot below shows Activity.Current as null but somehow the On top of this, if you inspect an instance of It looks like a much older version of System.Diagnostics.DiagnosticSource is being loaded than the one directly referenced, which I can't work around. Investigative informationCode:
Tools:
Please see the following repo: https://github.com/BlakeWills/SystemDiagnosticsFunction/blob/master/SystemDiagnosticsFunction Once cloned, start debugging and you should see that:
|
The fix unfortunately doesn't work for everyone (or at least me). I'm also open to alternatives that add data to request telemetry? EditScratch that, after talking to @johannesoenema it seems that the workaround is working when deployed to Azure but not locally. So downgrading to a lower version (4.x) works in Azure. |
I cannot downgrade. My project references EntityFramework.SqlServer which requires 4.71
Is there any other solution? Like other people, I use Activity.Current.AddTag to inject custom data into current Application Insights request data. Is there any other solution to inject that data into current request? |
I have the same issue I can't downgrade is there anyone finding a solution for this? |
In my opinion, requesting to upgrade to .NET 6 is not a perfect solution. There are cases where it's not possible to switch to .NET 6 or it requires time/effort not available in the mid term. /my2cents |
When using
Activity.Current
to add custom tags to request telemetry, we encounter the problem thatActivity.Current
is null. We have currently not a way to add custom telemetry to request. The following code will not work with the latest version ofSystem.Diagnostics.DiagnosticSource
:Information
Repro steps
We use
EFCore.BulkExtensions
which has a dependency on version4.7.1
ofSystem.Diagnostics.DiagnosticSource
and because of thatActivity.Current
isn't working anymore. See repro here: https://github.com/johannesoenema/ActivityIssueAlso very weird,
Activity.Current
is null according to the code, but in the debug window it isn't null...Expected behavior
Activity.Current
is not null.Actual behavior
Activity.Current
is null.Known workarounds
Downgrading to version 4.6 of
System.Diagnostics.DiagnosticSource
:Of course we prefer to use latest version of packages.
Related information
This issue is already described in another issue #5014. Because it is a separate issue from the original issue, I open a new one as suggested.
@brettsam suggested that this change (removing
System.Diagnostics.DiagnosticSource
from the unification) could be related: #4941The text was updated successfully, but these errors were encountered: