9

We have been running on Salesforce platform for just over 6 months with considerate amount of customizations. The data volume has been growing and features have been added into existing codebase overtime. We would like to have good way to monitor the performance of our customization code including apex, batch job, web service. (I will post another question on monitoring Visualforce page from user's perspective. This question focus on monitoring backend process.) What are the best process doing so? Here is my take with some questions:

  1. SF debug logging is not ideal since it doesn't persist and no API to access that info.
  2. We can create custom object to record information. It's good for those none-frequent process, but not ideal for frequent process because of database hit.
  3. Custom settings are cached and the performance penalty is small. It has data storage size limitation.

Based on the above 3 facts, I'd like to explore some options:

  1. Can we use custom setting for logging? We can take advantage of its low latency of write if writing is memory operation; and avoid the size limitation by moving the data into custom object periodically in batch mode and free the space. Does this sound?
  2. What are other options for logging performance data without much overhead?

Thanks! Lin

  • 1
    Doing this sort of logging will only decrease performance. If you want to review the performance of specific code the dev console will provide that information in real time. – Eric Aug 28 '15 at 18:07
  • 1
    If you want to analyze performance, passive monitoring is probably not the way to go. I would favor profiling utilities that you can run on demand, and some of this can be accomplished with unit tests as well. – Adrian Larson Aug 28 '15 at 18:13
  • 1
    I write my batch jobs to always write a log record at finish() - one DML statement so low overhead. The log record contains a formatted string and optionally, numerical stats of interesting things that happen during the batch job. Everything done with utility classes and interfaces for consistent approach across batch classes – cropredy Aug 28 '15 at 19:54
  • @crop1645 - But in order to write the data you have to collect it, possibly with Stateful, calculate, etc. Does that not add overhead? While one batch is not a big deal it sounds like the OP wants to do it for triggers, classes, batches, everything. That could have an impact on performance. – Eric Aug 28 '15 at 21:53
  • 1
    yes - it does add overhead and I would only do it for batch jobs - in my experience, the logging is minimal overhead compared to the value in diagnostics - especially for async jobs; I wouldn't do it for VF or std page interactions as there are other tools for web performance monitoring – cropredy Aug 28 '15 at 22:10
7

Have a look at the Event Monitoring API. You can use it to pull an event log file down for certain event types.

From docs for EventLogFile:

The event monitoring feature allows you to gather information about your Salesforce organization’s operational events, which you can use to analyze usage trends and user behavior. You can interact with event monitoring data by querying fields on the EventLogFile object (like EventType and LogDate). To view the underlying event data, query the LogFile field. The EventType determines the schema of this field.

Some of interest would be:

Each of these can include a wealth of information, such as CPU_TIME:

The CPU time in milliseconds used to complete the request. This field indicates the amount of activity taking place in the app server layer, highlighting pieces of Apex or Visualforce code that need refactoring.

Example finding the available logs with SOQL:

enter image description here

Example of EventLog output for Visualforce Requests:

enter image description here

NOTE

There is a cost associated with this outside of a Developer Edition org for anything other than user login and logout events.

  • Hi Daniel, quick question,. Does the EventLogfile have any information on the records accessed, for example if I access any Account record is it tracked? If yes, under which type is this info located. Thanks! – raym0nd Oct 6 '15 at 16:36
  • @raym0nd Hi, please ask this as a separate question. Feel free to link to it here. Comments are considered temporary, so it would be sad to lose the details over time. – Daniel Ballinger Oct 6 '15 at 18:40
  • I asked a similar question here. Can you please take a look. Thanks – raym0nd Oct 6 '15 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.