elastic / apm-agent-nodejs

https://www.elastic.co/guide/en/apm/agent/nodejs/current/index.html
BSD 2-Clause "Simplified" License
574 stars 222 forks source link

be defensive in reading/parsing Azure Function "function.json" and "host.json" #3185

Open trentm opened 1 year ago

trentm commented 1 year ago

The Azure Functions instrumentation assumes that "function.json" and "../host.json" exist and are valid JSON in an Azure Function. If that isn't the case, then the APM agent (and the Azure Function worker process) could crash.

Those files are specified here:

My understanding is that a Node.js Azure Function is invalid and non-functional without those files, but I haven't tried hard to break it.

The APM agent should fallback to just not instrumenting the Azure Function (or limited instrumentation) if there is a problem reading those files.

Grant-Visser commented 7 months ago

function.json file has been removed in the new Azure functions 4 implementation for javascript functions, meaning this is now an incompatibility as far as I can see. Here's a stacktrace:

Message processing error (Action=ProcessMessageCallback, EntityPath=webhook-update, Endpoint=No)
System.Private.CoreLib: Exception while executing function: Functions.serviceBusQueueTrigger1. System.Private.CoreLib: Result: Failure
Exception: bindingDefinitions is not iterable
Stack: TypeError: bindingDefinitions is not iterable
    at new FunctionInfo (/project/node_modules/elastic-apm-node/lib/instrumentation/azure-functions.js:74:22)

Trying to find a way around this now.

suhaschintala12 commented 3 months ago

@Grant-Visser

Trying to find a way around this now.

Any update on this issue? I am facing the same issue. I am using apm agent nodejs 4.5.0 and azure functions 4.1 and simple azure function setup fails with the bindingDefinitions error

mito4ek commented 5 days ago

Same issue for me :(

"elastic-apm-node": "4.7.0" "@azure/functions": "4.5.0"