Merge branch 'MSP-7358' into 'main'

Resolve MSP-7391

Closes MSP-7391

See merge request isp/isp-gate-service!32
This commit is contained in:
Синельник Тимур Романович committed 2026-03-24 17:40:16 +03:00
commit c523d2347d
5 files changed
+20 -5

No files matched your search

+1 -1
View File
@@ -1 +1 @@
5.9.1
5.9.2
+3
View File
@@ -1,3 +1,6 @@
### v5.9.2
* При проверке `logging.skipBodyLoggingEndpointPrefixes` игнорируется `/` в начале, путь для проверки берётся из `pathSchema`, если `pathSchema` пустая, берётся вызываемый `endpoint`
* В логе `log request` из значения в поле `endpoint` удаляется `/` в начале, путь берётся из `pathSchema`, если `pathSchema` пустая, берётся вызываемый `endpoint`
### v5.9.1
* Добавлен `warn` лог на неизвестный endpoint
### v5.9.0
+7 -1
View File
@@ -2,6 +2,7 @@ package assembly
import (
"net/http"
"strings"
"time"
"github.com/txix-open/isp-kit/metrics"
@@ -72,6 +73,11 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
dailyLimitService := service.NewDailyLimit(lockRepo, config.DailyLimits)
throttlingService := service.NewThrottling(lockRepo, config.Throttling)
skipBodyLoggingEndpointPrefixes := make([]string, 0, len(config.Logging.SkipBodyLoggingEndpointPrefixes))
for _, prefix := range config.Logging.SkipBodyLoggingEndpointPrefixes {
skipBodyLoggingEndpointPrefixes = append(skipBodyLoggingEndpointPrefixes, strings.TrimPrefix(prefix, "/"))
}
mux := mux2.NewRouter()
for _, location := range locations {
var proxyFunc middleware.Handler
@@ -126,7 +132,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
proxyFunc,
middleware.Logger(l.logger, config.Logging.RequestLogEnable,
enableBodyLog,
config.Logging.SkipBodyLoggingEndpointPrefixes,
skipBodyLoggingEndpointPrefixes,
config.Logging.EnableForceUnescapingUnicode,
),
middleware.RequestId(),
+1 -1
View File
@@ -40,7 +40,7 @@ type Logging struct {
LogLevel log.Level `schemaGen:"logLevel" schema:"Уровень логирования,логирование запросов осуществляется на уровне debug"`
RequestLogEnable bool `schema:"Включить логирование запросов"`
BodyLogEnable bool `schema:"Включить логирование тел запросов и ответов,должно быть включено логирование запросов"`
SkipBodyLoggingEndpointPrefixes []string `schema:"регулярные выражения для отключения логирования"`
SkipBodyLoggingEndpointPrefixes []string `schema:"Выключить логирование тел запросов и ответов для путей имеющих префикс из списка,'/' в начале игнорируется"`
EnableForceUnescapingUnicode bool `schema:"Включить перевод тел запроса из unicode в utf-8, должно быть включено логирование тел запросов и ответов"`
}
+8 -2
View File
@@ -65,10 +65,16 @@ func Logger( // nolint:gocognit,funlen
r := ctx.Request()
endpoint := ctx.EndpointMeta().Endpoint
if ctx.EndpointMeta().PathSchema != "" {
endpoint = ctx.EndpointMeta().PathSchema
}
strings.TrimPrefix(endpoint, "/")
logBodyFromCurrenRequest := enableBodyLogging
if logBodyFromCurrenRequest {
for _, prefix := range skipBodyLoggingEndpointPrefixes {
if strings.HasPrefix(ctx.EndpointMeta().Endpoint, prefix) {
if strings.HasPrefix(endpoint, prefix) {
logBodyFromCurrenRequest = false
break
}
@@ -110,7 +116,7 @@ func Logger( // nolint:gocognit,funlen
log.String("xForwardedFor", r.Header.Get("X-Forwarded-For")),
log.Int("statusCode", scSrc.StatusCode()),
log.String("path", originalPath),
log.String("endpoint", ctx.EndpointMeta().Endpoint),
log.String("endpoint", endpoint),
log.Int("applicationId", authData.ApplicationId),
log.String("applicationName", authData.AppName),
log.Int("adminId", ctx.AdminId()),