-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add subproject micrometer with generic PrefixMeterFilter (#219)
* feat: Add subproject micrometer with generic PrefixMeterFilter feat: Add more configuration options to MicrometerStatsDModule fix: prefix was not what it was meant to be * fix: compilation issue
- Loading branch information
1 parent
4ac6d75
commit eff6bac
Showing
5 changed files
with
63 additions
and
5 deletions.
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
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
10 changes: 10 additions & 0 deletions
10
micrometer/src/main/scala/com/avast/sst/micrometer/PrefixMeterFilter.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,10 @@ | ||
package com.avast.sst.micrometer | ||
|
||
import io.micrometer.core.instrument.Meter | ||
import io.micrometer.core.instrument.config.MeterFilter | ||
|
||
class PrefixMeterFilter(prefix: String) extends MeterFilter { | ||
|
||
override def map(id: Meter.Id): Meter.Id = id.withName(s"$prefix${id.getName}") | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
micrometer/src/test/scala/com/avast/sst/micrometer/PrefixMeterFilterTest.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.avast.sst.micrometer | ||
|
||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry | ||
import org.scalatest.funsuite.AnyFunSuite | ||
|
||
class PrefixMeterFilterTest extends AnyFunSuite { | ||
|
||
test("prefixing") { | ||
val registry = new SimpleMeterRegistry | ||
registry.config().meterFilter(new PrefixMeterFilter("this.is.prefix.")) | ||
val counter = registry.counter("test") | ||
|
||
assert(counter.getId.getName === "this.is.prefix.test") | ||
} | ||
|
||
} |