@Override public String toString() { return MoreObjects.toStringHelper(this) .add("timestamp", TextFormatter.epoch(timestampMillis())) .add("responseTime", TextFormatter.elapsed(responseTimeNanos())) .add("requestSize", TextFormatter.size(requestSize())) .add("responseSize", TextFormatter.size(responseSize())) .add("thriftServiceName", thriftServiceName) .add("thriftMethodName", thriftMethodName) .add("thriftCall", thriftCall) .add("thriftReply", thriftReply) .toString(); } }
private static ThriftStructuredLog buildLog(ThriftCall call, @Nullable ThriftReply reply) { return new ThriftStructuredLog( TIMESTAMP_MILLIS, RESPONSE_TIME_NANOS, REQUEST_SIZE, RESPONSE_SIZE, THRIFT_SERVICE_NAME, THRIFT_METHOD_NAME, call, reply); }
@Test(timeout = 10000) public void testStructuredLogging() throws Exception { final HelloService.Iface client = newClient(); client.hello("kawamuray"); final ThriftStructuredLog log = writtenLogs.take(); //assertThat(writtenLogs.size()).isEqualTo(1); assertThat(log.timestampMillis()).isGreaterThan(0); assertThat(log.responseTimeNanos()).isGreaterThanOrEqualTo(0); assertThat(log.thriftServiceName()).isEqualTo(HelloService.class.getCanonicalName()); assertThat(log.thriftMethodName()).isEqualTo("hello"); final ThriftCall call = log.thriftCall(); assertThat(call.header().name).isEqualTo("hello"); assertThat(call.header().type).isEqualTo(TMessageType.CALL); assertThat(call.args()).isEqualTo(new hello_args().setName("kawamuray")); final ThriftReply reply = log.thriftReply(); assertThat(reply.header().name).isEqualTo("hello"); assertThat(reply.header().type).isEqualTo(TMessageType.REPLY); assertThat(reply.header().seqid).isEqualTo(call.header().seqid); assertThat(reply.result()).isEqualTo(new hello_result().setSuccess("Hello kawamuray")); }
@Override public String toString() { return MoreObjects.toStringHelper(this) .add("timestamp", TextFormatter.epoch(timestampMillis())) .add("responseTime", TextFormatter.elapsed(responseTimeNanos())) .add("requestSize", TextFormatter.size(requestSize())) .add("responseSize", TextFormatter.size(responseSize())) .add("thriftServiceName", thriftServiceName) .add("thriftMethodName", thriftMethodName) .add("thriftCall", thriftCall) .add("thriftReply", thriftReply) .toString(); } }
@Override public String toString() { return MoreObjects.toStringHelper(this) .add("timestamp", TextFormatter.epoch(timestampMillis())) .add("responseTime", TextFormatter.elapsed(responseTimeNanos())) .add("requestSize", TextFormatter.size(requestSize())) .add("responseSize", TextFormatter.size(responseSize())) .add("thriftServiceName", thriftServiceName) .add("thriftMethodName", thriftMethodName) .add("thriftCall", thriftCall) .add("thriftReply", thriftReply) .toString(); } }
@Override public String toString() { return MoreObjects.toStringHelper(this) .add("timestamp", TextFormatter.epoch(timestampMillis())) .add("responseTime", TextFormatter.elapsed(responseTimeNanos())) .add("requestSize", TextFormatter.size(requestSize())) .add("responseSize", TextFormatter.size(responseSize())) .add("thriftServiceName", thriftServiceName) .add("thriftMethodName", thriftMethodName) .add("thriftCall", thriftCall) .add("thriftReply", thriftReply) .toString(); } }