Skip to content

Commit 7447f37

Browse files
authored
Merge pull request #99 from ovotech/scala-3
Scala 3
2 parents f3183db + f7b4782 commit 7447f37

File tree

7 files changed

+113
-68
lines changed

7 files changed

+113
-68
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
command: |
9595
set -e
9696
tags=`git describe --tags`
97-
sbt ';set version in ThisBuild := "'${tags}'"; test; publishSigned; sonatypeBundleRelease'
97+
sbt ';set version in ThisBuild := "'${tags}'"; +test; +publishSigned; +sonatypeBundleRelease'
9898
- *cache_save
9999

100100
test:
@@ -105,7 +105,7 @@ jobs:
105105
- *install_sbt
106106
- run:
107107
name: Test
108-
command: sbt test
108+
command: sbt +test
109109
- *cache_save
110110

111111
workflows:
@@ -117,7 +117,7 @@ workflows:
117117
- release:
118118
filters:
119119
tags:
120-
only: /^([0-9\\.]+(-RC[0-9]+)?)$/
120+
only: /^([0-9\\.]+(-(RC|M)[0-9]+)?)$/
121121
branches:
122122
ignore: /.*/
123123
pr-build:

build.sbt

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import microsites.MicrositesPlugin.autoImport.micrositeDescription
22

3-
val scalaVer: String = "2.13.8"
3+
val scala213Version = "2.13.8"
4+
val scala3Version = "3.2.2"
45

5-
ThisBuild / scalaVersion := scalaVer
6+
val scalaVersions = Seq(scala213Version, scala3Version)
67

78
ThisBuild / organization := "com.ovoenergy"
89

@@ -44,6 +45,8 @@ val common = Seq(
4445
libraryDependencies ++= Seq(
4546
compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
4647
compilerPlugin("org.typelevel" % "kind-projector" % "0.13.2" cross CrossVersion.full),
48+
).filterNot(_ => scalaVersion.value.startsWith("3.")),
49+
libraryDependencies ++= Seq(
4750
"org.typelevel" %% "cats-core" % "2.7.0",
4851
"org.typelevel" %% "cats-effect" % "3.3.5",
4952
"org.scalameta" %% "munit" % "0.7.29" % Test,
@@ -53,8 +56,9 @@ val common = Seq(
5356
)
5457
)
5558

56-
lazy val metricsCommon = project
59+
lazy val metricsCommon = projectMatrix
5760
.in(file("natchez-extras-metrics"))
61+
.jvmPlatform(scalaVersions = scalaVersions)
5862
.enablePlugins(GitVersioning)
5963
.settings(common :+ (name := "natchez-extras-metrics"))
6064

@@ -70,7 +74,7 @@ val doobieVersion = "1.0.0-RC2"
7074
lazy val natchezDatadog = projectMatrix
7175
.in(file("natchez-extras-datadog"))
7276
.customRow(
73-
scalaVersions = Seq(scalaVer),
77+
scalaVersions = scalaVersions,
7478
axisValues = Seq(Http4sVersion.Milestone, VirtualAxis.jvm),
7579
settings = List(
7680
name := "natchez-extras-datadog",
@@ -82,7 +86,7 @@ lazy val natchezDatadog = projectMatrix
8286
)
8387
)
8488
.customRow(
85-
scalaVersions = Seq(scalaVer),
89+
scalaVersions = scalaVersions,
8690
axisValues = Seq(Http4sVersion.Stable, VirtualAxis.jvm),
8791
settings = List(
8892
name := "natchez-extras-datadog-stable",
@@ -100,14 +104,14 @@ lazy val natchezDatadog = projectMatrix
100104
"org.tpolecat" %% "natchez-core" % natchezVersion,
101105
"io.circe" %% "circe-core" % circeVersion,
102106
"io.circe" %% "circe-generic" % circeVersion,
103-
"io.circe" %% "circe-generic-extras" % circeVersion,
104107
"io.circe" %% "circe-parser" % circeVersion,
105108
"org.slf4j" % "slf4j-api" % slf4jVersion
106109
)
107110
)
108111

109-
lazy val natchezSlf4j = project
112+
lazy val natchezSlf4j = projectMatrix
110113
.in(file("natchez-extras-slf4j"))
114+
.jvmPlatform(scalaVersions = scalaVersions)
111115
.enablePlugins(GitVersioning)
112116
.settings(common :+ (name := "natchez-extras-slf4j"))
113117
.settings(
@@ -121,7 +125,7 @@ lazy val natchezSlf4j = project
121125
lazy val natchezHttp4s = projectMatrix
122126
.in(file("natchez-extras-http4s"))
123127
.customRow(
124-
scalaVersions = Seq(scalaVer),
128+
scalaVersions = scalaVersions,
125129
axisValues = Seq(Http4sVersion.Milestone, VirtualAxis.jvm),
126130
settings = List(
127131
name := "natchez-extras-http4s",
@@ -132,7 +136,7 @@ lazy val natchezHttp4s = projectMatrix
132136
)
133137
)
134138
.customRow(
135-
scalaVersions = Seq(scalaVer),
139+
scalaVersions = scalaVersions,
136140
axisValues = Seq(Http4sVersion.Stable, VirtualAxis.jvm),
137141
settings = List(
138142
name := "natchez-extras-http4s-stable",
@@ -142,7 +146,7 @@ lazy val natchezHttp4s = projectMatrix
142146
)
143147
)
144148
)
145-
.configure(_.dependsOn(natchezTestkit))
149+
.dependsOn(natchezTestkit)
146150
.enablePlugins(GitVersioning)
147151
.settings(common)
148152
.settings(
@@ -151,8 +155,9 @@ lazy val natchezHttp4s = projectMatrix
151155
)
152156
)
153157

154-
lazy val natchezLog4Cats = project
158+
lazy val natchezLog4Cats = projectMatrix
155159
.in(file("natchez-extras-log4cats"))
160+
.jvmPlatform(scalaVersions = scalaVersions)
156161
.enablePlugins(GitVersioning)
157162
.settings(common :+ (name := "natchez-extras-log4cats"))
158163
.settings(
@@ -162,8 +167,9 @@ lazy val natchezLog4Cats = project
162167
)
163168
)
164169

165-
lazy val natchezTestkit = project
170+
lazy val natchezTestkit = projectMatrix
166171
.in(file("natchez-extras-testkit"))
172+
.jvmPlatform(scalaVersions = scalaVersions)
167173
.enablePlugins(GitVersioning)
168174
.settings(common :+ (name := "natchez-extras-testkit"))
169175
.settings(
@@ -172,21 +178,23 @@ lazy val natchezTestkit = project
172178
)
173179
)
174180

175-
lazy val natchezFs2 = project
181+
lazy val natchezFs2 = projectMatrix
176182
.in(file("natchez-extras-fs2"))
183+
.jvmPlatform(scalaVersions = scalaVersions)
177184
.dependsOn(natchezTestkit)
178185
.enablePlugins(GitVersioning)
179186
.settings(common :+ (name := "natchez-extras-fs2"))
180187
.settings(
181188
libraryDependencies ++= Seq(
182-
"org.typelevel" %% "kittens" % "2.3.2",
189+
"org.typelevel" %% "kittens" % "3.0.0-M4",
183190
"org.tpolecat" %% "natchez-core" % natchezVersion,
184191
"co.fs2" %% "fs2-core" % fs2Version
185192
)
186193
)
187194

188-
lazy val natchezDoobie = project
195+
lazy val natchezDoobie = projectMatrix
189196
.in(file("natchez-extras-doobie"))
197+
.jvmPlatform(scalaVersions = scalaVersions)
190198
.enablePlugins(GitVersioning)
191199
.settings(common :+ (name := "natchez-extras-doobie"))
192200
.settings(
@@ -198,23 +206,26 @@ lazy val natchezDoobie = project
198206
)
199207
.dependsOn(core)
200208

201-
lazy val core = project
209+
lazy val core = projectMatrix
202210
.in(file("natchez-extras-core"))
211+
.jvmPlatform(scalaVersions = scalaVersions)
203212
.enablePlugins(GitVersioning)
204213
.settings(
205214
common ++ Seq(
206215
name := "natchez-extras-core",
207216
)
208217
)
209218

210-
lazy val natchezCombine = project
219+
lazy val natchezCombine = projectMatrix
211220
.in(file("natchez-extras-combine"))
221+
.jvmPlatform(scalaVersions = scalaVersions)
212222
.enablePlugins(GitVersioning)
213223
.settings(common :+ (name := "natchez-extras-combine"))
214224
.settings(libraryDependencies += "org.tpolecat" %% "natchez-core" % natchezVersion)
215225

216-
lazy val datadogMetrics = project
226+
lazy val datadogMetrics = projectMatrix
217227
.in(file("natchez-extras-dogstatsd"))
228+
.jvmPlatform(scalaVersions = scalaVersions)
218229
.enablePlugins(GitVersioning)
219230
.settings(common :+ (name := "natchez-extras-dogstatsd"))
220231
.dependsOn(metricsCommon)
@@ -225,35 +236,39 @@ lazy val datadogMetrics = project
225236
)
226237
)
227238

228-
lazy val ce3Utils = project
239+
lazy val ce3Utils = projectMatrix
229240
.in(file("natchez-ce3"))
241+
.jvmPlatform(scalaVersions = scalaVersions)
230242
.enablePlugins(GitVersioning)
231243
.settings(common :+ (name := "natchez-extras-ce3"))
232244
.settings(libraryDependencies += "org.tpolecat" %% "natchez-core" % natchezVersion)
233245

234246
val logbackVersion = "1.2.3"
235247

236-
lazy val datadogStable = natchezDatadog.finder(Http4sVersion.Stable, VirtualAxis.jvm)(scalaVer)
237-
lazy val datadogMilestone = natchezDatadog.finder(Http4sVersion.Milestone, VirtualAxis.jvm)(scalaVer)
248+
lazy val datadogStable213 = natchezDatadog.finder(Http4sVersion.Stable, VirtualAxis.jvm)(scala213Version)
249+
lazy val datadogMilestone213 =
250+
natchezDatadog.finder(Http4sVersion.Milestone, VirtualAxis.jvm)(scala213Version)
238251

239-
lazy val natchezHttp4sStable = natchezHttp4s.finder(Http4sVersion.Stable, VirtualAxis.jvm)(scalaVer)
240-
lazy val natchezHttp4sMilestone = natchezHttp4s.finder(Http4sVersion.Milestone, VirtualAxis.jvm)(scalaVer)
252+
lazy val natchezHttp4sStable213 = natchezHttp4s.finder(Http4sVersion.Stable, VirtualAxis.jvm)(scala213Version)
253+
lazy val natchezHttp4sMilestone213 =
254+
natchezHttp4s.finder(Http4sVersion.Milestone, VirtualAxis.jvm)(scala213Version)
241255

242256
lazy val docs = project
243257
.in(file("docs"))
244258
.enablePlugins(MicrositesPlugin)
245259
.dependsOn(
246-
datadogMetrics,
247-
natchezDoobie,
248-
datadogStable,
249-
natchezCombine,
250-
natchezSlf4j,
251-
natchezFs2,
252-
natchezHttp4sStable,
253-
natchezLog4Cats,
254-
ce3Utils
260+
ce3Utils.jvm(scala213Version),
261+
datadogMetrics.jvm(scala213Version),
262+
natchezDoobie.jvm(scala213Version),
263+
datadogStable213,
264+
natchezCombine.jvm(scala213Version),
265+
natchezSlf4j.jvm(scala213Version),
266+
natchezFs2.jvm(scala213Version),
267+
natchezHttp4sStable213,
268+
natchezLog4Cats.jvm(scala213Version)
255269
)
256270
.settings(
271+
scalaVersion := scala213Version,
257272
micrositeName := "natchez-extras",
258273
micrositeBaseUrl := "/natchez-extras",
259274
micrositeDocumentationUrl := "/natchez-extras/docs",
@@ -282,21 +297,17 @@ lazy val root = (project in file("."))
282297
publish / skip := true
283298
)
284299
)
285-
.aggregate(
286-
core,
287-
metricsCommon,
288-
datadogMetrics,
289-
datadogMilestone,
290-
datadogStable,
291-
natchezCombine,
292-
natchezSlf4j,
293-
natchezDoobie,
294-
natchezLog4Cats,
295-
natchezHttp4sMilestone,
296-
natchezHttp4sStable,
297-
natchezFs2,
298-
natchezTestkit,
299-
ce3Utils
300-
)
300+
.aggregate(core.projectRefs: _*)
301+
.aggregate(ce3Utils.projectRefs: _*)
302+
.aggregate(metricsCommon.projectRefs: _*)
303+
.aggregate(datadogMetrics.projectRefs: _*)
304+
.aggregate(natchezDatadog.projectRefs: _*)
305+
.aggregate(natchezCombine.projectRefs: _*)
306+
.aggregate(natchezSlf4j.projectRefs: _*)
307+
.aggregate(natchezDoobie.projectRefs: _*)
308+
.aggregate(natchezLog4Cats.projectRefs: _*)
309+
.aggregate(natchezHttp4s.projectRefs: _*)
310+
.aggregate(natchezFs2.projectRefs: _*)
311+
.aggregate(natchezTestkit.projectRefs: _*)
301312

302313
Global / onChangedBuildSource := ReloadOnSourceChanges

natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/DatadogSpan.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import cats.syntax.flatMap._
1010
import cats.syntax.functor._
1111
import cats.syntax.traverse._
1212
import com.ovoenergy.natchez.extras.datadog.DatadogSpan.SpanNames
13-
import io.circe.generic.extras.Configuration
1413
import natchez.TraceValue.{BooleanValue, NumberValue, StringValue}
1514
import natchez.{Kernel, Span, TraceValue}
1615

@@ -79,9 +78,6 @@ object DatadogSpan {
7978
}
8079
}
8180

82-
implicit val config: Configuration =
83-
Configuration.default.withSnakeCaseMemberNames
84-
8581
/**
8682
* Given a span, complete it - this involves turning the span into a `CompletedSpan`
8783
* which 1:1 matches the Datadog JSON structure before submitting it to a queue of spans

natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/SubmittableSpan.scala

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import cats.syntax.apply._
77
import com.ovoenergy.natchez.extras.datadog.DatadogTags.{forThrowable, SpanType}
88
import com.ovoenergy.natchez.extras.datadog.data.UnsignedLong
99
import io.circe.Encoder.encodeString
10-
import io.circe.generic.extras.Configuration
11-
import io.circe.generic.extras.semiauto._
1210
import io.circe.{Decoder, Encoder}
1311
import natchez.TraceValue
1412
import natchez.TraceValue.StringValue
@@ -35,20 +33,58 @@ case class SubmittableSpan(
3533

3634
object SubmittableSpan {
3735

38-
implicit val config: Configuration =
39-
Configuration.default.withSnakeCaseMemberNames
40-
4136
implicit val encodeSpanType: Encoder[SpanType] =
4237
encodeString.contramap(_.toString.toLowerCase)
4338

4439
implicit val decodespanType: Decoder[Option[SpanType]] =
4540
Decoder[Option[String]].map(_.flatMap(s => inferSpanType(Map("span.type" -> s))))
4641

4742
implicit val encode: Encoder[SubmittableSpan] =
48-
deriveConfiguredEncoder
43+
Encoder.forProduct12(
44+
"trace_id",
45+
"span_id",
46+
"name",
47+
"service",
48+
"resource",
49+
"type",
50+
"start",
51+
"duration",
52+
"parent_id",
53+
"error",
54+
"meta",
55+
"metrics"
56+
)(s =>
57+
(
58+
s.traceId,
59+
s.spanId,
60+
s.name,
61+
s.service,
62+
s.resource,
63+
s.`type`,
64+
s.start,
65+
s.duration,
66+
s.parentId,
67+
s.error,
68+
s.meta,
69+
s.metrics
70+
)
71+
)
4972

5073
implicit val decode: Decoder[SubmittableSpan] =
51-
deriveConfiguredDecoder
74+
Decoder.forProduct12(
75+
"trace_id",
76+
"span_id",
77+
"name",
78+
"service",
79+
"resource",
80+
"type",
81+
"start",
82+
"duration",
83+
"parent_id",
84+
"error",
85+
"meta",
86+
"metrics"
87+
)(SubmittableSpan.apply)
5288

5389
/**
5490
* It is very difficult to find any docs on this other than this fun Github issue by fommil

natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClient.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ object TracedClient {
3333
span <- Kleisli.ask[F, Span[F]]
3434
headers <- trace(span.kernel.map(_.toHeaders.toSeq))
3535
withHeader = req.putHeaders(headers.map(keyValuesToRaw): _*).mapK(dropTracing(span))
36-
reqTags <- trace(config.request.value.run(req.mapK(dropTracing(span))))
37-
_ <- trace(span.put(reqTags.toSeq: _*))
38-
(resp, rel) <- client.run(withHeader).mapK(trace[F]).map(_.mapK(trace[F])).allocated
39-
respTags <- trace(config.response.value.run(resp.mapK(dropTracing(span))))
40-
_ <- trace(span.put(respTags.toSeq: _*))
36+
reqTags <- trace(config.request.value.run(req.mapK(dropTracing(span))))
37+
_ <- trace(span.put(reqTags.toSeq: _*))
38+
resTuple <- client.run(withHeader).mapK(trace[F]).map(_.mapK(trace[F])).allocated
39+
(resp, rel) = resTuple
40+
respTags <- trace(config.response.value.run(resp.mapK(dropTracing(span))))
41+
_ <- trace(span.put(respTags.toSeq: _*))
4142
} yield resp -> rel
4243
}
4344
)

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.5.5
1+
sbt.version=1.6.2

0 commit comments

Comments
 (0)