[Python] New Relic Insights not updating regularly bug

Hi, I have implemented new relic in my server less cron jobs and i am using record_exception for sending errors to new relic. but if any error is occurring in the cron job. it is not showing on insights transaction error table at that time. Because of which my alerts are not getting triggered correctly. But after some time when the cron job runs again the old entry of error can be seen in transaction error table. so its like if any error is not occurred twice then there will be no entry in transaction table. And my conditions runs for each minute so there is no alert at all.

Note:- I have also find out that this thing also happening on error tab of APM. if any error is occurred once then its trace back will not be shown but if that occurs again then its traceback will be shown.

Hello, @arup.kanti: It sounds like you may be experiencing the behavior described here, under the heading, Force registration of the Python agent:

By default the agent will register itself the first time a transaction (either web or non-web) is run. Because data cannot actually be accumulated until the agent registers itself and that will normally happen as a parallel task, then data for the initial transactions will not be captured.

See the linked document for two ways to address the issue.

1 Like

Hi @philweber: Thanks for responding. Actually this transaction has run more than once so its agent should be registered at the first time and it should send error all the other time as they are happening in my other apps. But on a particular app this error is coming. When i am running my lambda locally it is working fine for this application but when it runs on the server i am encountering
this error.

Hi It has been a week and i have not receive any solution for this. Please help me in this.

Hi Arup,

Sorry for the delay! I think what Phil said is on the right track. Even though the transaction ran more than once in the past, significant delay between running times can matter.

Have you tried some of the work arounds in the doc Phil linked? For instance, forcing registration of the agent in code within the application. Example:

import newrelic.agent

application = newrelic.agent.register_application(timeout=10.0)

def execute_task(task_name):
    with newrelic.agent.BackgroundTask(application, name=task_name, group='Task'):
        ...

With Cron jobs, you may also need to set Upload data on process shut down. Example:

shutdown_timeout = 2.5

Please give those a try and let us know if that works.

Cheers,
Giselle

2 Likes

Hi @Giselle

Thanks for Response.

I have tried to use “shutdown_timeout” in my configuration file. but after using it now error are going to new relic randomly. Some time they are not event going to new relic and sometime they are. So Can you please suggest something else.

Hi @Giselle @philweber

I think this issue is somewhat related to how “newrelic.agent.record_exception” works. I am using this for sending my catched errors and there might be some issue in it as error is not going to new relic or even if it is going sometimes it is going without the traces and if i hit the same lambda and then same error occur at 2 time. then only it is showing.