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

Request correlation doesnt work #78

Closed
ersah123 opened this issue May 6, 2024 · 3 comments
Closed

Request correlation doesnt work #78

ersah123 opened this issue May 6, 2024 · 3 comments

Comments

@ersah123
Copy link

ersah123 commented May 6, 2024

Environment

All, azure app services

Reproduction

azure performance dashboard

Describe the bug

When i deploy this to azure app service, i see that my server side requests are not corelated. Or is it same issue as dependency issue created here? :#19

I see this was implemented on legacy package here: https://github.com/nuxt-community/applicationinsights-module/blob/057714010160c4463423e41365bdd683787f492c/lib/runtime/nitro.js#L13C48-L13C66

Any idea how i can make it work?

Logs

Missing server side request calls

@huang-julien
Copy link
Owner

Hey 👋 for now you need to use some utils provided by nitro-applicationinsights/runtime to add a header on all your external calls to correctly track your dependencies.

I did try to use wrapWithCorrelationContext but it didn't worked for me (returning null when creating a correlation context) even though i was using container app and app services.

I may give it a try again later. Or we could also wait for node 22 LTS (21 is not going to be an LTS I think) to get AsyncLocalStorage support so we can trace everything automatically without azure's wrapWithCorrelationContext . I'll probably start to implement this as an experimental feature to enable (only for node >=21). Note that AsyncLocalStorage is also an experimental feature in nitro.

The issue on #19 is indeed the fact that we can't correctly correlate traces automatically between incoming request (manually done here ) .

@ersah123
Copy link
Author

ersah123 commented May 13, 2024

Thanks for clarifying, i have something working for now.

nitro-applicationinsights/runtime didnt help me so far because it requires event and context object to be passed from my services. And also i need to use it for axios (interceptors) and graphql client too, i decided to pass it myself.

i have access to appInsights in components

if (process.server) {
    const { ssrContext } = this.$nuxt.context;
    appInsights = ssrContext.event.$appInsights; 
  }

then use it as :

appInsights.client.trackDependency({ ... })

Not sure it is the best way but it is working perfectly so far.

@ersah123 ersah123 closed this as completed Jun 2, 2024
@huang-julien
Copy link
Owner

oh yeah, i also have an axios interceptor at work. Wasn't sure if it made sense to add it or if it was too much. I guess I can probably add an axios inteceptor in the utilities :)

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

No branches or pull requests

2 participants