Skip to content
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

ApplicationInsights:Failed to propagate context in Azure Functions #1111

Closed
Codesleuth opened this issue Mar 22, 2023 · 4 comments · Fixed by #1112
Closed

ApplicationInsights:Failed to propagate context in Azure Functions #1111

Codesleuth opened this issue Mar 22, 2023 · 4 comments · Fixed by #1112

Comments

@Codesleuth
Copy link

I'm getting the following error showing in our Azure Function log stream:

[Error]   ApplicationInsights:Failed to propagate context in Azure Functions [
[Error]     TypeError: Cannot read properties of null (reading 'customProperties')
[Information]         at AzureFunctionsHook.<anonymous> (/home/site/wwwroot/node_modules/applicationinsights/out/AutoCollection/AzureFunctionsHook.js:84:42)
[Information]         at step (/home/site/wwwroot/node_modules/applicationinsights/out/AutoCollection/AzureFunctionsHook.js:33:23)
[Information]         at Object.next (/home/site/wwwroot/node_modules/applicationinsights/out/AutoCollection/AzureFunctionsHook.js:14:53)
[Information]         at /home/site/wwwroot/node_modules/applicationinsights/out/AutoCollection/AzureFunctionsHook.js:8:71
[Information]         at new Promise (<anonymous>)
[Information]         at __awaiter (/home/site/wwwroot/node_modules/applicationinsights/out/AutoCollection/AzureFunctionsHook.js:4:12)
[Information]         at /home/site/wwwroot/node_modules/applicationinsights/out/AutoCollection/AzureFunctionsHook.js:78:136
[Information]         at t.WorkerChannel.<anonymous> (/azure-functions-host/workers/node/dist/src/worker-bundle.js:2:16100)
[Information]         at Generator.next (<anonymous>)
[Information]         at /azure-functions-host/workers/node/dist/src/worker-bundle.js:2:14637
[Information]   ]

This is using v2.5. A key thing to note is that we are not enabling any auto collection:

// note that we do not call `.start()`
appInsights.setup();

Even if we don't use the client directly, this still throws this error in the logs.

The Azure Function which is running here is an eventHubTrigger. These errors seem to align directly with each function invocation, so it suggests to me that auto collection is making an attempt to do something and it really shouldn't be.

Any ideas?

@willdkp
Copy link

willdkp commented Oct 3, 2023

Hi I am getting this error as well, what was the resolution?

@hectorhdzg
Copy link
Member

@willdkp can you add more details about your environment? this should be fixed in latest version of the SDK, if you are already using it then most likely you are hitting a different error, we can help with that if you provide more details about it.

@willdkp
Copy link

willdkp commented Oct 3, 2023

I see this every minute or so in my azure functions app, either run on the cloud or locally emulated:

[2023-10-03T19:27:23.602Z] ApplicationInsights:Failed to propagate context in Azure Functions [ [2023-10-03T19:27:23.603Z] TypeError: Cannot read properties of null (reading 'customProperties') [2023-10-03T19:27:23.604Z] at AzureFunctionsHook.<anonymous> (*******************\node_modules\applicationinsights\out\AutoCollection\AzureFunctionsHook.js:84:42) [2023-10-03T19:27:23.608Z] at step (*******************\node_modules\applicationinsights\out\AutoCollection\AzureFunctionsHook.js:33:23) [2023-10-03T19:27:23.609Z] at Object.next (*******************\node_modules\applicationinsights\out\AutoCollection\AzureFunctionsHook.js:14:53) [2023-10-03T19:27:23.611Z] at *******************\node_modules\applicationinsights\out\AutoCollection\AzureFunctionsHook.js:8:71 [2023-10-03T19:27:23.612Z] at new Promise (<anonymous>) [2023-10-03T19:27:23.613Z] at __awaiter (*******************\node_modules\applicationinsights\out\AutoCollection\AzureFunctionsHook.js:4:12) [2023-10-03T19:27:23.614Z] at *******************\node_modules\applicationinsights\out\AutoCollection\AzureFunctionsHook.js:78:136 [2023-10-03T19:27:23.615Z] at t.WorkerChannel.<anonymous> (*******************\AppData\Roaming\nvm\v18.14.1\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:17020) [2023-10-03T19:27:23.617Z] at Generator.next (<anonymous>) [2023-10-03T19:27:23.618Z] at *******************\AppData\Roaming\nvm\v18.14.1\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:15490

From package.json

"dependencies": { "@azure/identity": "^3.0.0", "@azure/keyvault-secrets": "^4.6.0", "@azure/storage-queue": "^12.10.0", "applicationinsights": "^2.3.4", "durable-functions": "^2.0.2", "moment": "^2.29.4", "mssql": "^9.0.1", "node-fetch": "^2.6.7", "parse-link-header": "^2.0.0" }

In code I do:

const appInsights = require('applicationinsights'); appInsights.setup(); const aiClient = appInsights.defaultClient;

@hectorhdzg
Copy link
Member

@willdkp the original issue was fixed in version 2.5.1, I recommend you to update to latest applicationinsights (currently 2.8.0), let me know if this is still an issue after updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants