{"action":"created","comment":{"url":"https://api.github.com/repos/getnelson/nelson/pulls/comments/185702102","pull_request_review_id":117142968,"id":185702102,"diff_hunk":"@@ -156,13 +159,17 @@ object Metrics {\n   /*\n    * Perform a timed operation with configurable handlers.\n    */\n-  def timer(before: Task[Unit], onComplete: Kleisli[Task, Double, Unit], onFail: Kleisli[Task, Throwable, Unit], onSuccess: Task[Unit]) = new (Task ~> Task) {\n-    def apply[A](op: Task[A]) : Task[A] = (for {\n-      _ <- before\n-      start <- Task.delay(System.nanoTime())\n-      a <- op\n-      elapsed = (System.nanoTime - start) / 1.0e9\n-      _ <- onComplete.run(elapsed)\n-    } yield a).onFinish(_.cata(onFail.run, onSuccess))\n+  def timer(before: IO[Unit], onComplete: Kleisli[IO, Double, Unit], onFail: Kleisli[IO, Throwable, Unit], onSuccess: IO[Unit]) = new (IO ~> IO) {\n+    def apply[A](op: IO[A]) : IO[A] = {\n+      val io = for {\n+        _       <- before\n+        start   <- IO(System.nanoTime())\n+        a       <- op\n+        elapsed = (System.nanoTime - start) / 1.0e9\n+        _       <- onComplete.run(elapsed)\n+      } yield a\n+\n+      (io <* onSuccess).onError { case err => onFail(err) }","path":"core/src/main/scala/Metrics.scala","position":38,"original_position":38,"commit_id":"65463b531165687eb53a6cfc4d27f5c75902f243","original_commit_id":"6f6755227a9b9040234b6969ff4d42d076ee6241","user":{"login":"adelbertc","id":1332980,"avatar_url":"https://avatars2.githubusercontent.com/u/1332980?v=4","gravatar_id":"","url":"https://api.github.com/users/adelbertc","html_url":"https://github.com/adelbertc","followers_url":"https://api.github.com/users/adelbertc/followers","following_url":"https://api.github.com/users/adelbertc/following{/other_user}","gists_url":"https://api.github.com/users/adelbertc/gists{/gist_id}","starred_url":"https://api.github.com/users/adelbertc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adelbertc/subscriptions","organizations_url":"https://api.github.com/users/adelbertc/orgs","repos_url":"https://api.github.com/users/adelbertc/repos","events_url":"https://api.github.com/users/adelbertc/events{/privacy}","received_events_url":"https://api.github.com/users/adelbertc/received_events","type":"User","site_admin":false},"body":"`onError` is from `ApplicativeError`: https://github.com/typelevel/cats/blob/master/core/src/main/scala/cats/ApplicativeError.scala#L99-L128\r\n\r\nI believe the use here is primarily convenience, we just want to run a handler and then give back the original result. Could do it with `handleErrorWith` with some dancing about. I also wonder if it might be better to just do something like:\r\n\r\n```scala\r\nio.attempt.flatMap {\r\n  case Left(e) => onFail(e) *> IO.raiseError(e)\r\n  case Right(a) => onSuccess(a) *> IO.pure(a)\r\n}\r\n```\r\n\r\nAs far as I know this is what the Scalaz equivalent of `onFinish` was doing: https://github.com/scalaz/scalaz/blob/series/7.3.x/concurrent/src/main/scala/scalaz/concurrent/Task.scala#L50-L61\r\n\r\nI'm also now wondering why it isn't just implemented the way I did above..","created_at":"2018-05-03T06:00:51Z","updated_at":"2018-05-03T06:00:52Z","html_url":"https://github.com/getnelson/nelson/pull/64#discussion_r185702102","pull_request_url":"https://api.github.com/repos/getnelson/nelson/pulls/64","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/getnelson/nelson/pulls/comments/185702102"},"html":{"href":"https://github.com/getnelson/nelson/pull/64#discussion_r185702102"},"pull_request":{"href":"https://api.github.com/repos/getnelson/nelson/pulls/64"}},"in_reply_to_id":169499582},"pull_request":{"url":"https://api.github.com/repos/getnelson/nelson/pulls/64","id":169868918,"html_url":"https://github.com/getnelson/nelson/pull/64","diff_url":"https://github.com/getnelson/nelson/pull/64.diff","patch_url":"https://github.com/getnelson/nelson/pull/64.patch","issue_url":"https://api.github.com/repos/getnelson/nelson/issues/64","number":64,"state":"closed","locked":false,"title":"s/scalaz.concurrent.Task/cats.effect.IO, s/scalaz.stream.Process/fs2.Stream","user":{"login":"adelbertc","id":1332980,"avatar_url":"https://avatars2.githubusercontent.com/u/1332980?v=4","gravatar_id":"","url":"https://api.github.com/users/adelbertc","html_url":"https://github.com/adelbertc","followers_url":"https://api.github.com/users/adelbertc/followers","following_url":"https://api.github.com/users/adelbertc/following{/other_user}","gists_url":"https://api.github.com/users/adelbertc/gists{/gist_id}","starred_url":"https://api.github.com/users/adelbertc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adelbertc/subscriptions","organizations_url":"https://api.github.com/users/adelbertc/orgs","repos_url":"https://api.github.com/users/adelbertc/repos","events_url":"https://api.github.com/users/adelbertc/events{/privacy}","received_events_url":"https://api.github.com/users/adelbertc/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-19T02:42:48Z","updated_at":"2018-05-03T06:00:52Z","closed_at":"2018-05-02T15:55:22Z","merged_at":"2018-05-02T15:55:22Z","merge_commit_sha":"797beaac2e85fee444ecd461b5c51ab6d568fe63","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/getnelson/nelson/pulls/64/commits","review_comments_url":"https://api.github.com/repos/getnelson/nelson/pulls/64/comments","review_comment_url":"https://api.github.com/repos/getnelson/nelson/pulls/comments{/number}","comments_url":"https://api.github.com/repos/getnelson/nelson/issues/64/comments","statuses_url":"https://api.github.com/repos/getnelson/nelson/statuses/65463b531165687eb53a6cfc4d27f5c75902f243","head":{"label":"adelbertc:catsify","ref":"catsify","sha":"65463b531165687eb53a6cfc4d27f5c75902f243","user":{"login":"adelbertc","id":1332980,"avatar_url":"https://avatars2.githubusercontent.com/u/1332980?v=4","gravatar_id":"","url":"https://api.github.com/users/adelbertc","html_url":"https://github.com/adelbertc","followers_url":"https://api.github.com/users/adelbertc/followers","following_url":"https://api.github.com/users/adelbertc/following{/other_user}","gists_url":"https://api.github.com/users/adelbertc/gists{/gist_id}","starred_url":"https://api.github.com/users/adelbertc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adelbertc/subscriptions","organizations_url":"https://api.github.com/users/adelbertc/orgs","repos_url":"https://api.github.com/users/adelbertc/repos","events_url":"https://api.github.com/users/adelbertc/events{/privacy}","received_events_url":"https://api.github.com/users/adelbertc/received_events","type":"User","site_admin":false},"repo":{"id":112286045,"name":"nelson","full_name":"adelbertc/nelson","owner":{"login":"adelbertc","id":1332980,"avatar_url":"https://avatars2.githubusercontent.com/u/1332980?v=4","gravatar_id":"","url":"https://api.github.com/users/adelbertc","html_url":"https://github.com/adelbertc","followers_url":"https://api.github.com/users/adelbertc/followers","following_url":"https://api.github.com/users/adelbertc/following{/other_user}","gists_url":"https://api.github.com/users/adelbertc/gists{/gist_id}","starred_url":"https://api.github.com/users/adelbertc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adelbertc/subscriptions","organizations_url":"https://api.github.com/users/adelbertc/orgs","repos_url":"https://api.github.com/users/adelbertc/repos","events_url":"https://api.github.com/users/adelbertc/events{/privacy}","received_events_url":"https://api.github.com/users/adelbertc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adelbertc/nelson","description":"Automated, multi-region container deployment","fork":true,"url":"https://api.github.com/repos/adelbertc/nelson","forks_url":"https://api.github.com/repos/adelbertc/nelson/forks","keys_url":"https://api.github.com/repos/adelbertc/nelson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adelbertc/nelson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adelbertc/nelson/teams","hooks_url":"https://api.github.com/repos/adelbertc/nelson/hooks","issue_events_url":"https://api.github.com/repos/adelbertc/nelson/issues/events{/number}","events_url":"https://api.github.com/repos/adelbertc/nelson/events","assignees_url":"https://api.github.com/repos/adelbertc/nelson/assignees{/user}","branches_url":"https://api.github.com/repos/adelbertc/nelson/branches{/branch}","tags_url":"https://api.github.com/repos/adelbertc/nelson/tags","blobs_url":"https://api.github.com/repos/adelbertc/nelson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adelbertc/nelson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adelbertc/nelson/git/refs{/sha}","trees_url":"https://api.github.com/repos/adelbertc/nelson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adelbertc/nelson/statuses/{sha}","languages_url":"https://api.github.com/repos/adelbertc/nelson/languages","stargazers_url":"https://api.github.com/repos/adelbertc/nelson/stargazers","contributors_url":"https://api.github.com/repos/adelbertc/nelson/contributors","subscribers_url":"https://api.github.com/repos/adelbertc/nelson/subscribers","subscription_url":"https://api.github.com/repos/adelbertc/nelson/subscription","commits_url":"https://api.github.com/repos/adelbertc/nelson/commits{/sha}","git_commits_url":"https://api.github.com/repos/adelbertc/nelson/git/commits{/sha}","comments_url":"https://api.github.com/repos/adelbertc/nelson/comments{/number}","issue_comment_url":"https://api.github.com/repos/adelbertc/nelson/issues/comments{/number}","contents_url":"https://api.github.com/repos/adelbertc/nelson/contents/{+path}","compare_url":"https://api.github.com/repos/adelbertc/nelson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adelbertc/nelson/merges","archive_url":"https://api.github.com/repos/adelbertc/nelson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adelbertc/nelson/downloads","issues_url":"https://api.github.com/repos/adelbertc/nelson/issues{/number}","pulls_url":"https://api.github.com/repos/adelbertc/nelson/pulls{/number}","milestones_url":"https://api.github.com/repos/adelbertc/nelson/milestones{/number}","notifications_url":"https://api.github.com/repos/adelbertc/nelson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adelbertc/nelson/labels{/name}","releases_url":"https://api.github.com/repos/adelbertc/nelson/releases{/id}","deployments_url":"https://api.github.com/repos/adelbertc/nelson/deployments","created_at":"2017-11-28T04:32:39Z","updated_at":"2017-11-28T04:32:41Z","pushed_at":"2018-05-03T04:16:21Z","git_url":"git://github.com/adelbertc/nelson.git","ssh_url":"git@github.com:adelbertc/nelson.git","clone_url":"https://github.com/adelbertc/nelson.git","svn_url":"https://github.com/adelbertc/nelson","homepage":"https://verizon.github.io/nelson/","size":3670,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"getnelson:master","ref":"master","sha":"cb51d8b6c286d762c82ffacc3dbf5ed5cf444ed1","user":{"login":"getnelson","id":34355038,"avatar_url":"https://avatars1.githubusercontent.com/u/34355038?v=4","gravatar_id":"","url":"https://api.github.com/users/getnelson","html_url":"https://github.com/getnelson","followers_url":"https://api.github.com/users/getnelson/followers","following_url":"https://api.github.com/users/getnelson/following{/other_user}","gists_url":"https://api.github.com/users/getnelson/gists{/gist_id}","starred_url":"https://api.github.com/users/getnelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getnelson/subscriptions","organizations_url":"https://api.github.com/users/getnelson/orgs","repos_url":"https://api.github.com/users/getnelson/repos","events_url":"https://api.github.com/users/getnelson/events{/privacy}","received_events_url":"https://api.github.com/users/getnelson/received_events","type":"Organization","site_admin":false},"repo":{"id":94270374,"name":"nelson","full_name":"getnelson/nelson","owner":{"login":"getnelson","id":34355038,"avatar_url":"https://avatars1.githubusercontent.com/u/34355038?v=4","gravatar_id":"","url":"https://api.github.com/users/getnelson","html_url":"https://github.com/getnelson","followers_url":"https://api.github.com/users/getnelson/followers","following_url":"https://api.github.com/users/getnelson/following{/other_user}","gists_url":"https://api.github.com/users/getnelson/gists{/gist_id}","starred_url":"https://api.github.com/users/getnelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getnelson/subscriptions","organizations_url":"https://api.github.com/users/getnelson/orgs","repos_url":"https://api.github.com/users/getnelson/repos","events_url":"https://api.github.com/users/getnelson/events{/privacy}","received_events_url":"https://api.github.com/users/getnelson/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/getnelson/nelson","description":"Automated, multi-region container deployment","fork":false,"url":"https://api.github.com/repos/getnelson/nelson","forks_url":"https://api.github.com/repos/getnelson/nelson/forks","keys_url":"https://api.github.com/repos/getnelson/nelson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/getnelson/nelson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/getnelson/nelson/teams","hooks_url":"https://api.github.com/repos/getnelson/nelson/hooks","issue_events_url":"https://api.github.com/repos/getnelson/nelson/issues/events{/number}","events_url":"https://api.github.com/repos/getnelson/nelson/events","assignees_url":"https://api.github.com/repos/getnelson/nelson/assignees{/user}","branches_url":"https://api.github.com/repos/getnelson/nelson/branches{/branch}","tags_url":"https://api.github.com/repos/getnelson/nelson/tags","blobs_url":"https://api.github.com/repos/getnelson/nelson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/getnelson/nelson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/getnelson/nelson/git/refs{/sha}","trees_url":"https://api.github.com/repos/getnelson/nelson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/getnelson/nelson/statuses/{sha}","languages_url":"https://api.github.com/repos/getnelson/nelson/languages","stargazers_url":"https://api.github.com/repos/getnelson/nelson/stargazers","contributors_url":"https://api.github.com/repos/getnelson/nelson/contributors","subscribers_url":"https://api.github.com/repos/getnelson/nelson/subscribers","subscription_url":"https://api.github.com/repos/getnelson/nelson/subscription","commits_url":"https://api.github.com/repos/getnelson/nelson/commits{/sha}","git_commits_url":"https://api.github.com/repos/getnelson/nelson/git/commits{/sha}","comments_url":"https://api.github.com/repos/getnelson/nelson/comments{/number}","issue_comment_url":"https://api.github.com/repos/getnelson/nelson/issues/comments{/number}","contents_url":"https://api.github.com/repos/getnelson/nelson/contents/{+path}","compare_url":"https://api.github.com/repos/getnelson/nelson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/getnelson/nelson/merges","archive_url":"https://api.github.com/repos/getnelson/nelson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/getnelson/nelson/downloads","issues_url":"https://api.github.com/repos/getnelson/nelson/issues{/number}","pulls_url":"https://api.github.com/repos/getnelson/nelson/pulls{/number}","milestones_url":"https://api.github.com/repos/getnelson/nelson/milestones{/number}","notifications_url":"https://api.github.com/repos/getnelson/nelson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/getnelson/nelson/labels{/name}","releases_url":"https://api.github.com/repos/getnelson/nelson/releases{/id}","deployments_url":"https://api.github.com/repos/getnelson/nelson/deployments","created_at":"2017-06-14T00:23:03Z","updated_at":"2018-05-03T04:16:20Z","pushed_at":"2018-05-03T04:16:17Z","git_url":"git://github.com/getnelson/nelson.git","ssh_url":"git@github.com:getnelson/nelson.git","clone_url":"https://github.com/getnelson/nelson.git","svn_url":"https://github.com/getnelson/nelson","homepage":"https://getnelson.github.io/nelson/","size":4348,"stargazers_count":198,"watchers_count":198,"language":"Scala","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":25,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":25,"open_issues":9,"watchers":198,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/getnelson/nelson/pulls/64"},"html":{"href":"https://github.com/getnelson/nelson/pull/64"},"issue":{"href":"https://api.github.com/repos/getnelson/nelson/issues/64"},"comments":{"href":"https://api.github.com/repos/getnelson/nelson/issues/64/comments"},"review_comments":{"href":"https://api.github.com/repos/getnelson/nelson/pulls/64/comments"},"review_comment":{"href":"https://api.github.com/repos/getnelson/nelson/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/getnelson/nelson/pulls/64/commits"},"statuses":{"href":"https://api.github.com/repos/getnelson/nelson/statuses/65463b531165687eb53a6cfc4d27f5c75902f243"}},"author_association":"OWNER"}}
{"actor":{"display_login":"adelbertc"}}