failed to setup new relic custom instrumentation in my node js app

27 Views Asked by At

I completed the basic setup for new relic, currently I'm able to monitor API'S but I need to monitor other functions that process some data 1- function one is responsible for producing data to a kafka topic and the second function responsible for consuming the data that was processed by that service. So I want to monitor these two functions all the time in new relic dashboard and calculate the time it takes from producing the data and consuming it back. This did not work for me as the app terminates once this function is called

// this produces data to kafka
newrelic.startBackgroundTransaction('replyWithAIAssistant', function(){
        const transaction = newrelic.getTransaction();
        this.sendToKafka();
        transaction.end();
      } ) 

// this is for consuming 

async consumingData(data) {
    try {
      // some logic  

    } catch (error) {
      console.error("Error", error)
    }
  }

0

There are 0 best solutions below