use of org.jboss.remoting3.Endpoint in project zipkin by openzipkin.
the class ProtobufSpanDecoder method decodeEndpoint.
private static Endpoint decodeEndpoint(CodedInputStream input) throws IOException {
Endpoint.Builder endpoint = Endpoint.newBuilder();
boolean done = false;
while (!done) {
int tag = input.readTag();
switch(tag) {
case 0:
done = true;
break;
case 10:
{
endpoint.serviceName(input.readStringRequireUtf8());
break;
}
case 18:
case 26:
{
endpoint.parseIp(input.readByteArray());
break;
}
case 32:
{
endpoint.port(input.readInt32());
break;
}
default:
{
logAndSkip(input, tag);
break;
}
}
}
return endpoint.build();
}
use of org.jboss.remoting3.Endpoint 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);
}
use of org.jboss.remoting3.Endpoint in project zipkin by openzipkin.
the class V1SpanWriter method sizeInBytes.
@Override
public int sizeInBytes(V1Span value) {
// {"traceId":"xxxxxxxxxxxxxxxx"
int sizeInBytes = 29;
if (value.traceIdHigh() != 0L)
sizeInBytes += 16;
if (value.parentId() != 0L) {
// ,"parentId":"0123456789abcdef"
sizeInBytes += 30;
}
// ,"id":"0123456789abcdef"
sizeInBytes += 24;
// ,"name":""
sizeInBytes += 10;
if (value.name() != null) {
sizeInBytes += jsonEscapedSizeInBytes(value.name());
}
if (value.timestamp() != 0L) {
// ,"timestamp":
sizeInBytes += 13;
sizeInBytes += asciiSizeInBytes(value.timestamp());
}
if (value.duration() != 0L) {
// ,"duration":
sizeInBytes += 12;
sizeInBytes += asciiSizeInBytes(value.duration());
}
int annotationCount = value.annotations().size();
Endpoint lastEndpoint = null;
int lastEndpointSize = 0;
if (annotationCount > 0) {
// ,"annotations":[]
sizeInBytes += 17;
// comma to join elements
if (annotationCount > 1)
sizeInBytes += annotationCount - 1;
for (int i = 0; i < annotationCount; i++) {
V1Annotation a = value.annotations().get(i);
Endpoint endpoint = a.endpoint();
int endpointSize;
if (endpoint == null) {
endpointSize = 0;
} else if (endpoint.equals(lastEndpoint)) {
endpointSize = lastEndpointSize;
} else {
lastEndpoint = endpoint;
endpointSize = lastEndpointSize = endpointSizeInBytes(endpoint, true);
}
sizeInBytes += V2SpanWriter.annotationSizeInBytes(a.timestamp(), a.value(), endpointSize);
}
}
int binaryAnnotationCount = value.binaryAnnotations().size();
if (binaryAnnotationCount > 0) {
// ,"binaryAnnotations":[]
sizeInBytes += 23;
// commas
if (binaryAnnotationCount > 1)
sizeInBytes += binaryAnnotationCount - 1;
for (int i = 0; i < binaryAnnotationCount; ) {
V1BinaryAnnotation a = value.binaryAnnotations().get(i++);
Endpoint endpoint = a.endpoint();
int endpointSize;
if (endpoint == null) {
endpointSize = 0;
} else if (endpoint.equals(lastEndpoint)) {
endpointSize = lastEndpointSize;
} else {
lastEndpoint = endpoint;
endpointSize = lastEndpointSize = endpointSizeInBytes(endpoint, true);
}
if (a.stringValue() != null) {
sizeInBytes += binaryAnnotationSizeInBytes(a.key(), a.stringValue(), endpointSize);
} else {
// {"key":"NN","value":true,"endpoint":}
sizeInBytes += 37;
sizeInBytes += endpointSize;
}
}
}
// ,"debug":true
if (Boolean.TRUE.equals(value.debug()))
sizeInBytes += 13;
// }
return ++sizeInBytes;
}
use of org.jboss.remoting3.Endpoint in project zipkin by openzipkin.
the class V2SpanWriter method endpointSizeInBytes.
static int endpointSizeInBytes(Endpoint value, boolean writeEmptyServiceName) {
// {
int sizeInBytes = 1;
String serviceName = value.serviceName();
if (serviceName == null && writeEmptyServiceName)
serviceName = "";
if (serviceName != null) {
// "serviceName":""
sizeInBytes += 16;
sizeInBytes += jsonEscapedSizeInBytes(serviceName);
}
if (value.ipv4() != null) {
// ,
if (sizeInBytes != 1)
sizeInBytes++;
// "ipv4":""
sizeInBytes += 9;
sizeInBytes += value.ipv4().length();
}
if (value.ipv6() != null) {
// ,
if (sizeInBytes != 1)
sizeInBytes++;
// "ipv6":""
sizeInBytes += 9;
sizeInBytes += value.ipv6().length();
}
int port = value.portAsInt();
if (port != 0) {
// ,
if (sizeInBytes != 1)
sizeInBytes++;
// "port":
sizeInBytes += 7;
sizeInBytes += asciiSizeInBytes(port);
}
// }
return ++sizeInBytes;
}
use of org.jboss.remoting3.Endpoint in project zipkin by openzipkin.
the class V1BinaryAnnotation method hashCode.
@Override
public int hashCode() {
int h = 1;
h *= 1000003;
h ^= key.hashCode();
h *= 1000003;
h ^= stringValue == null ? 0 : stringValue.hashCode();
h *= 1000003;
h ^= endpoint == null ? 0 : endpoint.hashCode();
return h;
}
Aggregations