<commit_before>package org.eigengo.monitor.agent.akka

import org.eigengo.monitor.{TestCounter, TestCounterInterface}
import akka.actor.Props

class ActorCountFilteringSpec extends ActorCellMonitoringAspectSpec(Some("count-filtering.conf")) {
  sequential
  import Aspects._

  "Actor count monitoring" should {

    // records the count of actors, grouped by simple class name
    "Not record the count of exluded actors" in {
      val monitoredActorTag = "org.eigengo.monitor.agent.akka.SimpleActor"
      val unmonitoredActorTag = "org.eigengo.monitor.agent.akka.KillableActor"
      TestCounterInterface.clear()

      val monitoredActor = system.actorOf(Props[SimpleActor], "simple")

      // this actor is excluded -- we shouldn't be monitoring it
      val unmonitoredActor = system.actorOf(Props[KillableActor], "killable")

      monitoredActor ! 1
      unmonitoredActor ! 1

      Thread.sleep(1000)

      val counterBeforeKill = TestCounterInterface.foldlByAspect(actorCount)((a,_) =>a)
      counterBeforeKill.size === 1
      counterBeforeKill must contain(TestCounter(actorCount, 1, List(monitoredActorTag)))

      monitoredActor ! 'stop
      unmonitoredActor ! 'stop

      Thread.sleep(500)

      val counterAfterKill = TestCounterInterface.foldlByAspect(actorCount)((a,_) =>a)
      counterAfterKill.size === 2
      counterAfterKill must contain(TestCounter(actorCount, 0, List(monitoredActorTag)))
    }
  }<commit_msg>Test excluded actors are also excluded from actor count<commit_after>package org.eigengo.monitor.agent.akka

import org.eigengo.monitor.{TestCounter, TestCounterInterface}
import akka.actor.Props

class ActorCountFilteringSpec extends ActorCellMonitoringAspectSpec(Some("count-filtering.conf")) {
  sequential
  import Aspects._

  "Actor count monitoring" should {

    // records the count of actors, grouped by simple class name
    "Not record the count of exluded actors" in {
      val monitoredActorTag = "org.eigengo.monitor.agent.akka.SimpleActor"
      val unmonitoredActorTag = "org.eigengo.monitor.agent.akka.KillableActor"
      TestCounterInterface.clear()

      val monitoredActor = system.actorOf(Props[SimpleActor], "simple")

      // this actor is excluded -- we shouldn't be monitoring it
      val unmonitoredActor = system.actorOf(Props[KillableActor], "killable")

      Thread.sleep(1000)

      val counterBeforeKill = TestCounterInterface.foldlByAspect(actorCount)((a,_) =>a)
      counterBeforeKill.size === 1
      counterBeforeKill must contain(TestCounter(actorCount, 1, List(monitoredActorTag)))

      monitoredActor ! 'stop
      unmonitoredActor ! 'stop

      Thread.sleep(500)

      val counterAfterKill = TestCounterInterface.foldlByAspect(actorCount)((a,_) =>a)
      counterAfterKill.size === 2
      counterAfterKill must contain(TestCounter(actorCount, 0, List(monitoredActorTag)))
    }
  }
{'fraction_non_alphanumeric': 0.09378256339006599, 'fraction_numerical': 0.008336227856894755, 'mean_word_length': 4.088339222614841, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '423346', 'n_tokens_mistral': 905, 'n_tokens_neox': 814, 'n_words': 188}