diff --git a/.circleci/config.yml b/.circleci/config.yml index 2380d9b..cec1441 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -94,7 +94,7 @@ jobs: command: | set -e tags=`git describe --tags` - sbt ';set version in ThisBuild := "'${tags}'"; test; publishSigned; sonatypeBundleRelease' + sbt ';set version in ThisBuild := "'${tags}'"; +test; +publishSigned; +sonatypeBundleRelease' - *cache_save test: @@ -105,7 +105,7 @@ jobs: - *install_sbt - run: name: Test - command: sbt test + command: sbt +test - *cache_save workflows: @@ -117,7 +117,7 @@ workflows: - release: filters: tags: - only: /^([0-9\\.]+(-RC[0-9]+)?)$/ + only: /^([0-9\\.]+(-(RC|M)[0-9]+)?)$/ branches: ignore: /.*/ pr-build: diff --git a/build.sbt b/build.sbt index 6e28fc1..ef4671b 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,9 @@ import microsites.MicrositesPlugin.autoImport.micrositeDescription -val scalaVer: String = "2.13.8" +val scala213Version = "2.13.8" +val scala3Version = "3.2.2" -ThisBuild / scalaVersion := scalaVer +val scalaVersions = Seq(scala213Version, scala3Version) ThisBuild / organization := "com.ovoenergy" @@ -44,6 +45,8 @@ val common = Seq( libraryDependencies ++= Seq( compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"), compilerPlugin("org.typelevel" % "kind-projector" % "0.13.2" cross CrossVersion.full), + ).filterNot(_ => scalaVersion.value.startsWith("3.")), + libraryDependencies ++= Seq( "org.typelevel" %% "cats-core" % "2.7.0", "org.typelevel" %% "cats-effect" % "3.3.5", "org.scalameta" %% "munit" % "0.7.29" % Test, @@ -53,8 +56,9 @@ val common = Seq( ) ) -lazy val metricsCommon = project +lazy val metricsCommon = projectMatrix .in(file("natchez-extras-metrics")) + .jvmPlatform(scalaVersions = scalaVersions) .enablePlugins(GitVersioning) .settings(common :+ (name := "natchez-extras-metrics")) @@ -70,7 +74,7 @@ val doobieVersion = "1.0.0-RC2" lazy val natchezDatadog = projectMatrix .in(file("natchez-extras-datadog")) .customRow( - scalaVersions = Seq(scalaVer), + scalaVersions = scalaVersions, axisValues = Seq(Http4sVersion.Milestone, VirtualAxis.jvm), settings = List( name := "natchez-extras-datadog", @@ -82,7 +86,7 @@ lazy val natchezDatadog = projectMatrix ) ) .customRow( - scalaVersions = Seq(scalaVer), + scalaVersions = scalaVersions, axisValues = Seq(Http4sVersion.Stable, VirtualAxis.jvm), settings = List( name := "natchez-extras-datadog-stable", @@ -100,14 +104,14 @@ lazy val natchezDatadog = projectMatrix "org.tpolecat" %% "natchez-core" % natchezVersion, "io.circe" %% "circe-core" % circeVersion, "io.circe" %% "circe-generic" % circeVersion, - "io.circe" %% "circe-generic-extras" % circeVersion, "io.circe" %% "circe-parser" % circeVersion, "org.slf4j" % "slf4j-api" % slf4jVersion ) ) -lazy val natchezSlf4j = project +lazy val natchezSlf4j = projectMatrix .in(file("natchez-extras-slf4j")) + .jvmPlatform(scalaVersions = scalaVersions) .enablePlugins(GitVersioning) .settings(common :+ (name := "natchez-extras-slf4j")) .settings( @@ -121,7 +125,7 @@ lazy val natchezSlf4j = project lazy val natchezHttp4s = projectMatrix .in(file("natchez-extras-http4s")) .customRow( - scalaVersions = Seq(scalaVer), + scalaVersions = scalaVersions, axisValues = Seq(Http4sVersion.Milestone, VirtualAxis.jvm), settings = List( name := "natchez-extras-http4s", @@ -132,7 +136,7 @@ lazy val natchezHttp4s = projectMatrix ) ) .customRow( - scalaVersions = Seq(scalaVer), + scalaVersions = scalaVersions, axisValues = Seq(Http4sVersion.Stable, VirtualAxis.jvm), settings = List( name := "natchez-extras-http4s-stable", @@ -142,7 +146,7 @@ lazy val natchezHttp4s = projectMatrix ) ) ) - .configure(_.dependsOn(natchezTestkit)) + .dependsOn(natchezTestkit) .enablePlugins(GitVersioning) .settings(common) .settings( @@ -151,8 +155,9 @@ lazy val natchezHttp4s = projectMatrix ) ) -lazy val natchezLog4Cats = project +lazy val natchezLog4Cats = projectMatrix .in(file("natchez-extras-log4cats")) + .jvmPlatform(scalaVersions = scalaVersions) .enablePlugins(GitVersioning) .settings(common :+ (name := "natchez-extras-log4cats")) .settings( @@ -162,8 +167,9 @@ lazy val natchezLog4Cats = project ) ) -lazy val natchezTestkit = project +lazy val natchezTestkit = projectMatrix .in(file("natchez-extras-testkit")) + .jvmPlatform(scalaVersions = scalaVersions) .enablePlugins(GitVersioning) .settings(common :+ (name := "natchez-extras-testkit")) .settings( @@ -172,21 +178,23 @@ lazy val natchezTestkit = project ) ) -lazy val natchezFs2 = project +lazy val natchezFs2 = projectMatrix .in(file("natchez-extras-fs2")) + .jvmPlatform(scalaVersions = scalaVersions) .dependsOn(natchezTestkit) .enablePlugins(GitVersioning) .settings(common :+ (name := "natchez-extras-fs2")) .settings( libraryDependencies ++= Seq( - "org.typelevel" %% "kittens" % "2.3.2", + "org.typelevel" %% "kittens" % "3.0.0-M4", "org.tpolecat" %% "natchez-core" % natchezVersion, "co.fs2" %% "fs2-core" % fs2Version ) ) -lazy val natchezDoobie = project +lazy val natchezDoobie = projectMatrix .in(file("natchez-extras-doobie")) + .jvmPlatform(scalaVersions = scalaVersions) .enablePlugins(GitVersioning) .settings(common :+ (name := "natchez-extras-doobie")) .settings( @@ -198,8 +206,9 @@ lazy val natchezDoobie = project ) .dependsOn(core) -lazy val core = project +lazy val core = projectMatrix .in(file("natchez-extras-core")) + .jvmPlatform(scalaVersions = scalaVersions) .enablePlugins(GitVersioning) .settings( common ++ Seq( @@ -207,14 +216,16 @@ lazy val core = project ) ) -lazy val natchezCombine = project +lazy val natchezCombine = projectMatrix .in(file("natchez-extras-combine")) + .jvmPlatform(scalaVersions = scalaVersions) .enablePlugins(GitVersioning) .settings(common :+ (name := "natchez-extras-combine")) .settings(libraryDependencies += "org.tpolecat" %% "natchez-core" % natchezVersion) -lazy val datadogMetrics = project +lazy val datadogMetrics = projectMatrix .in(file("natchez-extras-dogstatsd")) + .jvmPlatform(scalaVersions = scalaVersions) .enablePlugins(GitVersioning) .settings(common :+ (name := "natchez-extras-dogstatsd")) .dependsOn(metricsCommon) @@ -225,35 +236,39 @@ lazy val datadogMetrics = project ) ) -lazy val ce3Utils = project +lazy val ce3Utils = projectMatrix .in(file("natchez-ce3")) + .jvmPlatform(scalaVersions = scalaVersions) .enablePlugins(GitVersioning) .settings(common :+ (name := "natchez-extras-ce3")) .settings(libraryDependencies += "org.tpolecat" %% "natchez-core" % natchezVersion) val logbackVersion = "1.2.3" -lazy val datadogStable = natchezDatadog.finder(Http4sVersion.Stable, VirtualAxis.jvm)(scalaVer) -lazy val datadogMilestone = natchezDatadog.finder(Http4sVersion.Milestone, VirtualAxis.jvm)(scalaVer) +lazy val datadogStable213 = natchezDatadog.finder(Http4sVersion.Stable, VirtualAxis.jvm)(scala213Version) +lazy val datadogMilestone213 = + natchezDatadog.finder(Http4sVersion.Milestone, VirtualAxis.jvm)(scala213Version) -lazy val natchezHttp4sStable = natchezHttp4s.finder(Http4sVersion.Stable, VirtualAxis.jvm)(scalaVer) -lazy val natchezHttp4sMilestone = natchezHttp4s.finder(Http4sVersion.Milestone, VirtualAxis.jvm)(scalaVer) +lazy val natchezHttp4sStable213 = natchezHttp4s.finder(Http4sVersion.Stable, VirtualAxis.jvm)(scala213Version) +lazy val natchezHttp4sMilestone213 = + natchezHttp4s.finder(Http4sVersion.Milestone, VirtualAxis.jvm)(scala213Version) lazy val docs = project .in(file("docs")) .enablePlugins(MicrositesPlugin) .dependsOn( - datadogMetrics, - natchezDoobie, - datadogStable, - natchezCombine, - natchezSlf4j, - natchezFs2, - natchezHttp4sStable, - natchezLog4Cats, - ce3Utils + ce3Utils.jvm(scala213Version), + datadogMetrics.jvm(scala213Version), + natchezDoobie.jvm(scala213Version), + datadogStable213, + natchezCombine.jvm(scala213Version), + natchezSlf4j.jvm(scala213Version), + natchezFs2.jvm(scala213Version), + natchezHttp4sStable213, + natchezLog4Cats.jvm(scala213Version) ) .settings( + scalaVersion := scala213Version, micrositeName := "natchez-extras", micrositeBaseUrl := "/natchez-extras", micrositeDocumentationUrl := "/natchez-extras/docs", @@ -282,21 +297,17 @@ lazy val root = (project in file(".")) publish / skip := true ) ) - .aggregate( - core, - metricsCommon, - datadogMetrics, - datadogMilestone, - datadogStable, - natchezCombine, - natchezSlf4j, - natchezDoobie, - natchezLog4Cats, - natchezHttp4sMilestone, - natchezHttp4sStable, - natchezFs2, - natchezTestkit, - ce3Utils - ) + .aggregate(core.projectRefs: _*) + .aggregate(ce3Utils.projectRefs: _*) + .aggregate(metricsCommon.projectRefs: _*) + .aggregate(datadogMetrics.projectRefs: _*) + .aggregate(natchezDatadog.projectRefs: _*) + .aggregate(natchezCombine.projectRefs: _*) + .aggregate(natchezSlf4j.projectRefs: _*) + .aggregate(natchezDoobie.projectRefs: _*) + .aggregate(natchezLog4Cats.projectRefs: _*) + .aggregate(natchezHttp4s.projectRefs: _*) + .aggregate(natchezFs2.projectRefs: _*) + .aggregate(natchezTestkit.projectRefs: _*) Global / onChangedBuildSource := ReloadOnSourceChanges diff --git a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/DatadogSpan.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/DatadogSpan.scala index a4e52c4..b23bed5 100644 --- a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/DatadogSpan.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/DatadogSpan.scala @@ -10,7 +10,6 @@ import cats.syntax.flatMap._ import cats.syntax.functor._ import cats.syntax.traverse._ import com.ovoenergy.natchez.extras.datadog.DatadogSpan.SpanNames -import io.circe.generic.extras.Configuration import natchez.TraceValue.{BooleanValue, NumberValue, StringValue} import natchez.{Kernel, Span, TraceValue} @@ -79,9 +78,6 @@ object DatadogSpan { } } - implicit val config: Configuration = - Configuration.default.withSnakeCaseMemberNames - /** * Given a span, complete it - this involves turning the span into a `CompletedSpan` * which 1:1 matches the Datadog JSON structure before submitting it to a queue of spans diff --git a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/SubmittableSpan.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/SubmittableSpan.scala index d9b697b..ab39475 100644 --- a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/SubmittableSpan.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/SubmittableSpan.scala @@ -7,8 +7,6 @@ import cats.syntax.apply._ import com.ovoenergy.natchez.extras.datadog.DatadogTags.{forThrowable, SpanType} import com.ovoenergy.natchez.extras.datadog.data.UnsignedLong import io.circe.Encoder.encodeString -import io.circe.generic.extras.Configuration -import io.circe.generic.extras.semiauto._ import io.circe.{Decoder, Encoder} import natchez.TraceValue import natchez.TraceValue.StringValue @@ -35,9 +33,6 @@ case class SubmittableSpan( object SubmittableSpan { - implicit val config: Configuration = - Configuration.default.withSnakeCaseMemberNames - implicit val encodeSpanType: Encoder[SpanType] = encodeString.contramap(_.toString.toLowerCase) @@ -45,10 +40,51 @@ object SubmittableSpan { Decoder[Option[String]].map(_.flatMap(s => inferSpanType(Map("span.type" -> s)))) implicit val encode: Encoder[SubmittableSpan] = - deriveConfiguredEncoder + Encoder.forProduct12( + "trace_id", + "span_id", + "name", + "service", + "resource", + "type", + "start", + "duration", + "parent_id", + "error", + "meta", + "metrics" + )(s => + ( + s.traceId, + s.spanId, + s.name, + s.service, + s.resource, + s.`type`, + s.start, + s.duration, + s.parentId, + s.error, + s.meta, + s.metrics + ) + ) implicit val decode: Decoder[SubmittableSpan] = - deriveConfiguredDecoder + Decoder.forProduct12( + "trace_id", + "span_id", + "name", + "service", + "resource", + "type", + "start", + "duration", + "parent_id", + "error", + "meta", + "metrics" + )(SubmittableSpan.apply) /** * It is very difficult to find any docs on this other than this fun Github issue by fommil diff --git a/natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClient.scala b/natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClient.scala index ec6ff14..c0145dc 100644 --- a/natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClient.scala +++ b/natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClient.scala @@ -33,11 +33,12 @@ object TracedClient { span <- Kleisli.ask[F, Span[F]] headers <- trace(span.kernel.map(_.toHeaders.toSeq)) withHeader = req.putHeaders(headers.map(keyValuesToRaw): _*).mapK(dropTracing(span)) - reqTags <- trace(config.request.value.run(req.mapK(dropTracing(span)))) - _ <- trace(span.put(reqTags.toSeq: _*)) - (resp, rel) <- client.run(withHeader).mapK(trace[F]).map(_.mapK(trace[F])).allocated - respTags <- trace(config.response.value.run(resp.mapK(dropTracing(span)))) - _ <- trace(span.put(respTags.toSeq: _*)) + reqTags <- trace(config.request.value.run(req.mapK(dropTracing(span)))) + _ <- trace(span.put(reqTags.toSeq: _*)) + resTuple <- client.run(withHeader).mapK(trace[F]).map(_.mapK(trace[F])).allocated + (resp, rel) = resTuple + respTags <- trace(config.response.value.run(resp.mapK(dropTracing(span)))) + _ <- trace(span.put(respTags.toSeq: _*)) } yield resp -> rel } ) diff --git a/project/build.properties b/project/build.properties index 10fd9ee..c8fcab5 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.5 +sbt.version=1.6.2 diff --git a/project/plugins.sbt b/project/plugins.sbt index 011e12b..690b272 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,6 +2,7 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.9") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16") addSbtPlugin("com.47deg" % "sbt-microsites" % "1.3.4") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")