From 7477b4149fed7b89f83b60eec4dfc49ca1ac8ecd Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 15 Aug 2024 23:41:46 -0300 Subject: [PATCH] refactor: docs --- .../com/rollbar/api/payload/data/Source.java | 11 +++++ .../RollbarTelemetryEventTracker.java | 27 ------------- .../telemetry/TelemetryEventTracker.java | 40 +++++++++++++++++++ 3 files changed, 51 insertions(+), 27 deletions(-) diff --git a/rollbar-api/src/main/java/com/rollbar/api/payload/data/Source.java b/rollbar-api/src/main/java/com/rollbar/api/payload/data/Source.java index 9cde0a21..58048168 100644 --- a/rollbar-api/src/main/java/com/rollbar/api/payload/data/Source.java +++ b/rollbar-api/src/main/java/com/rollbar/api/payload/data/Source.java @@ -2,8 +2,19 @@ import com.rollbar.api.json.JsonSerializable; +/** + * The Source of a payload. + */ public enum Source implements JsonSerializable { + + /** + * A Client source (e.g. Android) + */ CLIENT("client"), + + /** + * A Server source (e.g. Spring) + */ SERVER("server"); private final String jsonName; diff --git a/rollbar-java/src/main/java/com/rollbar/notifier/telemetry/RollbarTelemetryEventTracker.java b/rollbar-java/src/main/java/com/rollbar/notifier/telemetry/RollbarTelemetryEventTracker.java index 8b60e3d2..44ddaeb3 100644 --- a/rollbar-java/src/main/java/com/rollbar/notifier/telemetry/RollbarTelemetryEventTracker.java +++ b/rollbar-java/src/main/java/com/rollbar/notifier/telemetry/RollbarTelemetryEventTracker.java @@ -38,37 +38,18 @@ public List dump() { return events; } - /** - * Record log telemetry event. ({@link TelemetryType#LOG}). - * - * @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}). - * @param message the message sent for this event (e.g. "hello world"). - */ public void recordLogEventFor(Level level, Source source, String message) { Map body = new HashMap<>(); body.put(LOG_KEY_MESSAGE, message); addEvent(new TelemetryEvent(TelemetryType.LOG, level, timestampProvider.provide(), source, body)); } - /** - * Record manual telemetry event. ({@link TelemetryType#MANUAL}) . - * - * @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}). - * @param message the message sent for this event (e.g. "hello world"). - */ public void recordManualEventFor(Level level, Source source, String message) { Map body = new HashMap<>(); body.put(LOG_KEY_MESSAGE, message); addEvent(new TelemetryEvent(TelemetryType.MANUAL, level, timestampProvider.provide(), source, body)); } - /** - * Record navigation telemetry event with from (origin) and to (destination).({@link TelemetryType#NAVIGATION}) . - * - * @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}). - * @param from the starting point (e.g. "SettingView"). - * @param to the destination point (e.g. "HomeView"). - */ public void recordNavigationEventFor(Level level, Source source, String from, String to) { Map body = new HashMap<>(); body.put(NAVIGATION_KEY_FROM, from); @@ -76,14 +57,6 @@ public void recordNavigationEventFor(Level level, Source source, String from, St addEvent(new TelemetryEvent(TelemetryType.NAVIGATION, level, timestampProvider.provide(), source, body)); } - /** - * Record network telemetry event with method, url, and status code.({@link TelemetryType#NETWORK}). - * - * @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}). - * @param method the verb used (e.g. "POST"). - * @param url the api url (e.g. "http://rollbar.com/test/api"). - * @param statusCode the response status code (e.g. "404"). - */ public void recordNetworkEventFor(Level level, Source source, String method, String url, String statusCode) { Map body = new HashMap<>(); body.put(NETWORK_KEY_METHOD, method); diff --git a/rollbar-java/src/main/java/com/rollbar/notifier/telemetry/TelemetryEventTracker.java b/rollbar-java/src/main/java/com/rollbar/notifier/telemetry/TelemetryEventTracker.java index 5f63067e..685e393c 100644 --- a/rollbar-java/src/main/java/com/rollbar/notifier/telemetry/TelemetryEventTracker.java +++ b/rollbar-java/src/main/java/com/rollbar/notifier/telemetry/TelemetryEventTracker.java @@ -3,13 +3,53 @@ import com.rollbar.api.payload.data.Level; import com.rollbar.api.payload.data.Source; import com.rollbar.api.payload.data.TelemetryEvent; +import com.rollbar.api.payload.data.TelemetryType; import java.util.List; public interface TelemetryEventTracker { + + /** + * Dump all the events recorded + */ List dump(); + + /** + * Record log telemetry event. ({@link TelemetryType#LOG}). + * + * @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}). + * @param source the {@link Source} this event is recorded from (e.g. {@link Source#CLIENT}). + * @param message the message sent for this event (e.g. "hello world"). + */ void recordLogEventFor(Level level, Source source, String message); + + /** + * Record manual telemetry event. ({@link TelemetryType#MANUAL}) . + * + * @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}). + * @param source the {@link Source} this event is recorded from (e.g. {@link Source#CLIENT}). + * @param message the message sent for this event (e.g. "hello world"). + */ void recordManualEventFor(Level level, Source source, String message); + + /** + * Record navigation telemetry event with from (origin) and to (destination).({@link TelemetryType#NAVIGATION}) . + * + * @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}). + * @param source the {@link Source} this event is recorded from (e.g. {@link Source#CLIENT}). + * @param from the starting point (e.g. "SettingView"). + * @param to the destination point (e.g. "HomeView"). + */ void recordNavigationEventFor(Level level, Source source, String from, String to); + + /** + * Record network telemetry event with method, url, and status code.({@link TelemetryType#NETWORK}). + * + * @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}). + * @param source the {@link Source} this event is recorded from (e.g. {@link Source#CLIENT}). + * @param method the verb used (e.g. "POST"). + * @param url the api url (e.g. "http://rollbar.com/test/api"). + * @param statusCode the response status code (e.g. "404"). + */ void recordNetworkEventFor(Level level, Source source, String method, String url, String statusCode); }