polish logging
This commit is contained in:
@@ -51,7 +51,7 @@ public class RouteToRequestUrlFilter implements GlobalFilter, Ordered {
|
||||
if (route == null) {
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
log.info("RouteToRequestUrlFilter start");
|
||||
log.trace("RouteToRequestUrlFilter start");
|
||||
URI requestUrl = UriComponentsBuilder.fromHttpRequest(exchange.getRequest())
|
||||
.uri(route.getUri())
|
||||
.build(true)
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -57,7 +58,7 @@ public class RedisRateLimiter implements RateLimiter {
|
||||
Instant.now().getEpochSecond() + "", "1");
|
||||
// allowed, tokens_left = redis.eval(SCRIPT, keys, args)
|
||||
Flux<Long> flux = this.redisTemplate.execute(this.script, keys, args)
|
||||
.log("redisratelimiter");
|
||||
.log("redisratelimiter", Level.FINER);
|
||||
return flux.onErrorResume(throwable -> Flux.just(1L, -1L))
|
||||
.reduce(new ArrayList<Long>(), (longs, l) -> {
|
||||
longs.add(l);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.springframework.cloud.gateway.handler;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.springframework.cloud.gateway.route.Route;
|
||||
import org.springframework.cloud.gateway.route.RouteLocator;
|
||||
@@ -49,7 +50,7 @@ public class RoutePredicateHandlerMapping extends AbstractHandlerMapping {
|
||||
exchange.getAttributes().put(GATEWAY_HANDLER_MAPPER_ATTR, getClass().getSimpleName());
|
||||
|
||||
return lookupRoute(exchange)
|
||||
.log() //name this
|
||||
.log("route-predicate-handler-mapping", Level.FINER) //name this
|
||||
.flatMap((Function<Route, Mono<?>>) r -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Mapping [" + getExchangeDesc(exchange) + "] to " + r);
|
||||
|
||||
@@ -10,15 +10,24 @@ local requested = tonumber(ARGV[4])
|
||||
local fill_time = capacity/rate
|
||||
local ttl = math.floor(fill_time*2)
|
||||
|
||||
--redis.log(redis.LOG_WARNING, "rate " .. ARGV[1])
|
||||
--redis.log(redis.LOG_WARNING, "capacity " .. ARGV[2])
|
||||
--redis.log(redis.LOG_WARNING, "now " .. ARGV[3])
|
||||
--redis.log(redis.LOG_WARNING, "requested " .. ARGV[4])
|
||||
--redis.log(redis.LOG_WARNING, "filltime " .. fill_time)
|
||||
--redis.log(redis.LOG_WARNING, "ttl " .. ttl)
|
||||
|
||||
local last_tokens = tonumber(redis.call("get", tokens_key))
|
||||
if last_tokens == nil then
|
||||
last_tokens = capacity
|
||||
end
|
||||
--redis.log(redis.LOG_WARNING, "last_tokens " .. last_tokens)
|
||||
|
||||
local last_refreshed = tonumber(redis.call("get", timestamp_key))
|
||||
if last_refreshed == nil then
|
||||
last_refreshed = 0
|
||||
end
|
||||
--redis.log(redis.LOG_WARNING, "last_refreshed " .. last_refreshed)
|
||||
|
||||
local delta = math.max(0, now-last_refreshed)
|
||||
local filled_tokens = math.min(capacity, last_tokens+(delta*rate))
|
||||
@@ -30,6 +39,11 @@ if allowed then
|
||||
allowed_num = 1
|
||||
end
|
||||
|
||||
--redis.log(redis.LOG_WARNING, "delta " .. delta)
|
||||
--redis.log(redis.LOG_WARNING, "filled_tokens " .. filled_tokens)
|
||||
--redis.log(redis.LOG_WARNING, "allowed_num " .. allowed_num)
|
||||
--redis.log(redis.LOG_WARNING, "new_tokens " .. new_tokens)
|
||||
|
||||
redis.call("setex", tokens_key, ttl, new_tokens)
|
||||
redis.call("setex", timestamp_key, ttl, now)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user