Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Change StatsService to ServiceStatsFilter #168

Closed
wants to merge 2 commits into from

2 participants

@franklinhu

It makes more sense for the stats to be a Filter rather than a Service

Franklin Hu added some commits
@franklinhu franklinhu closed this pull request from a commit
Franklin Hu Change StatsService to ServiceStatsFilter
It makes more sense for the stats to be a Filter rather than a Service

Author: @franklinhu
Fixes #168
URL: #168
282ab23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 27, 2012
  1. Change StatsService to ServiceStatsFilter

    Franklin Hu authored
  2. Fix import

    Franklin Hu authored
This page is out of date. Refresh to see the latest.
View
13 ...ter/zipkin/collector/processor/StatsService.scala → .../zipkin/collector/filter/ServiceStatsFilter.scala
@@ -14,16 +14,19 @@
* limitations under the License.
*
*/
-package com.twitter.zipkin.collector.processor
+package com.twitter.zipkin.collector.filter
-import com.twitter.finagle.Service
+import com.twitter.finagle.{Service, Filter}
import com.twitter.ostrich.stats.Stats
import com.twitter.util.Future
import com.twitter.zipkin.common.Span
-class StatsService extends Service[Span, Unit] {
- def apply(span: Span): Future[Unit] = {
+/**
+ * Filter that increments a counter for each service present in the Span
+ */
+class ServiceStatsFilter extends Filter[Span, Unit, Span, Unit] {
+ def apply(span: Span, service: Service[Span, Unit]): Future[Unit] = {
span.serviceNames.foreach { name => Stats.incr("process_" + name) }
- Future.Unit
+ service(span)
}
}
View
6 zipkin-collector-core/src/main/scala/com/twitter/zipkin/config/ZipkinCollectorConfig.scala
@@ -17,7 +17,7 @@ package com.twitter.zipkin.config
import com.twitter.zipkin.storage.{Aggregates, Index, Storage}
import com.twitter.zipkin.collector.{WriteQueue, ZipkinCollector}
-import com.twitter.zipkin.collector.filter.{SamplerFilter, ClientIndexFilter}
+import com.twitter.zipkin.collector.filter.{ServiceStatsFilter, SamplerFilter, ClientIndexFilter}
import com.twitter.zipkin.collector.sampler.{AdaptiveSampler, ZooKeeperGlobalSampler, GlobalSampler}
import com.twitter.zipkin.config.collector.CollectorServerConfig
import com.twitter.zipkin.config.sampler._
@@ -107,10 +107,10 @@ trait ZipkinCollectorConfig extends ZipkinConfig[ZipkinCollector] {
lazy val processor: Service[T, Unit] =
rawDataFilter andThen
new SamplerFilter(globalSampler) andThen
+ new ServiceStatsFilter andThen
new FanoutService[Span](
new StorageService(storage) ::
- (new ClientIndexFilter andThen new IndexService(index)) ::
- new StatsService
+ (new ClientIndexFilter andThen new IndexService(index))
)
def writeQueueConfig: WriteQueueConfig[T]
Something went wrong with that request. Please try again.