Skip to content

Commit

Permalink
Merge pull request #421 from iRevive/sdk-exporter/otlp-http
Browse files Browse the repository at this point in the history
sdk-exporter-trace: add `OtlpHttpSpanExporter`
  • Loading branch information
iRevive authored Feb 1, 2024
2 parents 8e1bde5 + f92bbe0 commit 954f9d0
Show file tree
Hide file tree
Showing 25 changed files with 2,684 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ jobs:
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Install brew formulae (ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: /home/linuxbrew/.linuxbrew/bin/brew install s2n utf8proc

- name: Check that workflows are up to date
run: sbt githubWorkflowCheck

Expand Down Expand Up @@ -239,7 +243,7 @@ jobs:
- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
modules-ignore: otel4s-sdk-common_native0.4_2.13 otel4s-sdk-common_native0.4_3 otel4s-benchmarks_2.13 otel4s-benchmarks_3 otel4s-examples_2.13 otel4s-examples_3 otel4s-sdk-common_sjs1_2.13 otel4s-sdk-common_sjs1_3 otel4s-sdk-trace_sjs1_2.13 otel4s-sdk-trace_sjs1_3 otel4s_2.13 otel4s_3 docs_2.13 docs_3 scalafix-output_2.13 scalafix-input_2.13 otel4s-sdk_native0.4_2.13 otel4s-sdk_native0.4_3 otel4s-sdk-common_2.13 otel4s-sdk-common_3 otel4s_2.13 otel4s_3 otel4s_2.13 otel4s_3 otel4s-sdk-trace_native0.4_2.13 otel4s-sdk-trace_native0.4_3 scalafix-tests_2.13 otel4s-sdk_sjs1_2.13 otel4s-sdk_sjs1_3 otel4s-sdk_2.13 otel4s-sdk_3 otel4s-sdk-trace_2.13 otel4s-sdk-trace_3
modules-ignore: otel4s-sdk-exporter-common_sjs1_2.13 otel4s-sdk-exporter-common_sjs1_3 otel4s-sdk-common_native0.4_2.13 otel4s-sdk-common_native0.4_3 otel4s-benchmarks_2.13 otel4s-benchmarks_3 otel4s-examples_2.13 otel4s-examples_3 otel4s-sdk-common_sjs1_2.13 otel4s-sdk-common_sjs1_3 otel4s-sdk-exporter_2.13 otel4s-sdk-exporter_3 otel4s-sdk-trace_sjs1_2.13 otel4s-sdk-trace_sjs1_3 otel4s-sdk-exporter-common_native0.4_2.13 otel4s-sdk-exporter-common_native0.4_3 otel4s-sdk-exporter-trace_2.13 otel4s-sdk-exporter-trace_3 otel4s_2.13 otel4s_3 docs_2.13 docs_3 scalafix-output_2.13 scalafix-input_2.13 otel4s-sdk-exporter-proto_2.13 otel4s-sdk-exporter-proto_3 otel4s-sdk-exporter-proto_sjs1_2.13 otel4s-sdk-exporter-proto_sjs1_3 otel4s-sdk_native0.4_2.13 otel4s-sdk_native0.4_3 otel4s-sdk-exporter-trace_native0.4_2.13 otel4s-sdk-exporter-trace_native0.4_3 otel4s-sdk-common_2.13 otel4s-sdk-common_3 otel4s_2.13 otel4s_3 otel4s_2.13 otel4s_3 otel4s-sdk-trace_native0.4_2.13 otel4s-sdk-trace_native0.4_3 otel4s-sdk-exporter-proto_native0.4_2.13 otel4s-sdk-exporter-proto_native0.4_3 otel4s-sdk-exporter-common_2.13 otel4s-sdk-exporter-common_3 otel4s-sdk-exporter-trace_sjs1_2.13 otel4s-sdk-exporter-trace_sjs1_3 scalafix-tests_2.13 otel4s-sdk-exporter_sjs1_2.13 otel4s-sdk-exporter_sjs1_3 otel4s-sdk_sjs1_2.13 otel4s-sdk_sjs1_3 otel4s-sdk_2.13 otel4s-sdk_3 otel4s-sdk-exporter_native0.4_2.13 otel4s-sdk-exporter_native0.4_3 otel4s-sdk-trace_2.13 otel4s-sdk-trace_3
configs-ignore: test scala-tool scala-doc-tool test-internal

validate-steward:
Expand Down
111 changes: 109 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import com.typesafe.tools.mima.core._

ThisBuild / tlBaseVersion := "0.5"

ThisBuild / organization := "org.typelevel"
Expand Down Expand Up @@ -27,6 +25,8 @@ val Scala213 = "2.13.12"
ThisBuild / crossScalaVersions := Seq(Scala213, "3.3.1")
ThisBuild / scalaVersion := Scala213 // the default Scala

ThisBuild / githubWorkflowBuildPreamble ++= nativeBrewInstallWorkflowSteps.value

val CatsVersion = "2.10.0"
val CatsEffectVersion = "3.5.3"
val CatsMtlVersion = "1.4.0"
Expand All @@ -38,11 +38,16 @@ val MUnitScalaCheckEffectVersion = "2.0.0-M2"
val OpenTelemetryVersion = "1.34.1"
val OpenTelemetryInstrumentationVersion = "2.0.0"
val OpenTelemetrySemConvVersion = "1.23.1-alpha"
val OpenTelemetryProtoVersion = "1.0.0-alpha"
val PekkoStreamVersion = "1.0.2"
val PekkoHttpVersion = "1.0.0"
val PlatformVersion = "1.0.2"
val ScodecVersion = "1.1.38"
val VaultVersion = "3.5.0"
val Http4sVersion = "0.23.25"
val CirceVersion = "0.14.6"
val EpollcatVersion = "0.1.6"
val ScalaPBCirceVersion = "0.15.1"

lazy val scalaReflectDependency = Def.settings(
libraryDependencies ++= {
Expand Down Expand Up @@ -77,6 +82,10 @@ lazy val root = tlCrossRootProject
`sdk-common`,
`sdk-trace`,
sdk,
`sdk-exporter-common`,
`sdk-exporter-proto`,
`sdk-exporter-trace`,
`sdk-exporter`,
`testkit-common`,
`testkit-metrics`,
testkit,
Expand Down Expand Up @@ -210,6 +219,101 @@ lazy val sdk = crossProject(JVMPlatform, JSPlatform, NativePlatform)
)
.settings(scalafixSettings)

//
// SDK exporter
//

lazy val `sdk-exporter-proto` =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.enablePlugins(NoPublishPlugin)
.in(file("sdk-exporter/proto"))
.settings(
name := "otel4s-sdk-exporter-proto",
Compile / PB.protoSources += baseDirectory.value.getParentFile / "src" / "main" / "protobuf",
Compile / PB.targets ++= Seq(
scalapb.gen(grpc = false) -> (Compile / sourceManaged).value / "scalapb"
),
scalacOptions := {
val opts = scalacOptions.value
if (tlIsScala3.value) opts.filterNot(_ == "-Wvalue-discard") else opts
},
// We use open-telemetry protobuf spec to generate models
// See https://scalapb.github.io/docs/third-party-protos/#there-is-a-library-on-maven-with-the-protos-and-possibly-generated-java-code
libraryDependencies ++= Seq(
"io.opentelemetry.proto" % "opentelemetry-proto" % OpenTelemetryProtoVersion % "protobuf-src" intransitive ()
)
)

lazy val `sdk-exporter-common` =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("sdk-exporter/common"))
.enablePlugins(NoPublishPlugin)
.dependsOn(
`sdk-common` % "compile->compile;test->test",
`sdk-exporter-proto`
)
.settings(
name := "otel4s-sdk-exporter-common",
startYear := Some(2023),
libraryDependencies ++= Seq(
"org.http4s" %%% "http4s-ember-client" % Http4sVersion,
"org.http4s" %%% "http4s-circe" % Http4sVersion,
"io.github.scalapb-json" %%% "scalapb-circe" % ScalaPBCirceVersion,
"org.typelevel" %%% "cats-laws" % CatsVersion % Test,
"org.typelevel" %%% "discipline-munit" % MUnitDisciplineVersion % Test,
"io.circe" %%% "circe-generic" % CirceVersion % Test
)
)
.settings(munitDependencies)
.settings(scalafixSettings)

lazy val `sdk-exporter-trace` =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Full)
.in(file("sdk-exporter/trace"))
.enablePlugins(NoPublishPlugin, DockerComposeEnvPlugin)
.dependsOn(
`sdk-exporter-common` % "compile->compile;test->test",
`sdk-trace` % "compile->compile;test->test"
)
.settings(
name := "otel4s-sdk-exporter-trace",
startYear := Some(2023),
dockerComposeEnvFile := crossProjectBaseDirectory.value / "docker" / "docker-compose.yml"
)
.jsSettings(
scalaJSLinkerConfig ~= (_.withESFeatures(
_.withESVersion(org.scalajs.linker.interface.ESVersion.ES2018)
)),
Test / scalaJSLinkerConfig ~= (_.withModuleKind(
ModuleKind.CommonJSModule
))
)
.nativeEnablePlugins(ScalaNativeBrewedConfigPlugin)
.nativeSettings(
libraryDependencies += "com.armanbilge" %%% "epollcat" % EpollcatVersion % Test,
Test / nativeBrewFormulas ++= Set("s2n", "utf8proc"),
Test / envVars ++= Map("S2N_DONT_MLOCK" -> "1")
)
.settings(munitDependencies)
.settings(scalafixSettings)

lazy val `sdk-exporter` = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("sdk-exporter/all"))
.enablePlugins(NoPublishPlugin)
.dependsOn(`sdk-exporter-common`, `sdk-exporter-trace`)
.settings(
name := "otel4s-sdk-exporter"
)
.settings(scalafixSettings)

//
// Testkit
//

lazy val `testkit-common` = crossProject(JVMPlatform)
.crossType(CrossType.Full)
.in(file("testkit/common"))
Expand Down Expand Up @@ -428,6 +532,9 @@ lazy val unidocs = project
`sdk-common`.jvm,
`sdk-trace`.jvm,
sdk.jvm,
`sdk-exporter-common`.jvm,
`sdk-exporter-trace`.jvm,
`sdk-exporter`.jvm,
`testkit-common`.jvm,
`testkit-metrics`.jvm,
testkit.jvm,
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
jdk.package = pkgs.jdk8;
nodejs.enable = true;
native.enable = true;
native.libraries = [ pkgs.zlib pkgs.s2n ];
};
};
}
Expand Down
60 changes: 60 additions & 0 deletions project/DockerComposeEnvPlugin.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import sbt._
import sbt.Keys._

import scala.sys.process._

object DockerComposeEnvPlugin extends AutoPlugin {

override def trigger = noTrigger

object autoImport {
lazy val dockerComposeEnvStart =
taskKey[Unit]("Start local docker compose environment")
lazy val dockerComposeEnvStop =
taskKey[Unit]("Stop local docker compose environment")
lazy val dockerComposeEnvTestOpts =
taskKey[Seq[TestOption]]("Setup and cleanup options")
lazy val dockerComposeEnvFile =
settingKey[File]("The docker compose file to use")
}

import autoImport._

override def projectSettings: Seq[Setting[_]] =
Seq(
dockerComposeEnvStart := {
val projectName = name.value
val file = dockerComposeEnvFile.value
val log = streams.value.log

start(projectName, file, log)
},
dockerComposeEnvStop := {
val projectName = name.value
val file = dockerComposeEnvFile.value
val log = streams.value.log

stop(projectName, file, log)
},
Test / testOptions := {
val projectName = name.value
val file = dockerComposeEnvFile.value
val log = streams.value.log

val setup = Tests.Setup(() => start(projectName, file, log))

Seq(setup)
}
)

private def start(projectName: String, file: File, log: Logger): Unit = {
log.info(s"Project [$projectName]. Creating integration environment")
s"docker compose -f $file -p $projectName up -d".!
}

private def stop(projectName: String, file: File, log: Logger): Unit = {
log.info(s"Project [$projectName]. Terminating integration environment")
s"docker compose -f $file -p $projectName down".!
}

}
6 changes: 6 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.7")
addSbtPlugin("com.github.sbt" % "sbt-javaagent" % "0.1.8")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6")
addSbtPlugin(
"com.armanbilge" % "sbt-scala-native-config-brew-github-actions" % "0.2.0-RC1"
)

libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.14"
Loading

0 comments on commit 954f9d0

Please sign in to comment.