-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util-stats: use service scopeSeparator in MetricBuilder
Problem ------- Metric Metadata uses / as the scope separator in all cases. As a result, when service owners configure a custom scope separator (ex, -) the metric names will differ in metrics.json and metric_metadata.json. Solution -------- Create an object in util-stats to store a scope separating character for MetricBuilder and metric_metadata.json to make use of. Result ------ Metric names now align across metrics.json and metric_metadata.json for services with custom configured scope separators JIRA Issues: CSL-10202 Differential Revision: https://phabricator.twitter.biz/D557994
- Loading branch information
Matt Dannenberg
authored and
jenkins
committed
Oct 1, 2020
1 parent
26e7874
commit 7665b9e
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
util-stats/src/test/scala/com/twitter/finagle/stats/MetricBuilderTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.twitter.finagle.stats | ||
|
||
import org.scalatest.funsuite.AnyFunSuite | ||
|
||
class MetricBuilderTest extends AnyFunSuite { | ||
|
||
test("metadataScopeSeparator affects stringification") { | ||
val mb = new MetricBuilder(name = Seq("foo", "bar"), statsReceiver = new InMemoryStatsReceiver) | ||
assert(mb.toString.contains("foo/bar")) | ||
metadataScopeSeparator.setSeparator("-") | ||
assert(mb.toString.contains("foo-bar")) | ||
metadataScopeSeparator.setSeparator("_aTerriblyLongStringForSomeReason_") | ||
assert(mb.toString.contains("foo_aTerriblyLongStringForSomeReason_bar")) | ||
} | ||
|
||
} |