-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat][sdk-105] Add telemetry (#313)
* feat(telemetry): add log events * feat(telemetry): add navigation events * feat(telemetry): add Network events * feat(telemetry): add Manual events * feat(telemetry): add maximum telemetry data * feat(telemetry): describe usage for static factories * fix(telemetry): add maximumTelemetryData to Reactive Streams ConfigBuilder * refactor(telemetry): replace static factories for TelemetryEventTracker * fix(telemetry): remove reference to TelemetryEventTracker in Body * fix(telemetry): set source only as "client" or "server" for Telemetry events * test(telemetry): add tests for TelemetryEvent * refactor(telemetry): modify equals and hashcode, and create a new hashmap in constructor * revert(notifier): previous reference * refactor: set source as an enum * refactor: docs * fix: test * fix: checkstyle * fix: checkstyle * fix: checkstyle * fix: checkstyle * fix: add revapi acceptedBreaks * fix: checkstyles * fix(ci): set expected release configuration * fix(ci): remove jdk7 condition * fix(ci): set release.sh new folder * fix(ci): suggested change * refactor(telemetry): move coerce in logic to RollbarTelemetryEventTracker * refactor(telemetry): rename class * fix(telemetry): checkstyle * refactor(telemetry): modify Telemetry queue capacity * refactor(telemetry): modify Telemetry capacity default value * fix(telemetry): checkstyle * docs(telemetry): fix ConfigBuilder.telemetryEventTracker javadoc * docs(telemetry): fix ConfigBuilder.maximumTelemetryData javadoc
- Loading branch information
1 parent
32abb9e
commit 2bbb12c
Showing
18 changed files
with
1,197 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
rollbar-api/src/main/java/com/rollbar/api/payload/data/Source.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.rollbar.api.payload.data; | ||
|
||
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; | ||
|
||
Source(String jsonName) { | ||
this.jsonName = jsonName; | ||
} | ||
|
||
@Override | ||
public Object asJson() { | ||
return jsonName; | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
rollbar-api/src/main/java/com/rollbar/api/payload/data/TelemetryEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package com.rollbar.api.payload.data; | ||
|
||
import com.rollbar.api.json.JsonSerializable; | ||
import com.rollbar.api.truncation.StringTruncatable; | ||
import com.rollbar.api.truncation.TruncationHelper; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Represents an event that allows you to leave a 'breadcrumb' leading up to an exception. | ||
*/ | ||
public class TelemetryEvent implements JsonSerializable, StringTruncatable<TelemetryEvent> { | ||
|
||
private final TelemetryType type; | ||
private final Level level; | ||
private final Long timestamp; | ||
private final Map<String, String> body; | ||
private final Source source; | ||
private static final long serialVersionUID = 2843361810242481727L; | ||
|
||
/** | ||
* Construct a TelemetryEvent. | ||
* | ||
* @param telemetryType {@link TelemetryType} | ||
* @param level {@link Level} | ||
* @param timestamp the timestamp for this TelemetryEvent | ||
* @param source {@link Source} | ||
* @param body a map containing all the data required by the {@link TelemetryType} | ||
*/ | ||
public TelemetryEvent( | ||
TelemetryType telemetryType, | ||
Level level, | ||
Long timestamp, | ||
Source source, | ||
Map<String, String> body | ||
) { | ||
type = telemetryType; | ||
this.timestamp = timestamp; | ||
this.level = level; | ||
this.source = source; | ||
this.body = new HashMap<>(body); | ||
} | ||
|
||
@Override | ||
public Map<String, Object> asJson() { | ||
Map<String, Object> values = new HashMap<>(); | ||
values.put("type", type.asJson()); | ||
values.put("level", level.asJson()); | ||
values.put("source", source.asJson()); | ||
values.put("timestamp_ms", timestamp); | ||
values.put("body", body); | ||
return values; | ||
} | ||
|
||
@Override | ||
public TelemetryEvent truncateStrings(int maxLength) { | ||
Map<String, String> truncatedMap = new HashMap<>(); | ||
for (Map.Entry<String, String> entry : body.entrySet()) { | ||
String truncatedValue = TruncationHelper.truncateString(entry.getValue(), maxLength); | ||
truncatedMap.put(entry.getKey(), truncatedValue); | ||
} | ||
return new TelemetryEvent( | ||
this.type, | ||
this.level, | ||
this.timestamp, | ||
this.source, | ||
truncatedMap | ||
); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "TelemetryEvent{" | ||
+ "type='" + type.asJson() + '\'' | ||
+ ", level='" + level.asJson() + '\'' | ||
+ ", source='" + source + '\'' | ||
+ ", timestamp_ms=" + timestamp | ||
+ ", body=" + body | ||
+ '}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
TelemetryEvent that = (TelemetryEvent) o; | ||
return type == that.type && level == that.level && Objects.equals(timestamp, that.timestamp) | ||
&& Objects.equals(body, that.body) && Objects.equals(source, that.source); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(type, level, timestamp, body, source); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
rollbar-api/src/main/java/com/rollbar/api/payload/data/TelemetryType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.rollbar.api.payload.data; | ||
|
||
import com.rollbar.api.json.JsonSerializable; | ||
|
||
/** | ||
* Represents the different types of {@link TelemetryEvent} available. | ||
*/ | ||
public enum TelemetryType implements JsonSerializable { | ||
LOG("log"), | ||
MANUAL("manual"), | ||
NAVIGATION("navigation"), | ||
NETWORK("network"); | ||
|
||
private final String jsonName; | ||
|
||
TelemetryType(String jsonName) { | ||
this.jsonName = jsonName; | ||
} | ||
|
||
@Override | ||
public Object asJson() { | ||
return jsonName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.