centraldogma icon indicating copy to clipboard operation
centraldogma copied to clipboard

Provide a way to log successful and failed requests

Open ikhoon opened this issue 1 year ago • 2 comments

Motivation:

To diagnose an exception error on the client-side, request logs are important to check request parameters, response duration and application errors.

Modifications:

  • Add RequestLogConfig which can limit the sampling rate, adjust target groups, and set the logging levels.
  • TransientServiceOption.WITH_SERVICE_LOGGING is specified to HealthCheckService or PrometheusExpositionService if METRICS or HEALTH group is defined in RequestLogConfig

Result:

  • Logging configuration example:
    {
      "targetGroups": [ "API", "HEALTH" ],
      "loggerName": "centraldogma.test",
      "requestLogLevel": "DEBUG",
      "successfulResponseLevel": "DEBUG",
      "failureResponseLevel": "ERROR",
      "successSamplingRate": 0.4,
      "failureSamplingRate": 0.6
    }
    
  • Fixes #718

ikhoon avatar Aug 25 '22 01:08 ikhoon

Codecov Report

Merging #719 (5a862e6) into master (f1a1c03) will increase coverage by 0.08%. The diff coverage is 80.00%.

@@             Coverage Diff              @@
##             master     #719      +/-   ##
============================================
+ Coverage     70.31%   70.40%   +0.08%     
- Complexity     3418     3444      +26     
============================================
  Files           349      351       +2     
  Lines         13470    13565      +95     
  Branches       1454     1466      +12     
============================================
+ Hits           9472     9550      +78     
- Misses         3139     3153      +14     
- Partials        859      862       +3     
Impacted Files Coverage Δ
...linecorp/centraldogma/server/RequestLogConfig.java 47.05% <47.05%> (ø)
...com/linecorp/centraldogma/server/CentralDogma.java 79.36% <94.82%> (+1.90%) :arrow_up:
...ecorp/centraldogma/server/CentralDogmaBuilder.java 55.03% <100.00%> (+1.07%) :arrow_up:
...necorp/centraldogma/server/CentralDogmaConfig.java 80.95% <100.00%> (+0.26%) :arrow_up:
.../linecorp/centraldogma/server/RequestLogGroup.java 100.00% <100.00%> (ø)
...server/internal/thrift/CentralDogmaExceptions.java 50.00% <0.00%> (-13.64%) :arrow_down:
...centraldogma/server/internal/api/WatchService.java 76.27% <0.00%> (-3.39%) :arrow_down:
...al/storage/repository/cache/CachingRepository.java 95.31% <0.00%> (+0.78%) :arrow_up:
.../linecorp/centraldogma/client/AbstractWatcher.java 80.00% <0.00%> (+2.66%) :arrow_up:
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Aug 25 '22 01:08 codecov[bot]

  • Could a user specify different logging settings for different target groups? For example, a user might want to lower the log level or rate for WEB but not for API.
  • Can we also add OTHERS, which is used for all other requests?
  • How about categories rather than target groups?

trustin avatar Mar 08 '23 10:03 trustin