-
Notifications
You must be signed in to change notification settings - Fork 140
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
2.5.1+ doesn't initialize when used with azure-functions-core-tools #1144
Comments
Hi @CreativeTechGuy, if you want to eliminate the conflict here you could disable Azure SDK auto-instrumentation. This won't fix the core issue that the two dependencies both monkey-patch the require method but might be able to resolve your issue for now. Let me know that workaround helps, thanks! |
@JacksonWeber This doesn't change anything unfortunately. The issue is that the auto-instrumentation doesn't work. So manually disabling the thing that doesn't work doesn't really do anything. |
I took a look and it seems like we're just waiting for the fix to propogate through various dependencies.
@JacksonWeber @hectorhdzg if you could help speed along those last two updates of packages that would be much appreciated :) |
Thank you @ejizba! |
@ejizba Absolutely. Thank you for noticing the updates in the dependency web there! |
…entation Packages (#25996) ### Packages impacted by this PR @azure/monitor-opentelemetry-exporter ### Issues associated with this PR microsoft/ApplicationInsights-node.js#1144 ### Describe the problem that is addressed by this PR Update the `@opentelemetry/instrumentation` libraries in order to resolve a dependency conflict with `@azure/functions-core` ### Are there test cases added in this PR? _(If not, why?)_ No. This is just an update of dependencies. ### Checklists - [x] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [x] Added a changelog (if necessary)
…entation Packages (Azure#25996) ### Packages impacted by this PR @azure/monitor-opentelemetry-exporter ### Issues associated with this PR microsoft/ApplicationInsights-node.js#1144 ### Describe the problem that is addressed by this PR Update the `@opentelemetry/instrumentation` libraries in order to resolve a dependency conflict with `@azure/functions-core` ### Are there test cases added in this PR? _(If not, why?)_ No. This is just an update of dependencies. ### Checklists - [x] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [x] Added a changelog (if necessary)
@CreativeTechGuy @ejizba The above issue should be resolved as our dependency on |
Is there a plan to release that fix? It looks like it's been committed but the package hasn't been released in a few weeks. |
@CreativeTechGuy we have a monthly release cadence in our side, we will be publishing a new version of Application Insights Node.js SDK end of next week. |
TLDR: Two different libraries,
applicationinsights
andazure-functions-core-tools
both overwrite Node.js'require
method, thus breaking the magic thatazure-functions-core-tools
is doing and preventingapplicationinsights
to hook into the local Azure Function server. This causes automatic logging when running Azure Functions locally to not work andgetCorrelationContext()
to return null.This is an incredibly complicated issue. I feel it's best explained by tracing the code since there's a lot going on.
@azure/opentelemetry-instrumentation-azure-sdk
.require
method in Node.js. Make a note of this for later.applicationinsights
to add the proper Azure Functions hooks, it checks if@azure/functions-core
exists here@azure/functions-core
package doesn't actually exist in NPM or on disk, it is instead provided by azure-functions-core-tools when developing locally. It does this by overwriting therequire
method in Node.js such that when that specific module is requested, it provides an in-memory object as the response.azure-functions-core-tools
it will make a request to install this file as a postinstall script and unpack it intonode_modules
. The source relevant source code which that zip includes is for the azure-functions-nodejs-worker package.require
to supply the fake@azure/functions-core
package.Now, the problem is that there's two packages which are loaded at runtime, both overwriting a global with a custom implementation.
azure-functions-core-tools
is loaded first so it overwrites first, thenrequire-in-the-middle
loads second and overwrites the overwrite. Thus whenapplicationinsights
tries to check for the existence of@azure/functions-core
at runtime, it cannot find it. As a result of all of this. our calls toappinsights.getCorrelationContext()
return null as it was never initialized as the Azure Function hooks were never setup.This issue was introduced in 2.5.1 and was not an issue in 2.5.0 of
applicationinsights
. It's unclear which package is the root cause, it seems like both are equally to blame as they aren't playing nice with each other. Bothazure-functions-core-tools
andrequire-in-the-middle
"try" to overwrite in a way to be compatible, but due to the use of the Proxy inazure-functions-core-tools
it is still incompatible if loaded first.The text was updated successfully, but these errors were encountered: