{"action":"created","comment":{"url":"https://api.github.com/repos/twitter/finagle/pulls/comments/65571089","id":65571089,"diff_hunk":"@@ -0,0 +1,159 @@\n+package com.twitter.finagle.zipkin.core\n+\n+import com.twitter.finagle.tracing.{TraceId, Record, Tracer, Annotation, Trace}\n+import com.twitter.io.Buf\n+import com.twitter.util.events.Event\n+import com.twitter.util.events.Sink\n+import com.twitter.util.{Time, Throw, Try}\n+import scala.util.control.NoStackTrace\n+\n+private object Json {\n+  import com.fasterxml.jackson.annotation.{JsonTypeInfo, JsonInclude}\n+  import com.fasterxml.jackson.core.`type`.TypeReference\n+  import com.fasterxml.jackson.databind.{ObjectMapper, JavaType, JsonNode}\n+  import com.fasterxml.jackson.databind.annotation.JsonDeserialize\n+  import com.fasterxml.jackson.module.scala.DefaultScalaModule\n+  import java.lang.reflect.{Type, ParameterizedType}\n+\n+  // Note: This type is a just a convenience for deserialization in other\n+  // other Event.Type constructions, but we actually require it for Trace\n+  // because we're using Jackson's default typing mechanism for Annotation.\n+  // If we use a Map, somewhere in Jackson's type resolution the type of\n+  // Annotation is forgotten, and it is passed into the type resolver as an\n+  // Object. Defining this Envelope preserves the type information.\n+  @JsonInclude(JsonInclude.Include.NON_NULL)\n+  case class Envelope(\n+                       id: String,\n+                       when: Long,\n+                       // We require an annotation here, because for small numbers, this gets\n+                       // deserialized with a runtime type of int.\n+                       // See: https://github.com/FasterXML/jackson-module-scala/issues/106.\n+                       @JsonDeserialize(contentAs=classOf[java.lang.Long]) traceId: Option[Long],\n+                       @JsonDeserialize(contentAs=classOf[java.lang.Long]) spanId: Option[Long],\n+                       data: Annotation)\n+\n+  val mapper = new ObjectMapper()\n+  mapper.registerModule(DefaultScalaModule)\n+\n+  // Configures the mapper to include class information for Annotation.\n+  object TypeResolverBuilder\n+    extends ObjectMapper.DefaultTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL) {\n+    override def useForType(typ: JavaType) =\n+    // Note: getRawClass would be an Object if not for `Envelope`.\n+      typ.getRawClass == classOf[Annotation]\n+  }\n+\n+  mapper.setDefaultTyping(\n+    TypeResolverBuilder\n+      .init(JsonTypeInfo.Id.CLASS, null)\n+      .inclusion(JsonTypeInfo.As.WRAPPER_ARRAY))\n+\n+  def serialize(o: AnyRef): String = mapper.writeValueAsString(o)\n+\n+  def deserialize[T: Manifest](value: String): T =\n+    mapper.readValue(value, typeReference[T])\n+\n+  def deserialize[T: Manifest](node: JsonNode): T =\n+    mapper.readValue(node.traverse, typeReference[T])\n+\n+  private[this] def typeReference[T: Manifest] = new TypeReference[T] {\n+    override def getType = typeFromManifest(manifest[T])\n+  }\n+\n+  private[this] def typeFromManifest(m: Manifest[_]): Type =\n+    if (m.typeArguments.isEmpty) m.runtimeClass else new ParameterizedType {\n+      def getRawType = m.runtimeClass\n+      def getActualTypeArguments = m.typeArguments.map(typeFromManifest).toArray\n+      def getOwnerType = null\n+    }\n+}\n+\n+object SamplingTracer {","path":"finagle-zipkin-core/src/main/scala/com/twitter/finagle/zipkin/core/SamplingTracer.scala","position":71,"original_position":71,"commit_id":"bbc135d36ab3084ba5c732d8339cc861fc6c2286","original_commit_id":"bbc135d36ab3084ba5c732d8339cc861fc6c2286","user":{"login":"kevinoliver","id":347229,"avatar_url":"https://avatars.githubusercontent.com/u/347229?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinoliver","html_url":"https://github.com/kevinoliver","followers_url":"https://api.github.com/users/kevinoliver/followers","following_url":"https://api.github.com/users/kevinoliver/following{/other_user}","gists_url":"https://api.github.com/users/kevinoliver/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinoliver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinoliver/subscriptions","organizations_url":"https://api.github.com/users/kevinoliver/orgs","repos_url":"https://api.github.com/users/kevinoliver/repos","events_url":"https://api.github.com/users/kevinoliver/events{/privacy}","received_events_url":"https://api.github.com/users/kevinoliver/received_events","type":"User","site_admin":false},"body":"ditto re breaking change.","created_at":"2016-06-02T16:16:02Z","updated_at":"2016-06-02T16:16:02Z","html_url":"https://github.com/twitter/finagle/pull/513#discussion_r65571089","pull_request_url":"https://api.github.com/repos/twitter/finagle/pulls/513","_links":{"self":{"href":"https://api.github.com/repos/twitter/finagle/pulls/comments/65571089"},"html":{"href":"https://github.com/twitter/finagle/pull/513#discussion_r65571089"},"pull_request":{"href":"https://api.github.com/repos/twitter/finagle/pulls/513"}}},"pull_request":{"url":"https://api.github.com/repos/twitter/finagle/pulls/513","id":72046753,"html_url":"https://github.com/twitter/finagle/pull/513","diff_url":"https://github.com/twitter/finagle/pull/513.diff","patch_url":"https://github.com/twitter/finagle/pull/513.patch","issue_url":"https://api.github.com/repos/twitter/finagle/issues/513","number":513,"state":"open","locked":false,"title":"Extract transport agnostic zipkin code into finagle-zipkin-core","user":{"login":"sveinnfannar","id":751254,"avatar_url":"https://avatars.githubusercontent.com/u/751254?v=3","gravatar_id":"","url":"https://api.github.com/users/sveinnfannar","html_url":"https://github.com/sveinnfannar","followers_url":"https://api.github.com/users/sveinnfannar/followers","following_url":"https://api.github.com/users/sveinnfannar/following{/other_user}","gists_url":"https://api.github.com/users/sveinnfannar/gists{/gist_id}","starred_url":"https://api.github.com/users/sveinnfannar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sveinnfannar/subscriptions","organizations_url":"https://api.github.com/users/sveinnfannar/orgs","repos_url":"https://api.github.com/users/sveinnfannar/repos","events_url":"https://api.github.com/users/sveinnfannar/events{/privacy}","received_events_url":"https://api.github.com/users/sveinnfannar/received_events","type":"User","site_admin":false},"body":"Problem\r\n\r\nAddress issue https://github.com/twitter/finagle/issues/465 (Add http and kafka transports to zipkin-tracer).\r\nZipkin can receive traces via Kafka, HTTP and Scribe. Some Finagle users (including Quizup) already using Kafka are reluctant to introduce Scribe into their stack as it is no longer maintained.\r\nSo the purpose of this PR is to support Kafka as a transport for Zipkin traces, as well as structuring the code such that it allows other transports to be added (like HTTP).\r\n\r\n\r\nSolution\r\n\r\nExtract most of finagle-zipkin into finagle-zipkin-core, leaving finagle-zipkin with only scribe specific stuff (with no api breaking changes to finagle-zipkin of course). ~~Then implement finagle-zipkin-kafka, which depends on finagle-zipkin-core~~. Kafka transport will be introduced in a separate PR.\r\n\r\nThis structure was initially suggested by @kevinoliver in https://github.com/twitter/finagle/issues/465#issuecomment-183012155. \r\n\r\n\r\nTodo\r\n\r\n - [x] Extract common code into finagle-zipkin-core (largest part)\r\n - [ ] ~~Implement finagle-zipkin-kafka (in progress)~~ (separate PR)\r\n - [x] Clean up Pants and SBT dependencies\r\n\r\n\r\nQuestions\r\n\r\n@mosesn can you check this out and provide some feedback?\r\n@adriancole is this in line with what you had envisioned?","created_at":"2016-05-31T16:32:39Z","updated_at":"2016-06-02T16:16:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02c7909bb2b72212c64c614018d828e03eca29f4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/twitter/finagle/pulls/513/commits","review_comments_url":"https://api.github.com/repos/twitter/finagle/pulls/513/comments","review_comment_url":"https://api.github.com/repos/twitter/finagle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/twitter/finagle/issues/513/comments","statuses_url":"https://api.github.com/repos/twitter/finagle/statuses/bbc135d36ab3084ba5c732d8339cc861fc6c2286","head":{"label":"sveinnfannar:develop","ref":"develop","sha":"bbc135d36ab3084ba5c732d8339cc861fc6c2286","user":{"login":"sveinnfannar","id":751254,"avatar_url":"https://avatars.githubusercontent.com/u/751254?v=3","gravatar_id":"","url":"https://api.github.com/users/sveinnfannar","html_url":"https://github.com/sveinnfannar","followers_url":"https://api.github.com/users/sveinnfannar/followers","following_url":"https://api.github.com/users/sveinnfannar/following{/other_user}","gists_url":"https://api.github.com/users/sveinnfannar/gists{/gist_id}","starred_url":"https://api.github.com/users/sveinnfannar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sveinnfannar/subscriptions","organizations_url":"https://api.github.com/users/sveinnfannar/orgs","repos_url":"https://api.github.com/users/sveinnfannar/repos","events_url":"https://api.github.com/users/sveinnfannar/events{/privacy}","received_events_url":"https://api.github.com/users/sveinnfannar/received_events","type":"User","site_admin":false},"repo":{"id":60018403,"name":"finagle","full_name":"sveinnfannar/finagle","owner":{"login":"sveinnfannar","id":751254,"avatar_url":"https://avatars.githubusercontent.com/u/751254?v=3","gravatar_id":"","url":"https://api.github.com/users/sveinnfannar","html_url":"https://github.com/sveinnfannar","followers_url":"https://api.github.com/users/sveinnfannar/followers","following_url":"https://api.github.com/users/sveinnfannar/following{/other_user}","gists_url":"https://api.github.com/users/sveinnfannar/gists{/gist_id}","starred_url":"https://api.github.com/users/sveinnfannar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sveinnfannar/subscriptions","organizations_url":"https://api.github.com/users/sveinnfannar/orgs","repos_url":"https://api.github.com/users/sveinnfannar/repos","events_url":"https://api.github.com/users/sveinnfannar/events{/privacy}","received_events_url":"https://api.github.com/users/sveinnfannar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sveinnfannar/finagle","description":"A fault tolerant, protocol-agnostic RPC system","fork":true,"url":"https://api.github.com/repos/sveinnfannar/finagle","forks_url":"https://api.github.com/repos/sveinnfannar/finagle/forks","keys_url":"https://api.github.com/repos/sveinnfannar/finagle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sveinnfannar/finagle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sveinnfannar/finagle/teams","hooks_url":"https://api.github.com/repos/sveinnfannar/finagle/hooks","issue_events_url":"https://api.github.com/repos/sveinnfannar/finagle/issues/events{/number}","events_url":"https://api.github.com/repos/sveinnfannar/finagle/events","assignees_url":"https://api.github.com/repos/sveinnfannar/finagle/assignees{/user}","branches_url":"https://api.github.com/repos/sveinnfannar/finagle/branches{/branch}","tags_url":"https://api.github.com/repos/sveinnfannar/finagle/tags","blobs_url":"https://api.github.com/repos/sveinnfannar/finagle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sveinnfannar/finagle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sveinnfannar/finagle/git/refs{/sha}","trees_url":"https://api.github.com/repos/sveinnfannar/finagle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sveinnfannar/finagle/statuses/{sha}","languages_url":"https://api.github.com/repos/sveinnfannar/finagle/languages","stargazers_url":"https://api.github.com/repos/sveinnfannar/finagle/stargazers","contributors_url":"https://api.github.com/repos/sveinnfannar/finagle/contributors","subscribers_url":"https://api.github.com/repos/sveinnfannar/finagle/subscribers","subscription_url":"https://api.github.com/repos/sveinnfannar/finagle/subscription","commits_url":"https://api.github.com/repos/sveinnfannar/finagle/commits{/sha}","git_commits_url":"https://api.github.com/repos/sveinnfannar/finagle/git/commits{/sha}","comments_url":"https://api.github.com/repos/sveinnfannar/finagle/comments{/number}","issue_comment_url":"https://api.github.com/repos/sveinnfannar/finagle/issues/comments{/number}","contents_url":"https://api.github.com/repos/sveinnfannar/finagle/contents/{+path}","compare_url":"https://api.github.com/repos/sveinnfannar/finagle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sveinnfannar/finagle/merges","archive_url":"https://api.github.com/repos/sveinnfannar/finagle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sveinnfannar/finagle/downloads","issues_url":"https://api.github.com/repos/sveinnfannar/finagle/issues{/number}","pulls_url":"https://api.github.com/repos/sveinnfannar/finagle/pulls{/number}","milestones_url":"https://api.github.com/repos/sveinnfannar/finagle/milestones{/number}","notifications_url":"https://api.github.com/repos/sveinnfannar/finagle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sveinnfannar/finagle/labels{/name}","releases_url":"https://api.github.com/repos/sveinnfannar/finagle/releases{/id}","deployments_url":"https://api.github.com/repos/sveinnfannar/finagle/deployments","created_at":"2016-05-30T14:59:09Z","updated_at":"2016-05-30T14:59:14Z","pushed_at":"2016-06-02T15:53:42Z","git_url":"git://github.com/sveinnfannar/finagle.git","ssh_url":"git@github.com:sveinnfannar/finagle.git","clone_url":"https://github.com/sveinnfannar/finagle.git","svn_url":"https://github.com/sveinnfannar/finagle","homepage":"http://twitter.github.io/finagle","size":39733,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"twitter:develop","ref":"develop","sha":"ef4612937ebcf9d51bda552fee84187ed7f20593","user":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"repo":{"id":1007362,"name":"finagle","full_name":"twitter/finagle","owner":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/twitter/finagle","description":"A fault tolerant, protocol-agnostic RPC system","fork":false,"url":"https://api.github.com/repos/twitter/finagle","forks_url":"https://api.github.com/repos/twitter/finagle/forks","keys_url":"https://api.github.com/repos/twitter/finagle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twitter/finagle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twitter/finagle/teams","hooks_url":"https://api.github.com/repos/twitter/finagle/hooks","issue_events_url":"https://api.github.com/repos/twitter/finagle/issues/events{/number}","events_url":"https://api.github.com/repos/twitter/finagle/events","assignees_url":"https://api.github.com/repos/twitter/finagle/assignees{/user}","branches_url":"https://api.github.com/repos/twitter/finagle/branches{/branch}","tags_url":"https://api.github.com/repos/twitter/finagle/tags","blobs_url":"https://api.github.com/repos/twitter/finagle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twitter/finagle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twitter/finagle/git/refs{/sha}","trees_url":"https://api.github.com/repos/twitter/finagle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twitter/finagle/statuses/{sha}","languages_url":"https://api.github.com/repos/twitter/finagle/languages","stargazers_url":"https://api.github.com/repos/twitter/finagle/stargazers","contributors_url":"https://api.github.com/repos/twitter/finagle/contributors","subscribers_url":"https://api.github.com/repos/twitter/finagle/subscribers","subscription_url":"https://api.github.com/repos/twitter/finagle/subscription","commits_url":"https://api.github.com/repos/twitter/finagle/commits{/sha}","git_commits_url":"https://api.github.com/repos/twitter/finagle/git/commits{/sha}","comments_url":"https://api.github.com/repos/twitter/finagle/comments{/number}","issue_comment_url":"https://api.github.com/repos/twitter/finagle/issues/comments{/number}","contents_url":"https://api.github.com/repos/twitter/finagle/contents/{+path}","compare_url":"https://api.github.com/repos/twitter/finagle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twitter/finagle/merges","archive_url":"https://api.github.com/repos/twitter/finagle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twitter/finagle/downloads","issues_url":"https://api.github.com/repos/twitter/finagle/issues{/number}","pulls_url":"https://api.github.com/repos/twitter/finagle/pulls{/number}","milestones_url":"https://api.github.com/repos/twitter/finagle/milestones{/number}","notifications_url":"https://api.github.com/repos/twitter/finagle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twitter/finagle/labels{/name}","releases_url":"https://api.github.com/repos/twitter/finagle/releases{/id}","deployments_url":"https://api.github.com/repos/twitter/finagle/deployments","created_at":"2010-10-19T22:10:09Z","updated_at":"2016-06-02T07:26:45Z","pushed_at":"2016-06-02T13:21:28Z","git_url":"git://github.com/twitter/finagle.git","ssh_url":"git@github.com:twitter/finagle.git","clone_url":"https://github.com/twitter/finagle.git","svn_url":"https://github.com/twitter/finagle","homepage":"http://twitter.github.io/finagle","size":44575,"stargazers_count":4680,"watchers_count":4680,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":887,"mirror_url":null,"open_issues_count":29,"forks":887,"open_issues":29,"watchers":4680,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/twitter/finagle/pulls/513"},"html":{"href":"https://github.com/twitter/finagle/pull/513"},"issue":{"href":"https://api.github.com/repos/twitter/finagle/issues/513"},"comments":{"href":"https://api.github.com/repos/twitter/finagle/issues/513/comments"},"review_comments":{"href":"https://api.github.com/repos/twitter/finagle/pulls/513/comments"},"review_comment":{"href":"https://api.github.com/repos/twitter/finagle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/twitter/finagle/pulls/513/commits"},"statuses":{"href":"https://api.github.com/repos/twitter/finagle/statuses/bbc135d36ab3084ba5c732d8339cc861fc6c2286"}}}}
{"actor":{"display_login":"kevinoliver"}}