Permalink
Browse files

share StatsFilter across all server connections

  • Loading branch information...
1 parent bb30b1d commit 71d1af17b8c367b803c5568745593a086984c1cd @mariusae mariusae committed Feb 23, 2011
Showing with 5 additions and 2 deletions.
  1. +5 −2 finagle-core/src/main/scala/com/twitter/finagle/builder/ServerBuilder.scala
@@ -188,6 +188,9 @@ case class ServerBuilder[Req, Rep](
val channels = new HashSet[ChannelHandle]
+ // Share this stats receiver to avoid per-connection overhead.
+ val statsFilter = scopedStatsReceiver map { new StatsFilter[Req, Rep](_) }
+
bs.setPipelineFactory(new ChannelPipelineFactory {
def getPipeline = {
val pipeline = codec.serverPipelineFactory.getPipeline
@@ -219,8 +222,8 @@ case class ServerBuilder[Req, Rep](
// Compose the service stack.
var service = codec.wrapServerChannel(serviceFactory())
- scopedStatsReceiver foreach { sr =>
- service = (new StatsFilter(sr)) andThen service
+ statsFilter foreach { sf =>
+ service = sf andThen service
}
// We add the idle time after the codec. This ensures that a

0 comments on commit 71d1af1

Please sign in to comment.