Azure Functions nodejs not showing transaction samples

Good day, I'm new to ELK stack and trying to setup APM transactions on my BE application.

We are using serverless infrastructure with Azure Functions and nodejs.

I cannot see any transaction samples in APM view:

Steps to reproduce:

  1. Download apm-agent-nodejs/examples/an-azure-function-app at main · elastic/apm-agent-nodejs · GitHub
  2. Setup required configuration (apm server url and token)
  3. Trigger any endpoint

Am I expecting something from from this?

P.S one of our functions runs on graphql and transactions logged properly. This reproduces for any other function, regardless of what's inside of it.

P.S.2 enabling tracing for apm shows that no spans being captured. Starting and ending span manually does not solve the issue

P.S.3 This reproduces with any version on npm packages and runtime.

Hello @shevkaboss thanks for reporting this!

May I ask you to clarify what setup of APM Server are you using?
For example, are you hosting the Elastic stack yourself or are you running it in cloud.elastic.co?

Can you also specify the versions for both the client and server part that you are using?
Cheers

We are running it on Cloud instance via Azure (yes, cloud.elastic.co).

Server instance is 8.12.2:
image

By the client part you mean version on npm in our case? The last attempt was on the demo provided by ELK: "elastic-apm-node": "^3.42.0".

It isn't working on latest as well: "elastic-apm-node": "^4.7.1"

Thank you for quick reply!

Hello

I was trying to figure what's wrong and re-created a similar setup but I could not face any issues.

Can you please clarify what you mean with "one of our functions runs on graphql and transactions logged properly."?
Does this mean that you see traces data populated in the APM UI for this function?

Also when you say "Starting and ending span manually does not solve the issue", do you mean adding instrumentation in the code, in form of spans?

I guess you already validated that the environment variables needed to configure the agent are populated equally in all functions?

Cheers

So the issue were found trying to inject APM to enterprise application.

It runs back-end on nodejs azure functions. There are around 10 of them.

The main data provider function under the hood is graphql server:


Traces appears for all graphql transactions.

On the other hand, we have couple of http trigger and time trigger. Traces from them aren't appearing on APM UI.

Regarding spans. Logging traces from apm I noticed that spans for Graphql function transaction were created during it's execution (even if there are no external dependencies on the code).
On the other hand, there was no spans for http/time functions transaction. I found that this can cause a problem as transaction will not display traces if there are not spans under it.

I've tried to add spans manually by calling apm.startSpan and endSpan during code execution. Even this span appears on logs (logs from local terminal), traces for transactions are still not display on APM UI.

I've also tried locally using CommonJS modules instead of ECMAscript (from docs I noticed that can be a problem), that didn't work.

ENV variables are the same for all functions as the code start on entry point from package.json

Do you have a working copy? I want to try find the differences.
My node version is 18.20.2, tried different versions on Azure Function runtime. On main env we are using "version": "[3.*, 4.0.0)".

P.S. From the screenshot above you can see a workaround creating require for ECMAscript module. This is in order to go through the bug in apm not capturing graphql requests properly (they are displayed as regular http request but not graphql methods. require-in-the-middle needs to be executed properly, but import-in-the-middle looks to be broken).

Hi @shevkaboss,

I work on the Node.js APM agent. Are you able to show a small example with code that reproduces the issue. If you run with ELASTIC_APM_LOG_LEVEL=trace that will provide helpful details on what the APM agent is doing.

I'm a little confused on whether we are talking about tracing HTTP or Time triggered Azure Functions, or something you are able to run locally to reproduce the problem.

Thanks.

Traces does not appear on your node-js examples. Tracing not working for neither HTTP nor Time trigger Azure Function.
My steps to reproduce:

  1. Clone apm-agent-nodejs/examples/an-azure-function-app at main · elastic/apm-agent-nodejs · GitHub
  2. Change initapm.js to contain following:
    require('elastic-apm-node').start({ secretToken: ''/*secret token*/, serverUrl: ''/*service url*/, serviceName: 'test-topic', environment: 'local-test-app', logLevel: 'trace' })
  3. run yarn install and yarn start
  4. trigger http function by calling GET http://localhost:7071/api/Bye

Results are:

  1. Transactions appearing in Trace view. Then, no more details/traces for it (sorry for merged screenshot, Im not allowed to upload more then one image):

  2. Traces for APM doesn't contain a lot of, the only things are:

  • start trace
  • setting default transcation name
  • setting transaction result
  • sending transaction
  1. Share me your email if you want to have a full logs (or let me know any other way to share them with you, I don't want to post them there lmao)
  2. Make a note, no spans created during this transaction. Manually creating spans (by apm.startSpan and endSpan) doesn't work. I except it working without any manual interactions.

P.S demo repo seems to be a little outdated. Latest npm version doesn't work either.

Good day!
Any updates on that?