Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert timestamp to seconds when serializing to JSON #91

Merged
merged 1 commit into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ public Map<String, Object> asJson() {
values.put("level", level.asJson());
}
if (timestamp != null) {
values.put("timestamp", timestamp);
double timestamp_secs = timestamp / 1000.0;
values.put("timestamp", timestamp_secs);
}
if (codeVersion != null) {
values.put("code_version", codeVersion);
Expand Down Expand Up @@ -474,7 +475,9 @@ public Builder level(Level level) {
/**
* The moment the bug happened, visible in ui as client_timestamp.
*
* @param timestamp the timestamp.
* @param timestamp the timestamp as a Long with millisecond precision.
* This vaulue is converted to seconds when serialized to JSON
* to conform to the API spec.
* @return the builder instance.
*/
public Builder timestamp(Long timestamp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public void shouldReturnAsJson() {
expected.put("level", data.getLevel().asJson());
}
if (data.getTimestamp() != null) {
expected.put("timestamp", data.getTimestamp());
double timestamp_secs = data.getTimestamp() / 1000.0;
expected.put("timestamp", timestamp_secs);
}
if (data.getCodeVersion() != null) {
expected.put("code_version", data.getCodeVersion());
Expand Down
1 change: 1 addition & 0 deletions rollbar-api/src/test/java/com/rollbar/test/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public static Data data() {
.level(Level.ERROR)
.codeVersion("1.2.3")
.platform("linux")
.timestamp(System.currentTimeMillis())
.language("java")
.framework("spring")
.request(request())
Expand Down