line / armeria

Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
https://armeria.dev
Apache License 2.0
4.82k stars 919 forks source link

Provide a way to customize time unit for `Logging{Service,Client}` #3312

Open ikhoon opened 3 years ago

ikhoon commented 3 years ago

A nanosecond and microsecondare used a default time unit for LoggingService and LoggingClient.

INFO c.l.a.s.l.LoggingService - [sreqId=...][h1c://foo.com/foo#GET] Request: ... duration=45446µs(45446187ns), scheme=none+h1c, user-agent=Mozilla/5.0...]}
INFO c.l.a.s.l.LoggingService - [sreqId=...][h1c://foo.com/foo#GET] Response: ... duration=16875µs(16875233ns), totalDuration=54124µs(54124177ns), headers=[...]}

Some users may want to use a millisecond or second unit for readabiliy. For example:

LoggingService.builder()
              .timeUnit(TimeUnit.MILLISECONDS)
              // or
              .timeUnit(TimeUnit.SECODNS, /* precision */ 6)
              ...
              .build()

INFO c.l.a.s.l.LoggingService - [sreqId=...][h1c://foo.com/foo#GET] Request: ... duration=45.446ms(45446187ns), scheme=none+h1c, user-agent=Mozilla/5.0...]}
INFO c.l.a.s.l.LoggingService - [sreqId=...][h1c://foo.com/foo#GET] Response: ... duration=16.875ms(16875233ns), totalDuration=54124µs(54124177ns), headers=[...]}
trustin commented 3 years ago

We may want to introduce a generic text formatter interface that replaces the static TextFormatter.

tomatophobia commented 1 year ago

Hi @ikhoon, if this issue is still ongoing, may I handle it?

ikhoon commented 1 year ago

4267 adds a new interface to customize the log format. I'm happy with your interest. However, I recommend you start this issue after #4267 is merged to minimize conflicts.

tomatophobia commented 1 year ago

Thanks for checking 👍 That might resolve this issue as well. I will try it after #4267 is merged, if the issue is still present. Thanks again!