mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-29 05:04:54 +01:00
Add the ability to trace methods in internal builds.
Currently only for internal builds. Use the @Trace annotation to trace methods for viewing in Perfetto.
This commit is contained in:
committed by
Cody Henthorne
parent
c3b5323010
commit
0b77b33902
@@ -0,0 +1,14 @@
|
||||
package org.thoughtcrime.securesms.tracing;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.CONSTRUCTOR;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
|
||||
@Target({TYPE, METHOD, CONSTRUCTOR}) @Retention(CLASS)
|
||||
public @interface Trace {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.thoughtcrime.securesms.tracing;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* A class to create Perfetto-compatible traces.
|
||||
*/
|
||||
public interface Tracer {
|
||||
|
||||
TracerImpl INSTANCE = new TracerImpl();
|
||||
|
||||
static @NonNull Tracer getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if enabled, otherwise false.
|
||||
*/
|
||||
boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Marks the start of a method call. Always follow this with a call to {@link #end(String)}.
|
||||
*/
|
||||
void start(@NonNull String methodName);
|
||||
|
||||
/**
|
||||
* Marks the start of a method call. Always follow this with a call to {@link #end(String)}.
|
||||
*
|
||||
* Includes the ability to pass a key-value pair that will be shown in the trace when you click
|
||||
* on the slice.
|
||||
*/
|
||||
void start(@NonNull String methodName, @NonNull String key, @NonNull String value);
|
||||
|
||||
/**
|
||||
* Marks the end of a method call.
|
||||
*/
|
||||
void end(@NonNull String methodName);
|
||||
|
||||
/**
|
||||
* Serializes the current state of the trace to a Perfetto-compatible byte array. Note that
|
||||
* there's no locking here, and therefore tracing will continue. We're just grabbing a best-effort
|
||||
* snapshot.
|
||||
*/
|
||||
@NonNull byte[] serialize();
|
||||
}
|
||||
Reference in New Issue
Block a user