Zuul访问日志在发送请求和记录响应之间存在延迟

时间:2019-02-04 15:54:25

标签: netflix-zuul

使用Zuul作为网关,并且除了访问日志中的响应时间以外,它始终按预期方式工作,并且始终保持相同的值,并且似乎没有任何影响时间的因素。添加了Thread.sleep()来查看是否可以增加时间,但是没有运气(这只是看时间是否会改变)。

通过邮递员发布请求时,JSON响应很快(在3秒内),但是此响应返回与随后被登录到项目访问日志之间的时间始终是相同的值。

使用Spring-cloud-sleuth进行日志记录。

下面是获取日志消息的示例。

0:0:0:0:0:0:0:1 - - [04/Feb/2019:15:40:19 +0000] "GET /api/product-data/product/4541 HTTP/1.1" 200 21160
0:0:0:0:0:0:0:1 - - [04/Feb/2019:15:13:58 +0000] "GET /api/product-data/product/4541 HTTP/1.1" 500 820
0:0:0:0:0:0:0:1 - - [04/Feb/2019:15:14:16 +0000] "GET /api/product-data/product/4541 HTTP/1.1" 200 21160
0:0:0:0:0:0:0:1 - - [04/Feb/2019:15:17:02 +0000] "GET /api/product-data/product/4541 HTTP/1.1" 500 820

应用示例。YML

spring:


profiles: dev
  cloud:
    gateway:
      discovery:
        locator:
          enabled: true
          lower-case-service-id: true

eureka:
  instance:
    metadata-map:
      user.name: test
      user.password: test
    leaseRenewalIntervalInSeconds: 60
    health-check-url-path: /actuator/health
    hostname: localhost
  client:
    registryFetchIntervalSeconds: 30
    serviceUrl:
      defaultZone: ${EUREKA_SERVICE_URL:http://system:Ph03bus_1@localhost:8761}/eureka/
  ribbon:
    ConnectTimeout: 100000
    SocketTimeout: 100000
    ReadTimeout: 100000

zuul:
  prefix: /api

ribbon:
  ConnectTimeout: 100000
  SocketTimeout: 100000
  ReadTimeout: 100000

server:
  port: ${PORT:8080}
  tomcat:
    accesslog:
      enabled: true
      directory: access-logs
    basedir: logs

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS
logging:
  path: logs
  file: logs/gateway.log

0 个答案:

没有答案