{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/comments/194846793","pull_request_review_id":128094477,"id":194846793,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NDg0Njc5Mw==","diff_hunk":"@@ -50,35 +72,111 @@ public void AddSessionListener(IProfilerSessionListener listener)\n         /// <summary>\n         /// Start monitoring the provided sessions\n         /// </summary>\n-        public bool StartMonitoringSession(ProfilerSession session)\n+        public bool StartMonitoringSession(string viewerID, IXEventSession session)\n         {\n             lock (this.sessionsLock)\n             {\n-                // start the monitoring thread \n+                // start the monitoring thread\n                 if (this.processorThread == null)\n                 {\n-                    this.processorThread = Task.Factory.StartNew(ProcessSessions);;\n+                    this.processorThread = Task.Factory.StartNew(ProcessSessions);\n+                }\n+\n+                // create new profiling session if needed\n+                if (!this.monitoredSessions.ContainsKey(session.ID))\n+                {\n+                    var profilerSession = new ProfilerSession();\n+                    profilerSession.XEventSession = session;\n+\n+                    this.monitoredSessions.Add(session.ID, profilerSession);\n                 }\n \n-                if (!this.monitoredSessions.ContainsKey(session.SessionId))\n+                // create a new viewer, or configure existing viewer\n+                Viewer viewer;\n+                if(!this.allViewers.TryGetValue(viewerID, out viewer))\n                 {\n-                    this.monitoredSessions.Add(session.SessionId, session);\n+                    viewer = new Viewer(viewerID, true, session.ID);\n+                    allViewers.Add(viewerID, viewer);\n+                }\n+                else\n+                {\n+                    viewer.active = true;\n+                    viewer.xeSessionID = session.ID;\n+                }\n+\n+                // add viewer to XEvent session viewers\n+                List<string> viewers;\n+                if(this.sessionViewers.TryGetValue(session.ID, out viewers))\n+                {\n+                    viewers.Add(viewerID);\n+                }\n+                else\n+                {\n+                    viewers = new List<string>{ viewerID };\n+                    sessionViewers.Add(session.ID, viewers);\n                 }\n             }\n \n             return true;\n         }\n \n+        // TODO: Clean this up\n+        /// <summary>\n+        /// Stop monitoring the session watched by viewerID\n+        /// </summary>\n+        public bool StopMonitoringSession(string viewerID, out ProfilerSession session)\n+        {\n+            lock (this.sessionsLock)\n+            {\n+                Viewer v;\n+                if(this.allViewers.TryGetValue(viewerID, out v))\n+                {\n+                    return RemoveSession(v.xeSessionID, out session);\n+                }\n+                else\n+                {\n+                    session = null;\n+                    return false;\n+                }\n+            }\n+        }\n+\n         /// <summary>\n-        /// Stop monitoring the session specified by the sessionId\n+        /// Toggle the pause state for the viewer\n         /// </summary>\n-        public bool StopMonitoringSession(string sessionId, out ProfilerSession session)\n+        public void PauseViewer(string viewerID)\n         {\n+\n             lock (this.sessionsLock)\n             {\n-                if (this.monitoredSessions.ContainsKey(sessionId))\n+                //update the status in all viewers\n+                Viewer v = this.allViewers[viewerID];\n+                this.allViewers[viewerID] = new Viewer(viewerID, !v.active, v.xeSessionID);","path":"src/Microsoft.SqlTools.ServiceLayer/Profiler/ProfilerSessionMonitor.cs","position":133,"original_position":133,"commit_id":"85ea599f78ca657d2da244e73616907dd89a8bf3","original_commit_id":"85ea599f78ca657d2da244e73616907dd89a8bf3","user":{"login":"MattIrv","id":3758704,"node_id":"MDQ6VXNlcjM3NTg3MDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/3758704?v=4","gravatar_id":"","url":"https://api.github.com/users/MattIrv","html_url":"https://github.com/MattIrv","followers_url":"https://api.github.com/users/MattIrv/followers","following_url":"https://api.github.com/users/MattIrv/following{/other_user}","gists_url":"https://api.github.com/users/MattIrv/gists{/gist_id}","starred_url":"https://api.github.com/users/MattIrv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattIrv/subscriptions","organizations_url":"https://api.github.com/users/MattIrv/orgs","repos_url":"https://api.github.com/users/MattIrv/repos","events_url":"https://api.github.com/users/MattIrv/events{/privacy}","received_events_url":"https://api.github.com/users/MattIrv/received_events","type":"User","site_admin":false},"body":"Is this just updating `v`'s `active` property? Why not do it directly instead of creating a new `Viewer`?","created_at":"2018-06-12T18:38:22Z","updated_at":"2018-06-12T18:54:50Z","html_url":"https://github.com/Microsoft/sqltoolsservice/pull/634#discussion_r194846793","pull_request_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/634","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/comments/194846793"},"html":{"href":"https://github.com/Microsoft/sqltoolsservice/pull/634#discussion_r194846793"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/634"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/634","id":194360002,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk0MzYwMDAy","html_url":"https://github.com/Microsoft/sqltoolsservice/pull/634","diff_url":"https://github.com/Microsoft/sqltoolsservice/pull/634.diff","patch_url":"https://github.com/Microsoft/sqltoolsservice/pull/634.patch","issue_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/issues/634","number":634,"state":"open","locked":false,"title":"Adding pausing functionality for the profiler","user":{"login":"madelinemacd","id":21250175,"node_id":"MDQ6VXNlcjIxMjUwMTc1","avatar_url":"https://avatars1.githubusercontent.com/u/21250175?v=4","gravatar_id":"","url":"https://api.github.com/users/madelinemacd","html_url":"https://github.com/madelinemacd","followers_url":"https://api.github.com/users/madelinemacd/followers","following_url":"https://api.github.com/users/madelinemacd/following{/other_user}","gists_url":"https://api.github.com/users/madelinemacd/gists{/gist_id}","starred_url":"https://api.github.com/users/madelinemacd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madelinemacd/subscriptions","organizations_url":"https://api.github.com/users/madelinemacd/orgs","repos_url":"https://api.github.com/users/madelinemacd/repos","events_url":"https://api.github.com/users/madelinemacd/events{/privacy}","received_events_url":"https://api.github.com/users/madelinemacd/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-12T17:54:49Z","updated_at":"2018-06-12T18:54:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"850f3c343e99647ff3d5eca7321080c811c8ba76","assignee":null,"assignees":[],"requested_reviewers":[{"login":"kburtram","id":599935,"node_id":"MDQ6VXNlcjU5OTkzNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/599935?v=4","gravatar_id":"","url":"https://api.github.com/users/kburtram","html_url":"https://github.com/kburtram","followers_url":"https://api.github.com/users/kburtram/followers","following_url":"https://api.github.com/users/kburtram/following{/other_user}","gists_url":"https://api.github.com/users/kburtram/gists{/gist_id}","starred_url":"https://api.github.com/users/kburtram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kburtram/subscriptions","organizations_url":"https://api.github.com/users/kburtram/orgs","repos_url":"https://api.github.com/users/kburtram/repos","events_url":"https://api.github.com/users/kburtram/events{/privacy}","received_events_url":"https://api.github.com/users/kburtram/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/634/commits","review_comments_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/634/comments","review_comment_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/issues/634/comments","statuses_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/statuses/85ea599f78ca657d2da244e73616907dd89a8bf3","head":{"label":"Microsoft:feature/profilerToolbar","ref":"feature/profilerToolbar","sha":"85ea599f78ca657d2da244e73616907dd89a8bf3","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":63441273,"node_id":"MDEwOlJlcG9zaXRvcnk2MzQ0MTI3Mw==","name":"sqltoolsservice","full_name":"Microsoft/sqltoolsservice","owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/sqltoolsservice","description":"SQL Tools API service that provides SQL Server data management capabilities.","fork":false,"url":"https://api.github.com/repos/Microsoft/sqltoolsservice","forks_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/forks","keys_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/teams","hooks_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/events","assignees_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/tags","blobs_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/languages","stargazers_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/subscription","commits_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/merges","archive_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/downloads","issues_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/deployments","created_at":"2016-07-15T18:00:16Z","updated_at":"2018-06-11T23:32:49Z","pushed_at":"2018-06-12T17:54:49Z","git_url":"git://github.com/Microsoft/sqltoolsservice.git","ssh_url":"git@github.com:Microsoft/sqltoolsservice.git","clone_url":"https://github.com/Microsoft/sqltoolsservice.git","svn_url":"https://github.com/Microsoft/sqltoolsservice","homepage":"","size":119395,"stargazers_count":140,"watchers_count":140,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":34,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":34,"open_issues":11,"watchers":140,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"7c1f78a67866cda27181967470ebb79816fe7f1e","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":63441273,"node_id":"MDEwOlJlcG9zaXRvcnk2MzQ0MTI3Mw==","name":"sqltoolsservice","full_name":"Microsoft/sqltoolsservice","owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/sqltoolsservice","description":"SQL Tools API service that provides SQL Server data management capabilities.","fork":false,"url":"https://api.github.com/repos/Microsoft/sqltoolsservice","forks_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/forks","keys_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/teams","hooks_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/events","assignees_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/tags","blobs_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/languages","stargazers_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/subscription","commits_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/merges","archive_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/downloads","issues_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/sqltoolsservice/deployments","created_at":"2016-07-15T18:00:16Z","updated_at":"2018-06-11T23:32:49Z","pushed_at":"2018-06-12T17:54:49Z","git_url":"git://github.com/Microsoft/sqltoolsservice.git","ssh_url":"git@github.com:Microsoft/sqltoolsservice.git","clone_url":"https://github.com/Microsoft/sqltoolsservice.git","svn_url":"https://github.com/Microsoft/sqltoolsservice","homepage":"","size":119395,"stargazers_count":140,"watchers_count":140,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":34,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":34,"open_issues":11,"watchers":140,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/634"},"html":{"href":"https://github.com/Microsoft/sqltoolsservice/pull/634"},"issue":{"href":"https://api.github.com/repos/Microsoft/sqltoolsservice/issues/634"},"comments":{"href":"https://api.github.com/repos/Microsoft/sqltoolsservice/issues/634/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/634/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/sqltoolsservice/pulls/634/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/sqltoolsservice/statuses/85ea599f78ca657d2da244e73616907dd89a8bf3"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"MattIrv"}}