* @return key that is used to store stats for this event.
*/
public String startCustomRecording(String packageName, String methodName, boolean recordParams,
Object... params) {
long preNow = clock.currentTimeMillis();
Environment environment = ApiProxy.getCurrentEnvironment();
packageName = Strings.isNullOrEmpty(packageName) ? "custom" : packageName;
methodName = Strings.isNullOrEmpty(methodName) ? "method" : methodName;
RecordingData recordingData = new RecordingData();
IndividualRpcStatsProto.Builder stats = IndividualRpcStatsProto.newBuilder();
stats.setServiceCallName(packageName + "." + methodName);
if (environment.getAttributes().containsKey(Recorder.CURRENT_NAMESPACE_KEY)) {
stats.setNamespace(
(String) environment.getAttributes().get(Recorder.CURRENT_NAMESPACE_KEY));
}
if (recordParams) {
stats.setRequestDataSummary(
settings.getPayloadRenderer().renderPayload(packageName, methodName, true, params));
}
Recorder.createStackTrace(2, stats, settings.getMaxLinesOfStackTrace());
stats.setWasSuccessful(false);
stats.setStartOffsetMilliseconds(clock.currentTimeMillis());
recordingData.setStats(stats);
if (!environment.getAttributes().containsKey(CUSTOM_RECORDING_KEY)) {
environment.getAttributes().put(CUSTOM_RECORDING_KEY, Maps.newLinkedHashMap());
}
@SuppressWarnings("unchecked")
Map<String, RecordingData> customRecordings =
(Map<String, RecordingData>) environment.getAttributes().get(CUSTOM_RECORDING_KEY);
String key = generateKey(stats.getServiceCallName(), preNow);
recordingData.addOverhead(clock.currentTimeMillis() - preNow);
customRecordings.put(key, recordingData);
return key;
}