Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
hexiaofeng committed Jan 23, 2025
2 parents 7baa4d7 + 8b6ef95 commit 8d202af
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.jd.live.agent.demo.response.LiveTrace;
import com.jd.live.agent.demo.response.LiveTransmission;
import com.jd.live.agent.demo.springcloud.v2021.provider.config.EchoConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

Expand All @@ -34,6 +36,8 @@ public class EchoController {

private final EchoConfig config;

private final static Logger logger = LoggerFactory.getLogger(EchoController.class);

@Value("${echo.suffix}")
private String echoSuffix;

Expand All @@ -56,6 +60,9 @@ public LiveResponse echo(@PathVariable String str, HttpServletRequest request) {
}
LiveResponse response = new LiveResponse(echoSuffix == null ? str : str + echoSuffix);
configure(request, response);
if (logger.isInfoEnabled()) {
logger.info("echo str: {}, time: {}", str, System.currentTimeMillis());
}
return response;
}

Expand All @@ -64,6 +71,9 @@ public LiveResponse status(@PathVariable int code, HttpServletRequest request, H
response.setStatus(code);
LiveResponse lr = new LiveResponse(code, null, code);
configure(request, lr);
if (logger.isInfoEnabled()) {
logger.info("status code: {}, time: {}", code, System.currentTimeMillis());
}
return lr;
}

Expand All @@ -79,11 +89,17 @@ public LiveResponse sleep(@PathVariable int millis, HttpServletRequest request,

@RequestMapping(value = "/exception", method = {RequestMethod.GET, RequestMethod.PUT, RequestMethod.POST})
public LiveResponse exception(HttpServletRequest request, HttpServletResponse response) {
if (logger.isInfoEnabled()) {
logger.info("exception at time: {}", System.currentTimeMillis());
}
throw new RuntimeException("RuntimeException happened!");
}

@RequestMapping(value = "/state/{code}", method = {RequestMethod.GET, RequestMethod.PUT, RequestMethod.POST})
public String state(@PathVariable int code, HttpServletRequest request, HttpServletResponse response) throws InterruptedException {
if (logger.isInfoEnabled()) {
logger.info("state code: {}, time: {}", code, System.currentTimeMillis());
}
if (code <= 0) {
throw new RuntimeException("RuntimeException happened!");
}
Expand Down

0 comments on commit 8d202af

Please sign in to comment.