Skip to content

Commit

Permalink
{finagle-core,util-stats}: Move LoadedStatsReceiver to util-stats fro…
Browse files Browse the repository at this point in the history
…m finagle-core

Problem

Putting LoadedStatsReceiver in finagle-core means that some things that finagle-core depends on
can't use LoadedStatsReceiver.

Solution

Let's push it down to util-stats, the only additional dependency we need is util-stats => util-app.

JIRA Issues: CSL-11393

Differential Revision: https://phabricator.twitter.biz/D763497
  • Loading branch information
mosesn authored and jenkins committed Oct 20, 2021
1 parent 2e6b8ac commit 266b69b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ New Features
java.time.OffsetDateTime. `toInstant`, `toZonedDateTime`, and `toOffsetDateTime` also preserve
nanosecond resolution. ``PHAB_ID=D757636``

* util-stats: Moved `c.t.finagle.stats.LoadedStatsReceiver` and `c.t.finagle.stats.DefaultStatsReceiver`
from the finagle-core module to util-stats. ``PHAB_ID=D763497``

21.9.0
------
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ lazy val utilStats = Project(
Seq("org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.3" % "test")
}
}
).dependsOn(utilCore, utilLint)
).dependsOn(utilApp, utilCore, utilLint)

lazy val utilTest = Project(
id = "util-test",
Expand Down
1 change: 1 addition & 0 deletions util-stats/src/main/scala/com/twitter/finagle/stats/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ scala_library(
"3rdparty/jvm/com/fasterxml/jackson/module:jackson-module-scala",
"3rdparty/jvm/com/github/ben-manes/caffeine",
"3rdparty/jvm/com/google/code/findbugs:jsr305",
"util/util-app/src/main/scala",
"util/util-core:util-core-util",
"util/util-lint/src/main/scala/com/twitter/util/lint",
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.twitter.finagle.stats

import com.twitter.app.LoadService

/**
* A [[com.twitter.finagle.stats.StatsReceiver]] that loads
* all service-loadable receivers and broadcasts stats to them.
*/
object LoadedStatsReceiver extends StatsReceiverProxy {

/**
* Mutating this value at runtime after it has been initialized should be done
* with great care. If metrics have been created using the prior
* [[StatsReceiver]], updates to those metrics may not be reflected in the
* [[StatsReceiver]] that replaces it. In addition, histograms created with
* the prior [[StatsReceiver]] will not be available.
*/
@volatile var self: StatsReceiver = BroadcastStatsReceiver(LoadService[StatsReceiver]())
}

/**
* A "default" StatsReceiver loaded by the
* [[com.twitter.finagle.util.LoadService]] mechanism.
*/
object DefaultStatsReceiver extends StatsReceiverProxy {
def self: StatsReceiver = LoadedStatsReceiver
override def repr: DefaultStatsReceiver.type = this

def get: StatsReceiver = this
}

0 comments on commit 266b69b

Please sign in to comment.