Skip to content

Commit

Permalink
Merge pull request #57 from ovotech/sonatype-move
Browse files Browse the repository at this point in the history
Sonatype move
  • Loading branch information
tomverran authored Apr 19, 2021
2 parents fadaf1b + 65a6a24 commit 71a0c6d
Show file tree
Hide file tree
Showing 44 changed files with 479 additions and 315 deletions.
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
57 changes: 41 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
# 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"
```

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
----------------|--------------------------------------------------------------------------------|-----------------------------------------
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.
106 changes: 62 additions & 44 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,48 +1,69 @@
import microsites.MicrositesPlugin.autoImport.micrositeDescription

scalaVersion in ThisBuild := "2.13.4"
scalaVersion in ThisBuild := "2.13.5"

classLoaderLayeringStrategy in ThisBuild := ClassLoaderLayeringStrategy.ScalaLibrary

organization in ThisBuild := "com.ovoenergy.effect"
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:[email protected]: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

developers in ThisBuild ++= List(
Developer("tomverran", "Tom Verran", "[email protected]", url("https://github.com/tomverran"))
)

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"),
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
),
)

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"
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-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,
Expand All @@ -58,9 +79,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,
Expand All @@ -70,10 +91,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,
Expand All @@ -83,9 +104,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,
Expand All @@ -94,54 +115,51 @@ 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
)
)

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",
"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-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,
"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
),
)

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(
Expand All @@ -167,9 +185,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"),
Expand All @@ -187,7 +205,7 @@ lazy val docs = project
lazy val root = (project in file("."))
.settings(
common ++ Seq(
name := "effect-utils",
name := "natchez-extras",
publish := nop,
publishLocal := nop
))
Expand Down
16 changes: 8 additions & 8 deletions docs/docs/docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"),
Expand Down Expand Up @@ -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)
Expand Down
21 changes: 10 additions & 11 deletions docs/docs/docs/natchez-combine.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,25 +17,24 @@ In your build.sbt

```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-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" % natchezExtrasVersion,
"com.ovoenergy" %% "natchez-extras-datadog" % natchezExtrasVersion,
"com.ovoenergy" %% "natchez-extras-slf4j" % natchezExtrasVersion
)
```

## 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
Expand Down
Loading

0 comments on commit 71a0c6d

Please sign in to comment.