Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit f509f38

Browse files
committed
Telemetry - WIP
1 parent edafafa commit f509f38

File tree

9 files changed

+1564
-8
lines changed

9 files changed

+1564
-8
lines changed

docker-compose.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
version: '3.9'
2+
3+
networks:
4+
monitoring:
5+
driver: bridge
6+
7+
volumes:
8+
prometheus_data: {}
9+
grafana_data: {}
10+
11+
services:
12+
grafana:
13+
container_name: grafana
14+
image: grafana/grafana-oss:9.5.7
15+
volumes:
16+
- ./infrastructure/grafana/etc:/etc/grafana:ro
17+
#- grafana-log:/var/log/grafana
18+
- grafana_data:/var/lib/grafana
19+
ports:
20+
- "3000:3000"
21+
restart: always
22+
depends_on:
23+
- prometheus
24+
privileged: true
25+
networks:
26+
- monitoring
27+
28+
prometheus:
29+
container_name: prometheus
30+
image: prom/prometheus:v2.46.0
31+
volumes:
32+
- ./infrastructure/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
33+
- prometheus_data:/prometheus
34+
ports:
35+
- "9090:9090"
36+
restart: always
37+
privileged: true
38+
networks:
39+
- monitoring
40+
extra_hosts:
41+
- "host.docker.internal:host-gateway"
42+
43+
zipkin:
44+
container_name: zipkin
45+
image: openzipkin/zipkin:2.24
46+
ports:
47+
- "9411:9411"
48+
networks:
49+
- monitoring

exercises/exercise_000_sudoku_solver_initial_state/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This application, written in Scala 2, implements an Akka Typed/Scala
2020
based Sudoku Solver that is composed of 29 actors.
2121

2222
The application will also start up an instance of a Sudoku problem generator
23-
that continuously cycles through a series of Sudoko problems at a configurable
23+
that continuously cycles through a series of Sudoku problems at a configurable
2424
rate, tunable via configuration.
2525

2626
The course consists of a series of exercises in which you change the source code to leverage Scala 3 specific features. The application comes with tests that are basically the same across all exercises. The tests should pass at every stage: if they don't, you've broken something and you will need to fix it.
@@ -83,7 +83,7 @@ SLF4J: See also http://www.slf4j.org/codes.html#replay
8383
man [e] > Scala 2 to Scala 3 > sudoku solver initial state >
8484
```
8585

86-
- Run the Sodukosolver by executing the `runSolver` command from the `sbt` prompt.
86+
- Run the Sudokusolver by executing the `runSolver` command from the `sbt` prompt.
8787

8888
- Note that you can stop the application by hitting `Return` in the sbt session.
8989

@@ -161,4 +161,3 @@ body {
161161
```
162162

163163
![IntelliJ Markdown viewer settings](images/Markdown-viewer-IntelliJ.png)
164-

exercises/exercise_000_sudoku_solver_initial_state/project/Build.scala

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ object CompileOptions {
1212

1313
object Versions {
1414
lazy val akkaVer = "2.6.20"
15+
lazy val kamonVer = "2.6.3"
1516
lazy val logbackVer = "1.2.3"
1617
lazy val mUnitVer = "0.7.26"
1718
}
@@ -29,9 +30,15 @@ object Dependencies {
2930

3031
private lazy val munitDeps = Seq("org.scalameta" %% "munit" % Versions.mUnitVer % Test)
3132

33+
private lazy val kamonDeps = Seq(
34+
"io.kamon" %% "kamon-bundle" % Versions.kamonVer,
35+
"io.kamon" %% "kamon-prometheus" % Versions.kamonVer
36+
)
37+
3238
lazy val dependencies: Seq[ModuleID] =
33-
logbackDeps ++
34-
munitDeps ++
35-
akkaDeps ++
36-
akkaTestkitDeps
39+
akkaDeps ++
40+
akkaTestkitDeps ++
41+
kamonDeps ++
42+
logbackDeps ++
43+
munitDeps
3744
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
2+
addSbtPlugin("io.kamon" % "sbt-kanela-runner" % "2.0.14")
23
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.7")
3-
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
44
addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.1")
5+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")

exercises/exercise_000_sudoku_solver_initial_state/src/main/resources/application.conf

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,88 @@ akka {
2323
}
2424
}
2525
}
26+
27+
kamon {
28+
environment {
29+
service = "scala2-to-scala3-course-service"
30+
}
31+
32+
trace {
33+
tick-interval = 5 seconds
34+
sampler = always
35+
}
36+
37+
instrumentation.akka.filters {
38+
actors.track {
39+
includes = [ "sudoku-solver-system/user/**" ]
40+
}
41+
42+
actors.trace {
43+
includes = [ "sudoku-solver-system/user/**" ]
44+
}
45+
46+
actors.start-trace {
47+
includes = [ "sudoku-solver-system/user/**" ]
48+
}
49+
50+
dispatchers {
51+
includes = [ "sudoku-solver-system/akka.actor.default-dispatcher" ]
52+
}
53+
}
54+
55+
# Source: https://kamon.io/docs/latest/reporters/prometheus/
56+
prometheus {
57+
include-environment-tags = true
58+
embedded-server {
59+
hostname = 0.0.0.0
60+
port = 9095
61+
}
62+
63+
# Source: https://kamon.io/docs/latest/reporters/prometheus/
64+
buckets {
65+
default-buckets = [
66+
10,
67+
30,
68+
100,
69+
300,
70+
1000,
71+
3000,
72+
10000,
73+
30000,
74+
100000
75+
]
76+
77+
time-buckets = [
78+
0.005,
79+
0.01,
80+
0.025,
81+
0.05,
82+
0.075,
83+
0.1,
84+
0.25,
85+
0.5,
86+
0.75,
87+
1,
88+
2.5,
89+
5,
90+
7.5,
91+
10
92+
]
93+
94+
information-buckets = [
95+
512,
96+
1024,
97+
2048,
98+
4096,
99+
16384,
100+
65536,
101+
524288,
102+
1048576
103+
]
104+
}
105+
}
106+
}
107+
108+
kanela {
109+
log-level = "DEBUG"
110+
}

exercises/exercise_000_sudoku_solver_initial_state/src/main/scala/org/lunatechlabs/dotty/SudokuSolverMain.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import akka.actor.typed.scaladsl.adapter.TypedActorSystemOps
2020
import akka.actor.typed.scaladsl.{Behaviors, Routers}
2121
import akka.actor.typed.{ActorSystem, Behavior, Terminated}
2222
import org.lunatechlabs.dotty.sudoku.{SudokuProblemSender, SudokuSolver, SudokuSolverSettings}
23+
import kamon.Kamon
2324

2425
import scala.Console.{GREEN, RESET}
2526
import scala.io.StdIn
@@ -42,6 +43,7 @@ object Main {
4243
object SudokuSolverMain {
4344

4445
def main(args: Array[String]): Unit = {
46+
Kamon.init()
4547

4648
val system = ActorSystem[NotUsed](Main(), "sudoku-solver-system")
4749

0 commit comments

Comments
 (0)