{"action":"created","comment":{"url":"https://api.github.com/repos/http4s/http4s/pulls/comments/207732046","pull_request_review_id":143406750,"id":207732046,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNzczMjA0Ng==","diff_hunk":"@@ -0,0 +1,71 @@\n+package org.http4s.client.metrics\n+\n+import cats.data.Kleisli\n+import cats.effect._\n+import cats.implicits._\n+import com.codahale.metrics.{Counter, MetricRegistry, Timer}\n+import java.util.concurrent.TimeUnit\n+import org.http4s.{Request, Status}\n+import org.http4s.client.{Client, DisposableResponse}\n+\n+object Metrics {\n+  def apply[F[_]: Sync](registry: MetricRegistry, prefix: String = \"org.http4s.client\")(\n+      client: Client[F]): Client[F] = {\n+\n+    def withMetrics(metrics: MetricsCollection)(req: Request[F]): F[DisposableResponse[F]] =\n+      for {\n+        start <- Sync[F].delay(System.nanoTime())\n+        _ <- Sync[F].delay(metrics.activeRequests.inc())\n+        resp <- client.open(req)\n+        _ <- Sync[F].delay(metrics.activeRequests.dec())\n+        iResp <- Sync[F].delay(instrumentResponse(start, metrics, resp))\n+      } yield iResp\n+\n+    def instrumentResponse(\n+        start: Long,\n+        metrics: MetricsCollection,\n+        disposableResponse: DisposableResponse[F]): DisposableResponse[F] = {\n+      val newDisposable = for {\n+        elapsed <- Sync[F].delay(System.nanoTime() - start)","path":"client-metrics/src/main/scala/org/http4s/client/metrics/Metrics.scala","position":29,"original_position":29,"commit_id":"cb96ff170aa61b753df94f8fac0ac6ed67a1dd88","original_commit_id":"cb96ff170aa61b753df94f8fac0ac6ed67a1dd88","user":{"login":"luisspringernature","id":26115153,"node_id":"MDQ6VXNlcjI2MTE1MTUz","avatar_url":"https://avatars2.githubusercontent.com/u/26115153?v=4","gravatar_id":"","url":"https://api.github.com/users/luisspringernature","html_url":"https://github.com/luisspringernature","followers_url":"https://api.github.com/users/luisspringernature/followers","following_url":"https://api.github.com/users/luisspringernature/following{/other_user}","gists_url":"https://api.github.com/users/luisspringernature/gists{/gist_id}","starred_url":"https://api.github.com/users/luisspringernature/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luisspringernature/subscriptions","organizations_url":"https://api.github.com/users/luisspringernature/orgs","repos_url":"https://api.github.com/users/luisspringernature/repos","events_url":"https://api.github.com/users/luisspringernature/events{/privacy}","received_events_url":"https://api.github.com/users/luisspringernature/received_events","type":"User","site_admin":false},"body":"I thought this will be measuring total time, as it's being recorded when disposing the response...","created_at":"2018-08-05T10:43:33Z","updated_at":"2018-08-05T10:43:33Z","html_url":"https://github.com/http4s/http4s/pull/1974#discussion_r207732046","pull_request_url":"https://api.github.com/repos/http4s/http4s/pulls/1974","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/http4s/http4s/pulls/comments/207732046"},"html":{"href":"https://github.com/http4s/http4s/pull/1974#discussion_r207732046"},"pull_request":{"href":"https://api.github.com/repos/http4s/http4s/pulls/1974"}},"in_reply_to_id":207721866},"pull_request":{"url":"https://api.github.com/repos/http4s/http4s/pulls/1974","id":205968473,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1OTY4NDcz","html_url":"https://github.com/http4s/http4s/pull/1974","diff_url":"https://github.com/http4s/http4s/pull/1974.diff","patch_url":"https://github.com/http4s/http4s/pull/1974.patch","issue_url":"https://api.github.com/repos/http4s/http4s/issues/1974","number":1974,"state":"open","locked":false,"title":"Add client middleware for dropwizard metrics","user":{"login":"luisdeltoro","id":4491204,"node_id":"MDQ6VXNlcjQ0OTEyMDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4491204?v=4","gravatar_id":"","url":"https://api.github.com/users/luisdeltoro","html_url":"https://github.com/luisdeltoro","followers_url":"https://api.github.com/users/luisdeltoro/followers","following_url":"https://api.github.com/users/luisdeltoro/following{/other_user}","gists_url":"https://api.github.com/users/luisdeltoro/gists{/gist_id}","starred_url":"https://api.github.com/users/luisdeltoro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luisdeltoro/subscriptions","organizations_url":"https://api.github.com/users/luisdeltoro/orgs","repos_url":"https://api.github.com/users/luisdeltoro/repos","events_url":"https://api.github.com/users/luisdeltoro/events{/privacy}","received_events_url":"https://api.github.com/users/luisdeltoro/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-08-03T09:03:25Z","updated_at":"2018-08-05T10:43:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"39d76607ccd009771d41f096d9bac5128ee98fcb","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/http4s/http4s/pulls/1974/commits","review_comments_url":"https://api.github.com/repos/http4s/http4s/pulls/1974/comments","review_comment_url":"https://api.github.com/repos/http4s/http4s/pulls/comments{/number}","comments_url":"https://api.github.com/repos/http4s/http4s/issues/1974/comments","statuses_url":"https://api.github.com/repos/http4s/http4s/statuses/cb96ff170aa61b753df94f8fac0ac6ed67a1dd88","head":{"label":"luisdeltoro:dropwizard_client_metrics_#1959","ref":"dropwizard_client_metrics_#1959","sha":"cb96ff170aa61b753df94f8fac0ac6ed67a1dd88","user":{"login":"luisdeltoro","id":4491204,"node_id":"MDQ6VXNlcjQ0OTEyMDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4491204?v=4","gravatar_id":"","url":"https://api.github.com/users/luisdeltoro","html_url":"https://github.com/luisdeltoro","followers_url":"https://api.github.com/users/luisdeltoro/followers","following_url":"https://api.github.com/users/luisdeltoro/following{/other_user}","gists_url":"https://api.github.com/users/luisdeltoro/gists{/gist_id}","starred_url":"https://api.github.com/users/luisdeltoro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luisdeltoro/subscriptions","organizations_url":"https://api.github.com/users/luisdeltoro/orgs","repos_url":"https://api.github.com/users/luisdeltoro/repos","events_url":"https://api.github.com/users/luisdeltoro/events{/privacy}","received_events_url":"https://api.github.com/users/luisdeltoro/received_events","type":"User","site_admin":false},"repo":{"id":138475130,"node_id":"MDEwOlJlcG9zaXRvcnkxMzg0NzUxMzA=","name":"http4s","full_name":"luisdeltoro/http4s","owner":{"login":"luisdeltoro","id":4491204,"node_id":"MDQ6VXNlcjQ0OTEyMDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4491204?v=4","gravatar_id":"","url":"https://api.github.com/users/luisdeltoro","html_url":"https://github.com/luisdeltoro","followers_url":"https://api.github.com/users/luisdeltoro/followers","following_url":"https://api.github.com/users/luisdeltoro/following{/other_user}","gists_url":"https://api.github.com/users/luisdeltoro/gists{/gist_id}","starred_url":"https://api.github.com/users/luisdeltoro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luisdeltoro/subscriptions","organizations_url":"https://api.github.com/users/luisdeltoro/orgs","repos_url":"https://api.github.com/users/luisdeltoro/repos","events_url":"https://api.github.com/users/luisdeltoro/events{/privacy}","received_events_url":"https://api.github.com/users/luisdeltoro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/luisdeltoro/http4s","description":"A minimal, idiomatic Scala interface for HTTP","fork":true,"url":"https://api.github.com/repos/luisdeltoro/http4s","forks_url":"https://api.github.com/repos/luisdeltoro/http4s/forks","keys_url":"https://api.github.com/repos/luisdeltoro/http4s/keys{/key_id}","collaborators_url":"https://api.github.com/repos/luisdeltoro/http4s/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/luisdeltoro/http4s/teams","hooks_url":"https://api.github.com/repos/luisdeltoro/http4s/hooks","issue_events_url":"https://api.github.com/repos/luisdeltoro/http4s/issues/events{/number}","events_url":"https://api.github.com/repos/luisdeltoro/http4s/events","assignees_url":"https://api.github.com/repos/luisdeltoro/http4s/assignees{/user}","branches_url":"https://api.github.com/repos/luisdeltoro/http4s/branches{/branch}","tags_url":"https://api.github.com/repos/luisdeltoro/http4s/tags","blobs_url":"https://api.github.com/repos/luisdeltoro/http4s/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/luisdeltoro/http4s/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/luisdeltoro/http4s/git/refs{/sha}","trees_url":"https://api.github.com/repos/luisdeltoro/http4s/git/trees{/sha}","statuses_url":"https://api.github.com/repos/luisdeltoro/http4s/statuses/{sha}","languages_url":"https://api.github.com/repos/luisdeltoro/http4s/languages","stargazers_url":"https://api.github.com/repos/luisdeltoro/http4s/stargazers","contributors_url":"https://api.github.com/repos/luisdeltoro/http4s/contributors","subscribers_url":"https://api.github.com/repos/luisdeltoro/http4s/subscribers","subscription_url":"https://api.github.com/repos/luisdeltoro/http4s/subscription","commits_url":"https://api.github.com/repos/luisdeltoro/http4s/commits{/sha}","git_commits_url":"https://api.github.com/repos/luisdeltoro/http4s/git/commits{/sha}","comments_url":"https://api.github.com/repos/luisdeltoro/http4s/comments{/number}","issue_comment_url":"https://api.github.com/repos/luisdeltoro/http4s/issues/comments{/number}","contents_url":"https://api.github.com/repos/luisdeltoro/http4s/contents/{+path}","compare_url":"https://api.github.com/repos/luisdeltoro/http4s/compare/{base}...{head}","merges_url":"https://api.github.com/repos/luisdeltoro/http4s/merges","archive_url":"https://api.github.com/repos/luisdeltoro/http4s/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/luisdeltoro/http4s/downloads","issues_url":"https://api.github.com/repos/luisdeltoro/http4s/issues{/number}","pulls_url":"https://api.github.com/repos/luisdeltoro/http4s/pulls{/number}","milestones_url":"https://api.github.com/repos/luisdeltoro/http4s/milestones{/number}","notifications_url":"https://api.github.com/repos/luisdeltoro/http4s/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/luisdeltoro/http4s/labels{/name}","releases_url":"https://api.github.com/repos/luisdeltoro/http4s/releases{/id}","deployments_url":"https://api.github.com/repos/luisdeltoro/http4s/deployments","created_at":"2018-06-24T11:08:47Z","updated_at":"2018-08-03T09:02:18Z","pushed_at":"2018-08-03T09:02:38Z","git_url":"git://github.com/luisdeltoro/http4s.git","ssh_url":"git@github.com:luisdeltoro/http4s.git","clone_url":"https://github.com/luisdeltoro/http4s.git","svn_url":"https://github.com/luisdeltoro/http4s","homepage":"https://http4s.org/","size":125133,"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","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"http4s:master","ref":"master","sha":"0beccf372420af04735b756632c379961224d842","user":{"login":"http4s","id":1527492,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1Mjc0OTI=","avatar_url":"https://avatars3.githubusercontent.com/u/1527492?v=4","gravatar_id":"","url":"https://api.github.com/users/http4s","html_url":"https://github.com/http4s","followers_url":"https://api.github.com/users/http4s/followers","following_url":"https://api.github.com/users/http4s/following{/other_user}","gists_url":"https://api.github.com/users/http4s/gists{/gist_id}","starred_url":"https://api.github.com/users/http4s/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/http4s/subscriptions","organizations_url":"https://api.github.com/users/http4s/orgs","repos_url":"https://api.github.com/users/http4s/repos","events_url":"https://api.github.com/users/http4s/events{/privacy}","received_events_url":"https://api.github.com/users/http4s/received_events","type":"Organization","site_admin":false},"repo":{"id":3692188,"node_id":"MDEwOlJlcG9zaXRvcnkzNjkyMTg4","name":"http4s","full_name":"http4s/http4s","owner":{"login":"http4s","id":1527492,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1Mjc0OTI=","avatar_url":"https://avatars3.githubusercontent.com/u/1527492?v=4","gravatar_id":"","url":"https://api.github.com/users/http4s","html_url":"https://github.com/http4s","followers_url":"https://api.github.com/users/http4s/followers","following_url":"https://api.github.com/users/http4s/following{/other_user}","gists_url":"https://api.github.com/users/http4s/gists{/gist_id}","starred_url":"https://api.github.com/users/http4s/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/http4s/subscriptions","organizations_url":"https://api.github.com/users/http4s/orgs","repos_url":"https://api.github.com/users/http4s/repos","events_url":"https://api.github.com/users/http4s/events{/privacy}","received_events_url":"https://api.github.com/users/http4s/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/http4s/http4s","description":"A minimal, idiomatic Scala interface for HTTP","fork":false,"url":"https://api.github.com/repos/http4s/http4s","forks_url":"https://api.github.com/repos/http4s/http4s/forks","keys_url":"https://api.github.com/repos/http4s/http4s/keys{/key_id}","collaborators_url":"https://api.github.com/repos/http4s/http4s/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/http4s/http4s/teams","hooks_url":"https://api.github.com/repos/http4s/http4s/hooks","issue_events_url":"https://api.github.com/repos/http4s/http4s/issues/events{/number}","events_url":"https://api.github.com/repos/http4s/http4s/events","assignees_url":"https://api.github.com/repos/http4s/http4s/assignees{/user}","branches_url":"https://api.github.com/repos/http4s/http4s/branches{/branch}","tags_url":"https://api.github.com/repos/http4s/http4s/tags","blobs_url":"https://api.github.com/repos/http4s/http4s/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/http4s/http4s/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/http4s/http4s/git/refs{/sha}","trees_url":"https://api.github.com/repos/http4s/http4s/git/trees{/sha}","statuses_url":"https://api.github.com/repos/http4s/http4s/statuses/{sha}","languages_url":"https://api.github.com/repos/http4s/http4s/languages","stargazers_url":"https://api.github.com/repos/http4s/http4s/stargazers","contributors_url":"https://api.github.com/repos/http4s/http4s/contributors","subscribers_url":"https://api.github.com/repos/http4s/http4s/subscribers","subscription_url":"https://api.github.com/repos/http4s/http4s/subscription","commits_url":"https://api.github.com/repos/http4s/http4s/commits{/sha}","git_commits_url":"https://api.github.com/repos/http4s/http4s/git/commits{/sha}","comments_url":"https://api.github.com/repos/http4s/http4s/comments{/number}","issue_comment_url":"https://api.github.com/repos/http4s/http4s/issues/comments{/number}","contents_url":"https://api.github.com/repos/http4s/http4s/contents/{+path}","compare_url":"https://api.github.com/repos/http4s/http4s/compare/{base}...{head}","merges_url":"https://api.github.com/repos/http4s/http4s/merges","archive_url":"https://api.github.com/repos/http4s/http4s/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/http4s/http4s/downloads","issues_url":"https://api.github.com/repos/http4s/http4s/issues{/number}","pulls_url":"https://api.github.com/repos/http4s/http4s/pulls{/number}","milestones_url":"https://api.github.com/repos/http4s/http4s/milestones{/number}","notifications_url":"https://api.github.com/repos/http4s/http4s/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/http4s/http4s/labels{/name}","releases_url":"https://api.github.com/repos/http4s/http4s/releases{/id}","deployments_url":"https://api.github.com/repos/http4s/http4s/deployments","created_at":"2012-03-12T04:41:20Z","updated_at":"2018-08-04T13:57:04Z","pushed_at":"2018-08-04T18:23:26Z","git_url":"git://github.com/http4s/http4s.git","ssh_url":"git@github.com:http4s/http4s.git","clone_url":"https://github.com/http4s/http4s.git","svn_url":"https://github.com/http4s/http4s","homepage":"https://http4s.org/","size":127272,"stargazers_count":1142,"watchers_count":1142,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":317,"mirror_url":null,"archived":false,"open_issues_count":143,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":317,"open_issues":143,"watchers":1142,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/http4s/http4s/pulls/1974"},"html":{"href":"https://github.com/http4s/http4s/pull/1974"},"issue":{"href":"https://api.github.com/repos/http4s/http4s/issues/1974"},"comments":{"href":"https://api.github.com/repos/http4s/http4s/issues/1974/comments"},"review_comments":{"href":"https://api.github.com/repos/http4s/http4s/pulls/1974/comments"},"review_comment":{"href":"https://api.github.com/repos/http4s/http4s/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/http4s/http4s/pulls/1974/commits"},"statuses":{"href":"https://api.github.com/repos/http4s/http4s/statuses/cb96ff170aa61b753df94f8fac0ac6ed67a1dd88"}},"author_association":"NONE"}}
{"actor":{"display_login":"luisspringernature"}}