forked from ScalaConsultants/mesmer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
271 lines (253 loc) · 10.7 KB
/
build.sbt
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
import Dependencies._
lazy val scala213 = "2.13"
inThisBuild(
List(
scalaVersion := "2.13.10",
organization := "io.scalac",
homepage := Some(url("https://github.com/ScalaConsultants/mesmer-akka-agent")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"jczuchnowski",
"Jakub Czuchnowski",
url("https://github.com/jczuchnowski")
),
Developer(
"worekleszczy",
"Piotr Jósiak",
url("https://github.com/worekleszczy")
),
Developer(
"lgajowy",
"Łukasz Gajowy",
url("https://github.com/lgajowy")
)
),
scalacOptions ++= Seq("-deprecation", "-feature"),
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision,
scalacOptions += "-Wunused:imports",
scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0",
scalafixScalaBinaryVersion := "2.13"
)
)
addCommandAlias("fmt", "scalafmtAll; scalafixAll")
addCommandAlias("check", "scalafixAll --check; scalafmtCheckAll")
addCommandAlias("testAll", "test; IntegrationTest/test")
val projectRootDir = all.base.absolutePath
lazy val all: Project = (project in file("."))
.disablePlugins(sbtassembly.AssemblyPlugin)
.settings(
name := "mesmer-all",
publish / skip := true
)
.aggregate(extension, otelExtension, example, core)
lazy val core = (project in file("core"))
.disablePlugins(sbtassembly.AssemblyPlugin)
.settings(
name := "mesmer-akka-core",
libraryDependencies ++= {
akka ++
opentelemetryExtensionApi ++
scalatest.map(_ % "test") ++
akkaTestkit.map(_ % "test")
}
)
lazy val extension = (project in file("extension"))
.enablePlugins(MultiJvmPlugin)
.disablePlugins(sbtassembly.AssemblyPlugin)
.configs(MultiJvm)
.settings(
Test / parallelExecution := true,
name := "mesmer-akka-extension",
libraryDependencies ++= {
akka ++
openTelemetryApi ++
akkaTestkit.map(_ % "test") ++
scalatest.map(_ % "test") ++
akkaMultiNodeTestKit.map(_ % "test") ++
logback.map(_ % Test)
}
)
.dependsOn(core % "compile->compile;test->test")
lazy val otelExtension = (project in file("otel-extension"))
.configs(IntegrationTest)
.settings(
Defaults.itSettings,
name := "mesmer-otel-extension",
excludeDependencies += "io.opentelemetry.javaagent" % "opentelemetry-javaagent-bootstrap",
libraryDependencies ++= {
zio.map(_ % "provided") ++
openTelemetryExtension.map(_ % "provided") ++
opentelemetryExtensionApi ++
openTelemetryMuzzle.map(_ % "provided") ++
openTelemetryInstrumentationApiSemanticConventions ++
byteBuddy.map(_ % "provided") ++
akkaTestkit.map(_ % "it,test") ++
scalatest.map(_ % "it,test") ++
openTelemetryTesting.map(_ % "it,test")
},
assembly / test := {},
assembly / assemblyJarName := s"${name.value}-assembly.jar",
assemblyMergeStrategySettings,
assembly / artifact := {
val art = (assembly / artifact).value
art.withClassifier(Some("assembly"))
},
addArtifact(assembly / artifact, assembly),
Test / fork := true,
Test / parallelExecution := true,
Test / testGrouping := (Test / testGrouping).value flatMap { group =>
group.tests.map { test =>
Tests.Group(name = test.name, tests = Seq(test), runPolicy = group.runPolicy)
}
},
Test / testOnly / testGrouping := (Test / testGrouping).value,
IntegrationTest / parallelExecution := false,
IntegrationTest / fork := true,
IntegrationTest / javaOptions ++= Seq(
s"-javaagent:$projectRootDir/opentelemetry-agent-for-testing-$OpentelemetryAlphaVersion.jar",
s"-Dotel.javaagent.extensions=${assembly.value.absolutePath}",
"-Dotel.javaagent.debug=false",
"-Dotel.metric.export.interval=50", // 100 ms so that the "eventually" assertions could catch up
"-Dotel.javaagent.testing.fail-on-context-leak=true",
"-Dotel.javaagent.testing.transform-safe-logging.enabled=true",
"-Dotel.metrics.exporter=otlp",
"-Dmesmer.akka.persistence.templated=false",
// suppress repeated logging of "No metric data to export - skipping export."
// since PeriodicMetricReader is configured with a short interval
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.opentelemetry.sdk.metrics.export.PeriodicMetricReader=INFO",
// suppress a couple of verbose ClassNotFoundException stack traces logged at debug level
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.internal.ServerImplBuilder=INFO",
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.internal.ManagedChannelImplBuilder=INFO",
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.perfmark.PerfMark=INFO",
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.Context=INFO"
)
)
.dependsOn(core % "provided->compile;test->test;compile->compile;it->test")
lazy val example = (project in file("example"))
.enablePlugins(JavaAppPackaging, UniversalPlugin)
.settings(
name := "mesmer-akka-example",
publish / skip := true,
libraryDependencies ++= {
akka ++
scalatest.map(_ % "test") ++
akkaTestkit.map(_ % "test") ++
akkaPersistance ++
zio ++
logback ++ Seq(
"io.circe" %% "circe-core" % CirceVersion,
"io.circe" %% "circe-generic" % CirceVersion,
"io.circe" %% "circe-parser" % CirceVersion,
"de.heikoseeberger" %% "akka-http-circe" % "1.39.2",
"org.postgresql" % "postgresql" % PostgresVersion,
"com.typesafe.slick" %% "slick" % SlickVersion,
"com.typesafe.slick" %% "slick-hikaricp" % SlickVersion,
"com.typesafe.akka" %% "akka-discovery" % AkkaVersion,
"com.lightbend.akka.management" %% "akka-management" % AkkaManagementVersion,
"com.lightbend.akka.management" %% "akka-management-cluster-http" % AkkaManagementVersion,
"com.lightbend.akka.management" %% "akka-management-cluster-bootstrap" % AkkaManagementVersion,
"io.opentelemetry" % "opentelemetry-sdk-extension-autoconfigure" % OpentelemetryAlphaMinor0Version,
"io.grpc" % "grpc-netty-shaded" % "1.52.1",
"org.wvlet.airframe" %% "airframe-log" % AirframeVersion
)
},
assemblyMergeStrategySettings,
mainClass := Some("example.Boot"),
assembly / assemblyJarName := "mesmer-akka-example.jar",
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
run / fork := true,
run / javaOptions ++= {
val properties = System.getProperties
import scala.collection.JavaConverters._
val keys = for {
(key, value) <- properties.asScala.toList if value.nonEmpty
} yield s"-D$key=$value"
keys
},
commands += runExampleWithOtelAgent,
commands += runStreamExampleWithOtelAgent,
commands += runZioExampleWithOtelAgent
)
.dependsOn(core)
lazy val docs = project
.in(file("mesmer-docs")) // important: it must not be docs/
.settings(
moduleName := "mesmer-docs"
)
.dependsOn(extension, otelExtension)
.enablePlugins(MdocPlugin, DocusaurusPlugin)
lazy val assemblyMergeStrategySettings = assembly / assemblyMergeStrategy := {
case PathList("META-INF", "services", _ @_*) => MergeStrategy.concat
case PathList("META-INF", _ @_*) => MergeStrategy.discard
case PathList("reference.conf") => MergeStrategy.concat
case PathList("jackson-annotations-2.10.3.jar", _ @_*) => MergeStrategy.last
case PathList("jackson-core-2.10.3.jar", _ @_*) => MergeStrategy.last
case PathList("jackson-databind-2.10.3.jar", _ @_*) => MergeStrategy.last
case PathList("jackson-dataformat-cbor-2.10.3.jar", _ @_*) =>
MergeStrategy.last
case PathList("jackson-datatype-jdk8-2.10.3.jar", _ @_*) => MergeStrategy.last
case PathList("jackson-datatype-jsr310-2.10.3.jar", _ @_*) =>
MergeStrategy.last
case PathList("jackson-module-parameter-names-2.10.3.jar", _ @_*) =>
MergeStrategy.last
case PathList("jackson-module-paranamer-2.10.3.jar", _ @_*) =>
MergeStrategy.last
case _ => MergeStrategy.first
}
def runExampleWithOtelAgent = Command.command("runExampleWithOtelAgent") { state =>
val extracted = Project extract state
val newState = extracted.appendWithSession(
Seq(
run / javaOptions ++= Seq(
s"-javaagent:$projectRootDir/opentelemetry-javaagent-$OpentelemetryVersion.jar",
s"-Dotel.service.name=mesmer-example",
s"-Dotel.metric.export.interval=5000",
s"-Dotel.javaagent.extensions=${(otelExtension / assembly).value.absolutePath}",
"-Dotel.javaagent.debug=true"
)
),
state
)
val (s, _) =
Project.extract(newState).runInputTask(Compile / runMain, " example.Boot", newState)
s
}
def runStreamExampleWithOtelAgent = Command.command("runStreamExampleWithOtelAgent") { state =>
val extracted = Project extract state
val newState = extracted.appendWithSession(
Seq(
run / javaOptions ++= Seq(
s"-javaagent:$projectRootDir/opentelemetry-javaagent-$OpentelemetryVersion.jar",
s"-Dotel.service.name=mesmer-stream-example",
s"-Dotel.metric.export.interval=5000",
s"-Dotel.javaagent.extensions=${(otelExtension / assembly).value.absolutePath}"
)
),
state
)
val (s, _) =
Project.extract(newState).runInputTask(Compile / runMain, " example.SimpleStreamExample", newState)
s
}
def runZioExampleWithOtelAgent = Command.command("runZioExampleWithOtelAgent") { state =>
val extracted = Project extract state
val newState = extracted.appendWithSession(
Seq(
run / javaOptions ++= Seq(
s"-javaagent:$projectRootDir/opentelemetry-javaagent-$OpentelemetryVersion.jar",
s"-Dotel.service.name=mesmer-zio-example",
s"-Dotel.metric.export.interval=1000",
s"-Dotel.javaagent.extensions=${(otelExtension / assembly).value.absolutePath}"
)
),
state
)
val (s, _) =
Project.extract(newState).runInputTask(Compile / runMain, " example.SimpleZioExample", newState)
s
}