Skip to content

Commit d96155a

Browse files
tigerlily-hejenkins
authored and
jenkins
committed
finagle-core: add "implementation" label to DefaultStatsReceiver
Problem: We want to indicate which metrics are added by users as custom, application-specific metrics. Solution: Add the scope "app" to DefaultStatsReceiver. Add the label `implementation="app"`. All custom metrics will look like ``` app_serviceA_metricB {implementation="app"} ``` JIRA Issues: CSL-12028 Differential Revision: https://phabricator.twitter.biz/D901903
1 parent 8c96a44 commit d96155a

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

util-stats/src/main/scala/com/twitter/finagle/stats/LoadedStatsReceiver.scala

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ object LoadedStatsReceiver extends StatsReceiverProxy {
2323
* [[com.twitter.finagle.util.LoadService]] mechanism.
2424
*/
2525
object DefaultStatsReceiver extends StatsReceiverProxy {
26-
def self: StatsReceiver = LoadedStatsReceiver
26+
val self: StatsReceiver =
27+
LoadedStatsReceiver
28+
.dimensionalScope("app")
29+
.label("implementation", "app")
30+
2731
override def repr: DefaultStatsReceiver.type = this
2832

2933
def get: StatsReceiver = this
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.twitter.finagle.stats
2+
3+
import org.scalatest.funsuite.AnyFunSuite
4+
5+
class DefaultStatsReceiverTest extends AnyFunSuite {
6+
test("DefaultStatsReceiver has app in dimensional scope and label") {
7+
LoadedStatsReceiver.self = new InMemoryStatsReceiver
8+
val fooCounter = DefaultStatsReceiver.counter("foo")
9+
val identity = fooCounter.metadata.toMetricBuilder.get.identity
10+
11+
assert(identity.dimensionalName == Seq("app", "foo"))
12+
assert(identity.hierarchicalName == Seq("foo"))
13+
assert(identity.labels == Map("implementation" -> "app"))
14+
}
15+
}

0 commit comments

Comments
 (0)