From be1e0ec2c6621c847a086279fbc63eb6e015d541 Mon Sep 17 00:00:00 2001 From: Tom Verran Date: Fri, 16 Apr 2021 11:47:35 +0100 Subject: [PATCH 1/8] Rename everything to natchez-extras --- build.sbt | 50 +++++++++---------- docs/docs/docs/natchez-datadog.md | 2 +- .../ovoenergy/natchez/extras}/Combine.scala | 2 +- .../ovoenergy/natchez/extras}/Datadog.scala | 4 +- .../natchez/extras}/DatadogSpan.scala | 4 +- .../natchez/extras}/DatadogTags.scala | 2 +- .../natchez/extras}/SpanIdentifiers.scala | 2 +- .../natchez/extras}/SubmittableSpan.scala | 5 +- .../natchez/extras}/DatadogTest.scala | 8 +-- .../natchez/extras}/SpanIdentifiersTest.scala | 4 +- .../natchez/extras}/TestClient.scala | 2 +- .../ovoenergy/natchez/extras/Dogstatsd.scala | 22 ++++---- .../ovoenergy/natchez/extras}/Events.scala | 4 +- .../natchez/extras}/DatadogTest.scala | 8 +-- .../natchez/extras}/TracedStatement.scala | 2 +- .../natchez/extras}/TracedTransactor.scala | 2 +- .../extras}/TracedTransactorTest.scala | 4 +- .../natchez/extras}/AllocatedSpan.scala | 2 +- .../ovoenergy/natchez/extras}/syntax.scala | 5 +- .../natchez/extras}/AllocatedSpanTest.scala | 2 +- .../extras}/http4s/Configuration.scala | 4 +- .../extras}/http4s/client/TracedClient.scala | 6 +-- .../http4s/server/TraceMiddleware.scala | 4 +- .../extras}/http4s/client/TestClient.scala | 2 +- .../http4s/client/TracedClientTest.scala | 8 +-- .../http4s/server/TraceMiddlewareTest.scala | 4 +- .../natchez/extras}/TracedLogger.scala | 2 +- .../ovoenergy/natchez/extras}/Metrics.scala | 4 +- .../com/ovoenergy/natchez/extras}/Slf4j.scala | 2 +- .../ovoenergy/natchez/extras}/Slf4jSpan.scala | 2 +- .../natchez/extras}/Slf4jSpanTest.scala | 2 +- .../natchez/extras}/TestEntryPoint.scala | 4 +- 32 files changed, 90 insertions(+), 90 deletions(-) rename {natchez-combine/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-combine/src/main/scala/com/ovoenergy/natchez/extras}/Combine.scala (97%) rename {natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras}/Datadog.scala (97%) rename {natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras}/DatadogSpan.scala (97%) rename {natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras}/DatadogTags.scala (97%) rename {natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras}/SpanIdentifiers.scala (98%) rename {natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras}/SubmittableSpan.scala (97%) rename {natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez => natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras}/DatadogTest.scala (95%) rename {natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez => natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras}/SpanIdentifiersTest.scala (94%) rename {natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez => natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras}/TestClient.scala (96%) rename metrics-datadog/src/main/scala/com/ovoenergy/effect/Datadog.scala => natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Dogstatsd.scala (88%) rename {metrics-datadog/src/main/scala/com/ovoenergy/effect => natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras}/Events.scala (94%) rename {metrics-datadog/src/test/scala/com/ovoenergy/effect => natchez-extras-dogstatsd/src/test/scala/com/ovoenergy/natchez/extras}/DatadogTest.scala (95%) rename {natchez-doobie/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras}/TracedStatement.scala (99%) rename {natchez-doobie/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras}/TracedTransactor.scala (98%) rename {natchez-doobie/src/test/scala/com/ovoenergy/effect/natchez => natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras}/TracedTransactorTest.scala (96%) rename {natchez-fs2/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras}/AllocatedSpan.scala (99%) rename {natchez-fs2/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras}/syntax.scala (84%) rename {natchez-fs2/src/test/scala/com/ovoenergy/effect/natchez => natchez-extras-fs2/src/test/scala/com/ovoenergy/natchez/extras}/AllocatedSpanTest.scala (99%) rename {natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras}/http4s/Configuration.scala (97%) rename {natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras}/http4s/client/TracedClient.scala (89%) rename {natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras}/http4s/server/TraceMiddleware.scala (94%) rename {natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez => natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras}/http4s/client/TestClient.scala (92%) rename {natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez => natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras}/http4s/client/TracedClientTest.scala (87%) rename {natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez => natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras}/http4s/server/TraceMiddlewareTest.scala (98%) rename {natchez-log4cats/src/main/scala/com/ovoenergy/effect => natchez-extras-log4cats/src/main/scala/com/ovoenergy/natchez/extras}/TracedLogger.scala (99%) rename {metrics-common/src/main/scala/com/ovoenergy/effect => natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras}/Metrics.scala (95%) rename {natchez-slf4j/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras}/Slf4j.scala (95%) rename {natchez-slf4j/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras}/Slf4jSpan.scala (98%) rename {natchez-slf4j/src/test/scala/com/ovoenergy/effect/natchez => natchez-extras-slf4j/src/test/scala/com/ovoenergy/natchez/extras}/Slf4jSpanTest.scala (98%) rename {natchez-testkit/src/main/scala/com/ovoenergy/effect/natchez => natchez-extras-testkit/src/main/scala/com/ovoenergy/natchez/extras}/TestEntryPoint.scala (95%) diff --git a/build.sbt b/build.sbt index 81ffae5..f912631 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ scalaVersion in ThisBuild := "2.13.4" classLoaderLayeringStrategy in ThisBuild := ClassLoaderLayeringStrategy.ScalaLibrary -organization in ThisBuild := "com.ovoenergy.effect" +organization in ThisBuild := "com.ovoenergy" organizationName in ThisBuild := "OVO Energy" @@ -28,9 +28,9 @@ val common = Seq( ) lazy val metricsCommon = project - .in(file("metrics-common")) + .in(file("natchez-extras-metrics")) .enablePlugins(GitVersioning) - .settings(common :+ (name := "metrics-common")) + .settings(common :+ (name := "natchez-extras-metrics")) val log4catsVersion = "1.2.2" val natchezVersion = "0.0.19" @@ -40,9 +40,9 @@ val slf4jVersion = "1.7.30" val fs2Version = "2.5.0" lazy val natchezDatadog = project - .in(file("natchez-datadog")) + .in(file("natchez-extras-datadog")) .enablePlugins(GitVersioning) - .settings(common :+ (name := "natchez-datadog")) + .settings(common :+ (name := "natchez-extras-datadog")) .settings( libraryDependencies ++= Seq( "org.tpolecat" %% "natchez-core" % natchezVersion, @@ -58,9 +58,9 @@ lazy val natchezDatadog = project ) lazy val natchezSlf4j = project - .in(file("natchez-slf4j")) + .in(file("natchez-extras-slf4j")) .enablePlugins(GitVersioning) - .settings(common :+ (name := "natchez-slf4j")) + .settings(common :+ (name := "natchez-extras-slf4j")) .settings( libraryDependencies ++= Seq( "org.tpolecat" %% "natchez-core" % natchezVersion, @@ -70,10 +70,10 @@ lazy val natchezSlf4j = project ) lazy val natchezHttp4s = project - .in(file("natchez-http4s")) + .in(file("natchez-extras-http4s")) .dependsOn(natchezTestkit) .enablePlugins(GitVersioning) - .settings(common :+ (name := "natchez-http4s")) + .settings(common :+ (name := "natchez-extras-http4s")) .settings( libraryDependencies ++= Seq( "org.tpolecat" %% "natchez-core" % natchezVersion, @@ -83,9 +83,9 @@ lazy val natchezHttp4s = project ) lazy val natchezLog4Cats = project - .in(file("natchez-log4cats")) + .in(file("natchez-extras-log4cats")) .enablePlugins(GitVersioning) - .settings(common :+ (name := "natchez-log4cats")) + .settings(common :+ (name := "natchez-extras-log4cats")) .settings( libraryDependencies ++= Seq( "org.tpolecat" %% "natchez-core" % natchezVersion, @@ -94,9 +94,9 @@ lazy val natchezLog4Cats = project ) lazy val natchezTestkit = project - .in(file("natchez-testkit")) + .in(file("natchez-extras-testkit")) .enablePlugins(GitVersioning) - .settings(common :+ (name := "natchez-testkit")) + .settings(common :+ (name := "natchez-extras-testkit")) .settings( libraryDependencies ++= Seq( "org.tpolecat" %% "natchez-core" % natchezVersion @@ -104,10 +104,10 @@ lazy val natchezTestkit = project ) lazy val natchezFs2 = project - .in(file("natchez-fs2")) + .in(file("natchez-extras-fs2")) .dependsOn(natchezTestkit) .enablePlugins(GitVersioning) - .settings(common :+ (name := "natchez-fs2")) + .settings(common :+ (name := "natchez-extras-fs2")) .settings( libraryDependencies ++= Seq( "org.typelevel" %% "kittens" % "2.2.1", @@ -119,9 +119,9 @@ lazy val natchezFs2 = project val silencerVersion = "1.7.1" val doobieVersion = "0.10.0" lazy val natchezDoobie = project - .in(file("natchez-doobie")) + .in(file("natchez-extras-doobie")) .enablePlugins(GitVersioning) - .settings(common :+ (name := "natchez-doobie")) + .settings(common :+ (name := "natchez-extras-doobie")) .settings( libraryDependencies ++= Seq( "org.tpolecat" %% "natchez-core" % natchezVersion, @@ -133,15 +133,15 @@ lazy val natchezDoobie = project ) lazy val natchezCombine = project - .in(file("natchez-combine")) + .in(file("natchez-extras-combine")) .enablePlugins(GitVersioning) - .settings(common :+ (name := "natchez-combine")) + .settings(common :+ (name := "natchez-extras-combine")) .settings(libraryDependencies += "org.tpolecat" %% "natchez-core" % natchezVersion) lazy val datadogMetrics = project - .in(file("metrics-datadog")) + .in(file("natchez-extras-dogstatsd")) .enablePlugins(GitVersioning) - .settings(common :+ (name := "datadog-metrics")) + .settings(common :+ (name := "natchez-extras-dogstatsd")) .dependsOn(metricsCommon) .settings( libraryDependencies ++= Seq( @@ -167,9 +167,9 @@ lazy val docs = project natchezLog4Cats ) .settings( - micrositeName := "effect-utils", - micrositeBaseUrl := "/effect-utils", - micrositeDocumentationUrl := "/effect-utils/docs", + micrositeName := "natchez-extras", + micrositeBaseUrl := "/natchez-extras", + micrositeDocumentationUrl := "/natchez-extras/docs", micrositeDescription := "Datadog integrations for functional Scala", micrositeImgDirectory := (resourceDirectory in Compile).value / "microsite" / "img", micrositePalette := micrositePalette.value ++ Map("brand-primary" -> "#632CA6"), @@ -187,7 +187,7 @@ lazy val docs = project lazy val root = (project in file(".")) .settings( common ++ Seq( - name := "effect-utils", + name := "natchez-extras", publish := nop, publishLocal := nop )) diff --git a/docs/docs/docs/natchez-datadog.md b/docs/docs/docs/natchez-datadog.md index 1aee081..c876438 100644 --- a/docs/docs/docs/natchez-datadog.md +++ b/docs/docs/docs/natchez-datadog.md @@ -92,7 +92,7 @@ A number of helper functions to create tags that Datadog uses to drive its trace An example of how to use them follows: ```scala -import com.ovoenergy.effect.natchez.DatadogTags._ +import com.ovoenergy.natchez.extras.DatadogTags._ import natchez.Trace object DatadogTagsExample { diff --git a/natchez-combine/src/main/scala/com/ovoenergy/effect/natchez/Combine.scala b/natchez-extras-combine/src/main/scala/com/ovoenergy/natchez/extras/Combine.scala similarity index 97% rename from natchez-combine/src/main/scala/com/ovoenergy/effect/natchez/Combine.scala rename to natchez-extras-combine/src/main/scala/com/ovoenergy/natchez/extras/Combine.scala index d86a48f..2ab483f 100644 --- a/natchez-combine/src/main/scala/com/ovoenergy/effect/natchez/Combine.scala +++ b/natchez-extras-combine/src/main/scala/com/ovoenergy/natchez/extras/Combine.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import cats.data.OptionT import cats.effect.{Resource, Sync} diff --git a/natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/Datadog.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/Datadog.scala similarity index 97% rename from natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/Datadog.scala rename to natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/Datadog.scala index 7cc7762..292736d 100644 --- a/natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/Datadog.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/Datadog.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import cats.Applicative import cats.effect._ @@ -7,7 +7,7 @@ import cats.instances.option._ import cats.syntax.flatMap._ import cats.syntax.functor._ import cats.syntax.traverse._ -import com.ovoenergy.effect.natchez.DatadogSpan.SpanNames +import DatadogSpan.SpanNames import fs2.concurrent.Queue import io.circe.{Encoder, Printer} import fs2._ diff --git a/natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/DatadogSpan.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogSpan.scala similarity index 97% rename from natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/DatadogSpan.scala rename to natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogSpan.scala index 73d1cbb..510dd09 100644 --- a/natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/DatadogSpan.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogSpan.scala @@ -1,10 +1,10 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import cats.effect.concurrent.Ref import cats.effect.{Clock, ExitCase, Resource, Sync} import cats.syntax.flatMap._ import cats.syntax.functor._ -import com.ovoenergy.effect.natchez.DatadogSpan.SpanNames +import DatadogSpan.SpanNames import fs2.concurrent.Queue import io.circe.generic.extras.Configuration import natchez.{Kernel, Span, TraceValue} diff --git a/natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/DatadogTags.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogTags.scala similarity index 97% rename from natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/DatadogTags.scala rename to natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogTags.scala index 525f5e4..0be0f5e 100644 --- a/natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/DatadogTags.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogTags.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import natchez.TraceValue diff --git a/natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/SpanIdentifiers.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SpanIdentifiers.scala similarity index 98% rename from natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/SpanIdentifiers.scala rename to natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SpanIdentifiers.scala index b2d2231..92745c2 100644 --- a/natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/SpanIdentifiers.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SpanIdentifiers.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import java.util.UUID diff --git a/natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/SubmittableSpan.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SubmittableSpan.scala similarity index 97% rename from natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/SubmittableSpan.scala rename to natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SubmittableSpan.scala index 91813fe..5d542ea 100644 --- a/natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/SubmittableSpan.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SubmittableSpan.scala @@ -1,11 +1,10 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import java.util.concurrent.TimeUnit.NANOSECONDS - import cats.Applicative import cats.effect.{Clock, ExitCase} import cats.syntax.apply._ -import com.ovoenergy.effect.natchez.DatadogTags.{forThrowable, SpanType} +import com.ovoenergy.natchez.extras.DatadogTags.{SpanType, forThrowable} import io.circe.{Decoder, Encoder} import io.circe.Encoder.encodeString import io.circe.generic.extras.Configuration diff --git a/natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez/DatadogTest.scala b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala similarity index 95% rename from natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez/DatadogTest.scala rename to natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala index dd49d20..229d647 100644 --- a/natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez/DatadogTest.scala +++ b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala @@ -1,12 +1,12 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import cats.effect._ import cats.instances.list._ import cats.syntax.flatMap._ import cats.syntax.traverse._ -import com.ovoenergy.effect.natchez.Datadog.entryPoint -import com.ovoenergy.effect.natchez.DatadogTags.SpanType.{Cache, Db, Web} -import com.ovoenergy.effect.natchez.DatadogTags.spanType +import Datadog.entryPoint +import DatadogTags.SpanType.{Cache, Db, Web} +import DatadogTags.spanType import natchez.EntryPoint import org.http4s.Request import org.http4s.circe.CirceEntityDecoder._ diff --git a/natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez/SpanIdentifiersTest.scala b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/SpanIdentifiersTest.scala similarity index 94% rename from natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez/SpanIdentifiersTest.scala rename to natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/SpanIdentifiersTest.scala index 2c9060f..75692ff 100644 --- a/natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez/SpanIdentifiersTest.scala +++ b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/SpanIdentifiersTest.scala @@ -1,7 +1,7 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import cats.effect.IO -import com.ovoenergy.effect.natchez.SpanIdentifiers._ +import SpanIdentifiers._ import natchez.Kernel import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec diff --git a/natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez/TestClient.scala b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/TestClient.scala similarity index 96% rename from natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez/TestClient.scala rename to natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/TestClient.scala index 3fe2b37..f112a35 100644 --- a/natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez/TestClient.scala +++ b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/TestClient.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import cats.effect.concurrent.Ref import cats.effect.{Concurrent, Resource, Sync} diff --git a/metrics-datadog/src/main/scala/com/ovoenergy/effect/Datadog.scala b/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Dogstatsd.scala similarity index 88% rename from metrics-datadog/src/main/scala/com/ovoenergy/effect/Datadog.scala rename to natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Dogstatsd.scala index 4d391c3..a1fab87 100644 --- a/metrics-datadog/src/main/scala/com/ovoenergy/effect/Datadog.scala +++ b/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Dogstatsd.scala @@ -1,15 +1,15 @@ -package com.ovoenergy.effect +package com.ovoenergy.natchez.extras import java.net.InetSocketAddress import java.nio.charset.StandardCharsets.UTF_8 import cats.effect._ -import com.ovoenergy.effect.Events.Event -import com.ovoenergy.effect.Metrics.Metric +import Events.Event +import Metrics.Metric import fs2.Chunk.array import fs2.io.udp._ -object Datadog { +object Dogstatsd { // just for readability type UTF8Bytes = Array[Byte] @@ -56,14 +56,14 @@ object Datadog { * Datadog enforces all metrics must start with a letter * and not contain any chars other than letters, numbers and underscores */ - private[effect] def filterName(s: String): String = + private[extras] def filterName(s: String): String = s.dropWhile(!_.isLetter).replaceAll("[^A-Za-z0-9.]+", "_").take(maxMetricNameLength) /** * More lenient filtering for tag values, * we allow alpha numeric characters, slashes, hyphens and numbers */ - private[effect] def filterTagValue(s: String): String = + private[extras] def filterTagValue(s: String): String = s.replaceAll("[^A-Za-z0-9./\\-]+", "_") /** @@ -71,7 +71,7 @@ object Datadog { * https://github.com/DataDog/datadog-agent/blob/21a80ab80de389adb9c74e3e9a7162f83fda3e0c/pkg/dogstatsd/parse_events.go#L62 * As such we obtain the byte values from the string in UTF-8 */ - private[effect] def filterEventText(s: String): UTF8Bytes = + private[extras] def filterEventText(s: String): UTF8Bytes = s.take(maxStringLength).replaceAll("[\\r\\n]", "\\\\n").utf8Bytes private def serialiseTags(t: Map[String, String]): UTF8Bytes = { @@ -83,13 +83,13 @@ object Datadog { .fold(Array.empty[Byte])(ts => s"|#$ts".utf8Bytes) } - private[effect] def serialiseCounter(m: Metric, value: Long): UTF8Bytes = + private[extras] def serialiseCounter(m: Metric, value: Long): UTF8Bytes = s"${filterName(m.name)}:$value|c".utf8Bytes ++ serialiseTags(m.tags) - private[effect] def serialiseHistogram(m: Metric, value: Long): UTF8Bytes = + private[extras] def serialiseHistogram(m: Metric, value: Long): UTF8Bytes = s"${filterName(m.name)}:$value|h|@1.0".utf8Bytes ++ serialiseTags(m.tags) - private[effect] def serialiseEvent(e: Event): UTF8Bytes = { + private[extras] def serialiseEvent(e: Event): UTF8Bytes = { val body = filterEventText(e.body) val title = filterEventText(e.title) val lengths = s"{${title.length},${body.length}}".utf8Bytes @@ -97,7 +97,7 @@ object Datadog { "_e".utf8Bytes ++ lengths.colon(title).pipe(body).pipe(meta ++ serialiseTags(e.tags)) } - private[effect] def applyConfig(m: Metric, config: Config): Metric = + private[extras] def applyConfig(m: Metric, config: Config): Metric = Metric((config.metricPrefix.toList :+ m.name).mkString("."), config.globalTags ++ m.tags) /** diff --git a/metrics-datadog/src/main/scala/com/ovoenergy/effect/Events.scala b/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Events.scala similarity index 94% rename from metrics-datadog/src/main/scala/com/ovoenergy/effect/Events.scala rename to natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Events.scala index be847f8..1ed1c14 100644 --- a/metrics-datadog/src/main/scala/com/ovoenergy/effect/Events.scala +++ b/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Events.scala @@ -1,6 +1,6 @@ -package com.ovoenergy.effect +package com.ovoenergy.natchez.extras -import com.ovoenergy.effect.Events.Event +import Events.Event /** * Events are a Datadog extension to StatsD diff --git a/metrics-datadog/src/test/scala/com/ovoenergy/effect/DatadogTest.scala b/natchez-extras-dogstatsd/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala similarity index 95% rename from metrics-datadog/src/test/scala/com/ovoenergy/effect/DatadogTest.scala rename to natchez-extras-dogstatsd/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala index b7d2ecf..45635ab 100644 --- a/metrics-datadog/src/test/scala/com/ovoenergy/effect/DatadogTest.scala +++ b/natchez-extras-dogstatsd/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala @@ -1,11 +1,11 @@ -package com.ovoenergy.effect +package com.ovoenergy.natchez.extras import java.net.InetSocketAddress import java.nio.charset.StandardCharsets.UTF_8 -import com.ovoenergy.effect.Datadog._ -import com.ovoenergy.effect.Events.{AlertType, Event, Priority} -import com.ovoenergy.effect.Metrics.Metric +import com.ovoenergy.natchez.extras.Dogstatsd._ +import Events.{AlertType, Event, Priority} +import Metrics.Metric import org.scalacheck.Gen.mapOf import org.scalacheck.{Arbitrary, Gen, Prop} import org.scalatest.matchers.should.Matchers diff --git a/natchez-doobie/src/main/scala/com/ovoenergy/effect/natchez/TracedStatement.scala b/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedStatement.scala similarity index 99% rename from natchez-doobie/src/main/scala/com/ovoenergy/effect/natchez/TracedStatement.scala rename to natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedStatement.scala index fee8646..1727966 100644 --- a/natchez-doobie/src/main/scala/com/ovoenergy/effect/natchez/TracedStatement.scala +++ b/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedStatement.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import java.io.{InputStream, Reader} import java.net.URL diff --git a/natchez-doobie/src/main/scala/com/ovoenergy/effect/natchez/TracedTransactor.scala b/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedTransactor.scala similarity index 98% rename from natchez-doobie/src/main/scala/com/ovoenergy/effect/natchez/TracedTransactor.scala rename to natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedTransactor.scala index ae879d6..bf5a4a9 100644 --- a/natchez-doobie/src/main/scala/com/ovoenergy/effect/natchez/TracedTransactor.scala +++ b/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedTransactor.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import java.sql.{Connection, PreparedStatement, ResultSet} diff --git a/natchez-doobie/src/test/scala/com/ovoenergy/effect/natchez/TracedTransactorTest.scala b/natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/TracedTransactorTest.scala similarity index 96% rename from natchez-doobie/src/test/scala/com/ovoenergy/effect/natchez/TracedTransactorTest.scala rename to natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/TracedTransactorTest.scala index 52c787b..ed8c759 100644 --- a/natchez-doobie/src/test/scala/com/ovoenergy/effect/natchez/TracedTransactorTest.scala +++ b/natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/TracedTransactorTest.scala @@ -1,8 +1,8 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import cats.effect.concurrent.Ref import cats.effect.{Blocker, ContextShift, IO, Resource} -import com.ovoenergy.effect.natchez.TracedTransactor.Traced +import TracedTransactor.Traced import doobie.h2.H2Transactor.newH2Transactor import doobie.implicits._ import doobie.util.transactor.Transactor diff --git a/natchez-fs2/src/main/scala/com/ovoenergy/effect/natchez/AllocatedSpan.scala b/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/AllocatedSpan.scala similarity index 99% rename from natchez-fs2/src/main/scala/com/ovoenergy/effect/natchez/AllocatedSpan.scala rename to natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/AllocatedSpan.scala index e6cfafe..df15568 100644 --- a/natchez-fs2/src/main/scala/com/ovoenergy/effect/natchez/AllocatedSpan.scala +++ b/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/AllocatedSpan.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import cats.Traverse import cats.effect.{Concurrent, Resource, Sync} diff --git a/natchez-fs2/src/main/scala/com/ovoenergy/effect/natchez/syntax.scala b/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/syntax.scala similarity index 84% rename from natchez-fs2/src/main/scala/com/ovoenergy/effect/natchez/syntax.scala rename to natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/syntax.scala index dec4fc4..d549e2f 100644 --- a/natchez-fs2/src/main/scala/com/ovoenergy/effect/natchez/syntax.scala +++ b/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/syntax.scala @@ -1,7 +1,8 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras + import cats.data.Kleisli import cats.effect.Sync -import com.ovoenergy.effect.natchez.AllocatedSpan.Traced +import AllocatedSpan.Traced import cats.syntax.traverse._ import fs2._ import natchez.Span diff --git a/natchez-fs2/src/test/scala/com/ovoenergy/effect/natchez/AllocatedSpanTest.scala b/natchez-extras-fs2/src/test/scala/com/ovoenergy/natchez/extras/AllocatedSpanTest.scala similarity index 99% rename from natchez-fs2/src/test/scala/com/ovoenergy/effect/natchez/AllocatedSpanTest.scala rename to natchez-extras-fs2/src/test/scala/com/ovoenergy/natchez/extras/AllocatedSpanTest.scala index ae44303..40959d8 100644 --- a/natchez-fs2/src/test/scala/com/ovoenergy/effect/natchez/AllocatedSpanTest.scala +++ b/natchez-extras-fs2/src/test/scala/com/ovoenergy/natchez/extras/AllocatedSpanTest.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import java.util.UUID diff --git a/natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez/http4s/Configuration.scala b/natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/Configuration.scala similarity index 97% rename from natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez/http4s/Configuration.scala rename to natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/Configuration.scala index abe90b7..02b05ef 100644 --- a/natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez/http4s/Configuration.scala +++ b/natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/Configuration.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez.http4s +package com.ovoenergy.natchez.extras.http4s import cats.Applicative import cats.data.Kleisli @@ -9,7 +9,7 @@ import cats.kernel.{Monoid, Semigroup} import cats.syntax.foldable._ import cats.syntax.functor._ import cats.syntax.monoid._ -import com.ovoenergy.effect.natchez.http4s.Configuration.TagReader.{MessageReader, RequestReader, ResponseReader} +import Configuration.TagReader.{MessageReader, RequestReader, ResponseReader} import natchez.TraceValue import natchez.TraceValue.StringValue import org.http4s.util.{CaseInsensitiveString, StringWriter} diff --git a/natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez/http4s/client/TracedClient.scala b/natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClient.scala similarity index 89% rename from natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez/http4s/client/TracedClient.scala rename to natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClient.scala index 9fd9eb2..62ba39e 100644 --- a/natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez/http4s/client/TracedClient.scala +++ b/natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClient.scala @@ -1,11 +1,11 @@ -package com.ovoenergy.effect.natchez.http4s.client +package com.ovoenergy.natchez.extras.http4s.client import cats.data.Kleisli import cats.effect.{Resource, Sync} import cats.syntax.functor._ import cats.~> -import com.ovoenergy.effect.natchez.http4s.Configuration -import com.ovoenergy.effect.natchez.http4s.server.TraceMiddleware.removeNumericPathSegments +import com.ovoenergy.natchez.extras.http4s.Configuration +import com.ovoenergy.natchez.extras.http4s.server.TraceMiddleware.removeNumericPathSegments import natchez.{Span, Trace} import org.http4s._ import org.http4s.client.Client diff --git a/natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez/http4s/server/TraceMiddleware.scala b/natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/server/TraceMiddleware.scala similarity index 94% rename from natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez/http4s/server/TraceMiddleware.scala rename to natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/server/TraceMiddleware.scala index c83a689..b0700fc 100644 --- a/natchez-http4s/src/main/scala/com/ovoenergy/effect/natchez/http4s/server/TraceMiddleware.scala +++ b/natchez-extras-http4s/src/main/scala/com/ovoenergy/natchez/extras/http4s/server/TraceMiddleware.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez.http4s.server +package com.ovoenergy.natchez.extras.http4s.server import cats.data.Kleisli import cats.effect.Sync @@ -7,7 +7,7 @@ import natchez._ import org.http4s._ import cats.syntax.flatMap._ import cats.syntax.functor._ -import com.ovoenergy.effect.natchez.http4s.Configuration +import com.ovoenergy.natchez.extras.http4s.Configuration object TraceMiddleware { diff --git a/natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez/http4s/client/TestClient.scala b/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/client/TestClient.scala similarity index 92% rename from natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez/http4s/client/TestClient.scala rename to natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/client/TestClient.scala index c9da690..ebe420c 100644 --- a/natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez/http4s/client/TestClient.scala +++ b/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/client/TestClient.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez.http4s.client +package com.ovoenergy.natchez.extras.http4s.client import cats.data.Kleisli import cats.effect.Sync diff --git a/natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez/http4s/client/TracedClientTest.scala b/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClientTest.scala similarity index 87% rename from natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez/http4s/client/TracedClientTest.scala rename to natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClientTest.scala index ab1ae35..e073e93 100644 --- a/natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez/http4s/client/TracedClientTest.scala +++ b/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClientTest.scala @@ -1,10 +1,10 @@ -package com.ovoenergy.effect.natchez.http4s.client +package com.ovoenergy.natchez.extras.http4s.client import cats.data.Kleisli import cats.effect.{IO, Timer} -import com.ovoenergy.effect.natchez.TestEntryPoint -import com.ovoenergy.effect.natchez.TestEntryPoint.TestSpan -import com.ovoenergy.effect.natchez.http4s.Configuration +import com.ovoenergy.natchez.extras.TestEntryPoint +import com.ovoenergy.natchez.extras.TestEntryPoint.TestSpan +import com.ovoenergy.natchez.extras.http4s.Configuration import natchez.{Kernel, Span} import org.http4s.Request import org.scalatest.matchers.should.Matchers diff --git a/natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez/http4s/server/TraceMiddlewareTest.scala b/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/server/TraceMiddlewareTest.scala similarity index 98% rename from natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez/http4s/server/TraceMiddlewareTest.scala rename to natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/server/TraceMiddlewareTest.scala index f6ffe1e..5cc34e4 100644 --- a/natchez-http4s/src/test/scala/com/ovoenergy/effect/natchez/http4s/server/TraceMiddlewareTest.scala +++ b/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/server/TraceMiddlewareTest.scala @@ -1,10 +1,10 @@ -package com.ovoenergy.effect.natchez.http4s.server +package com.ovoenergy.natchez.extras.http4s.server import cats.data.Kleisli import cats.effect.concurrent.Ref import cats.effect.{IO, Resource} import cats.{Applicative, Monad} -import com.ovoenergy.effect.natchez.http4s.Configuration +import com.ovoenergy.natchez.extras.http4s.Configuration import fs2._ import natchez.TraceValue.{NumberValue, StringValue} import natchez.{EntryPoint, Kernel, Span, TraceValue} diff --git a/natchez-log4cats/src/main/scala/com/ovoenergy/effect/TracedLogger.scala b/natchez-extras-log4cats/src/main/scala/com/ovoenergy/natchez/extras/TracedLogger.scala similarity index 99% rename from natchez-log4cats/src/main/scala/com/ovoenergy/effect/TracedLogger.scala rename to natchez-extras-log4cats/src/main/scala/com/ovoenergy/natchez/extras/TracedLogger.scala index 6fbc2e9..6a7380d 100644 --- a/natchez-log4cats/src/main/scala/com/ovoenergy/effect/TracedLogger.scala +++ b/natchez-extras-log4cats/src/main/scala/com/ovoenergy/natchez/extras/TracedLogger.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect +package com.ovoenergy.natchez.extras import cats.Monad import cats.data.Kleisli diff --git a/metrics-common/src/main/scala/com/ovoenergy/effect/Metrics.scala b/natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/Metrics.scala similarity index 95% rename from metrics-common/src/main/scala/com/ovoenergy/effect/Metrics.scala rename to natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/Metrics.scala index eddadd2..5d5e9d8 100644 --- a/metrics-common/src/main/scala/com/ovoenergy/effect/Metrics.scala +++ b/natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/Metrics.scala @@ -1,8 +1,8 @@ -package com.ovoenergy.effect +package com.ovoenergy.natchez.extras import cats.{~>, Functor, Monad} import cats.syntax.apply._ -import com.ovoenergy.effect.Metrics.Metric +import Metrics.Metric /** * A type class representing the ability to push metrics diff --git a/natchez-slf4j/src/main/scala/com/ovoenergy/effect/natchez/Slf4j.scala b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4j.scala similarity index 95% rename from natchez-slf4j/src/main/scala/com/ovoenergy/effect/natchez/Slf4j.scala rename to natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4j.scala index 4f11899..8b0df15 100644 --- a/natchez-slf4j/src/main/scala/com/ovoenergy/effect/natchez/Slf4j.scala +++ b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4j.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import cats.MonadError import cats.effect.{Resource, Sync} diff --git a/natchez-slf4j/src/main/scala/com/ovoenergy/effect/natchez/Slf4jSpan.scala b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4jSpan.scala similarity index 98% rename from natchez-slf4j/src/main/scala/com/ovoenergy/effect/natchez/Slf4jSpan.scala rename to natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4jSpan.scala index 9bc3f54..bcced71 100644 --- a/natchez-slf4j/src/main/scala/com/ovoenergy/effect/natchez/Slf4jSpan.scala +++ b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4jSpan.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import java.util.UUID.randomUUID import cats.Monad diff --git a/natchez-slf4j/src/test/scala/com/ovoenergy/effect/natchez/Slf4jSpanTest.scala b/natchez-extras-slf4j/src/test/scala/com/ovoenergy/natchez/extras/Slf4jSpanTest.scala similarity index 98% rename from natchez-slf4j/src/test/scala/com/ovoenergy/effect/natchez/Slf4jSpanTest.scala rename to natchez-extras-slf4j/src/test/scala/com/ovoenergy/natchez/extras/Slf4jSpanTest.scala index c9d8773..5673640 100644 --- a/natchez-slf4j/src/test/scala/com/ovoenergy/effect/natchez/Slf4jSpanTest.scala +++ b/natchez-extras-slf4j/src/test/scala/com/ovoenergy/natchez/extras/Slf4jSpanTest.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import cats.effect.{Concurrent, ContextShift, IO} import org.scalatest.BeforeAndAfterEach diff --git a/natchez-testkit/src/main/scala/com/ovoenergy/effect/natchez/TestEntryPoint.scala b/natchez-extras-testkit/src/main/scala/com/ovoenergy/natchez/extras/TestEntryPoint.scala similarity index 95% rename from natchez-testkit/src/main/scala/com/ovoenergy/effect/natchez/TestEntryPoint.scala rename to natchez-extras-testkit/src/main/scala/com/ovoenergy/natchez/extras/TestEntryPoint.scala index 6957716..d1d3c4b 100644 --- a/natchez-testkit/src/main/scala/com/ovoenergy/effect/natchez/TestEntryPoint.scala +++ b/natchez-extras-testkit/src/main/scala/com/ovoenergy/natchez/extras/TestEntryPoint.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.effect.natchez +package com.ovoenergy.natchez.extras import java.time.Instant import java.util.concurrent.TimeUnit @@ -6,7 +6,7 @@ import cats.effect.concurrent.Ref import cats.effect.{Clock, ExitCase, Resource, Sync} import cats.syntax.flatMap._ import cats.syntax.functor._ -import com.ovoenergy.effect.natchez.TestEntryPoint.TestSpan +import TestEntryPoint.TestSpan import natchez.{EntryPoint, Kernel, Span, TraceValue} import java.net.URI From e3faa5af3a42b8883a9f8eccff2d7a456253a63a Mon Sep 17 00:00:00 2001 From: Tom Verran Date: Fri, 16 Apr 2021 13:19:52 +0100 Subject: [PATCH 2/8] Update README with new names --- README.md | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 0951bbd..fd3ce1a 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,37 @@ -# effect-utils +# natchez-extras -[ ![Download](https://api.bintray.com/packages/ovotech/maven/natchez-datadog/images/download.svg) ](https://bintray.com/ovotech/maven/logging/_latestVersion) +This repository consists of a number of additional integrations for [Natchez](https://github.com/tpolecat/natchez), +primarily to assist with integrating Natchez & Datadog. Separate to the Natchez integrations but included here for simplicity +is a module to send metrics to Datadog over UDP with FS2. -This repository consists of a number of type classes which add behaviours to a generic `F[_]` type in your cats-effect projects. -Each type class will be deployed to bintray as an independent jar to minimise transitive dependency issues if you only -want to use some of the library. +## Migration from effect-utils -To create a release, push a tag to master of the format `x.y.z`. See the [semantic versioning guide](https://semver.org/) -for details of how to choose a version number. +For historical reasons prior to 4.0.0 this repository was called `effect-utils`. +If you're upgrading your dependencies the renamings are as follows: + +``` +"com.ovoenergy.effect" % "datadog-metrics" => "com.ovoenergy" % "natchez-extras-dogstatsd" +"com.ovoenergy.effect" % "natchez-datadog" => "com.ovoenergy" % "natchez-extras-datadog" +"com.ovoenergy.effect" % "natchez-doobie" => "com.ovoenergy" % "natchez-extras-doobie" +"com.ovoenergy.effect" % "natchez-slf4j" => "com.ovoenergy" % "natchez-extras-slf4j" +"com.ovoenergy.effect" % "natchez-combine" => "com.ovoenergy" % "natchez-extras-combine" +"com.ovoenergy.effect" % "natchez-fs2" => "com.ovoenergy" % "natchez-extras-fs2" +"com.ovoenergy.effect" % "natchez-testkit" => "com.ovoenergy" % "natchez-extras-testkit" +``` ## Current modules -| Module | Description | Artifact -----------------|--------------------------------------------------------------------------------|----------------------------------------- -Datadog Metrics | Submits metrics to Datadog over UDP with FS2 | "com.ovoenergy.effect" % "datadog-metrics" -Natchez Datadog | Integrates [natchez](https://github.com/tpolecat/natchez) with the Datadog APM | "com.ovoenergy.effect" % "natchez-datadog" -Natchez Doobie | Integrates [natchez](https://github.com/tpolecat/natchez) with Doobie | "com.ovoenergy.effect" % "natchez-doobie" -Natchez SLF4J | Integrates [natchez](https://github.com/tpolecat/natchez) with SLF4J | "com.ovoenergy.effect" % "natchez-slf4j" -Natchez Combine | Provides a function to combine two Natchez `EntryPoint[F]`s together | "com.ovoenergy.effect" % "natchez-combine" -Natchez FS2 | Provides an `AllocatedSpan` you submit manually for streams | "com.ovoenergy.effect" % "natchez-fs2" -Natchez Testkit | Provides a `TestEntrypoint` backed by a `Ref` for unit tests | "com.ovoenergy.effect" % "natchez-testkit" + Module | Description | Artifact +-----------|--------------------------------------------------------------------------------|----------------------------------------- +Dogstatsd | Submits metrics to Datadog over UDP with FS2 | "com.ovoenergy" % "natchez-extras-dogstatsd" +Datadog | Integrates [natchez](https://github.com/tpolecat/natchez) with the Datadog APM | "com.ovoenergy" % "natchez-extras-datadog" +Doobie | Integrates [natchez](https://github.com/tpolecat/natchez) with Doobie | "com.ovoenergy" % "natchez-extras-doobie" +SLF4J | Integrates [natchez](https://github.com/tpolecat/natchez) with SLF4J | "com.ovoenergy" % "natchez-extras-slf4j" +Combine | Provides a function to combine two Natchez `EntryPoint[F]`s together | "com.ovoenergy" % "natchez-extras-combine" +FS2 | Provides an `AllocatedSpan` you submit manually for streams | "com.ovoenergy" % "natchez-extras-fs2" +Testkit | Provides a `TestEntrypoint` backed by a `Ref` for unit tests | "com.ovoenergy" % "natchez-extras-testkit" + +### For maintainers + +To create a release, push a tag to master of the format `x.y.z`. See the [semantic versioning guide](https://semver.org/) +for details of how to choose a version number. From a73332e2e577e5721f3da8e97041a25d4650459f Mon Sep 17 00:00:00 2001 From: Tom Verran Date: Fri, 16 Apr 2021 13:59:10 +0100 Subject: [PATCH 3/8] Move everything into consistent packages, run scalafmt --- docs/docs/docs/metrics.md | 16 +-- docs/docs/docs/natchez-combine.md | 19 ++-- docs/docs/docs/natchez-datadog.md | 19 ++-- docs/docs/docs/natchez-doobie.md | 10 +- docs/docs/docs/natchez-fs2.md | 12 +- docs/docs/docs/natchez-http4s.md | 17 ++- docs/docs/docs/natchez-log4cats.md | 9 +- docs/docs/docs/natchez-slf4j.md | 9 +- docs/docs/docs/natchez-testkit.md | 7 +- .../extras/{ => combine}/Combine.scala | 9 +- .../extras/{ => datadog}/Datadog.scala | 50 +++++---- .../extras/{ => datadog}/DatadogSpan.scala | 35 +++--- .../extras/{ => datadog}/DatadogTags.scala | 5 +- .../{ => datadog}/SpanIdentifiers.scala | 5 +- .../{ => datadog}/SubmittableSpan.scala | 9 +- .../extras/{ => datadog}/DatadogTest.scala | 8 +- .../{ => datadog}/SpanIdentifiersTest.scala | 4 +- .../extras/{ => datadog}/TestClient.scala | 2 +- .../extras/{ => dogstatsd}/Dogstatsd.scala | 21 ++-- .../extras/{ => dogstatsd}/Events.scala | 6 +- .../extras/{ => dogstatsd}/DatadogTest.scala | 14 +-- .../extras/{ => doobie}/TracedStatement.scala | 104 +++++++++++++++++- .../{ => doobie}/TracedTransactor.scala | 8 +- .../{ => doobie}/TracedTransactorTest.scala | 6 +- .../extras/{ => fs2}/AllocatedSpan.scala | 2 +- .../natchez/extras/{ => fs2}/syntax.scala | 9 +- .../extras/{ => fs2}/AllocatedSpanTest.scala | 6 +- .../extras/http4s/client/TracedClient.scala | 31 +++--- .../http4s/client/TracedClientTest.scala | 4 +- .../extras/{ => log4cats}/TracedLogger.scala | 2 +- .../extras/{ => metrics}/Metrics.scala | 6 +- .../natchez/extras/{ => slf4j}/Slf4j.scala | 4 +- .../extras/{ => slf4j}/Slf4jSpan.scala | 4 +- .../extras/{ => slf4j}/Slf4jSpanTest.scala | 7 +- .../extras/{ => testkit}/TestEntryPoint.scala | 9 +- 35 files changed, 304 insertions(+), 184 deletions(-) rename natchez-extras-combine/src/main/scala/com/ovoenergy/natchez/extras/{ => combine}/Combine.scala (97%) rename natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/{ => datadog}/Datadog.scala (76%) rename natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/{ => datadog}/DatadogSpan.scala (87%) rename natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/{ => datadog}/DatadogTags.scala (96%) rename natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/{ => datadog}/SpanIdentifiers.scala (98%) rename natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/{ => datadog}/SubmittableSpan.scala (97%) rename natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/{ => datadog}/DatadogTest.scala (94%) rename natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/{ => datadog}/SpanIdentifiersTest.scala (93%) rename natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/{ => datadog}/TestClient.scala (95%) rename natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/{ => dogstatsd}/Dogstatsd.scala (90%) rename natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/{ => dogstatsd}/Events.scala (91%) rename natchez-extras-dogstatsd/src/test/scala/com/ovoenergy/natchez/extras/{ => dogstatsd}/DatadogTest.scala (93%) rename natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/{ => doobie}/TracedStatement.scala (98%) rename natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/{ => doobie}/TracedTransactor.scala (96%) rename natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/{ => doobie}/TracedTransactorTest.scala (95%) rename natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/{ => fs2}/AllocatedSpan.scala (98%) rename natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/{ => fs2}/syntax.scala (81%) rename natchez-extras-fs2/src/test/scala/com/ovoenergy/natchez/extras/{ => fs2}/AllocatedSpanTest.scala (97%) rename natchez-extras-log4cats/src/main/scala/com/ovoenergy/natchez/extras/{ => log4cats}/TracedLogger.scala (98%) rename natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/{ => metrics}/Metrics.scala (93%) rename natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/{ => slf4j}/Slf4j.scala (94%) rename natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/{ => slf4j}/Slf4jSpan.scala (98%) rename natchez-extras-slf4j/src/test/scala/com/ovoenergy/natchez/extras/{ => slf4j}/Slf4jSpanTest.scala (98%) rename natchez-extras-testkit/src/main/scala/com/ovoenergy/natchez/extras/{ => testkit}/TestEntryPoint.scala (94%) diff --git a/docs/docs/docs/metrics.md b/docs/docs/docs/metrics.md index abf6915..80b9510 100644 --- a/docs/docs/docs/metrics.md +++ b/docs/docs/docs/metrics.md @@ -17,8 +17,7 @@ For more details about events see the [event documentation.](https://docs.datado In your build.sbt ```scala -resolvers += Resolver.bintrayRepo("ovotech", "maven") -libraryDependencies += "com.ovoenergy.effect" %% "datadog-metrics" % "@VERSION@" +libraryDependencies += "com.ovoenergy" %% "natchez-extras-dogstatsd" % "@VERSION@" ``` ## Example usage @@ -27,14 +26,15 @@ libraryDependencies += "com.ovoenergy.effect" %% "datadog-metrics" % "@VERSION@" import java.net.InetSocketAddress import cats.effect.{ExitCode, IO, IOApp} -import com.ovoenergy.effect.Events.{AlertType, Priority} -import com.ovoenergy.effect.Metrics.Metric -import com.ovoenergy.effect.{Datadog, Events, Metrics} +import com.ovoenergy.natchez.extras.dogstatsd.Events.{AlertType, Priority} +import com.ovoenergy.natchez.extras.metrics.Metrics.Metric +import com.ovoenergy.natchez.extras.metrics.Metrics +import com.ovoenergy.natchez.extras.dogstatsd.{Dogstatsd, Events} object MetricApp extends IOApp { - val metricConfig: Datadog.Config = - Datadog.Config( + val metricConfig: Dogstatsd.Config = + Dogstatsd.Config( // adds a prefix to all metrics, e.g. `my_app.metricname` metricPrefix = Some("my_app"), @@ -62,7 +62,7 @@ object MetricApp extends IOApp { Metric(name = "my_histogram", tags = Map.empty) def run(args: List[String]): IO[ExitCode] = - Datadog[IO, IO](metricConfig).use { metrics: Metrics[IO] with Events[IO] => + Dogstatsd[IO, IO](metricConfig).use { metrics: Metrics[IO] with Events[IO] => for { _ <- metrics.counter(exampleCounter)(1) _ <- metrics.histogram(exampleHistogram)(1) diff --git a/docs/docs/docs/natchez-combine.md b/docs/docs/docs/natchez-combine.md index 703fddd..f4d6017 100644 --- a/docs/docs/docs/natchez-combine.md +++ b/docs/docs/docs/natchez-combine.md @@ -5,7 +5,7 @@ title: "Natchez Combine" # Natchez Combine -`natchez-combine` is a module that allows you to combine two Natchez EntryPoints into one, +`natchez-extras-combine` is a module that allows you to combine two Natchez EntryPoints into one, allowing you to send tracing information to more than one destination. At OVO we use this module to send traces both to Datadog and also to STDOUT (via `natchez-slf4j`) so when @@ -18,24 +18,23 @@ In your build.sbt ```scala val http4sVersion = "0.21.4" val effectUtilsVersion = "@VERSION@" -resolvers += Resolver.bintrayRepo("ovotech", "maven") libraryDependencies ++= Seq( - "org.http4s" %% "http4s-blaze-client" % http4sVersion, - "com.ovoenergy.effect" %% "natchez-combine" % effectUtilsVersion, - "com.ovoenergy.effect" %% "natchez-datadog" % effectUtilsVersion, - "com.ovoenergy.effect" %% "natchez-slf4j" % effectUtilsVersion, + "org.http4s" %% "http4s-blaze-client" % http4sVersion, + "com.ovoenergy" %% "natchez-extras-combine" % effectUtilsVersion, + "com.ovoenergy" %% "natchez-extras-datadog" % effectUtilsVersion, + "com.ovoenergy" %% "natchez-extras-slf4j" % effectUtilsVersion ) ``` ## Example usage: -This example combines `natchez-datadog` and `natchez-slf4j` hence the extra dependencies +This example combines `natchez-extras-datadog` and `natchez-extras-slf4j` hence the extra dependencies ```scala mdoc -import com.ovoenergy.effect.natchez.Combine -import com.ovoenergy.effect.natchez.Slf4j -import com.ovoenergy.effect.natchez.Datadog +import com.ovoenergy.natchez.extras.combine.Combine +import com.ovoenergy.natchez.extras.slf4j.Slf4j +import com.ovoenergy.natchez.extras.datadog.Datadog import org.http4s.client.blaze.BlazeClientBuilder import natchez.EntryPoint import cats.effect.IO diff --git a/docs/docs/docs/natchez-datadog.md b/docs/docs/docs/natchez-datadog.md index c876438..fc73f45 100644 --- a/docs/docs/docs/natchez-datadog.md +++ b/docs/docs/docs/natchez-datadog.md @@ -13,22 +13,21 @@ Once you've got the `EntryPoint` you can then use Natchez as described in [its R Depending on how you're using the Datadog agent you may need to set some configuration values to enable the APM. Details can be found [on the Datadog website](https://docs.datadoghq.com/tracing/send_traces/) -`natchez-datadog` currently expects the agent to be reachable over HTTP at `http://localhost:8126` - if you're running the +`natchez-extras-datadog` currently expects the agent to be reachable over HTTP at `http://localhost:8126` - if you're running the agent in a docker container this should typically be the case. ## Installation -`natchez-datadog` uses HTTP4s to submit traces to the [Datadog trace API](https://docs.datadoghq.com/api/v1/tracing/), hence the need for `http4s-blaze-client`. +`natchez-extras-datadog` uses HTTP4s to submit traces to the [Datadog trace API](https://docs.datadoghq.com/api/v1/tracing/), hence the need for `http4s-blaze-client`. ```scala val http4sVersion = "0.21.4" -val effectUtilsVersion = "@VERSION@" -resolvers += Resolver.bintrayRepo("ovotech", "maven") +val natchezExtrasVersion = "@VERSION@" libraryDependencies ++= Seq( - "org.http4s" %% "http4s-blaze-client" % http4sVersion, - "com.ovoenergy.effect" %% "natchez-datadog" % effectUtilsVersion, - "com.ovoenergy.effect" %% "natchez-slf4j" % effectUtilsVersion + "org.http4s" %% "http4s-blaze-client" % http4sVersion, + "com.ovoenergy" %% "natchez-extras-datadog" % natchezExtrasVersion, + "com.ovoenergy" %% "natchez-extras-slf4j" % natchezExtrasVersion ) ``` @@ -36,7 +35,7 @@ libraryDependencies ++= Seq( ```scala mdoc import cats.effect.{ExitCode, IO, IOApp, Resource} -import com.ovoenergy.effect.natchez.Datadog +import com.ovoenergy.natchez.extras.datadog.Datadog import natchez.EntryPoint import org.http4s.client.blaze.BlazeClientBuilder @@ -91,8 +90,8 @@ for a particular span you can pass the new values into the span name as a colon A number of helper functions to create tags that Datadog uses to drive its trace UI can be found in `DatadogTags.scala`. An example of how to use them follows: -```scala -import com.ovoenergy.natchez.extras.DatadogTags._ +```scala mdoc +import com.ovoenergy.natchez.extras.datadog.DatadogTags._ import natchez.Trace object DatadogTagsExample { diff --git a/docs/docs/docs/natchez-doobie.md b/docs/docs/docs/natchez-doobie.md index a64c181..cf550ac 100644 --- a/docs/docs/docs/natchez-doobie.md +++ b/docs/docs/docs/natchez-doobie.md @@ -6,16 +6,15 @@ title: "Natchez Doobie" # Natchez Doobie -`natchez-doobie` provides a `Transactor` that adds spans for database queries to your traces. +`natchez-extras-doobie` provides a `Transactor` that adds spans for database queries to your traces. ## Installation ```scala -val effectUtilsVersion = "@VERSION@" -resolvers += Resolver.bintrayRepo("ovotech", "maven") +val natchezExtrasVersion = "@VERSION@" libraryDependencies ++= Seq( - "com.ovoenergy.effect" %% "natchez-doobie" % effectUtilsVersion + "com.ovoenergy" %% "natchez-extras-doobie" % natchezExtrasVersion ) ``` @@ -33,7 +32,8 @@ and then passing that into a tagless final application that queries the database import cats.data.Kleisli import cats.effect.{Blocker, ExitCode, IO, IOApp, Resource, Sync} import cats.syntax.functor._ -import com.ovoenergy.effect.natchez.{Datadog, TracedTransactor} +import com.ovoenergy.natchez.extras.datadog.Datadog +import com.ovoenergy.natchez.extras.doobie.TracedTransactor import doobie.implicits._ import doobie.util.transactor.Transactor import natchez.{EntryPoint, Span, Trace} diff --git a/docs/docs/docs/natchez-fs2.md b/docs/docs/docs/natchez-fs2.md index f46c560..fd90314 100644 --- a/docs/docs/docs/natchez-fs2.md +++ b/docs/docs/docs/natchez-fs2.md @@ -13,17 +13,16 @@ i.e. Kafka consumers using FS2. ## Installation ```scala -val effectUtilsVersion = "@VERSION@" -resolvers += Resolver.bintrayRepo("ovotech", "maven") +val natchezExtrasVersion = "@VERSION@" libraryDependencies ++= Seq( - "com.ovoenergy.effect" %% "natchez-fs2" % effectUtilsVersion + "com.ovoenergy" %% "natchez-fs2" % natchezExtrasVersion ) ``` ## Usage -`natchez-fs2` provides an FS2 `Pipe` that given an element in a stream returns it alongside an `AllocatedSpan`. +`natchez-extras-fs2` provides an FS2 `Pipe` that given an element in a stream returns it alongside an `AllocatedSpan`. You can then create subspans for this span as you process the message before manually committing it with `.submit`. A small `syntax` object provides two functions - `evalMapNamed` and `evalMapTraced` to reduce the boilerplate involved @@ -34,8 +33,9 @@ If the stream is cancelled the span will be closed automatically. ```scala mdoc import cats.Monad import cats.effect.{ExitCode, IO, IOApp} -import com.ovoenergy.effect.natchez.syntax._ -import com.ovoenergy.effect.natchez.{AllocatedSpan, Slf4j} +import com.ovoenergy.natchez.extras.fs2.syntax._ +import com.ovoenergy.natchez.extras.fs2.AllocatedSpan +import com.ovoenergy.natchez.extras.slf4j.Slf4j import fs2._ import natchez.{EntryPoint, Kernel} diff --git a/docs/docs/docs/natchez-http4s.md b/docs/docs/docs/natchez-http4s.md index 34f07f6..69ce531 100644 --- a/docs/docs/docs/natchez-http4s.md +++ b/docs/docs/docs/natchez-http4s.md @@ -5,18 +5,17 @@ title: "Natchez HTTP4s" # Natchez HTTP4s -`natchez-http4s` provides HTTP4s [Middleware](https://http4s.org/v0.21/middleware/) to trace all HTTP requests. +`natchez-extras-http4s` provides HTTP4s [Middleware](https://http4s.org/v0.21/middleware/) to trace all HTTP requests. At the time of writing there is a [PR on Natchez itself](https://github.com/tpolecat/natchez/pull/75) that will provide this functionality. When it is merged this module will continue to exist but as a wrapper that adds tags used by Datadog. ## Installation ```scala -val effectUtilsVersion = "@VERSION@" -resolvers += Resolver.bintrayRepo("ovotech", "maven") +val natchezExtrasVersion = "@VERSION@" libraryDependencies ++= Seq( - "com.ovoenergy.effect" %% "natchez-fs2" % effectUtilsVersion + "com.ovoenergy" %% "natchez-fs2" % natchezExtrasVersion ) ``` @@ -30,9 +29,9 @@ import cats.data.Kleisli import cats.effect.{ExitCode, IO, IOApp, Resource, Sync, Timer} import cats.syntax.flatMap._ import cats.syntax.functor._ -import com.ovoenergy.effect.natchez.Datadog -import com.ovoenergy.effect.natchez.http4s.Configuration -import com.ovoenergy.effect.natchez.http4s.server.TraceMiddleware +import com.ovoenergy.natchez.extras.datadog.Datadog +import com.ovoenergy.natchez.extras.http4s.Configuration +import com.ovoenergy.natchez.extras.http4s.server.TraceMiddleware import natchez.{EntryPoint, Span, Trace} import org.http4s.{HttpApp, HttpRoutes} import org.http4s.client.blaze.BlazeClientBuilder @@ -117,8 +116,8 @@ it is set up to create tags suitable for Datadog but you can use the helper func ```scala mdoc import cats.effect.IO -import com.ovoenergy.effect.natchez.http4s.Configuration -import com.ovoenergy.effect.natchez.http4s.Configuration.TagReader._ +import com.ovoenergy.natchez.extras.http4s.Configuration +import com.ovoenergy.natchez.extras.http4s.Configuration.TagReader._ import natchez.TraceValue.BooleanValue import cats.syntax.semigroup._ diff --git a/docs/docs/docs/natchez-log4cats.md b/docs/docs/docs/natchez-log4cats.md index 468669c..ce836f7 100644 --- a/docs/docs/docs/natchez-log4cats.md +++ b/docs/docs/docs/natchez-log4cats.md @@ -16,11 +16,10 @@ the [agentless logging](https://docs.datadoghq.com/logs/log_collection/java/?tab ## Installation ```scala -val effectUtilsVersion = "@VERSION@" -resolvers += Resolver.bintrayRepo("ovotech", "maven") +val natchezExtrasVersion = "@VERSION@" libraryDependencies ++= Seq( - "com.ovoenergy.effect" %% "natchez-fs2" % effectUtilsVersion + "com.ovoenergy" %% "natchez-fs2" % natchezExtrasVersion ) ``` @@ -30,8 +29,8 @@ libraryDependencies ++= Seq( import cats.Functor import cats.data.Kleisli import cats.effect.{ExitCode, IO, IOApp, Resource} -import com.ovoenergy.effect.TracedLogger -import com.ovoenergy.effect.natchez.Datadog +import com.ovoenergy.natchez.extras.log4cats.TracedLogger +import com.ovoenergy.natchez.extras.datadog.Datadog import org.typelevel.log4cats.StructuredLogger import org.typelevel.log4cats.slf4j.Slf4jLogger import natchez.{EntryPoint, Span, Trace} diff --git a/docs/docs/docs/natchez-slf4j.md b/docs/docs/docs/natchez-slf4j.md index 9c894b7..6bd6378 100644 --- a/docs/docs/docs/natchez-slf4j.md +++ b/docs/docs/docs/natchez-slf4j.md @@ -18,12 +18,11 @@ Add this module and an SLF4J binding (in this example we're using [Logback](http://logback.qos.ch/)) to your `build.sbt`: ```scala -val effectUtilsVersion = "@VERSION@" -resolvers += Resolver.bintrayRepo("ovotech", "maven") +val natchezExtrasVersion = "@VERSION@" libraryDependencies ++= Seq( - "ch.qos.logback" % "logback-classic" % "1.2.3", - "com.ovoenergy.effect" %% "natchez-slf4j" % effectUtilsVersion + "ch.qos.logback" % "logback-classic" % "1.2.3", + "com.ovoenergy" %% "natchez-extras-slf4j" % natchezExtrasVersion ) ``` @@ -32,7 +31,7 @@ libraryDependencies ++= Seq( ```scala mdoc import cats.effect.{ExitCode, IO, IOApp} -import com.ovoenergy.effect.natchez.Slf4j +import com.ovoenergy.natchez.extras.slf4j.Slf4j import natchez.EntryPoint import scala.concurrent.duration._ diff --git a/docs/docs/docs/natchez-testkit.md b/docs/docs/docs/natchez-testkit.md index 7418756..aa63682 100644 --- a/docs/docs/docs/natchez-testkit.md +++ b/docs/docs/docs/natchez-testkit.md @@ -11,17 +11,16 @@ that check your application is sending the right information to Natchez. ## Installation ```scala -val effectUtilsVersion = "@VERSION@" -resolvers += Resolver.bintrayRepo("ovotech", "maven") +val natchezExtrasVersion = "@VERSION@" libraryDependencies ++= Seq( - "com.ovoenergy.effect" %% "natchez-testkit" % effectUtilsVersion % Test + "com.ovoenergy" %% "natchez-testkit" % natchezExtrasVersion % Test ) ``` ## Usage -An example of how to use it can be found in the test for `natchez-fs2`: +An example of how to use it can be found in the test for `natchez-extras-fs2`: [https://github.com/ovotech/effect-utils/blob/master/natchez-fs2/src/test/scala/com/ovoenergy/effect/natchez/AllocatedSpanTest.scala]( https://github.com/ovotech/effect-utils/blob/master/natchez-fs2/src/test/scala/com/ovoenergy/effect/natchez/AllocatedSpanTest.scala diff --git a/natchez-extras-combine/src/main/scala/com/ovoenergy/natchez/extras/Combine.scala b/natchez-extras-combine/src/main/scala/com/ovoenergy/natchez/extras/combine/Combine.scala similarity index 97% rename from natchez-extras-combine/src/main/scala/com/ovoenergy/natchez/extras/Combine.scala rename to natchez-extras-combine/src/main/scala/com/ovoenergy/natchez/extras/combine/Combine.scala index 2ab483f..dd0b7c5 100644 --- a/natchez-extras-combine/src/main/scala/com/ovoenergy/natchez/extras/Combine.scala +++ b/natchez-extras-combine/src/main/scala/com/ovoenergy/natchez/extras/combine/Combine.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.combine import cats.data.OptionT import cats.effect.{Resource, Sync} @@ -18,14 +18,19 @@ object Combine { new Span[F] { def kernel: F[Kernel] = (s1.kernel, s2.kernel).mapN { case (k1, k2) => Kernel(k1.toHeaders ++ k2.toHeaders) } + def span(name: String): Resource[F, Span[F]] = (s1.span(name), s2.span(name)).mapN[Span[F]](combineSpan[F]) + def put(fields: (String, TraceValue)*): F[Unit] = (s1.put(fields: _*), s2.put(fields: _*)).tupled.as(()) + def traceId: F[Option[String]] = OptionT(s1.traceId).orElseF(s2.traceId).value + def spanId: F[Option[String]] = OptionT(s1.spanId).orElseF(s2.spanId).value + def traceUri: F[Option[URI]] = OptionT(s1.traceUri).orElseF(s2.traceUri).value } @@ -34,8 +39,10 @@ object Combine { new EntryPoint[F] { def root(name: String): Resource[F, Span[F]] = (e1.root(name), e2.root(name)).mapN(combineSpan[F]) + def continue(name: String, kernel: Kernel): Resource[F, Span[F]] = (e1.continue(name, kernel), e2.continue(name, kernel)).mapN(combineSpan[F]) + def continueOrElseRoot(name: String, kernel: Kernel): Resource[F, Span[F]] = (e1.continueOrElseRoot(name, kernel), e2.continueOrElseRoot(name, kernel)).mapN(combineSpan[F]) } diff --git a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/Datadog.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/Datadog.scala similarity index 76% rename from natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/Datadog.scala rename to natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/Datadog.scala index 292736d..e2dd196 100644 --- a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/Datadog.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/Datadog.scala @@ -1,23 +1,22 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.datadog import cats.Applicative -import cats.effect._ import cats.effect.concurrent.{Ref, Semaphore} -import cats.instances.option._ +import cats.effect.{Clock, Concurrent, Resource, Sync, Timer} import cats.syntax.flatMap._ import cats.syntax.functor._ import cats.syntax.traverse._ -import DatadogSpan.SpanNames +import com.ovoenergy.natchez.extras.datadog.DatadogSpan.SpanNames +import fs2.Stream import fs2.concurrent.Queue import io.circe.{Encoder, Printer} -import fs2._ import natchez.{EntryPoint, Kernel, Span} import org.http4s.Method.PUT import org.http4s.circe.CirceInstances.builder import org.http4s.client.Client +import org.http4s.syntax.literals._ import org.http4s.{EntityEncoder, Header, Request, Uri} import org.slf4j.{Logger, LoggerFactory} -import org.http4s.syntax.literals._ import scala.concurrent.duration._ @@ -48,20 +47,22 @@ object Datadog { .tryDequeueChunk1(maxSize = 1000) .flatMap { items => items.traverse { traces => - Sync[F].attempt( - client.status( - Request[F](uri = agentHost.withPath("/v0.3/traces"), method = PUT) - .withHeaders(Header("X-DataDog-Trace-Count", traces.size.toString)) - .withEntity(traces.toList.groupBy(_.traceId).values.toList) + Sync[F] + .attempt( + client.status( + Request[F](uri = agentHost.withPath("/v0.3/traces"), method = PUT) + .withHeaders(Header("X-DataDog-Trace-Count", traces.size.toString)) + .withEntity(traces.toList.groupBy(_.traceId).values.toList) + ) ) - ).flatMap { - case Left(exception) => - Sync[F].delay(logger.warn("Failed to submit to Datadog", exception)) - case Right(status) if !status.isSuccess => - Sync[F].delay(logger.warn(s"Got $status from Datadog agent")) - case Right(status) => - Sync[F].delay(logger.debug(s"Got $status from Datadog agent")) - } + .flatMap { + case Left(exception) => + Sync[F].delay(logger.warn("Failed to submit to Datadog", exception)) + case Right(status) if !status.isSuccess => + Sync[F].delay(logger.warn(s"Got $status from Datadog agent")) + case Right(status) => + Sync[F].delay(logger.debug(s"Got $status from Datadog agent")) + } } } .as(()) @@ -113,11 +114,16 @@ object Datadog { } yield { new EntryPoint[F] { def root(name: String): Resource[F, Span[F]] = - Resource.liftF( - SpanIdentifiers.create.flatMap(Ref.of[F, SpanIdentifiers]) - ).flatMap(DatadogSpan.create(queue, names(name))).widen + Resource + .liftF( + SpanIdentifiers.create.flatMap(Ref.of[F, SpanIdentifiers]) + ) + .flatMap(DatadogSpan.create(queue, names(name))) + .widen + def continue(name: String, kernel: Kernel): Resource[F, Span[F]] = DatadogSpan.fromKernel(queue, names(name), kernel).widen + def continueOrElseRoot(name: String, kernel: Kernel): Resource[F, Span[F]] = DatadogSpan.fromKernel(queue, names(name), kernel).widen } diff --git a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogSpan.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/DatadogSpan.scala similarity index 87% rename from natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogSpan.scala rename to natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/DatadogSpan.scala index 510dd09..bc39ae2 100644 --- a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogSpan.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/DatadogSpan.scala @@ -1,16 +1,16 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.datadog import cats.effect.concurrent.Ref import cats.effect.{Clock, ExitCase, Resource, Sync} +import cats.instances.option._ import cats.syntax.flatMap._ import cats.syntax.functor._ -import DatadogSpan.SpanNames +import cats.syntax.traverse._ +import com.ovoenergy.natchez.extras.datadog.DatadogSpan.SpanNames import fs2.concurrent.Queue import io.circe.generic.extras.Configuration -import natchez.{Kernel, Span, TraceValue} -import cats.syntax.traverse._ -import cats.instances.option._ import natchez.TraceValue.{BooleanValue, NumberValue, StringValue} +import natchez.{Kernel, Span, TraceValue} import java.net.URI import java.util.concurrent.TimeUnit.NANOSECONDS @@ -29,11 +29,14 @@ case class DatadogSpan[F[_]: Sync: Clock]( ) extends Span[F] { def updateTraceToken(fields: Map[String, TraceValue]): F[Unit] = - fields.get("traceToken").traverse { - case StringValue(v) => ids.update(_.copy(traceToken = v)) - case BooleanValue(v) => ids.update(_.copy(traceToken = v.toString)) - case NumberValue(v) => ids.update(_.copy(traceToken = v.toString)) - }.void + fields + .get("traceToken") + .traverse { + case StringValue(v) => ids.update(_.copy(traceToken = v)) + case BooleanValue(v) => ids.update(_.copy(traceToken = v.toString)) + case NumberValue(v) => ids.update(_.copy(traceToken = v.toString)) + } + .void def put(fields: (String, TraceValue)*): F[Unit] = meta.update(m => fields.foldLeft(m) { case (m, (k, v)) => m.updated(k, v) }) >> @@ -124,9 +127,11 @@ object DatadogSpan { names: SpanNames, kernel: Kernel ): Resource[F, DatadogSpan[F]] = - Resource.liftF( - SpanIdentifiers - .fromKernel(kernel) - .flatMap(Ref.of[F, SpanIdentifiers]) - ).flatMap(create(queue, names)) + Resource + .liftF( + SpanIdentifiers + .fromKernel(kernel) + .flatMap(Ref.of[F, SpanIdentifiers]) + ) + .flatMap(create(queue, names)) } diff --git a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogTags.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/DatadogTags.scala similarity index 96% rename from natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogTags.scala rename to natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/DatadogTags.scala index 0be0f5e..f2ccedb 100644 --- a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/DatadogTags.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/DatadogTags.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.datadog import natchez.TraceValue @@ -12,8 +12,11 @@ object DatadogTags { object SpanType { case object Custom extends SpanType + case object Cache extends SpanType + case object Web extends SpanType + case object Db extends SpanType } diff --git a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SpanIdentifiers.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/SpanIdentifiers.scala similarity index 98% rename from natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SpanIdentifiers.scala rename to natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/SpanIdentifiers.scala index 92745c2..726c7b6 100644 --- a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SpanIdentifiers.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/SpanIdentifiers.scala @@ -1,6 +1,4 @@ -package com.ovoenergy.natchez.extras - -import java.util.UUID +package com.ovoenergy.natchez.extras.datadog import cats.data.OptionT import cats.effect.Sync @@ -8,6 +6,7 @@ import cats.syntax.apply._ import cats.syntax.functor._ import natchez.Kernel +import java.util.UUID import scala.util.Try case class SpanIdentifiers( diff --git a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SubmittableSpan.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/SubmittableSpan.scala similarity index 97% rename from natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SubmittableSpan.scala rename to natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/SubmittableSpan.scala index 5d542ea..d1a38f7 100644 --- a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/SubmittableSpan.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/SubmittableSpan.scala @@ -1,17 +1,18 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.datadog -import java.util.concurrent.TimeUnit.NANOSECONDS import cats.Applicative import cats.effect.{Clock, ExitCase} import cats.syntax.apply._ -import com.ovoenergy.natchez.extras.DatadogTags.{SpanType, forThrowable} -import io.circe.{Decoder, Encoder} +import com.ovoenergy.natchez.extras.datadog.DatadogTags.{forThrowable, SpanType} 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 +import java.util.concurrent.TimeUnit.NANOSECONDS + /** * This is the type we need to send to the Datadog agent * to submit traces. Turning a span into one of these involves some trickery diff --git a/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/DatadogTest.scala similarity index 94% rename from natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala rename to natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/DatadogTest.scala index 229d647..daffae7 100644 --- a/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala +++ b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/DatadogTest.scala @@ -1,12 +1,12 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.datadog import cats.effect._ import cats.instances.list._ import cats.syntax.flatMap._ import cats.syntax.traverse._ -import Datadog.entryPoint -import DatadogTags.SpanType.{Cache, Db, Web} -import DatadogTags.spanType +import com.ovoenergy.natchez.extras.datadog.Datadog.entryPoint +import com.ovoenergy.natchez.extras.datadog.DatadogTags.SpanType.{Cache, Db, Web} +import com.ovoenergy.natchez.extras.datadog.DatadogTags.spanType import natchez.EntryPoint import org.http4s.Request import org.http4s.circe.CirceEntityDecoder._ diff --git a/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/SpanIdentifiersTest.scala b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/SpanIdentifiersTest.scala similarity index 93% rename from natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/SpanIdentifiersTest.scala rename to natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/SpanIdentifiersTest.scala index 75692ff..586444a 100644 --- a/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/SpanIdentifiersTest.scala +++ b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/SpanIdentifiersTest.scala @@ -1,7 +1,7 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.datadog import cats.effect.IO -import SpanIdentifiers._ +import com.ovoenergy.natchez.extras.datadog.SpanIdentifiers._ import natchez.Kernel import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec diff --git a/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/TestClient.scala b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/TestClient.scala similarity index 95% rename from natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/TestClient.scala rename to natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/TestClient.scala index f112a35..cd81679 100644 --- a/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/TestClient.scala +++ b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/TestClient.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.datadog import cats.effect.concurrent.Ref import cats.effect.{Concurrent, Resource, Sync} diff --git a/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Dogstatsd.scala b/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/dogstatsd/Dogstatsd.scala similarity index 90% rename from natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Dogstatsd.scala rename to natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/dogstatsd/Dogstatsd.scala index a1fab87..9ff3ffd 100644 --- a/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Dogstatsd.scala +++ b/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/dogstatsd/Dogstatsd.scala @@ -1,14 +1,15 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.dogstatsd + +import cats.effect.{Async, Blocker, ConcurrentEffect, ContextShift, Effect, Resource} +import com.ovoenergy.natchez.extras.dogstatsd.Events.Event +import com.ovoenergy.natchez.extras.metrics.Metrics +import com.ovoenergy.natchez.extras.metrics.Metrics.Metric +import fs2.Chunk.array +import fs2.io.udp.{Packet, Socket, SocketGroup} import java.net.InetSocketAddress import java.nio.charset.StandardCharsets.UTF_8 -import cats.effect._ -import Events.Event -import Metrics.Metric -import fs2.Chunk.array -import fs2.io.udp._ - object Dogstatsd { // just for readability @@ -104,7 +105,11 @@ object Dogstatsd { * Take care of the gymnastics required to send a string to the `to` destination through * a socket in F before turning the resulting unit into a `G[Unit]` so our types line up */ - private def send[F[_]: Effect, G[_]: Async](skt: Socket[F], to: InetSocketAddress, what: UTF8Bytes): G[Unit] = + private def send[F[_]: Effect, G[_]: Async]( + skt: Socket[F], + to: InetSocketAddress, + what: UTF8Bytes + ): G[Unit] = Async[G].liftIO(Effect[F].toIO(skt.write(Packet(to, array(what))))) /** diff --git a/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Events.scala b/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/dogstatsd/Events.scala similarity index 91% rename from natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Events.scala rename to natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/dogstatsd/Events.scala index 1ed1c14..29cd24e 100644 --- a/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/Events.scala +++ b/natchez-extras-dogstatsd/src/main/scala/com/ovoenergy/natchez/extras/dogstatsd/Events.scala @@ -1,6 +1,6 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.dogstatsd -import Events.Event +import com.ovoenergy.natchez.extras.dogstatsd.Events.Event /** * Events are a Datadog extension to StatsD @@ -48,4 +48,4 @@ object Events { def forThrowable(t: Throwable): Event = Event("Exception", t.getMessage, AlertType.Error, Map.empty, Priority.Normal) } -} \ No newline at end of file +} diff --git a/natchez-extras-dogstatsd/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala b/natchez-extras-dogstatsd/src/test/scala/com/ovoenergy/natchez/extras/dogstatsd/DatadogTest.scala similarity index 93% rename from natchez-extras-dogstatsd/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala rename to natchez-extras-dogstatsd/src/test/scala/com/ovoenergy/natchez/extras/dogstatsd/DatadogTest.scala index 45635ab..04836e6 100644 --- a/natchez-extras-dogstatsd/src/test/scala/com/ovoenergy/natchez/extras/DatadogTest.scala +++ b/natchez-extras-dogstatsd/src/test/scala/com/ovoenergy/natchez/extras/dogstatsd/DatadogTest.scala @@ -1,11 +1,8 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.dogstatsd -import java.net.InetSocketAddress -import java.nio.charset.StandardCharsets.UTF_8 - -import com.ovoenergy.natchez.extras.Dogstatsd._ -import Events.{AlertType, Event, Priority} -import Metrics.Metric +import com.ovoenergy.natchez.extras.dogstatsd.Dogstatsd._ +import com.ovoenergy.natchez.extras.dogstatsd.Events.{AlertType, Event, Priority} +import com.ovoenergy.natchez.extras.metrics.Metrics.Metric import org.scalacheck.Gen.mapOf import org.scalacheck.{Arbitrary, Gen, Prop} import org.scalatest.matchers.should.Matchers @@ -13,6 +10,9 @@ import org.scalatest.wordspec.AnyWordSpec import org.scalatestplus.scalacheck.Checkers import org.typelevel.claimant.Claim +import java.net.InetSocketAddress +import java.nio.charset.StandardCharsets.UTF_8 + class DatadogTest extends AnyWordSpec with Matchers with Checkers { val string: Gen[String] = diff --git a/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedStatement.scala b/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/doobie/TracedStatement.scala similarity index 98% rename from natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedStatement.scala rename to natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/doobie/TracedStatement.scala index 1727966..4bc1090 100644 --- a/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedStatement.scala +++ b/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/doobie/TracedStatement.scala @@ -1,12 +1,12 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.doobie + +import com.github.ghik.silencer.silent import java.io.{InputStream, Reader} import java.net.URL import java.sql.{Array => _, _} import java.util.Calendar -import com.github.ghik.silencer.silent - /** * This is an absolutely abominable brute force solution to linking PreparedStatements * with a SQL string so we can include it in traces but hey I figure it is a one time cost @@ -18,119 +18,217 @@ private[natchez] case class TracedStatement( queryString: String ) extends PreparedStatement { def executeQuery(): ResultSet = p.executeQuery() + def executeUpdate(): Int = p.executeUpdate() + def setNull(parameterIndex: Int, sqlType: Int): Unit = p.setNull(parameterIndex, sqlType) + def setBoolean(parameterIndex: Int, x: Boolean): Unit = p.setBoolean(parameterIndex, x) + def setByte(parameterIndex: Int, x: Byte): Unit = p.setByte(parameterIndex, x) + def setShort(parameterIndex: Int, x: Short): Unit = p.setShort(parameterIndex, x) + def setInt(parameterIndex: Int, x: Int): Unit = p.setInt(parameterIndex, x) + def setLong(parameterIndex: Int, x: Long): Unit = p.setLong(parameterIndex, x) + def setFloat(parameterIndex: Int, x: Float): Unit = p.setFloat(parameterIndex, x) + def setDouble(parameterIndex: Int, x: Double): Unit = p.setDouble(parameterIndex, x) + def setBigDecimal(parameterIndex: Int, x: java.math.BigDecimal): Unit = p.setBigDecimal(parameterIndex, x) + def setString(parameterIndex: Int, x: String): Unit = p.setString(parameterIndex, x) + def setBytes(parameterIndex: Int, x: Array[Byte]): Unit = p.setBytes(parameterIndex, x) + def setDate(parameterIndex: Int, x: Date): Unit = p.setDate(parameterIndex, x) + def setTime(parameterIndex: Int, x: Time): Unit = p.setTime(parameterIndex, x) + def setTimestamp(parameterIndex: Int, x: Timestamp): Unit = p.setTimestamp(parameterIndex, x) + def setAsciiStream(parameterIndex: Int, x: InputStream, length: Int): Unit = p.setAsciiStream(parameterIndex, x, length) + def setUnicodeStream(parameterIndex: Int, x: InputStream, length: Int): Unit = p.setUnicodeStream(parameterIndex, x, length) + def setBinaryStream(parameterIndex: Int, x: InputStream, length: Int): Unit = p.setBinaryStream(parameterIndex, x, length) + def clearParameters(): Unit = p.clearParameters() + def setObject(parameterIndex: Int, x: Any, targetSqlType: Int): Unit = p.setObject(parameterIndex, x, targetSqlType) + def setObject(parameterIndex: Int, x: Any): Unit = p.setObject(parameterIndex, x) + def execute(): Boolean = p.execute() + def addBatch(): Unit = p.addBatch() + def setCharacterStream(parameterIndex: Int, reader: Reader, length: Int): Unit = p.setCharacterStream(parameterIndex, reader, length) + def setRef(parameterIndex: Int, x: Ref): Unit = p.setRef(parameterIndex, x) + def setBlob(parameterIndex: Int, x: Blob): Unit = p.setBlob(parameterIndex, x) + def setClob(parameterIndex: Int, x: Clob): Unit = p.setClob(parameterIndex, x) + def setArray(parameterIndex: Int, x: java.sql.Array): Unit = p.setArray(parameterIndex, x) + def getMetaData: ResultSetMetaData = p.getMetaData + def setDate(parameterIndex: Int, x: Date, cal: Calendar): Unit = p.setDate(parameterIndex, x, cal) + def setTime(parameterIndex: Int, x: Time, cal: Calendar): Unit = p.setTime(parameterIndex, x, cal) + def setTimestamp(parameterIndex: Int, x: Timestamp, cal: Calendar): Unit = p.setTimestamp(parameterIndex, x, cal) + def setNull(parameterIndex: Int, sqlType: Int, typeName: String): Unit = p.setNull(parameterIndex, sqlType, typeName) + def setURL(parameterIndex: Int, x: URL): Unit = p.setURL(parameterIndex, x) + def getParameterMetaData: ParameterMetaData = p.getParameterMetaData + def setRowId(parameterIndex: Int, x: RowId): Unit = p.setRowId(parameterIndex, x) + def setNString(parameterIndex: Int, value: String): Unit = p.setNString(parameterIndex, value) + def setNCharacterStream(parameterIndex: Int, value: Reader, length: Long): Unit = p.setNCharacterStream(parameterIndex, value, length) + def setNClob(parameterIndex: Int, value: NClob): Unit = p.setNClob(parameterIndex, value) + def setClob(parameterIndex: Int, reader: Reader, length: Long): Unit = p.setClob(parameterIndex, reader, length) + def setBlob(parameterIndex: Int, inputStream: InputStream, length: Long): Unit = p.setBlob(parameterIndex, inputStream, length) + def setNClob(parameterIndex: Int, reader: Reader, length: Long): Unit = p.setNClob(parameterIndex, reader, length) + def setSQLXML(parameterIndex: Int, xmlObject: SQLXML): Unit = p.setSQLXML(parameterIndex, xmlObject) + def setObject(parameterIndex: Int, x: Any, targetSqlType: Int, scaleOrLength: Int): Unit = p.setObject(parameterIndex, x, targetSqlType, scaleOrLength) + def setAsciiStream(parameterIndex: Int, x: InputStream, length: Long): Unit = p.setAsciiStream(parameterIndex, x, length) + def setBinaryStream(parameterIndex: Int, x: InputStream, length: Long): Unit = p.setBinaryStream(parameterIndex, x, length) + def setCharacterStream(parameterIndex: Int, reader: Reader, length: Long): Unit = p.setCharacterStream(parameterIndex, reader, length) + def setAsciiStream(parameterIndex: Int, x: InputStream): Unit = p.setAsciiStream(parameterIndex, x) + def setBinaryStream(parameterIndex: Int, x: InputStream): Unit = p.setBinaryStream(parameterIndex, x) + def setCharacterStream(parameterIndex: Int, reader: Reader): Unit = p.setCharacterStream(parameterIndex, reader) + def setNCharacterStream(parameterIndex: Int, value: Reader): Unit = p.setNCharacterStream(parameterIndex, value) + def setClob(parameterIndex: Int, reader: Reader): Unit = p.setClob(parameterIndex, reader) + def setBlob(parameterIndex: Int, inputStream: InputStream): Unit = p.setBlob(parameterIndex, inputStream) + def setNClob(parameterIndex: Int, reader: Reader): Unit = p.setNClob(parameterIndex, reader) + def executeQuery(sql: String): ResultSet = p.executeQuery(sql) + def executeUpdate(sql: String): Int = p.executeUpdate(sql) + def close(): Unit = p.close() + def getMaxFieldSize: Int = p.getMaxFieldSize + def setMaxFieldSize(max: Int): Unit = p.setMaxFieldSize(max) + def getMaxRows: Int = p.getMaxRows + def setMaxRows(max: Int): Unit = p.setMaxRows(max) + def setEscapeProcessing(enable: Boolean): Unit = p.setEscapeProcessing(enable) + def getQueryTimeout: Int = p.getQueryTimeout + def setQueryTimeout(seconds: Int): Unit = p.setQueryTimeout(seconds) + def cancel(): Unit = p.cancel() + def getWarnings: SQLWarning = p.getWarnings + def clearWarnings(): Unit = p.clearWarnings() + def setCursorName(name: String): Unit = p.setCursorName(name) + def execute(sql: String): Boolean = p.execute(sql) + def getResultSet: ResultSet = p.getResultSet + def getUpdateCount: Int = p.getUpdateCount + def getMoreResults: Boolean = p.getMoreResults() + def setFetchDirection(direction: Int): Unit = p.setFetchDirection(direction) + def getFetchDirection: Int = p.getFetchDirection + def setFetchSize(rows: Int): Unit = p.setFetchSize(rows) + def getFetchSize: Int = p.getFetchSize + def getResultSetConcurrency: Int = p.getResultSetConcurrency + def getResultSetType: Int = p.getResultSetType + def addBatch(sql: String): Unit = p.addBatch(sql) + def clearBatch(): Unit = p.clearBatch() + def executeBatch(): Array[Int] = p.executeBatch() + def getConnection: Connection = p.getConnection + def getMoreResults(current: Int): Boolean = p.getMoreResults(current) + def getGeneratedKeys: ResultSet = p.getGeneratedKeys + def executeUpdate(sql: String, autoGeneratedKeys: Int): Int = p.executeUpdate(sql, autoGeneratedKeys) + def executeUpdate(sql: String, columnIndexes: Array[Int]): Int = p.executeUpdate(sql, columnIndexes) + def executeUpdate(sql: String, columnNames: Array[String]): Int = p.executeUpdate(sql, columnNames) + def execute(sql: String, autoGeneratedKeys: Int): Boolean = p.execute(sql, autoGeneratedKeys) + def execute(sql: String, columnIndexes: Array[Int]): Boolean = p.execute(sql, columnIndexes) + def execute(sql: String, columnNames: Array[String]): Boolean = p.execute(sql, columnNames) + def getResultSetHoldability: Int = p.getResultSetHoldability + def isClosed: Boolean = p.isClosed + def setPoolable(poolable: Boolean): Unit = p.setPoolable(poolable) + def isPoolable: Boolean = p.isPoolable + def closeOnCompletion(): Unit = p.closeOnCompletion() + def isCloseOnCompletion: Boolean = p.isCloseOnCompletion + def unwrap[T](iface: Class[T]): T = p.unwrap(iface) + def isWrapperFor(iface: Class[_]): Boolean = p.isWrapperFor(iface) } diff --git a/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedTransactor.scala b/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/doobie/TracedTransactor.scala similarity index 96% rename from natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedTransactor.scala rename to natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/doobie/TracedTransactor.scala index bf5a4a9..dd87f2d 100644 --- a/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/TracedTransactor.scala +++ b/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/doobie/TracedTransactor.scala @@ -1,12 +1,12 @@ -package com.ovoenergy.natchez.extras - -import java.sql.{Connection, PreparedStatement, ResultSet} +package com.ovoenergy.natchez.extras.doobie import cats.data.Kleisli import cats.effect.{Async, Blocker, Concurrent, ContextShift} import doobie.free.KleisliInterpreter -import doobie.util.transactor._ +import doobie.util.transactor.Transactor import natchez.{Span, Trace} + +import java.sql.{Connection, PreparedStatement, ResultSet} import cats.syntax.flatMap._ object TracedTransactor { diff --git a/natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/TracedTransactorTest.scala b/natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/doobie/TracedTransactorTest.scala similarity index 95% rename from natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/TracedTransactorTest.scala rename to natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/doobie/TracedTransactorTest.scala index ed8c759..7767545 100644 --- a/natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/TracedTransactorTest.scala +++ b/natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/doobie/TracedTransactorTest.scala @@ -1,15 +1,15 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.doobie import cats.effect.concurrent.Ref import cats.effect.{Blocker, ContextShift, IO, Resource} -import TracedTransactor.Traced +import cats.syntax.flatMap._ +import com.ovoenergy.natchez.extras.doobie.TracedTransactor.Traced import doobie.h2.H2Transactor.newH2Transactor import doobie.implicits._ import doobie.util.transactor.Transactor import natchez.{Kernel, Span, TraceValue} import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec -import cats.syntax.flatMap._ import java.net.URI import scala.concurrent.ExecutionContext.global diff --git a/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/AllocatedSpan.scala b/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/fs2/AllocatedSpan.scala similarity index 98% rename from natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/AllocatedSpan.scala rename to natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/fs2/AllocatedSpan.scala index df15568..ff560b6 100644 --- a/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/AllocatedSpan.scala +++ b/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/fs2/AllocatedSpan.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.fs2 import cats.Traverse import cats.effect.{Concurrent, Resource, Sync} diff --git a/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/syntax.scala b/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/fs2/syntax.scala similarity index 81% rename from natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/syntax.scala rename to natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/fs2/syntax.scala index d549e2f..b6cdb1d 100644 --- a/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/syntax.scala +++ b/natchez-extras-fs2/src/main/scala/com/ovoenergy/natchez/extras/fs2/syntax.scala @@ -1,17 +1,18 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.fs2 import cats.data.Kleisli import cats.effect.Sync -import AllocatedSpan.Traced -import cats.syntax.traverse._ -import fs2._ +import com.ovoenergy.natchez.extras.fs2.AllocatedSpan.Traced +import fs2.Stream import natchez.Span +import cats.syntax.traverse._ object syntax { implicit class StreamOps[F[_]: Sync, A](s: Stream[F, Traced[F, A]]) { def evalMapNamed[B](name: String)(op: A => F[B]): Stream[F, Traced[F, B]] = s.evalMap(t => t.traverse(a => t.span.span(name).use(_ => op(a)))) + def evalMapTraced[B](name: String)(op: A => Kleisli[F, Span[F], B]): Stream[F, Traced[F, B]] = s.evalMap(t => t.traverse(a => t.span.span(name).use(op(a).run))) } diff --git a/natchez-extras-fs2/src/test/scala/com/ovoenergy/natchez/extras/AllocatedSpanTest.scala b/natchez-extras-fs2/src/test/scala/com/ovoenergy/natchez/extras/fs2/AllocatedSpanTest.scala similarity index 97% rename from natchez-extras-fs2/src/test/scala/com/ovoenergy/natchez/extras/AllocatedSpanTest.scala rename to natchez-extras-fs2/src/test/scala/com/ovoenergy/natchez/extras/fs2/AllocatedSpanTest.scala index 40959d8..9dcc9a3 100644 --- a/natchez-extras-fs2/src/test/scala/com/ovoenergy/natchez/extras/AllocatedSpanTest.scala +++ b/natchez-extras-fs2/src/test/scala/com/ovoenergy/natchez/extras/fs2/AllocatedSpanTest.scala @@ -1,13 +1,13 @@ -package com.ovoenergy.natchez.extras - -import java.util.UUID +package com.ovoenergy.natchez.extras.fs2 import cats.effect.{Clock, ContextShift, ExitCase, IO, Timer} +import com.ovoenergy.natchez.extras.testkit.TestEntryPoint import fs2.Stream import org.scalatest.Inspectors import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec +import java.util.UUID import scala.concurrent.ExecutionContext import scala.concurrent.duration._ 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 62ba39e..a632ef7 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 @@ -25,20 +25,21 @@ object TracedClient { Kleisli.liftK def apply[F[_]: Sync](client: Client[F], config: Configuration[F]): TracedClient[Traced[F, *]] = - name => Client[Traced[F, *]] { req => - Resource( - Trace[Traced[F, *]].span(s"$name:http.request:${removeNumericPathSegments(req.uri)}") { - for { - span <- Kleisli.ask[F, Span[F]] - headers <- trace(span.kernel.map(_.toHeaders.map { case (k, v) => Header(k, v) })) - withHeader = req.putHeaders(headers.toSeq: _*).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)).allocated - respTags <- trace(config.response.value.run(resp.mapK(dropTracing(span)))) - _ <- trace(span.put(respTags.toSeq:_*)) - } yield resp -> rel - } - ) + name => + Client[Traced[F, *]] { req => + Resource( + Trace[Traced[F, *]].span(s"$name:http.request:${removeNumericPathSegments(req.uri)}") { + for { + span <- Kleisli.ask[F, Span[F]] + headers <- trace(span.kernel.map(_.toHeaders.map { case (k, v) => Header(k, v) })) + withHeader = req.putHeaders(headers.toSeq: _*).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)).allocated + respTags <- trace(config.response.value.run(resp.mapK(dropTracing(span)))) + _ <- trace(span.put(respTags.toSeq: _*)) + } yield resp -> rel + } + ) } } diff --git a/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClientTest.scala b/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClientTest.scala index e073e93..c153ce8 100644 --- a/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClientTest.scala +++ b/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/client/TracedClientTest.scala @@ -2,9 +2,9 @@ package com.ovoenergy.natchez.extras.http4s.client import cats.data.Kleisli import cats.effect.{IO, Timer} -import com.ovoenergy.natchez.extras.TestEntryPoint -import com.ovoenergy.natchez.extras.TestEntryPoint.TestSpan +import com.ovoenergy.natchez.extras.testkit.TestEntryPoint.TestSpan import com.ovoenergy.natchez.extras.http4s.Configuration +import com.ovoenergy.natchez.extras.testkit.TestEntryPoint import natchez.{Kernel, Span} import org.http4s.Request import org.scalatest.matchers.should.Matchers diff --git a/natchez-extras-log4cats/src/main/scala/com/ovoenergy/natchez/extras/TracedLogger.scala b/natchez-extras-log4cats/src/main/scala/com/ovoenergy/natchez/extras/log4cats/TracedLogger.scala similarity index 98% rename from natchez-extras-log4cats/src/main/scala/com/ovoenergy/natchez/extras/TracedLogger.scala rename to natchez-extras-log4cats/src/main/scala/com/ovoenergy/natchez/extras/log4cats/TracedLogger.scala index 6a7380d..337953d 100644 --- a/natchez-extras-log4cats/src/main/scala/com/ovoenergy/natchez/extras/TracedLogger.scala +++ b/natchez-extras-log4cats/src/main/scala/com/ovoenergy/natchez/extras/log4cats/TracedLogger.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.log4cats import cats.Monad import cats.data.Kleisli diff --git a/natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/Metrics.scala b/natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/metrics/Metrics.scala similarity index 93% rename from natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/Metrics.scala rename to natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/metrics/Metrics.scala index 5d5e9d8..c3fcf0f 100644 --- a/natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/Metrics.scala +++ b/natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/metrics/Metrics.scala @@ -1,8 +1,8 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.metrics -import cats.{~>, Functor, Monad} import cats.syntax.apply._ -import Metrics.Metric +import cats.{~>, Functor, Monad} +import com.ovoenergy.natchez.extras.metrics.Metrics.Metric /** * A type class representing the ability to push metrics diff --git a/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4j.scala b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4j.scala similarity index 94% rename from natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4j.scala rename to natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4j.scala index 8b0df15..a35862c 100644 --- a/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4j.scala +++ b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4j.scala @@ -1,4 +1,4 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.slf4j import cats.MonadError import cats.effect.{Resource, Sync} @@ -11,8 +11,10 @@ object Slf4j { new EntryPoint[F] { def root(name: String): Resource[F, Span[F]] = Slf4jSpan.create(name).widen + def continue(name: String, kernel: Kernel): Resource[F, Span[F]] = Resource.liftF(Slf4jSpan.fromKernel(name, kernel).widen).flatMap(identity).widen + def continueOrElseRoot(name: String, kernel: Kernel): Resource[F, Span[F]] = Resource .liftF( diff --git a/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4jSpan.scala b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4jSpan.scala similarity index 98% rename from natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4jSpan.scala rename to natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4jSpan.scala index bcced71..86ad44d 100644 --- a/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/Slf4jSpan.scala +++ b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4jSpan.scala @@ -1,6 +1,5 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.slf4j -import java.util.UUID.randomUUID import cats.Monad import cats.data.OptionT import cats.effect.concurrent.Ref @@ -12,6 +11,7 @@ import natchez.{Kernel, Span, TraceValue} import org.slf4j.{Logger, LoggerFactory, MDC} import java.net.URI +import java.util.UUID.randomUUID case class Slf4jSpan[F[_]: Sync]( mdc: Ref[F, Map[String, TraceValue]], diff --git a/natchez-extras-slf4j/src/test/scala/com/ovoenergy/natchez/extras/Slf4jSpanTest.scala b/natchez-extras-slf4j/src/test/scala/com/ovoenergy/natchez/extras/slf4j/Slf4jSpanTest.scala similarity index 98% rename from natchez-extras-slf4j/src/test/scala/com/ovoenergy/natchez/extras/Slf4jSpanTest.scala rename to natchez-extras-slf4j/src/test/scala/com/ovoenergy/natchez/extras/slf4j/Slf4jSpanTest.scala index 5673640..4beeb6a 100644 --- a/natchez-extras-slf4j/src/test/scala/com/ovoenergy/natchez/extras/Slf4jSpanTest.scala +++ b/natchez-extras-slf4j/src/test/scala/com/ovoenergy/natchez/extras/slf4j/Slf4jSpanTest.scala @@ -1,6 +1,8 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.slf4j import cats.effect.{Concurrent, ContextShift, IO} +import cats.syntax.flatMap._ +import natchez.Kernel import org.scalatest.BeforeAndAfterEach import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec @@ -8,9 +10,6 @@ import uk.org.lidalia.slf4jtest.{LoggingEvent, TestLoggerFactory} import scala.concurrent.ExecutionContext import scala.jdk.CollectionConverters._ -import cats.syntax.flatMap._ -import natchez.Kernel - import scala.util.Try class Slf4jSpanTest extends AnyWordSpec with Matchers with BeforeAndAfterEach { diff --git a/natchez-extras-testkit/src/main/scala/com/ovoenergy/natchez/extras/TestEntryPoint.scala b/natchez-extras-testkit/src/main/scala/com/ovoenergy/natchez/extras/testkit/TestEntryPoint.scala similarity index 94% rename from natchez-extras-testkit/src/main/scala/com/ovoenergy/natchez/extras/TestEntryPoint.scala rename to natchez-extras-testkit/src/main/scala/com/ovoenergy/natchez/extras/testkit/TestEntryPoint.scala index d1d3c4b..9030d30 100644 --- a/natchez-extras-testkit/src/main/scala/com/ovoenergy/natchez/extras/TestEntryPoint.scala +++ b/natchez-extras-testkit/src/main/scala/com/ovoenergy/natchez/extras/testkit/TestEntryPoint.scala @@ -1,15 +1,15 @@ -package com.ovoenergy.natchez.extras +package com.ovoenergy.natchez.extras.testkit -import java.time.Instant -import java.util.concurrent.TimeUnit import cats.effect.concurrent.Ref import cats.effect.{Clock, ExitCase, Resource, Sync} import cats.syntax.flatMap._ import cats.syntax.functor._ -import TestEntryPoint.TestSpan +import com.ovoenergy.natchez.extras.testkit.TestEntryPoint.TestSpan import natchez.{EntryPoint, Kernel, Span, TraceValue} import java.net.URI +import java.time.Instant +import java.util.concurrent.TimeUnit /** * Test implementation of Natchez that is backed by a Ref @@ -31,7 +31,6 @@ object TestEntryPoint { def apply[F[_]: Clock](implicit F: Sync[F]): F[TestEntryPoint[F]] = Ref.of[F, List[TestSpan]](List.empty).map { submitted => - def span(myName: String, k: Kernel): Span[F] = new Span[F] { def span(name: String): Resource[F, Span[F]] = makeSpan(name, Some(myName), k) def put(fields: (String, TraceValue)*): F[Unit] = F.unit From d0457257e70d699b47adcd382081f5561ed06dc7 Mon Sep 17 00:00:00 2001 From: Tom Verran Date: Fri, 16 Apr 2021 15:33:17 +0100 Subject: [PATCH 4/8] Set up sonatype publishing --- build.sbt | 27 ++++++++++++++++++++++----- project/plugins.sbt | 5 +++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index f912631..eb46d3c 100644 --- a/build.sbt +++ b/build.sbt @@ -2,19 +2,36 @@ import microsites.MicrositesPlugin.autoImport.micrositeDescription scalaVersion in ThisBuild := "2.13.4" -classLoaderLayeringStrategy in ThisBuild := ClassLoaderLayeringStrategy.ScalaLibrary - organization in ThisBuild := "com.ovoenergy" organizationName in ThisBuild := "OVO Energy" organizationHomepage in ThisBuild := Some(url("http://www.ovoenergy.com")) +scmInfo in ThisBuild := Some( + ScmInfo( + url("https://github.com/ovotech/natchez-extras"), + "scm:git@github.com:ovotech/natchez-extras.git" + ) +) + +homepage in ThisBuild := Some(url("https://ovotech.github.io/natchez-extras/")) + +licenses in ThisBuild += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html")) + +publishMavenStyle in ThisBuild := true + +publishTo in ThisBuild := sonatypePublishToBundle.value + +credentials in ThisBuild += ( + for { + user <- sys.env.get("SONATYPE_USERNAME") + pass <- sys.env.get("SONATYPE_PASSWORD") + } yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", user, pass) +).getOrElse(Credentials(Path.userHome / ".sbt" / ".sonatype_credentials")) + val common = Seq( fork in Test := true, - bintrayRepository := "maven", - bintrayOrganization := Some("ovotech"), - licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html")), git.useGitDescribe := true, libraryDependencies ++= Seq( compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"), diff --git a/project/plugins.sbt b/project/plugins.sbt index 4e7fc71..c6d6ee5 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,8 @@ addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.15") -addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4") 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.1") addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1") \ No newline at end of file +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7") +addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") From ad07aa1f9efac8057ef5b2b84cc8677ca74cb505 Mon Sep 17 00:00:00 2001 From: Tom Verran Date: Fri, 16 Apr 2021 16:08:01 +0100 Subject: [PATCH 5/8] Take the opportunity to update all the libraries --- build.sbt | 25 ++++++++----------- .../natchez/extras/datadog/Datadog.scala | 9 +++---- .../natchez/extras/datadog/DatadogSpan.scala | 8 +++--- .../natchez/extras/datadog/TestClient.scala | 4 +-- .../extras/doobie/TracedStatement.scala | 7 +++--- .../extras/doobie/TracedTransactorTest.scala | 2 +- .../http4s/server/TraceMiddlewareTest.scala | 6 ++--- .../natchez/extras/metrics/Metrics.scala | 4 +-- .../natchez/extras/slf4j/Slf4j.scala | 5 ++-- .../natchez/extras/slf4j/Slf4jSpan.scala | 2 +- 10 files changed, 33 insertions(+), 39 deletions(-) diff --git a/build.sbt b/build.sbt index eb46d3c..6e50acf 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ import microsites.MicrositesPlugin.autoImport.micrositeDescription -scalaVersion in ThisBuild := "2.13.4" +scalaVersion in ThisBuild := "2.13.5" organization in ThisBuild := "com.ovoenergy" @@ -36,10 +36,10 @@ val common = Seq( libraryDependencies ++= Seq( compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"), compilerPlugin("org.typelevel" % "kind-projector" % "0.11.3" cross CrossVersion.full), - "org.typelevel" %% "cats-core" % "2.3.1", - "org.typelevel" %% "cats-effect" % "2.3.1", - "org.scalatest" %% "scalatest" % "3.2.3" % Test, - "org.scalacheck" %% "scalacheck" % "1.15.2" % Test, + "org.typelevel" %% "cats-core" % "2.5.0", + "org.typelevel" %% "cats-effect" % "2.4.1", + "org.scalatest" %% "scalatest" % "3.2.7" % Test, + "org.scalacheck" %% "scalacheck" % "1.15.3" % Test, "org.scalatestplus" %% "scalacheck-1-14" % "3.2.2.0" % Test ), ) @@ -50,11 +50,11 @@ lazy val metricsCommon = project .settings(common :+ (name := "natchez-extras-metrics")) val log4catsVersion = "1.2.2" -val natchezVersion = "0.0.19" -val http4sVersion = "0.21.16" +val natchezVersion = "0.0.22" +val http4sVersion = "0.21.22" val circeVersion = "0.13.0" val slf4jVersion = "1.7.30" -val fs2Version = "2.5.0" +val fs2Version = "2.5.4" lazy val natchezDatadog = project .in(file("natchez-extras-datadog")) @@ -127,14 +127,13 @@ lazy val natchezFs2 = project .settings(common :+ (name := "natchez-extras-fs2")) .settings( libraryDependencies ++= Seq( - "org.typelevel" %% "kittens" % "2.2.1", + "org.typelevel" %% "kittens" % "2.2.2", "org.tpolecat" %% "natchez-core" % natchezVersion, "co.fs2" %% "fs2-core" % fs2Version ) ) -val silencerVersion = "1.7.1" -val doobieVersion = "0.10.0" +val doobieVersion = "0.12.1" lazy val natchezDoobie = project .in(file("natchez-extras-doobie")) .enablePlugins(GitVersioning) @@ -143,9 +142,7 @@ lazy val natchezDoobie = project libraryDependencies ++= Seq( "org.tpolecat" %% "natchez-core" % natchezVersion, "org.tpolecat" %% "doobie-core" % doobieVersion, - "org.tpolecat" %% "doobie-h2" % doobieVersion, - "com.github.ghik" % "silencer-lib" % silencerVersion % Provided cross CrossVersion.full, - compilerPlugin("com.github.ghik" % "silencer-plugin" % silencerVersion cross CrossVersion.full), + "org.tpolecat" %% "doobie-h2" % doobieVersion ), ) diff --git a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/Datadog.scala b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/Datadog.scala index e2dd196..6bb815c 100644 --- a/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/Datadog.scala +++ b/natchez-extras-datadog/src/main/scala/com/ovoenergy/natchez/extras/datadog/Datadog.scala @@ -1,6 +1,5 @@ package com.ovoenergy.natchez.extras.datadog -import cats.Applicative import cats.effect.concurrent.{Ref, Semaphore} import cats.effect.{Clock, Concurrent, Resource, Sync, Timer} import cats.syntax.flatMap._ @@ -26,9 +25,9 @@ object Datadog { Sync[F].delay(LoggerFactory.getLogger(getClass.getName)) private def spanQueue[F[_]: Concurrent]: Resource[F, Queue[F, SubmittableSpan]] = - Resource.liftF(Queue.circularBuffer[F, SubmittableSpan](maxSize = 1000)) + Resource.eval(Queue.circularBuffer[F, SubmittableSpan](maxSize = 1000)) - private implicit def encoder[F[_]: Applicative, A: Encoder]: EntityEncoder[F, A] = + private implicit def encoder[F[_], A: Encoder]: EntityEncoder[F, A] = builder.withPrinter(Printer.noSpaces.copy(dropNullValues = true)).build.jsonEncoderOf[F, A] /** @@ -77,7 +76,7 @@ object Datadog { agent: Uri, queue: Queue[F, SubmittableSpan] ): Resource[F, Unit] = - Resource.liftF(logger[F]).flatMap { logger => + Resource.eval(logger[F]).flatMap { logger => val submit: F[Unit] = submitOnce(queue, http, logger, agent) Resource .make( @@ -115,7 +114,7 @@ object Datadog { new EntryPoint[F] { def root(name: String): Resource[F, Span[F]] = Resource - .liftF( + .eval( SpanIdentifiers.create.flatMap(Ref.of[F, SpanIdentifiers]) ) .flatMap(DatadogSpan.create(queue, names(name))) 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 bc39ae2..8c32a42 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 @@ -116,9 +116,9 @@ object DatadogSpan { def fromParent[F[_]: Sync: Clock](name: String, parent: DatadogSpan[F]): Resource[F, DatadogSpan[F]] = for { - meta <- Resource.liftF(parent.meta.get) - ids <- Resource.liftF(parent.ids.get.flatMap(SpanIdentifiers.child[F])) - ref <- Resource.liftF(Ref.of[F, SpanIdentifiers](ids)) + meta <- Resource.eval(parent.meta.get) + ids <- Resource.eval(parent.ids.get.flatMap(SpanIdentifiers.child[F])) + ref <- Resource.eval(Ref.of[F, SpanIdentifiers](ids)) child <- create(parent.queue, SpanNames.withFallback(name, parent.names), meta)(ref) } yield child @@ -128,7 +128,7 @@ object DatadogSpan { kernel: Kernel ): Resource[F, DatadogSpan[F]] = Resource - .liftF( + .eval( SpanIdentifiers .fromKernel(kernel) .flatMap(Ref.of[F, SpanIdentifiers]) diff --git a/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/TestClient.scala b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/TestClient.scala index cd81679..e0bee57 100644 --- a/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/TestClient.scala +++ b/natchez-extras-datadog/src/test/scala/com/ovoenergy/natchez/extras/datadog/TestClient.scala @@ -17,7 +17,7 @@ trait TestClient[F[_]] { object TestClient { - def apply[F[_]: Sync: Concurrent]: F[TestClient[F]] = + def apply[F[_]: Concurrent]: F[TestClient[F]] = ( Ref.of[F, List[Request[F]]](List.empty), Queue.unbounded[F, F[Response[F]]] @@ -29,7 +29,7 @@ object TestClient { resps.enqueue1(r) def client: Client[F] = Client { r => - Resource.liftF( + Resource.eval( reqs.update(_ :+ r) >> resps.tryDequeue1.flatMap(r => r.getOrElse(Sync[F].pure(Response[F]()))) ) diff --git a/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/doobie/TracedStatement.scala b/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/doobie/TracedStatement.scala index 4bc1090..f103ee0 100644 --- a/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/doobie/TracedStatement.scala +++ b/natchez-extras-doobie/src/main/scala/com/ovoenergy/natchez/extras/doobie/TracedStatement.scala @@ -1,19 +1,18 @@ package com.ovoenergy.natchez.extras.doobie -import com.github.ghik.silencer.silent - import java.io.{InputStream, Reader} import java.net.URL import java.sql.{Array => _, _} import java.util.Calendar +import scala.annotation.nowarn /** * This is an absolutely abominable brute force solution to linking PreparedStatements * with a SQL string so we can include it in traces but hey I figure it is a one time cost * Pretend this doesn't exist and you never had to see it */ -@silent("deprecated") -private[natchez] case class TracedStatement( +@nowarn +private[doobie] case class TracedStatement( p: PreparedStatement, queryString: String ) extends PreparedStatement { diff --git a/natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/doobie/TracedTransactorTest.scala b/natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/doobie/TracedTransactorTest.scala index 7767545..3fa1dad 100644 --- a/natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/doobie/TracedTransactorTest.scala +++ b/natchez-extras-doobie/src/test/scala/com/ovoenergy/natchez/extras/doobie/TracedTransactorTest.scala @@ -26,7 +26,7 @@ class TracedTransactorTest extends AnyWordSpec with Matchers { Ref.of[IO, List[SpanData]](List(SpanData("root", Map.empty))).flatMap { sps => lazy val spanMock: Span[IO] = new Span[IO] { def span(name: String): Resource[IO, Span[IO]] = - Resource.liftF(sps.update(_ :+ SpanData(name, Map.empty)).as(spanMock)) + Resource.eval(sps.update(_ :+ SpanData(name, Map.empty)).as(spanMock)) def kernel: IO[Kernel] = IO.pure(Kernel(Map.empty)) def put(fields: (String, TraceValue)*): IO[Unit] = diff --git a/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/server/TraceMiddlewareTest.scala b/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/server/TraceMiddlewareTest.scala index 5cc34e4..8444235 100644 --- a/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/server/TraceMiddlewareTest.scala +++ b/natchez-extras-http4s/src/test/scala/com/ovoenergy/natchez/extras/http4s/server/TraceMiddlewareTest.scala @@ -43,11 +43,11 @@ class TraceMiddlewareTest extends AnyWordSpec with Matchers with Inspectors { Ref.of[IO, Map[String, TraceValue]](Map.empty).map { ref => new TestEntryPoint[IO] { def root(name: String): Resource[IO, Span[IO]] = - Resource.liftF(Monad[IO].pure(spanMock(ref))) + Resource.eval(Monad[IO].pure(spanMock(ref))) def continue(name: String, kernel: Kernel): Resource[IO, Span[IO]] = - Resource.liftF(Monad[IO].pure(spanMock(ref))) + Resource.eval(Monad[IO].pure(spanMock(ref))) def continueOrElseRoot(name: String, kernel: Kernel): Resource[IO, Span[IO]] = - Resource.liftF(Monad[IO].pure(spanMock(ref))) + Resource.eval(Monad[IO].pure(spanMock(ref))) def tags: IO[Map[String, TraceValue]] = ref.get } diff --git a/natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/metrics/Metrics.scala b/natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/metrics/Metrics.scala index c3fcf0f..6ab4574 100644 --- a/natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/metrics/Metrics.scala +++ b/natchez-extras-metrics/src/main/scala/com/ovoenergy/natchez/extras/metrics/Metrics.scala @@ -1,7 +1,7 @@ package com.ovoenergy.natchez.extras.metrics import cats.syntax.apply._ -import cats.{~>, Functor, Monad} +import cats.{Monad, ~>} import com.ovoenergy.natchez.extras.metrics.Metrics.Metric /** @@ -21,7 +21,7 @@ object Metrics { /** * Transform the effect type of the given Metrics instance with a natural transformation */ - def mapK[F[_], G[_]: Functor](metrics: Metrics[F], nt: F ~> G): Metrics[G] = + def mapK[F[_], G[_]](metrics: Metrics[F], nt: F ~> G): Metrics[G] = new Metrics[G] { def counter(metric: Metric)(value: Long): G[Unit] = nt(metrics.counter(metric)(value)) diff --git a/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4j.scala b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4j.scala index a35862c..d338d97 100644 --- a/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4j.scala +++ b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4j.scala @@ -13,11 +13,10 @@ object Slf4j { Slf4jSpan.create(name).widen def continue(name: String, kernel: Kernel): Resource[F, Span[F]] = - Resource.liftF(Slf4jSpan.fromKernel(name, kernel).widen).flatMap(identity).widen + Resource.eval(Slf4jSpan.fromKernel(name, kernel).widen).flatMap(identity).widen def continueOrElseRoot(name: String, kernel: Kernel): Resource[F, Span[F]] = - Resource - .liftF( + Resource.eval( MonadError[F, Throwable] .recover(Slf4jSpan.fromKernel(name, kernel)) { case _ => Slf4jSpan.create(name) } ) diff --git a/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4jSpan.scala b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4jSpan.scala index 86ad44d..6992808 100644 --- a/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4jSpan.scala +++ b/natchez-extras-slf4j/src/main/scala/com/ovoenergy/natchez/extras/slf4j/Slf4jSpan.scala @@ -27,7 +27,7 @@ case class Slf4jSpan[F[_]: Sync]( Monad[F].pure(Kernel(Map("X-Trace-Token" -> token))) def span(name: String): Resource[F, Span[F]] = - Resource.liftF(mdc.get).flatMap(Slf4jSpan.create(name, Some(token), _)).widen + Resource.eval(mdc.get).flatMap(Slf4jSpan.create(name, Some(token), _)).widen def traceId: F[Option[String]] = Sync[F].pure(Some(token)) From 2f722ccb51a37147fe76f3e145a00df6a9adf2cf Mon Sep 17 00:00:00 2001 From: Tom Verran Date: Mon, 19 Apr 2021 11:14:19 +0100 Subject: [PATCH 6/8] Add developer info, deploy from CI --- .circleci/config.yml | 5 ++++- build.sbt | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6d6ad25..ee4a706 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -71,12 +71,15 @@ jobs: steps: - checkout - *cache_restore + - run: + name: import PGP key + command: echo -e "$PGP_KEY" | gpg --batch --import - run: name: Release command: | set -e tags=`git describe --tags` - sbt ';set version in ThisBuild := "'${tags}'"; test; publish' + sbt ';set version in ThisBuild := "'${tags}'"; test; publishSigned; sonatypeBundleRelease' - *cache_save test: diff --git a/build.sbt b/build.sbt index 6e50acf..af5553a 100644 --- a/build.sbt +++ b/build.sbt @@ -23,6 +23,10 @@ publishMavenStyle in ThisBuild := true publishTo in ThisBuild := sonatypePublishToBundle.value +developers in ThisBuild ++= List( + Developer("tomverran", "Tom Verran", "github@tomverran.co.uk", url("https://github.com/tomverran")) +) + credentials in ThisBuild += ( for { user <- sys.env.get("SONATYPE_USERNAME") From c93057c2711a7fc09838a885e0106d7355ad0784 Mon Sep 17 00:00:00 2001 From: Tom Verran Date: Mon, 19 Apr 2021 11:15:40 +0100 Subject: [PATCH 7/8] Update variable name --- docs/docs/docs/natchez-combine.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/docs/natchez-combine.md b/docs/docs/docs/natchez-combine.md index f4d6017..3882319 100644 --- a/docs/docs/docs/natchez-combine.md +++ b/docs/docs/docs/natchez-combine.md @@ -17,13 +17,13 @@ In your build.sbt ```scala val http4sVersion = "0.21.4" -val effectUtilsVersion = "@VERSION@" +val natchezExtrasVersion = "@VERSION@" libraryDependencies ++= Seq( "org.http4s" %% "http4s-blaze-client" % http4sVersion, - "com.ovoenergy" %% "natchez-extras-combine" % effectUtilsVersion, - "com.ovoenergy" %% "natchez-extras-datadog" % effectUtilsVersion, - "com.ovoenergy" %% "natchez-extras-slf4j" % effectUtilsVersion + "com.ovoenergy" %% "natchez-extras-combine" % natchezExtrasVersion, + "com.ovoenergy" %% "natchez-extras-datadog" % natchezExtrasVersion, + "com.ovoenergy" %% "natchez-extras-slf4j" % natchezExtrasVersion ) ``` From 65a6a24fe4604b3ff0855593a53bac796c0e48b0 Mon Sep 17 00:00:00 2001 From: Tom Verran Date: Mon, 19 Apr 2021 11:27:27 +0100 Subject: [PATCH 8/8] Add details of the renaming to the README --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index fd3ce1a..1439363 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,16 @@ If you're upgrading your dependencies the renamings are as follows: "com.ovoenergy.effect" % "natchez-testkit" => "com.ovoenergy" % "natchez-extras-testkit" ``` +Other significant changes are the `Datadog` metrics object being renamed to `Dogstatsd` and the +modules having their code moved into a subpackage under `com.ovoenergy.natchez.extras` + +i.e. + +`com.ovoenergy.effect.Combine` becomes `com.ovoenergy.natchez.extras.combine.Combine` + +This is to ensure that the `com.ovoenergy.natchez.extras` namespace won't be polluted by +two modules defining, for example, a `syntax` object. + ## Current modules Module | Description | Artifact