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
SoCal AdminSoCal Admin 

Apex API Call Detail

 

Are there any methods to capture the Govenor limit / summary info from custom apex methods and classes?

 

i.e.

 

1) Class created

2) Methods Created

3) Trigger is executed -> Code and Queries evaluated -> Written to Debug logs

 

But I need to write the Govenor Limit info to some other target using Code inside the method

 

Are there any object/variable/properties or run-time data structures(objects/variables/properties) that contain the information for the resulting queries/api calls, etc...

MJ Kahn / OpFocusMJ Kahn / OpFocus

To my knowledge, there are no objects or structures that contain the data from a debug log in a form that you could readily query to find the limit info. However, Apex has a Limits class that has methods that you can call from within your Apex code that will tell you the number of queries, records queried, DML operations, etc. that are allowed for your transaction, as well as the number that you've actually consumed to that point in your transaction. You could call those methods and save the results in a custom object for later examination. 

 

Of course, if your code hits a governor limit, any such data that you saved in an object for that transaction will be rolled back, so this isn't an ideal solution, but depending on why you're looking for this information, the Limits methods might be sufficient.