function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDCMattSFDCMatt 

Performance monitoring for custom Apex REST API server layer

Hi all - I'm in the middle of scoping the build for a Apex REST API service layer for one of my clients. One of their team members brought up an interesting point. They've asked about how they can monitor traffic and performance of the custom services, as well as watch for issues (like failed requests, long running responses, etc) in real time for proactive support. Overall traffic of the services across 5 clients is expected to be somewhere in the range of 10K to 30K requests per day.

 

First question, does Salesforce provide any such capabilities out of the box? My strong suspicion is no, but can't hurt to ask.

 

Second question, should this type of thing be built? I certainly think the request is well intentioned, but is the overhead for this type of thing going to be too expensive? Adding additional operations to the API itself will obviously decrease response time, even if a few milliseconds.

 

Third question, assuming this is not a terrible idea, how would you build this? My thoughts initially are:

 

  • Custom object to house records for individual requests
  • Each record contains data about each request / response, including which system submitted the request, response time, incoming request, outgoing response, etc
  • Within each RestResource method, at any catch point or right before the return, call a global "LogRESTActivity()" method to log the traffic
  • A scheduled batchable process that runs nightly to flush these records after some time (time determined by a custom setting)

This data structure would allow us to drive some pretty rich reports and dashboards to monitor performance in real time.

 

Curious if others have ever tackled this type of request, and how you handled it. Or if you have thoughts about the concept I outlined above.