Skip to content

Commit

Permalink
Use epoch micros for intake v2
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbarny committed Oct 8, 2018
1 parent a76f83c commit 839bb41
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private void serializeErrors(List<ErrorCapture> errors) {
private void serializeError(ErrorCapture errorCapture) {
jw.writeByte(JsonWriter.OBJECT_START);

writeDateField("timestamp", errorCapture.getTimestamp());
writeTimestamp(errorCapture.getTimestamp());

if (distributedTracing) {
if (errorCapture.getTraceContext().hasContent()) {
Expand Down Expand Up @@ -422,7 +422,7 @@ private void serializeTransactions(final List<Transaction> transactions) {

private void serializeTransaction(final Transaction transaction) {
jw.writeByte(OBJECT_START);
writeDateField("timestamp", transaction.getTimestamp());
writeTimestamp(transaction.getTimestamp());
writeField("name", transaction.getName());
if (distributedTracing) {
serializeTraceContext(transaction.getTraceContext(), false);
Expand Down Expand Up @@ -475,7 +475,7 @@ private void serializeSpans(final List<Span> spans) {
private void serializeSpan(final Span span) {
jw.writeByte(OBJECT_START);
writeField("name", span.getName());
writeDateField("timestamp", span.getTimestamp());
writeTimestamp(span.getTimestamp());
if (distributedTracing) {
serializeTraceContext(span.getTraceContext(), true);
} else {
Expand All @@ -484,9 +484,9 @@ private void serializeSpan(final Span span) {
if (parent != 0) {
writeField("parent", parent);
}
writeField("start", span.getStart());
}
writeField("duration", span.getDuration());
writeField("start", span.getStart());
if (span.getStacktrace() != null) {
serializeStacktrace(span.getStacktrace().getStackTrace());
}
Expand Down Expand Up @@ -940,11 +940,15 @@ private void writeHexField(String fieldName, Id traceId) {
jw.writeByte(COMMA);
}

private void writeDateField(final String fieldName, final long epochMicros) {
writeFieldName(fieldName);
jw.writeByte(QUOTE);
dateSerializer.serializeEpochTimestampAsIsoDateTime(jw, epochMicros / 1000);
jw.writeByte(QUOTE);
private void writeTimestamp(final long epochMicros) {
writeFieldName("timestamp");
if (distributedTracing) {
NumberConverter.serialize(epochMicros, jw);
} else {
jw.writeByte(QUOTE);
dateSerializer.serializeEpochTimestampAsIsoDateTime(jw, epochMicros / 1000);
jw.writeByte(QUOTE);
}
jw.writeByte(COMMA);
}
}
4 changes: 1 addition & 3 deletions apm-agent-core/src/main/resources/schema/errors/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@
"required": ["message"]
},
"timestamp": {
"type": "string",
"format": "date-time",
"pattern": "Z$",
"type": ["string", "integer"],
"description": "Recorded time of the error, UTC based and formatted as YYYY-MM-DDTHH:mm:ss.sssZ"
},
"transaction": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
"pattern": "^[a-fA-F0-9]{16}$"
},
"timestamp": {
"type": "string",
"pattern": "Z$",
"format": "date-time",
"type": ["string", "integer"],
"description": "Recorded time of the span, UTC based and formatted as YYYY-MM-DDTHH:mm:ss.sssZ"
},
"parent": {
Expand Down Expand Up @@ -99,5 +97,5 @@
"required": ["id"]
}
},
"required": ["duration", "name", "start", "type", "timestamp"]
"required": ["duration", "name", "type", "timestamp"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
"maxLength": 1024
},
"timestamp": {
"type": "string",
"pattern": "Z$",
"format": "date-time",
"type": ["string", "integer"],
"description": "Recorded time of the transaction, UTC based and formatted as YYYY-MM-DDTHH:mm:ss.sssZ"
},
"spans": {
Expand Down

0 comments on commit 839bb41

Please sign in to comment.