-
Notifications
You must be signed in to change notification settings - Fork 451
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
Injecting TelemetryConfiguration no longer works after updating from v3-Preview to v3 #5353
Comments
I get the same error, worked in 2.2, but doesn't work in 3 private readonly TelemetryClient _telemetryClient;
Executed 'Function1' (Failed, Id=e836d513-5157-432f-9b85-11566f864c5e) |
This might be related to Azure/azure-functions-dotnet-extensions#5 but I can confirm that my
is being invoked. Not sure how the telemetry setup is applied though. |
Related issue too: Azure/azure-functions-dotnet-extensions#32 |
I'm seeing something similar running locally where I can't resolve the |
I got it to work by Injecting the TelemetryClient manually. This is against what the documentation says in v2 [assembly: FunctionsStartup(typeof(FunctionApp7.Startup))] namespace FunctionApp7 |
@JAugustusSmith What you are doing is just re-adding it to the service collection. That's not how this is supposed to work. Functions are adding its own stuff that we want to resolve. So dont just blindly add the above code without confirmation from microsoft that this is how they want us to do it now. Its a breaking change from 2.0 |
The reason why its failing is:
proved by the following
as i am stepping though the linked source code. |
i am confused, its the same type but a is resolved, b is null. But this is properly the reason.
How do i get that into my application that two dlls are loaded for the same ? |
What version of App Insights are you referencing in your project? I'd recommend referencing the latest https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Logging.ApplicationInsights/, rather than the App Insights package itself. Sometimes they move ahead of where we are (we are typically a couple weeks behind) and these odd type resolution issues hit. |
Using Microsoft.Azure.WebJobs.Logging.ApplicationInsights (v 3.0.14) did not resolve the issue for me. |
@brettsam I am using the samme version, see the output from my previus post. I am finding the type of Telemetry Configuration in the service collection that the framework injects and check the version and locaiton dll, its same version as application but the dll location is the framework and the other is the app location. |
Using Microsoft.Azure.WebJobs.Logging.ApplicationInsights also didn't help me. It's the first thing I tried.
It was the only way I could get it to work with the current bug. I'm not leaving it in as a solution, but it was either this, or go to 2.2 |
@JAugustusSmith - i get that, i was facing the same decision myself. I had this
that i had added in 2.2 to get better operation names for my functions hosting aspnet core application. in 3.0 its i cant get the TelemetryContext and add it anymore. But got it working now using reflection only instead and building the telemetry processor by hand at runtime using il code generation. I can make a class that can be resolved with the type of the telemetry configuration.
and register it
and add a telemetry processor
that uses the fixrequest method to set operation name.
that is called from il generated code.
So thanks for making a breaking change here :) I would love to see @brettsam provide a minimal example where its resolved out of the box and it not being a breaking change. I assume that this was not testet. So lets not assume its the same as the other times we had these issues. |
Flagging this as triaged for investigation. We'll provide an update once we have more information (this will be triaged as soon as possible for a sprint assignment). |
One quick comment.... We took a very quick initial look at this and it doesn't look like a runtime regression. This issue is present in 2.0 and the preview releases as well, and what changed here was actually the default behavior of the SDK build process. Adding the following project property is a workaround that will restore the previous behavior and work in 3.0: <SkipFunctionsDepsCopy>true</SkipFunctionsDepsCopy> This should unblock you until a permanent fix is made. |
@fabiocav while adding |
@dcousino, yes, removing that file has potential side effects like what you're seeing before, but this wouldn't be a change in behavior from 2.0. Are you using the storage SDK supported by the storage extension you're referencing? There will be a version of the extension coming up soon targeting newer storage releases, but in some of those cases, there were significant changes and they are essentially completely different SDKs, which may lead to what you're seeing above. You can follow the progress on that here: Azure/azure-webjobs-sdk#2065 (comment) |
@fabiocav I can also confirm that |
I can also confirm that |
Using Is there a timeline for a permanent fix to this issue? |
Might be the same as #4952 |
I just ran into this. |
Similar to @jabbera this also started affecting one of my V2 functions. I've spent about 4 hours switching the version of Microsoft.ApplicationInsights but no version from 2.9.1+ will work. |
To avoid break the function code or to have to deal with obscure MSBuild props, we went to the simplest route for now: builder.Services.AddSingleton<TelemetryConfiguration>(sp =>
{
var key = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY");
if (!string.IsNullOrWhiteSpace(key))
{
return new TelemetryConfiguration(key);
}
return new TelemetryConfiguration();
}); Although it is a ridiculous solution, it at least works for now and don't have the side-effects other had mentioned here... This is a critical problem that should be catch on the release tests as it is one of the built-in features provided by the host... I hope some fix would come soon... |
@fabiocav You've closed this with the merge of the fix, but when can we expect the release train to push out updated packages that actually resolve this for end users? |
Where is |
@Adrian10988 I placed it in the top level property group (and it goes in your <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<SkipFunctionsDepsCopy>true</SkipFunctionsDepsCopy>
</PropertyGroup>
<ItemGroup>
.... And I can confirm that it worked for my basic function. |
@dougxwok2 -- this will be in the next release payload which should start within the next couple of business days. I'd tentatively say it'll be everywhere within 2 weeks. |
@brettsam , can this patch be expedited? The workaround is causing other issues, and the inability to inject TelemetryConfiguration in v3 is affecting customer projects and deliverables ... |
Any update on when this will be released? We cannot keep operation id between calls that go through our azure functions so debugging and bench marking is a nightmare right now |
It's part of https://github.com/Azure/azure-functions-host/releases/tag/v2.0.12998. The rollout has started. Unless we hit snags it should be everywhere later next week. |
@brettsam Is there a timeline for the VS tools to be updated to use 2.0.12998 / 3.0.13130? Alternatively, is there a supported way to update VS's tools to use a newer runtime version? |
@brettsam any update? 9 days passed and I don't see any update neither the tools or the packages. Thanks |
@galvesribeiro I believe @brettsam was referring to the rollout to Azure Function instances, which has indeed happened for us. |
@richardszalay what you mean? the service runtime? If that is the case, we still need to get tool/package updates otherwise we still have the same problem on our dev machines or on Azure IoT Edge and/or kubernetes based Azure Function deployments... |
@galvesribeiro Correct. Here's what I'm using to work around the issue in local environments which is enough for us, but you'll want to test it with your IoT / Kubernetes environments to ensure it doesn't clobber any platform AI data. public override void Configure(IFunctionsHostBuilder builder)
{
if (IsAppInsightsRegistrationRequired(builder.Services))
{
builder.Services.AddSingleton(sp =>
{
var key = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY");
var telemetryConfiguration = (!string.IsNullOrWhiteSpace(key))
? new TelemetryConfiguration(key)
: new TelemetryConfiguration();
telemetryConfiguration.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());
return new TelemetryClient(telemetryConfiguration);
});
}
}
// Temporary workaround until the client tools (ie. VS support) includes the fixes from 3.0.13130
static bool IsAppInsightsRegistrationRequired(IEnumerable<ServiceDescriptor> services) =>
!IsServiceRegistered<TelemetryClient>(services);
static bool IsServiceRegistered<T>(IEnumerable<ServiceDescriptor> services) =>
services.Any(descriptor => descriptor.ServiceType == typeof(T)); |
Yes, as I mentioned here #5353 (comment) We're doing something similar to inject the config type. It works both locally and on the hosts but it is far from ideal. To fix that, we need everything updated with the fix... |
@brettsam any idea when version 3.0.13130 (with this fix) will hit Azure Gov? |
Following the instructions in https://docs.microsoft.com/en-us/azure/azure-functions/functions-monitoring#version-2x-3 used to work in the v3-preview but when updating to v3 + netcoreapp3.1 TelemetryConfiguration is no longer available and function blow up with:
This commit shows the details of the upgrade attempt:
andreasohlund/PublicApi@2783a2b
"APPINSIGHTS_INSTRUMENTATIONKEY": "..."
is set inlocal.setting.json
Could it be the the v3 host no longer enable telemetry when running locally?
Investigative information
Please provide the following:
Repro steps
Provide the steps required to reproduce the problem:
TelemetryClient
orTelemetryConfiguration
Expected behavior
Should inject the
TelemetryConfiguration
according to https://docs.microsoft.com/en-us/azure/azure-functions/functions-monitoring#version-2x-3Actual behavior
Injection fails with
Known workarounds
None at the stage
Related information
The text was updated successfully, but these errors were encountered: