All Projects → ScalaConsultants → akka-periscope

ScalaConsultants / akka-periscope

Licence: MIT license
Akka plugin to collect various data about actors

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to akka-periscope

Akka.net
Port of Akka actors for .NET
Stars: ✭ 4,024 (+25050%)
Mutual labels:  akka, actor
young-crawler
scala结合actor编写的分布式网络爬虫
Stars: ✭ 15 (-6.25%)
Mutual labels:  akka, actor
kamon-akka
Kamon Instrumentation for Akka
Stars: ✭ 44 (+175%)
Mutual labels:  akka, actor
kotlin-akka
Akka-Kotlin sample, and support library.
Stars: ✭ 25 (+56.25%)
Mutual labels:  akka
Akka
Examples and explanations of how Akka toolkit works
Stars: ✭ 20 (+25%)
Mutual labels:  akka
akkordeon
training neural networks with akka
Stars: ✭ 51 (+218.75%)
Mutual labels:  akka
akka-log4j
Logging backend for Akka based on Log4j
Stars: ✭ 28 (+75%)
Mutual labels:  akka
mmqtt
An Open-Source, Distributed MQTT Broker for IoT.
Stars: ✭ 58 (+262.5%)
Mutual labels:  akka
protoactor-go
Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
Stars: ✭ 4,138 (+25762.5%)
Mutual labels:  akka
cassandra.realtime
Different ways to process data into Cassandra in realtime with technologies such as Kafka, Spark, Akka, Flink
Stars: ✭ 25 (+56.25%)
Mutual labels:  akka
akka-http-actor-per-request
Example akka application that uses the actor per request model
Stars: ✭ 16 (+0%)
Mutual labels:  akka
akka-cluster-minimal
Akka Cluster - absolute minimal
Stars: ✭ 16 (+0%)
Mutual labels:  akka
jwt-akka-http
An example how to implement a very simple authentication and authorization with Akka HTTP. Related to https://blog.codecentric.de/en/2017/09/jwt-authentication-akka-http
Stars: ✭ 23 (+43.75%)
Mutual labels:  akka
play-grpc
Play + Akka gRPC
Stars: ✭ 31 (+93.75%)
Mutual labels:  akka
akka-mock-scheduler
A mock Akka scheduler to simplify testing scheduler-dependent code
Stars: ✭ 86 (+437.5%)
Mutual labels:  akka
MuezzinAPI
A web server application for Islamic prayer times
Stars: ✭ 33 (+106.25%)
Mutual labels:  akka
ecommerce
A project for exploring Akka with Scala
Stars: ✭ 24 (+50%)
Mutual labels:  akka
akka-microservice
Example of a microservice with Scala, Akka, Spray and Camel/ActiveMQ
Stars: ✭ 45 (+181.25%)
Mutual labels:  akka
WatchSomething
Project that uses an API to list movies and tv shows that are latest, popular, top rated & on air.
Stars: ✭ 11 (-31.25%)
Mutual labels:  actor
generator-jvm
Generate JVM (java, kotlin, scala) project with gradle / maven / sbt build systems and docker / docker-compose for rapid development
Stars: ✭ 40 (+150%)
Mutual labels:  akka

akka-periscope

CI Maven Central

Akka diagnostics collector plugin.

Provides akka-related data for Panopticon monitoring tool, but can be used for general purposes as well.

What is this?

This is a small library for akka applications, that can collect valuable data about your actor system:

  • the whole tree of actors in the actor system, starting from root guardians;
  • total count of actors in the actor system.

It also provides facilities for this data to be exposed for diagnostic purposes, specifically to work with Panopticon, which is a terminal-based monitoring tool for Scala apps.

Dependencies?

No, except for (obviously) akka.

How to use.

Import the library in your build.sbt:

libraryDependencies += "io.scalac" %% "akka-periscope-core" % "0.4.0"

If you want additional integrations, consider adding one/several of the following:

libraryDependencies += "io.scalac" %% "akka-periscope-akka-http" % "0.4.0"

Getting raw data

If you want to just get the data to use it in some way, there are following two function available in akka-periscope-core.

Actor tree

Here's an example of how to build an actor tree for some particular actor system:

import akka.actor.ActorSystem
import akka.util.Timeout
import scala.concurrent.{Future, ExecutionContext}

import io.scalac.periscope.akka.tree.build
import io.scalac.periscope.akka.tree.ActorTree

val system: ActorSystem = ???
implicit val timeout: Timeout = ??? // time limit for the tree to be assembled
implicit val ec: ExecutionContext = system.scheduler // can use another executor if you prefer to
 
val tree: Future[ActorTree] = build(system)

⚠️ Please note, that if some actor is overwhelmed and does not make it in time to answer the ping message, it will not be present in the tree. We have to use this "best-effort" approach, because there's no way to get full list of actor's children from the outside, so we have to discover it first by sending a broadcast message.

Actor count

Here's an example of a more simple, but less memory intensive metric, which is actor count:

import akka.actor.ActorSystem
import akka.util.Timeout
import scala.concurrent.{Future, ExecutionContext}

import io.scalac.periscope.akka.counter.count

val system: ActorSystem = ???
implicit val timeout: Timeout = ??? // time limit for the actor hierarchy to be processed
implicit val ec: ExecutionContext = system.scheduler // can use another executor if you prefer to
 
val actorCount: Future[Long] = count(system)

⚠️ See the same note about time limits and possibility of not counting in actors that have to much message backlog to answer pings in time.

Setting up Panopticon endpoints

If your primary goal is to make Panopticon work with your app, there are some convenient shortcuts.

Akka-http endpoints

If you use akka-http, then you can add akka-periscope-akka-http to your build. After that you can create akka-http Routes for both actor tree and actor system status (including actor count) using these smart-constructors:

import io.scalac.periscope.akka.http.ActorTreeRoute
import io.scalac.periscope.akka.http.ActorSystemStatusRoute
import akka.actor.ActorSystem
import akka.http.scaladsl.server.Directives._
import scala.concurrent.ExecutionContext

val system: ActorSystem = ???
implicit val ec: ExecutionContext = system.dispatcher

pathPrefix("actor-tree") {
  ActorTreeRoute(system)
} ~
pathPrefix("actor-system-status") {
  ActorSystemStatusRoute(system)
}

For these endpoints the timeout (in milliseconds) is passed as a query parameter, like this:

curl --request GET \
  --url 'http://localhost:8080/actor-tree?timeout=2000'

Response will be in the format, ready to be consumed by Panopticon:

{
  "system": {
    "log1-Slf4jLogger": {},
    "IO-TCP": {
      "selectors": {
        "$a": {
          "0": {},
          "1": {}
        }
      }
    },
    "Materializers": {
      "StreamSupervisor-0": {
        "flow-1-0-detacher": {},
        "flow-0-0-ignoreSink": {}
      },
      "StreamSupervisor-1": {}
    },
    "eventStreamUnsubscriber-1": {},
    "localReceptionist": {},
    "pool-master": {},
    "deadLetterListener": {}
  },
  "user": {
    "actor-tree-builder-1589444625750": {}
  }
}

Developed by Scalac

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].