-
Notifications
You must be signed in to change notification settings - Fork 289
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
How to find the source of "TelemetryChannel found a telemetry item without an InstrumentationKey" #2070
Comments
Can you share the full code showing how you enabled ApplicationInsights? Its not clear which nuget package you are using, and which code snippet is being used. Without seeing them, its not possible to give any useful response. |
My bad, I've updated the question with details. I thought adding the appinsights telemetry at the very beginning would make the key available everywhere, and am unable to track the intermittent error about not finding the key. |
@rnarayana I have updated to v2.15.0 last night and I've started to see this problem happening. It is really hard to find the source, but I did not have the problem with v2.14.0, so I'll just revert to get back my telemetry |
@poveilleux Are you also on kubernetes? |
@rnarayana I am, but I don't see how this would be related. |
@rnarayana Are you facing this issue only when deploying to AKS ? Are you able to seeing telemetry flowing correctly without issues when running locally? |
@cijothomas I see this issue when deploying to kuberentes (AKS and non-AKS). Note that I have all my other telemetry flowing in correctly, but this one particular message keeps coming in at exactly 15 minutes apart. I've checked multiple services, and in every service, this entry is there, every 15 minutes. I have run locally in Debug mode for more than 15 mins, but did not see this issue. |
@rnarayana The 15 min interval hints that this may have something to do with Heartbeat module..Can you check if you have heartbeats flowing for the app in aks/local? Heartbeats would be a "customMetric" with the name "heartbeat". Also, if possible, can isolate the issue to particular version. Specifically - please confirm if you have repro with 2.15 only, or its repro in 2.14 as well? (There were changes in heartbeat modules in 2.15, so we want to narrow the scope down further to quickly reach the root cause). Appreciate your patience! |
I can confirm that the following two methods get rid of this issue:
|
We encountered the described issue in a SF stateless ASP.NET Core service that is using the We have noticed 1 more thing that might be a different issue but might be related to this one. Some of the Trace logs have provider name |
Reverting back to v2.14.0 as @poveilleux suggested in 1 of the above comments fixes the |
Thanks everyone for reporting the issue. This would be a regression from 2.14, most likelyt in the heartbeat area. Wil investigate and provide fix. |
im getting the same problem, reverted to 2.14.0 and everything worked |
@rnarayana, I started investigating this issue, but could not recreate in my environment. Adding the code as in issue description did not recreate an issue. I see a note stating issue does not get recreated in debug environment. Is it reproducible only in AKS? Could you please provide the steps the recreate an issue, this will help us investigate this issue faster. Also it could help if you can provide below data.
|
We haven't fixed this yet, which means this won't be part of 2.16. Will continue to get to the root cause for this, and will do 2.15.1 release for this, if this is confirmed to be a regression introduced by 2.15. (Similarly, it'll be part of 2.16.1 release as well) 2.16 cannot be delayed, as its a release done just to pick DiagnosticSource package version update to 5.0, which is releasing tomorrow. |
I'll send full repro by this weekend. |
I've uploaded the repro here
|
My team is also seeing this on Microsoft.ApplicationInsights.AspNetCore 2.15.0 and we are trying to determine the cause as we have 1 API service exhibiting the issue and 3 that are not. It's a very weird issue. If this is the issue, that the key isn't there, why is the Definitely sounds like a red herring to whatever the real issue is. At this point, we're pulling back slight configuration differences between the working and not working APIs to see if we can determine the cause. |
As we started to peel away, we found that removing this configuration from our api app in Azure fixed the issue, and re-adding it re-introduced the issue.
|
It would appear this configuration change causes the issue on a resource that is not currently exhibiting it:
This caused the issue in our QA environment resource that was not previous exhibiting the issue. |
We have confirmed that |
@rnarayana Thanks for the repro, it helped investigate an issue. Workaround for this issue is to set services.AddApplicationInsightsTelemetry(o =>
{
o.InstrumentationKey = instrumentationKey;
o.EnableAdaptiveSampling = false;
o.EnableActiveTelemetryConfigurationSetup = true;
}); Please note that still duplicate heartbeat is sent every 15 minutes and above proposed change will ensure that the duplicate heartbeat has Root Cause |
Seeing the same message, but in our case it is in a netcore webjob project. We are using the following code to setup Application Insights:
Because it is not a aspnet project I don't have EnableActiveTelemetryConfigurationSetup available as a workaround. Any idea how to solve it in our case? |
@cijothomas Any thoughts on a possible due date for the bugfix?
|
We're seeing this same behavior in an Azure Function where we've added Application Insights to the logging path. Here's where we've wired up AppInisghts to our logger: Here's what the configuration in host.json looks like:
We've got older function apps on .NET Core 3.1 that aren't having this problem. I've only seen it on our .NET 6.0 functions. We have both an APPINSIGHTS_INSTRUMENTATIONKEY and an APPLICATIONINSIGHTS_CONNECTION_STRING in the function configuration. |
Has anyone experienced this issue using just the SDK? |
I dont think it is supported to do |
I have the same issue with .NET6
then
|
@cijothomas Any updates on this? Thanks! |
The only update I have is that, based on #2070 (comment), this issue is occurring when using LoggingAdapters (except |
Thanks for the quick reply! |
We have the same problem with one service that is running on-premise that uses |
Check your appsettings in Azure. Maybe the appservice set a default app insight key for your service. |
My service is running on premise, logging to app insights. There is no app service. |
Setting the APPINSIGHTS_INSTRUMENTATIONKEY config value solved it for me. The connection string was already set and worked. .NET6 |
@FredrikDahlberg: Adding I'm also using .NET6 app, |
@rajkumar-rangaraj: Doesn't work for me |
@Saibamen Could you share a repro app ? Its very hard to find whats wrong without seeing a repro. |
Thanks. It looks like you are using Serilog and Serilog sink for Application Insights. Could you remove it and see if the issue repro? |
@cijothomas: Still have this trace warning message :( Code without Serilog is inside remove_serilog branch. You can see code changes in PR Saibamen/AppInsightsTraceWarning#1 |
From a quick attempt, did not repro for me. Are you able to run the app locally (without docker or app service), and it still repros? |
No. Everything is fine locally (Visual Studio on Windows 10) |
@Saibamen I do not see a repro with the code shared. If things work locally, but not when you deploy to Docker, can you check if the appsettings.json is copied correctly in docker? |
Any updates on this issue, we are still facing this issue in 2.21.0 version. |
Any news on this? |
@cijothomas Hi, I can confirm that the same issue is happening for .NET 6 worker services and .NET 4.7.2 console apps with NLog provider (Microsoft.ApplicationInsights.NLogTarget 2.21.0) and Application Insights SDK 2.21.0. Another weird thing is that I can't reproduce it when testing locally - then it works perfectly and data is being sent as expected (both Debug and Release build output), but once it's deployed on the servers, nothing is logged except for the lacking instrumentation key message. Can you please hint to what workaround can be used for non-web apps? #2070 solved it for ASP.NET Core 6 web apps but the non-web apps are only logging this "TelemetryChannel found a telemetry item without an InstrumentationKey" message. It's non-Azure services, regular Windows services and console apps on-prem that are sending data to an ApplicationInsights instance in Azure. Can't find any useful info on where to start fixing this as we have followed official guidance on setting up Application Insights with worker services: https://learn.microsoft.com/en-us/azure/azure-monitor/app/worker-service @eriksteinebach maybe you were able to find a solution, ref. your comment #2070 (comment) ? It would be so helpful if you could share how you approached this! |
Yes, it is copied correctly. |
Hi All, private static void AddLoggingAndTelemetry(this IServiceCollection services, IConfiguration configuration)
{
services.AddApplicationInsightsTelemetryWorkerService();
services.AddLogging(b =>
{
b.ClearProviders();
b.SetMinimumLevel(LogLevel.Trace);
b.AddNLog(configuration);
});
foreach (var target in NLog.LogManager.Configuration.AllTargets.OfType<ApplicationInsightsTarget>())
{
var config = target.GetPrivateField("telemetryClient").GetPrivateField("configuration") as TelemetryConfiguration;
config.ConnectionString = configuration["ApplicationInsights:ConnectionString"];
}
}
private static object GetPrivateField(this object o, string field)
=> o.GetType().GetField(field, BindingFlags.NonPublic | BindingFlags.Instance).GetValue(o); This solution worked for me. |
As for now, this issue still persists for worker services. I found out that the NLog target is using the (deprecated) default constructor of the TelemetryClient class which takes the singleton TelemetryConfiguration.Active as the parameter for the base class constructor. (see here and here) Although the static TelemetryConfiguration.Active property is also marked as obsolete, you can set the ConnectionString on the Active property which is then taken into account by the NLog target. This may be a bit better than using reflection for setting the property. |
*.csproj
file):.Net Core 3.1.7
Kubernetes (Rancher) and also on AKS on Alpine Linux
What are you trying to achieve?
Almost all the telemetry comes through properly, but I still get the trace "AI: TelemetryChannel found a telemetry item without an InstrumentationKey. This is a required field and must be set in either your config file or at application startup." at regular intervals
The key is set as the first step in ConfigureServices() itself in Startup.cs:
What have you tried so far?
I tried adding a TelemetryProcessor to try and inspect each item and figure out this, but did not get any leads.
The text was updated successfully, but these errors were encountered: