{"action":"created","issue":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-sleuth/issues/714","repository_url":"https://api.github.com/repos/spring-cloud/spring-cloud-sleuth","labels_url":"https://api.github.com/repos/spring-cloud/spring-cloud-sleuth/issues/714/labels{/name}","comments_url":"https://api.github.com/repos/spring-cloud/spring-cloud-sleuth/issues/714/comments","events_url":"https://api.github.com/repos/spring-cloud/spring-cloud-sleuth/issues/714/events","html_url":"https://github.com/spring-cloud/spring-cloud-sleuth/issues/714","id":260783957,"number":714,"title":"Exceptions that escape SpringMVC DispatcherServlet should be logged with trace & span IDs","user":{"login":"jfuerth","id":673927,"avatar_url":"https://avatars2.githubusercontent.com/u/673927?v=4","gravatar_id":"","url":"https://api.github.com/users/jfuerth","html_url":"https://github.com/jfuerth","followers_url":"https://api.github.com/users/jfuerth/followers","following_url":"https://api.github.com/users/jfuerth/following{/other_user}","gists_url":"https://api.github.com/users/jfuerth/gists{/gist_id}","starred_url":"https://api.github.com/users/jfuerth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfuerth/subscriptions","organizations_url":"https://api.github.com/users/jfuerth/orgs","repos_url":"https://api.github.com/users/jfuerth/repos","events_url":"https://api.github.com/users/jfuerth/events{/privacy}","received_events_url":"https://api.github.com/users/jfuerth/received_events","type":"User","site_admin":false},"labels":[{"id":184100570,"url":"https://api.github.com/repos/spring-cloud/spring-cloud-sleuth/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":{"login":"marcingrzejszczak","id":3297437,"avatar_url":"https://avatars0.githubusercontent.com/u/3297437?v=4","gravatar_id":"","url":"https://api.github.com/users/marcingrzejszczak","html_url":"https://github.com/marcingrzejszczak","followers_url":"https://api.github.com/users/marcingrzejszczak/followers","following_url":"https://api.github.com/users/marcingrzejszczak/following{/other_user}","gists_url":"https://api.github.com/users/marcingrzejszczak/gists{/gist_id}","starred_url":"https://api.github.com/users/marcingrzejszczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcingrzejszczak/subscriptions","organizations_url":"https://api.github.com/users/marcingrzejszczak/orgs","repos_url":"https://api.github.com/users/marcingrzejszczak/repos","events_url":"https://api.github.com/users/marcingrzejszczak/events{/privacy}","received_events_url":"https://api.github.com/users/marcingrzejszczak/received_events","type":"User","site_admin":false},"assignees":[{"login":"marcingrzejszczak","id":3297437,"avatar_url":"https://avatars0.githubusercontent.com/u/3297437?v=4","gravatar_id":"","url":"https://api.github.com/users/marcingrzejszczak","html_url":"https://github.com/marcingrzejszczak","followers_url":"https://api.github.com/users/marcingrzejszczak/followers","following_url":"https://api.github.com/users/marcingrzejszczak/following{/other_user}","gists_url":"https://api.github.com/users/marcingrzejszczak/gists{/gist_id}","starred_url":"https://api.github.com/users/marcingrzejszczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcingrzejszczak/subscriptions","organizations_url":"https://api.github.com/users/marcingrzejszczak/orgs","repos_url":"https://api.github.com/users/marcingrzejszczak/repos","events_url":"https://api.github.com/users/marcingrzejszczak/events{/privacy}","received_events_url":"https://api.github.com/users/marcingrzejszczak/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-sleuth/milestones/36","html_url":"https://github.com/spring-cloud/spring-cloud-sleuth/milestone/36","labels_url":"https://api.github.com/repos/spring-cloud/spring-cloud-sleuth/milestones/36/labels","id":2861318,"number":36,"title":"1.3.0.RELEASE","description":"","creator":{"login":"marcingrzejszczak","id":3297437,"avatar_url":"https://avatars0.githubusercontent.com/u/3297437?v=4","gravatar_id":"","url":"https://api.github.com/users/marcingrzejszczak","html_url":"https://github.com/marcingrzejszczak","followers_url":"https://api.github.com/users/marcingrzejszczak/followers","following_url":"https://api.github.com/users/marcingrzejszczak/following{/other_user}","gists_url":"https://api.github.com/users/marcingrzejszczak/gists{/gist_id}","starred_url":"https://api.github.com/users/marcingrzejszczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcingrzejszczak/subscriptions","organizations_url":"https://api.github.com/users/marcingrzejszczak/orgs","repos_url":"https://api.github.com/users/marcingrzejszczak/repos","events_url":"https://api.github.com/users/marcingrzejszczak/events{/privacy}","received_events_url":"https://api.github.com/users/marcingrzejszczak/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":9,"state":"closed","created_at":"2017-10-24T06:23:32Z","updated_at":"2017-11-22T14:42:40Z","due_on":null,"closed_at":"2017-11-22T14:42:40Z"},"comments":3,"created_at":"2017-09-26T22:00:41Z","updated_at":"2018-02-03T22:45:10Z","closed_at":"2017-11-03T21:37:07Z","author_association":"NONE","body":"Hi,\r\n\r\nWe are re-raising the issue reported in #579 and #542 because we've tried the suggested solution of handling and logging all the errors ourselves, but we have yet to land on a workable solution.\r\n\r\nWe tried adding a method like this to our global ControllerAdvice bean:\r\n\r\n```\r\n    @ExceptionHandler(Exception.class)\r\n    ResponseEntity<ErrorPayload> otherwiseUnhandledException(Exception e) {\r\n        log.error(\"Unexpected exception occurred. Will return HTTP 500.\", e);\r\n        return new ResponseEntity<>(new ErrorPayload(e.getMessage(), \"\"), INTERNAL_SERVER_ERROR);\r\n    }\r\n```\r\n\r\nThe error is logged with the correct trace and span IDs (great!) but the killer side effect is that all the internal Spring MVC exceptions that do nice things like return 400 on missing mandatory by our ExceptionHandler method and thus return HTTP 500 to our clients.\r\n\r\nWe also experimented with registering our own `BasicErrorController` bean based on the callout box in the docs linked from #579 (https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-error-handling). We see that it is getting instantiated, but its `onError` method is not getting called for our failing JSON API requests:\r\n\r\n```\r\n@Slf4j\r\n@Controller\r\npublic class MyErrorController extends BasicErrorController {\r\n\r\n    public MyErrorController(ErrorAttributes errorAttributes) {\r\n        super(errorAttributes, new ErrorProperties());\r\n        log.info(\"Created error controller with errorAttributes {}\", errorAttributes);\r\n    }\r\n\r\n    @RequestMapping(produces = \"application/json\")\r\n    public ErrorPayload onError() {\r\n        log.error(\"KABOOM!\");\r\n        return new ErrorPayload(\"Something broke (TODO: resolve actual exception)\", \"????\");\r\n    }\r\n}\r\n```\r\n\r\nWe'd really appreciate any advice you can offer on how to preserve Spring MVC's default response codes while also including the Sleuth trace and span IDs in the MDC.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-sleuth/issues/comments/362861609","html_url":"https://github.com/spring-cloud/spring-cloud-sleuth/issues/714#issuecomment-362861609","issue_url":"https://api.github.com/repos/spring-cloud/spring-cloud-sleuth/issues/714","id":362861609,"user":{"login":"brenuart","id":3028601,"avatar_url":"https://avatars3.githubusercontent.com/u/3028601?v=4","gravatar_id":"","url":"https://api.github.com/users/brenuart","html_url":"https://github.com/brenuart","followers_url":"https://api.github.com/users/brenuart/followers","following_url":"https://api.github.com/users/brenuart/following{/other_user}","gists_url":"https://api.github.com/users/brenuart/gists{/gist_id}","starred_url":"https://api.github.com/users/brenuart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brenuart/subscriptions","organizations_url":"https://api.github.com/users/brenuart/orgs","repos_url":"https://api.github.com/users/brenuart/repos","events_url":"https://api.github.com/users/brenuart/events{/privacy}","received_events_url":"https://api.github.com/users/brenuart/received_events","type":"User","site_admin":false},"created_at":"2018-02-03T22:45:10Z","updated_at":"2018-02-03T22:45:10Z","author_association":"NONE","body":"> But the Tomcat Valve is not traced isn't it?\r\n\r\nNot sure I understand your question... If that's what you mean, I confirm the exception stack trace logged by Tomcat is *NOT* traced (reason why you decided to log it first inside the TraceFilter).\r\n\r\n> can you show an example of using the `javax.servlet.ServletRequestListener` ?\r\n\r\nI had a look at the TraceFilter code and honestly it looks quite complex and I still don't understand why and when a Span must be started/closed/detached/suspended/etc.\r\n\r\nIt's your comment saying you would have to leave stuff on the ThreadLocal until the end of the request but don't know how to clean it after that made me think about the ServletRequestListener. I posted to share ideas...\r\n\r\nI don't have enough Sleuth knowledge for this task I'm afraid - but I would be glad to help if you give me some more explanation about the TraceFilter internals!"}}
{"actor":{"display_login":"brenuart"}}