use of org.openstack4j.model.identity.v2.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.openstack4j.model.identity.v2.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.openstack4j.model.identity.v2.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.openstack4j.model.identity.v2.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;
}
use of org.openstack4j.model.identity.v2.Endpoint in project zipkin by openzipkin.
the class SelectSpansAndAnnotations method endpoint.
static Endpoint endpoint(Record a) {
Endpoint.Builder result = Endpoint.newBuilder().serviceName(a.getValue(ZIPKIN_ANNOTATIONS.ENDPOINT_SERVICE_NAME)).port(Schema.maybeGet(a, ZIPKIN_ANNOTATIONS.ENDPOINT_PORT, (short) 0));
int ipv4 = maybeGet(a, ZIPKIN_ANNOTATIONS.ENDPOINT_IPV4, 0);
if (ipv4 != 0) {
// allocation is ok here as Endpoint.ipv4Bytes would anyway
result.parseIp(new byte[] { (byte) (ipv4 >> 24 & 0xff), (byte) (ipv4 >> 16 & 0xff), (byte) (ipv4 >> 8 & 0xff), (byte) (ipv4 & 0xff) });
}
result.parseIp(Schema.maybeGet(a, ZIPKIN_ANNOTATIONS.ENDPOINT_IPV6, null));
return result.build();
}
Aggregations