aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/test/scala/kamon/metric/FilterSpec.scala
blob: c0f0e2e147d5088d60c0d74f3e566635aadbb40c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package kamon
package metric

import com.typesafe.config.ConfigFactory
import org.scalatest.{Matchers, WordSpec}


//class FilterSpec extends WordSpec with Matchers {
//  val testConfig = ConfigFactory.parseString(
//    """
//      |kamon.metric.filters {
//      |  accept-unmatched-categories = false
//      |
//      |  some-category {
//      |    includes = ["**"]
//      |    excludes = ["not-me"]
//      |  }
//      |
//      |  only-includes {
//      |    includes = ["only-me"]
//      |  }
//      |
//      |  only-excludes {
//      |    excludes = ["not-me"]
//      |  }
//      |
//      |  specific-rules {
//      |    includes = ["glob:/user/**", "regex:test-[0-5]"]
//      |  }
//      |}
//    """.stripMargin
//  )
//
//  "the entity filters" should {
//    "use the accept-unmatched-categories setting when there is no configuration for a given category" in {
//      val acceptUnmatched = Filter.fromConfig(ConfigFactory.parseString("kamon.metric.filters.accept-unmatched-categories=true"))
//      val rejectUnmatched = Filter.fromConfig(ConfigFactory.parseString("kamon.metric.filters.accept-unmatched-categories=false"))
//
//      acceptUnmatched.accept(Entity("a", "b", Map.empty)) shouldBe true
//      rejectUnmatched.accept(Entity("a", "b", Map.empty)) shouldBe false
//    }
//
//    "accept entities that are matched by any include and none exclude filters" in {
//      val entityFilter = Filter.fromConfig(testConfig)
//
//      entityFilter.accept(Entity("anything", "anything", Map.empty)) shouldBe false
//      entityFilter.accept(Entity("anything", "some-category", Map.empty)) shouldBe true
//      entityFilter.accept(Entity("not-me", "some-category", Map.empty)) shouldBe false
//    }
//
//    "allow configuring includes only or excludes only for any category" in {
//      val entityFilter = Filter.fromConfig(testConfig)
//
//      entityFilter.accept(Entity("only-me", "only-includes", Map.empty)) shouldBe true
//      entityFilter.accept(Entity("anything", "only-includes", Map.empty)) shouldBe false
//      entityFilter.accept(Entity("any-other", "only-excludes", Map.empty)) shouldBe false
//      entityFilter.accept(Entity("not-me", "only-excludes", Map.empty)) shouldBe false
//    }
//
//    "allow to explicitly decide whether patterns are treated as Glob or Regex" in {
//      val entityFilter = Filter.fromConfig(testConfig)
//
//      entityFilter.accept(Entity("/user/accepted", "specific-rules", Map.empty)) shouldBe true
//      entityFilter.accept(Entity("/other/rejected/", "specific-rules", Map.empty)) shouldBe false
//      entityFilter.accept(Entity("test-5", "specific-rules", Map.empty)) shouldBe true
//      entityFilter.accept(Entity("test-6", "specific-rules", Map.empty)) shouldBe false
//    }
//  }
//}