use of com.google.firebase.perf.metrics.Trace in project capacitor-firebase by robingenz.
the class FirebasePerformance method incrementMetric.
public void incrementMetric(String traceName, String metricName, Integer incrementBy) {
Trace trace = this.traces.get(traceName);
trace.incrementMetric(metricName, incrementBy);
}
use of com.google.firebase.perf.metrics.Trace in project capacitor-firebase by robingenz.
the class FirebasePerformancePlugin method incrementMetric.
@PluginMethod
public void incrementMetric(PluginCall call) {
String traceName = call.getString("traceName");
String metricName = call.getString("metricName");
Integer incrementBy = call.getInt("incrementBy", 1);
if (traceName == null) {
call.reject(ERROR_TRACE_NAME_MISSING);
return;
}
if (metricName == null) {
call.reject(ERROR_METRIC_NAME_MISSING);
return;
}
Trace trace = implementation.getTraceByName(traceName);
if (trace == null) {
call.reject(ERROR_TRACE_NOT_FOUND);
return;
}
implementation.incrementMetric(traceName, metricName, incrementBy);
call.resolve();
}
use of com.google.firebase.perf.metrics.Trace in project capacitor-firebase by robingenz.
the class FirebasePerformancePlugin method startTrace.
@PluginMethod
public void startTrace(PluginCall call) {
String traceName = call.getString("traceName");
if (traceName == null) {
call.reject(ERROR_TRACE_NAME_MISSING);
return;
}
Trace trace = implementation.getTraceByName(traceName);
if (trace != null) {
call.reject(ERROR_TRACE_NAME_ALREADY_ASSIGNED);
return;
}
implementation.startTrace(traceName);
call.resolve();
}
use of com.google.firebase.perf.metrics.Trace in project snippets-android by firebase.
the class MainActivity method basicTrace.
// [END perf_traced_create]
public void basicTrace() {
ItemCache cache = new ItemCache();
// [START perf_basic_trace_start]
Trace myTrace = FirebasePerformance.getInstance().newTrace("test_trace");
myTrace.start();
// [END perf_basic_trace_start]
// [START perf_basic_trace_increment]
Item item = cache.fetch("item");
if (item != null) {
myTrace.incrementMetric("item_cache_hit", 1);
} else {
myTrace.incrementMetric("item_cache_miss", 1);
}
// [END perf_basic_trace_increment]
// [START perf_basic_trace_stop]
myTrace.stop();
// [END perf_basic_trace_stop]
}
use of com.google.firebase.perf.metrics.Trace in project snippets-android by firebase.
the class MainActivity method piiExamples.
public void piiExamples() {
Trace trace = FirebasePerformance.getInstance().newTrace("trace");
User user = new User();
// [START perf_attr_no_pii]
trace.putAttribute("experiment", "A");
// [END perf_attr_no_pii]
// [START perf_attr_pii]
trace.putAttribute("email", user.getEmailAddress());
// [END perf_attr_pii]
}
Aggregations