Skip to content

Commit

Permalink
zipkin-finatra fixes
Browse files Browse the repository at this point in the history
- Bump to Finatra `0.2.3`
- Fix /api/query response
- Fix timestamp text on query results

Author: @franklinhu
Fixes #104
URL: #104
  • Loading branch information
Franklin Hu committed Aug 9, 2012
1 parent 45d3c06 commit 4795387
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion project/Project.scala
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ object Zipkin extends Build {
resolvers += "codahale" at "http://repo.codahale.com",

libraryDependencies ++= Seq(
"com.twitter" % "finatra" % "0.2.1",
"com.twitter" % "finatra" % "0.2.3",

"com.twitter.common.zookeeper" % "server-set" % "1.0.7",

Expand Down
4 changes: 2 additions & 2 deletions zipkin-finatra/src/main/resources/public/css/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ ul.traces li .trace-details {
}

ul.traces li .services {
width: 79.7%;
width: 80%;
}

ul.traces li .timestamp {
width: 20%;
width: 19%;
text-align: right;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ Zipkin.Application.Index = (function() {

data.sort(function(a, b) {
if (sortOrder == ORDER_TIMESTAMP_ASC) {
return new Date(a.start_time) - new Date(b.start_time);
return new Date(a.startTimestamp) - new Date(b.startTimestamp);
} else if (sortOrder == ORDER_TIMESTAMP_DESC) {
return new Date(b.start_time) - new Date(a.start_time);
return new Date(b.startTimestamp) - new Date(a.startTimestamp);
} else if (sortOrder == ORDER_DURATION_ASC) {
return a.duration - b.duration;
} else {
Expand Down Expand Up @@ -419,6 +419,7 @@ Zipkin.Application.Index = (function() {
return { name: key, count: count };
});
e.url = root_url + "show/" + e.traceId;
e.startTime = Zipkin.Util.timeAgoInWords(e.startTimestamp / 1000);
return e;
});
traces = updateFilteredServices(traces);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</span>
{{/serviceCounts}}
</div>
<div class="trace-details timestamp">
<div class="trace-details timestamp pull-right">
<span class="label">{{startTime}}</span>
</div>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class App(config: ZipkinWebConfig, client: gen.ZipkinQuery.FinagledClient) exten
}
}
}
}.map(render.json(_))
}.flatten.map(render.json(_))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,28 @@ import com.twitter.finagle.http.Http
import com.twitter.finagle.builder.{ClientBuilder, ServerBuilder, Server}
import com.twitter.finagle.thrift.ThriftClientFramedCodec
import com.twitter.finagle.zookeeper.ZookeeperServerSetCluster
import com.twitter.finatra.{AppService, Controller, FinatraServer}
import com.twitter.ostrich.admin.{ServiceTracker, Service}
import com.twitter.finatra_core.{AbstractFinatraController, ControllerCollection}
import com.twitter.finatra._
import com.twitter.ostrich.admin.ServiceTracker
import com.twitter.ostrich.admin
import com.twitter.logging.Logger
import com.twitter.io.{Files, TempFile}
import com.twitter.zipkin.config.ZipkinWebConfig
import com.twitter.zipkin.gen
import com.twitter.util.Future
import java.net.InetSocketAddress
import org.jboss.netty.handler.codec.http.HttpResponse
import scala.Left
import scala.Right
import scala.Some

class ZipkinWeb(config: ZipkinWebConfig) extends Service {
class ZipkinWeb(config: ZipkinWebConfig) extends admin.Service {

val log = Logger.get()
var server: Option[Server] = None

val controllers = new ControllerCollection[Request, Future[Response], Future[HttpResponse]]

def start() {
val clientBuilder = ClientBuilder()
.codec(ThriftClientFramedCodec())
Expand All @@ -43,10 +52,10 @@ class ZipkinWeb(config: ZipkinWebConfig) extends Service {
val resource = config.resource
val app = config.appConfig(client)

FinatraServer.register(resource)
FinatraServer.register(app)
register(resource)
register(app)

val finatraService = new AppService
val finatraService = new AppService(controllers)
val service = finatraService

server = Some {
Expand All @@ -63,6 +72,10 @@ class ZipkinWeb(config: ZipkinWebConfig) extends Service {
def shutdown() {
server.foreach { _.close() }
}

def register(app: AbstractFinatraController[Request, Future[Response], Future[HttpResponse]]) {
controllers.add(app)
}
}

class Resource(resourceDirs: Map[String, String]) extends Controller {
Expand Down

0 comments on commit 4795387

Please sign in to comment.