{"action":"created","issue":{"url":"https://api.github.com/repos/openzipkin-contrib/brave-opentracing/issues/76","repository_url":"https://api.github.com/repos/openzipkin-contrib/brave-opentracing","labels_url":"https://api.github.com/repos/openzipkin-contrib/brave-opentracing/issues/76/labels{/name}","comments_url":"https://api.github.com/repos/openzipkin-contrib/brave-opentracing/issues/76/comments","events_url":"https://api.github.com/repos/openzipkin-contrib/brave-opentracing/issues/76/events","html_url":"https://github.com/openzipkin-contrib/brave-opentracing/issues/76","id":315962509,"number":76,"title":"Behavior of  BraveScopeManager.active()","user":{"login":"tutufool","id":1931469,"avatar_url":"https://avatars1.githubusercontent.com/u/1931469?v=4","gravatar_id":"","url":"https://api.github.com/users/tutufool","html_url":"https://github.com/tutufool","followers_url":"https://api.github.com/users/tutufool/followers","following_url":"https://api.github.com/users/tutufool/following{/other_user}","gists_url":"https://api.github.com/users/tutufool/gists{/gist_id}","starred_url":"https://api.github.com/users/tutufool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tutufool/subscriptions","organizations_url":"https://api.github.com/users/tutufool/orgs","repos_url":"https://api.github.com/users/tutufool/repos","events_url":"https://api.github.com/users/tutufool/events{/privacy}","received_events_url":"https://api.github.com/users/tutufool/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-04-19T17:02:36Z","updated_at":"2018-04-23T05:13:11Z","closed_at":null,"author_association":"NONE","body":"Hi, \r\n\r\nI'm not quite sure this is an issue, since I don't know where is a better place to ask question :)\r\n\r\nIn BraveScopeManager:\r\n\r\n```\r\n  BraveSpan currentSpan() {\r\n    BraveScope scope = currentScopes.get().pollFirst(); --- not sure if it should be peekFirst()?\r\n    if (scope != null) {\r\n      return scope.span();\r\n    } else {\r\n      brave.Span braveSpan = tracer.currentSpan();\r\n      if (braveSpan != null) {\r\n        return new BraveSpan(tracer, braveSpan, BraveSpan.EMPTY_ENDPOINT);\r\n      }\r\n    }\r\n    return null;\r\n  }\r\n```\r\n\r\nIf I call active() multiple times, only the first call benefits from currentScopes.get().\r\nOthers will lead to new BraveSpan() creation.\r\n\r\n(I guess the only reason that we have currentScopes is to avoid object creation, considering the fact that CurrentTraceContext already handle threadlocal things)\r\n\r\nAlso,  maybe LinkedList is more efficient than ArrayDeque when do stack push/pop.\r\n\r\n\r\n\r\n\r\nThanks\r\n\r\nLeon\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/openzipkin-contrib/brave-opentracing/issues/comments/383456269","html_url":"https://github.com/openzipkin-contrib/brave-opentracing/issues/76#issuecomment-383456269","issue_url":"https://api.github.com/repos/openzipkin-contrib/brave-opentracing/issues/76","id":383456269,"user":{"login":"tutufool","id":1931469,"avatar_url":"https://avatars1.githubusercontent.com/u/1931469?v=4","gravatar_id":"","url":"https://api.github.com/users/tutufool","html_url":"https://github.com/tutufool","followers_url":"https://api.github.com/users/tutufool/followers","following_url":"https://api.github.com/users/tutufool/following{/other_user}","gists_url":"https://api.github.com/users/tutufool/gists{/gist_id}","starred_url":"https://api.github.com/users/tutufool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tutufool/subscriptions","organizations_url":"https://api.github.com/users/tutufool/orgs","repos_url":"https://api.github.com/users/tutufool/repos","events_url":"https://api.github.com/users/tutufool/events{/privacy}","received_events_url":"https://api.github.com/users/tutufool/received_events","type":"User","site_admin":false},"created_at":"2018-04-23T05:13:11Z","updated_at":"2018-04-23T05:13:11Z","author_association":"NONE","body":"By \"adding a flag\", do you suggest to allow user to control the \"action against abnormal operation\" by providing some configuration?\r\n\r\nFor example, a configurable flag/enum can be passed to BraveScopeManager via BraveTracer.Builder.\r\nSo user can enforce different behavior for Dev/QA/Prod.\r\n\r\nAnd the deregsiter could be something like:\r\n\r\n```\r\n  void deregister(BraveScope span) {\r\n\tDeque<BraveScope> scopeStack = currentScopes.get();\r\n\tif(span.equals(scopeStack.peekFirst())){\r\n\t\tscopeStack.pollFirst();\r\n\t}else {\r\n\t\tif(suppressBadOperation){\r\n                    //log with FINE level\r\n                }else{\r\n                    //throw exception \r\n                }\r\n\t}\r\n    \r\n  }\r\n\r\n\r\n```\r\n\r\nI can submit another PR for this change if we're on the same page.\r\n\r\n"}}
{"actor":{"display_login":"tutufool"}}