{"action":"opened","issue":{"url":"https://api.github.com/repos/naver/pinpoint/issues/4903","repository_url":"https://api.github.com/repos/naver/pinpoint","labels_url":"https://api.github.com/repos/naver/pinpoint/issues/4903/labels{/name}","comments_url":"https://api.github.com/repos/naver/pinpoint/issues/4903/comments","events_url":"https://api.github.com/repos/naver/pinpoint/issues/4903/events","html_url":"https://github.com/naver/pinpoint/issues/4903","id":383689951,"node_id":"MDU6SXNzdWUzODM2ODk5NTE=","number":4903,"title":"I got two exceptions when I add some features in before() and after() method","user":{"login":"ganpengyu","id":18089371,"node_id":"MDQ6VXNlcjE4MDg5Mzcx","avatar_url":"https://avatars0.githubusercontent.com/u/18089371?v=4","gravatar_id":"","url":"https://api.github.com/users/ganpengyu","html_url":"https://github.com/ganpengyu","followers_url":"https://api.github.com/users/ganpengyu/followers","following_url":"https://api.github.com/users/ganpengyu/following{/other_user}","gists_url":"https://api.github.com/users/ganpengyu/gists{/gist_id}","starred_url":"https://api.github.com/users/ganpengyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ganpengyu/subscriptions","organizations_url":"https://api.github.com/users/ganpengyu/orgs","repos_url":"https://api.github.com/users/ganpengyu/repos","events_url":"https://api.github.com/users/ganpengyu/events{/privacy}","received_events_url":"https://api.github.com/users/ganpengyu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-23T02:48:50Z","updated_at":"2018-11-23T02:48:50Z","closed_at":null,"author_association":"NONE","body":"I only need to collect the request that carries the specified parameters. When I add the following code to the before() and after() methods of the class `com.navercorp.pinpoint.plugin.tomcat.interceptor.StandardHostValveInvokeInterceptor` in Tomcat plugin：\r\n\r\n```java\r\nif (!trace.canSampled()) {\r\n    // .....\r\n    return;\r\n}\r\n//  code I added begin\r\nfinal HttpServletRequest request = (HttpServletRequest) args[0];\r\nString tag = request.getHeader(\"isNeeded\");\r\nif (StringUtils.isEmpty(tag) && trace.isRoot()) {\r\n    return;\r\n}\r\n//  code I added end\r\ntry {\r\n} catch () {\r\n} finally {\r\n}\r\n```\r\nThe above code indicates that if this is a Root request but does not carry the specified Header, then I will not collect it.\r\n\r\nThe Agent log will always have two exceptions, one is `not empty call stack`, another is `already closed trace`.\r\n\r\nHow should I avoid these two exceptions?"}}
{"actor":{"display_login":"ganpengyu"}}