* @param key the identifier for this recording event used to store stats.
* @param wasSuccessful whether this method executed successfully.
*/
public void endCustomRecording(String key, boolean wasSuccessful) {
long preNow = clock.currentTimeMillis();
Environment environment = ApiProxy.getCurrentEnvironment();
if (environment.getAttributes().containsKey(CUSTOM_RECORDING_KEY)) {
@SuppressWarnings("unchecked")
Map<String, RecordingData> customRecordings =
(Map<String, RecordingData>) environment.getAttributes().get(CUSTOM_RECORDING_KEY);
RecordingData recordingData = customRecordings.get(key);
if (recordingData != null) {
writeCustomRecording(environment, recordingData, preNow, wasSuccessful);
customRecordings.remove(key);
}