How to ignore certain endpoints in NewRelic APM in Django?
Arghya Saha -
The best way to ignore certain endpoints/api from NewRelic APM would be to tweak the NewRelic agent flag using a middleware
The details of how to configure new relic agent is mentioned in this doc
Basically what we are doing in the custom_middleware.py file
Create a new middleware CustomMiddleware
In the custom middleware check if the requested url is to be ignored or not.
If the requested url is to be ignored, then set the flag agent.ignore_transaction(flag=True)
So this whole transaction would now be ignored from the new relic monitoring, no data would be captured for the particular request.
If you are looking to integrate NewRelic to your existing Django Application then follow this guide.
When should we use this feature?
This should be used for health checks, so that the overall response time and Apdex score of the application is not impacted by slow response time. In general if you have celery added to your Django application then you will notice that the health-check for your application will have higher response time, this might bring down your overall Apdex score, so I would advice to ignore any health-check monitoring from NewRelic.
If you want to learn how to add health check to your system monitoring, you can follow my blog