Embrace

public final class Embrace implements EmbraceAndroidApi

Entry point for the SDK. This class is part of the Embrace Public API.

Contains a singleton instance of itself, and is used for initializing the SDK.

Types

Link copied to clipboard
public enum AppFramework
The AppFramework that is in use.
Link copied to clipboard
public enum LastRunEndState
Enum representing the end state of the last run of the application.

Functions

Link copied to clipboard
public void addBreadcrumb(@NonNull() String message)
Adds a breadcrumb.
Link copied to clipboard
public void addLogRecordExporter(@NonNull() LogRecordExporter logRecordExporter)
Adds a [LogRecordExporter] to the open telemetry logger.
Link copied to clipboard
public boolean addSessionProperty(@NonNull() String key, @NonNull() String value, boolean permanent)
Adds a property to the current session, overwriting any previous property set with the given key.
Link copied to clipboard
public void addSpanExporter(@NonNull() SpanExporter spanExporter)
Adds a [SpanExporter] to the tracer.
Link copied to clipboard
public void addUserPersona(@NonNull() String persona)
Adds a custom user persona.
Link copied to clipboard
public void clearAllUserPersonas()
Clears all custom user personas from the user.
Link copied to clipboard
public void clearUserAsPayer()
Clears this user as a paying user.
Link copied to clipboard
public void clearUserEmail()
Clears the currently set user's email address.
Link copied to clipboard
public void clearUserIdentifier()
Clears the currently set user ID.
Link copied to clipboard
public void clearUsername()
Clears the username of the currently logged in user, for example if the user has logged out.
Link copied to clipboard
public void clearUserPersona(@NonNull() String persona)
Clears the custom user persona, if it is set.
Link copied to clipboard
Create an EmbraceSpan with the given name that will be the root span of a new trace.
Create an EmbraceSpan with the given name and parent.
Link copied to clipboard
public void endAppStartup()
public void endAppStartup(@NonNull() Map<String, Object> properties)
Signals that the app has completed startup.
Link copied to clipboard
public void endMoment(@NonNull() String name)
public void endMoment(@NonNull() String name, @Nullable() String identifier)
public void endMoment(@NonNull() String name, @Nullable() Map<String, Object> properties)
public void endMoment(@NonNull() String name, @Nullable() String identifier, @Nullable() Map<String, Object> properties)
Signals the end of a moment with the specified name.
Link copied to clipboard
public synchronized void endSession()
public synchronized void endSession(boolean clearUserInfo)
Ends the current session and starts a new one.
Link copied to clipboard
public boolean endView(@NonNull() String name)
Records that a view 'ended'.
Link copied to clipboard
Randomly generate a W3C-compliant traceparent
Link copied to clipboard
Get the ID for the current session.
Link copied to clipboard
Get the user identifier assigned to the device by Embrace
Link copied to clipboard
public static Embrace getInstance()
Gets the singleton instance of the Embrace SDK.
Link copied to clipboard
Get the end state of the last run of the application.
Link copied to clipboard
Retrieves a map of the current session properties.
Link copied to clipboard
public EmbraceSpan getSpan(@NonNull() String spanId)
Return the EmbraceSpan corresponding to the given spanId if it is active or it has completed in the current session.
Link copied to clipboard
Retrieve the HTTP request header to extract trace ID from.
Link copied to clipboard
public boolean isStarted()
Whether or not the SDK has been started.
Link copied to clipboard
public boolean isTracingAvailable()
Link copied to clipboard
public void logCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements)
Remotely logs a custom stacktrace at ERROR level.
public void logCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements, @NonNull() Severity severity)
public void logCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements, @NonNull() Severity severity, @Nullable() Map<String, ? extends Object> properties)
public void logCustomStacktrace(@NonNull() Array<StackTraceElement> stacktraceElements, @NonNull() Severity severity, @Nullable() Map<String, ? extends Object> properties, @Nullable() String message)
Remotely logs a custom stacktrace at given severity level.
Link copied to clipboard
public void logError(@NonNull() String message)
Remotely logs a message at ERROR level.
Link copied to clipboard
public void logException(@NonNull() Throwable throwable)
Remotely logs a Throwable/Exception at ERROR level.
public void logException(@NonNull() Throwable throwable, @NonNull() Severity severity)
public void logException(@NonNull() Throwable throwable, @NonNull() Severity severity, @Nullable() Map<String, ? extends Object> properties)
public void logException(@NonNull() Throwable throwable, @NonNull() Severity severity, @Nullable() Map<String, ? extends Object> properties, @Nullable() String message)
Remotely logs a Throwable/Exception at given severity level.
Link copied to clipboard
public void logInfo(@NonNull() String message)
Remotely logs a message at INFO level.
Link copied to clipboard
public void logMessage(@NonNull() String message, @NonNull() Severity severity)
public void logMessage(@NonNull() String message, @NonNull() Severity severity, @Nullable() Map<String, ? extends Object> properties)
Remotely logs a message at the given severity level.
Link copied to clipboard
public void logPushNotification(@Nullable() String title, @Nullable() String body, @Nullable() String topic, @Nullable() String id, @Nullable() Integer notificationPriority, @NonNull() Integer messageDeliveredPriority, @NonNull() Boolean isNotification, @NonNull() Boolean hasData)
Saves captured push notification information into session payload
Link copied to clipboard
public void logWarning(@NonNull() String message)
Remotely logs a message at WARN level.
Link copied to clipboard
public boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs)
public boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events)
Record a span with the given name, start time, and end time (epoch time in milliseconds).
public boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() EmbraceSpan parent)
Record a span with the given name, parent, start time, and end time (epoch time in milliseconds).
public boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() ErrorCode errorCode)
Record a span with the given name, error code, start time, and end time (epoch time in milliseconds).
public boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() ErrorCode errorCode, @Nullable() EmbraceSpan parent)
Record a span with the given name, parent, error code, start time, and end time (epoch time in milliseconds).
public boolean recordCompletedSpan(@NonNull() String name, long startTimeMs, long endTimeMs, @Nullable() ErrorCode errorCode, @Nullable() EmbraceSpan parent, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events)
Record a span with the given name, error code, parent, start time, and end time (epoch time in milliseconds).
Link copied to clipboard
public void recordNetworkRequest(@NonNull() EmbraceNetworkRequest networkRequest)
Logs the fact that a network call occurred.
Link copied to clipboard
public T recordSpan<T>(@NonNull() String name, @NonNull() Function0<? extends T> code)
Execute the given block of code and record a new trace around it.
public T recordSpan<T>(@NonNull() String name, @Nullable() EmbraceSpan parent, @NonNull() Function0<? extends T> code)
Execute the given block of code and record a new span around it with the given parent.
public T recordSpan<T>(@NonNull() String name, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events, @NonNull() Function0<? extends T> code)
Execute the given block of code and record a new trace around it with optional attributes and list of EmbraceSpanEvent.
public T recordSpan<T>(@NonNull() String name, @Nullable() EmbraceSpan parent, @Nullable() Map<String, String> attributes, @Nullable() List<EmbraceSpanEvent> events, @NonNull() Function0<? extends T> code)
Execute the given block of code and record a new span around it with the given parent with optional attributes and list of EmbraceSpanEvent.
Link copied to clipboard
public boolean removeSessionProperty(@NonNull() String key)
Removes a property from the current session.
Link copied to clipboard
public boolean setAppId(@NonNull() String appId)
Sets a custom app ID that overrides the one specified at build time.
Link copied to clipboard
public void setUserAsPayer()
Sets this user as a paying user.
Link copied to clipboard
public void setUserEmail(@Nullable() String email)
Sets the current user's email address.
Link copied to clipboard
public void setUserIdentifier(@Nullable() String userId)
Sets the user ID.
Link copied to clipboard
public void setUsername(@Nullable() String username)
Sets the username of the currently logged in user.
Link copied to clipboard
public void start(@NonNull() Context context)
public void start(@NonNull() Context context, boolean enableIntegrationTesting)
public void start(@NonNull() Context context, boolean enableIntegrationTesting, @NonNull() Embrace.AppFramework appFramework)
Starts instrumentation of the Android application using the Embrace SDK.
Link copied to clipboard
public void startMoment(@NonNull() String name)
public void startMoment(@NonNull() String name, @Nullable() String identifier)
public void startMoment(@NonNull() String name, @Nullable() String identifier, @Nullable() Map<String, Object> properties)
Starts a 'moment'.
Link copied to clipboard
Create, start, and return a new EmbraceSpan with the given name that will be the root span of a new trace.
public EmbraceSpan startSpan(@NonNull() String name, @Nullable() EmbraceSpan parent)
Create, start, and return a new EmbraceSpan with the given name and parent.
public EmbraceSpan startSpan(@NonNull() String name, @Nullable() EmbraceSpan parent, @Nullable() Long startTimeMs)
Create, start, and return a new EmbraceSpan with the given name, parent, and start time (epoch time in milliseconds).
Link copied to clipboard
public boolean startView(@NonNull() String name)
Records that a view 'started'.
Link copied to clipboard
public void trackWebViewPerformance(@NonNull() String tag, @NonNull() ConsoleMessage consoleMessage)
public void trackWebViewPerformance(@NonNull() String tag, @NonNull() String message)
Listen to performance-tracking JavaScript previously embedded in the website's code.