Java spring 集成网关请求响应时间记录
Java spring integration gateway request response time logging
我正在使用 spring 集成网关来公开休息服务。它配置了请求通道和回复通道。我正在寻找能给我每次休息操作所需时间的配置。
网关配置如下:
<int:gateway id="testServiceGateway"
service-interface="com.test.ws.TransactionServices"
default-reply-time-out="5000"
error-channel="txErrorChan">
<int:method name="evaluateTransaction"
request-channel="tranRequestChan"
reply-channel="tranResponseChan"
reply-time-out="3000" />
</int:gateway>
例如:我为 kafka-outbound-channel-adapter 使用了自定义请求处理程序建议链。正在为网关寻找类似的东西?
既然你谈到了 REST 调用,你可能会考虑使用 tracing 工具,比如 Spring Cloud Sleuth:https://cloud.spring.io/spring-cloud-static/spring-cloud-sleuth/2.2.2.RELEASE/reference/html/#http-client-integration
虽然对于你这么简单 use-case 我会在调用那个 TransactionServices.evaluateTransaction()
方法之前和之后计算整个调用周期。
您也可以在 Spring Integration - Log time taken for whole file processing 提到的答案中遵循我的建议。因此,您可以在 tranRequestChan
的拦截器中注入 startTime
header 并在 tranResponseChan
.
的拦截器中进行计算
另一种方法是依靠通道或 MessageHandler
s 上的测微计:https://docs.spring.io/spring-integration/docs/current/reference/html/system-management.html#mgmt-channel-features
我正在使用 spring 集成网关来公开休息服务。它配置了请求通道和回复通道。我正在寻找能给我每次休息操作所需时间的配置。
网关配置如下:
<int:gateway id="testServiceGateway"
service-interface="com.test.ws.TransactionServices"
default-reply-time-out="5000"
error-channel="txErrorChan">
<int:method name="evaluateTransaction"
request-channel="tranRequestChan"
reply-channel="tranResponseChan"
reply-time-out="3000" />
</int:gateway>
例如:我为 kafka-outbound-channel-adapter 使用了自定义请求处理程序建议链。正在为网关寻找类似的东西?
既然你谈到了 REST 调用,你可能会考虑使用 tracing 工具,比如 Spring Cloud Sleuth:https://cloud.spring.io/spring-cloud-static/spring-cloud-sleuth/2.2.2.RELEASE/reference/html/#http-client-integration
虽然对于你这么简单 use-case 我会在调用那个 TransactionServices.evaluateTransaction()
方法之前和之后计算整个调用周期。
您也可以在 Spring Integration - Log time taken for whole file processing 提到的答案中遵循我的建议。因此,您可以在 tranRequestChan
的拦截器中注入 startTime
header 并在 tranResponseChan
.
另一种方法是依靠通道或 MessageHandler
s 上的测微计:https://docs.spring.io/spring-integration/docs/current/reference/html/system-management.html#mgmt-channel-features