use of zipkin2.internal.JsonCodec.JsonReader in project zipkin by openzipkin.
the class V1JsonSpanReader method readBinaryAnnotation.
void readBinaryAnnotation(JsonReader reader) throws IOException {
String key = null;
Endpoint endpoint = null;
Boolean booleanValue = null;
String stringValue = null;
reader.beginObject();
while (reader.hasNext()) {
String nextName = reader.nextName();
if (reader.peekNull()) {
reader.skipValue();
continue;
}
if (nextName.equals("key")) {
key = reader.nextString();
} else if (nextName.equals("value")) {
if (reader.peekString()) {
stringValue = reader.nextString();
} else if (reader.peekBoolean()) {
booleanValue = reader.nextBoolean();
} else {
reader.skipValue();
}
} else if (nextName.equals("endpoint")) {
endpoint = ENDPOINT_READER.fromJson(reader);
} else {
reader.skipValue();
}
}
if (key == null) {
throw new IllegalArgumentException("No key at " + reader.getPath());
}
reader.endObject();
if (stringValue != null) {
builder.addBinaryAnnotation(key, stringValue, endpoint);
} else if (booleanValue != null && booleanValue && endpoint != null) {
if (key.equals("sa") || key.equals("ca") || key.equals("ma")) {
builder.addBinaryAnnotation(key, endpoint);
}
}
}
use of zipkin2.internal.JsonCodec.JsonReader in project zipkin by openzipkin.
the class V1JsonSpanReader method readList.
public boolean readList(ReadBuffer buffer, Collection<Span> out) {
if (buffer.available() == 0)
return false;
V1SpanConverter converter = V1SpanConverter.create();
JsonReader reader = new JsonReader(buffer);
try {
reader.beginArray();
if (!reader.hasNext())
return false;
while (reader.hasNext()) {
V1Span result = fromJson(reader);
converter.convert(result, out);
}
reader.endArray();
return true;
} catch (Exception e) {
throw exceptionReading("List<Span>", e);
}
}
use of zipkin2.internal.JsonCodec.JsonReader in project zipkin by openzipkin.
the class V1JsonSpanReader method readAnnotation.
void readAnnotation(JsonReader reader) throws IOException {
String nextName;
reader.beginObject();
Long timestamp = null;
String value = null;
Endpoint endpoint = null;
while (reader.hasNext()) {
nextName = reader.nextName();
if (nextName.equals("timestamp")) {
timestamp = reader.nextLong();
} else if (nextName.equals("value")) {
value = reader.nextString();
} else if (nextName.equals("endpoint") && !reader.peekNull()) {
endpoint = ENDPOINT_READER.fromJson(reader);
} else {
reader.skipValue();
}
}
if (timestamp == null || value == null) {
throw new IllegalArgumentException("Incomplete annotation at " + reader.getPath());
}
reader.endObject();
builder.addAnnotation(timestamp, value, endpoint);
}
Aggregations