Skip to content

Commit

Permalink
Merge branch 'refs/heads/upstream-main' into context-storage
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/ci.yml
  • Loading branch information
iRevive committed Dec 31, 2024
2 parents b54341a + e050e47 commit 333fd4e
Show file tree
Hide file tree
Showing 20 changed files with 2,471 additions and 162 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p semconv/stable/.jvm/target oteljava/metrics/target oteljava/context-storage/target sdk/common/native/target core/trace/.js/target semconv/metrics/stable/.jvm/target semconv/metrics/experimental/.jvm/target semconv/metrics/stable/.native/target sdk-exporter/all/.jvm/target semconv/experimental/.js/target core/common/.jvm/target oteljava/common-testkit/target sdk/metrics/.native/target sdk-exporter/metrics/.jvm/target sdk-exporter/trace/.jvm/target unidocs/target sdk-contrib/aws/resource/.jvm/target oteljava/trace-testkit/target core/metrics/.native/target core/all/.native/target sdk/trace-testkit/.jvm/target sdk/trace-testkit/.native/target sdk/testkit/.native/target sdk-exporter/prometheus/.jvm/target semconv/experimental/.native/target core/metrics/.jvm/target core/all/.js/target sdk-exporter/proto/.jvm/target sdk-exporter/proto/.js/target semconv/stable/.native/target sdk/all/.native/target sdk/metrics-testkit/.js/target sdk-contrib/aws/xray-propagator/.native/target core/metrics/.js/target sdk/testkit/.js/target core/all/.jvm/target sdk/common/jvm/target core/trace/.native/target oteljava/metrics-testkit/target sdk/trace/.native/target semconv/experimental/.jvm/target sdk/metrics-testkit/.native/target sdk/metrics/.jvm/target oteljava/common/target scalafix/rules/target sdk-exporter/proto/.native/target core/trace/.jvm/target sdk-exporter/common/.jvm/target sdk/metrics-testkit/.jvm/target core/common/.native/target sdk/trace-testkit/.js/target core/common/.js/target oteljava/trace/target semconv/metrics/experimental/.native/target oteljava/testkit/target sdk/testkit/.jvm/target sdk-exporter/all/.js/target sdk-contrib/aws/xray/.native/target semconv/metrics/experimental/.js/target semconv/metrics/stable/.js/target sdk/all/.jvm/target sdk-exporter/all/.native/target oteljava/all/target sdk/trace/.jvm/target sdk-contrib/aws/xray-propagator/.jvm/target semconv/stable/.js/target sdk-contrib/aws/xray/.jvm/target project/target
run: mkdir -p semconv/stable/.jvm/target oteljava/metrics/target instrumentation/metrics/js/target sdk-exporter/common/.js/target sdk/common/native/target sdk/common/js/target core/trace/.js/target semconv/metrics/stable/.jvm/target semconv/metrics/experimental/.jvm/target semconv/metrics/stable/.native/target sdk-exporter/all/.jvm/target sdk-exporter/prometheus/.js/target semconv/experimental/.js/target sdk/trace/.js/target core/common/.jvm/target oteljava/common-testkit/target sdk/metrics/.native/target sdk-exporter/metrics/.jvm/target sdk-exporter/trace/.jvm/target unidocs/target sdk-contrib/aws/resource/.jvm/target oteljava/trace-testkit/target core/metrics/.native/target core/all/.native/target sdk/trace-testkit/.jvm/target sdk/trace-testkit/.native/target sdk/testkit/.native/target sdk-exporter/prometheus/.jvm/target sdk-contrib/aws/resource/.js/target semconv/experimental/.native/target core/metrics/.jvm/target core/all/.js/target sdk-exporter/proto/.jvm/target sdk-exporter/proto/.js/target sdk-exporter/metrics/.js/target semconv/stable/.native/target sdk/all/.native/target sdk/metrics-testkit/.js/target sdk-contrib/aws/xray-propagator/.native/target core/metrics/.js/target sdk/testkit/.js/target core/all/.jvm/target sdk/common/jvm/target core/trace/.native/target oteljava/metrics-testkit/target instrumentation/metrics/jvm/target sdk/trace/.native/target semconv/experimental/.jvm/target sdk/metrics-testkit/.native/target sdk/metrics/.jvm/target oteljava/common/target scalafix/rules/target sdk-exporter/proto/.native/target core/trace/.jvm/target sdk-exporter/common/.jvm/target sdk/metrics-testkit/.jvm/target sdk/metrics/.js/target sdk-exporter/trace/.js/target core/common/.native/target sdk/trace-testkit/.js/target core/common/.js/target oteljava/trace/target semconv/metrics/experimental/.native/target oteljava/testkit/target sdk/testkit/.jvm/target sdk-exporter/all/.js/target sdk-contrib/aws/xray/.native/target sdk-contrib/aws/xray/.js/target sdk-contrib/aws/xray-propagator/.js/target semconv/metrics/experimental/.js/target semconv/metrics/stable/.js/target instrumentation/metrics/native/target sdk/all/.js/target sdk/all/.jvm/target sdk-exporter/all/.native/target oteljava/all/target sdk/trace/.jvm/target sdk-contrib/aws/xray-propagator/.jvm/target semconv/stable/.js/target sdk-contrib/aws/xray/.jvm/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar semconv/stable/.jvm/target oteljava/metrics/target oteljava/context-storage/target sdk/common/native/target core/trace/.js/target semconv/metrics/stable/.jvm/target semconv/metrics/experimental/.jvm/target semconv/metrics/stable/.native/target sdk-exporter/all/.jvm/target semconv/experimental/.js/target core/common/.jvm/target oteljava/common-testkit/target sdk/metrics/.native/target sdk-exporter/metrics/.jvm/target sdk-exporter/trace/.jvm/target unidocs/target sdk-contrib/aws/resource/.jvm/target oteljava/trace-testkit/target core/metrics/.native/target core/all/.native/target sdk/trace-testkit/.jvm/target sdk/trace-testkit/.native/target sdk/testkit/.native/target sdk-exporter/prometheus/.jvm/target semconv/experimental/.native/target core/metrics/.jvm/target core/all/.js/target sdk-exporter/proto/.jvm/target sdk-exporter/proto/.js/target semconv/stable/.native/target sdk/all/.native/target sdk/metrics-testkit/.js/target sdk-contrib/aws/xray-propagator/.native/target core/metrics/.js/target sdk/testkit/.js/target core/all/.jvm/target sdk/common/jvm/target core/trace/.native/target oteljava/metrics-testkit/target sdk/trace/.native/target semconv/experimental/.jvm/target sdk/metrics-testkit/.native/target sdk/metrics/.jvm/target oteljava/common/target scalafix/rules/target sdk-exporter/proto/.native/target core/trace/.jvm/target sdk-exporter/common/.jvm/target sdk/metrics-testkit/.jvm/target core/common/.native/target sdk/trace-testkit/.js/target core/common/.js/target oteljava/trace/target semconv/metrics/experimental/.native/target oteljava/testkit/target sdk/testkit/.jvm/target sdk-exporter/all/.js/target sdk-contrib/aws/xray/.native/target semconv/metrics/experimental/.js/target semconv/metrics/stable/.js/target sdk/all/.jvm/target sdk-exporter/all/.native/target oteljava/all/target sdk/trace/.jvm/target sdk-contrib/aws/xray-propagator/.jvm/target semconv/stable/.js/target sdk-contrib/aws/xray/.jvm/target project/target
run: tar cf targets.tar semconv/stable/.jvm/target oteljava/metrics/target instrumentation/metrics/js/target sdk-exporter/common/.js/target sdk/common/native/target sdk/common/js/target core/trace/.js/target semconv/metrics/stable/.jvm/target semconv/metrics/experimental/.jvm/target semconv/metrics/stable/.native/target sdk-exporter/all/.jvm/target sdk-exporter/prometheus/.js/target semconv/experimental/.js/target sdk/trace/.js/target core/common/.jvm/target oteljava/common-testkit/target sdk/metrics/.native/target sdk-exporter/metrics/.jvm/target sdk-exporter/trace/.jvm/target unidocs/target sdk-contrib/aws/resource/.jvm/target oteljava/trace-testkit/target core/metrics/.native/target core/all/.native/target sdk/trace-testkit/.jvm/target sdk/trace-testkit/.native/target sdk/testkit/.native/target sdk-exporter/prometheus/.jvm/target sdk-contrib/aws/resource/.js/target semconv/experimental/.native/target core/metrics/.jvm/target core/all/.js/target sdk-exporter/proto/.jvm/target sdk-exporter/proto/.js/target sdk-exporter/metrics/.js/target semconv/stable/.native/target sdk/all/.native/target sdk/metrics-testkit/.js/target sdk-contrib/aws/xray-propagator/.native/target core/metrics/.js/target sdk/testkit/.js/target core/all/.jvm/target sdk/common/jvm/target core/trace/.native/target oteljava/metrics-testkit/target instrumentation/metrics/jvm/target sdk/trace/.native/target semconv/experimental/.jvm/target sdk/metrics-testkit/.native/target sdk/metrics/.jvm/target oteljava/common/target scalafix/rules/target sdk-exporter/proto/.native/target core/trace/.jvm/target sdk-exporter/common/.jvm/target sdk/metrics-testkit/.jvm/target sdk/metrics/.js/target sdk-exporter/trace/.js/target core/common/.native/target sdk/trace-testkit/.js/target core/common/.js/target oteljava/trace/target semconv/metrics/experimental/.native/target oteljava/testkit/target sdk/testkit/.jvm/target sdk-exporter/all/.js/target sdk-contrib/aws/xray/.native/target sdk-contrib/aws/xray/.js/target sdk-contrib/aws/xray-propagator/.js/target semconv/metrics/experimental/.js/target semconv/metrics/stable/.js/target instrumentation/metrics/native/target sdk/all/.js/target sdk/all/.jvm/target sdk-exporter/all/.native/target oteljava/all/target sdk/trace/.jvm/target sdk-contrib/aws/xray-propagator/.jvm/target semconv/stable/.js/target sdk-contrib/aws/xray/.jvm/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
Expand Down
21 changes: 21 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ lazy val root = tlCrossRootProject
`core-metrics`,
`core-trace`,
core,
`instrumentation-metrics`,
`sdk-common`,
`sdk-metrics`,
`sdk-metrics-testkit`,
Expand Down Expand Up @@ -237,6 +238,24 @@ lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
)
.settings(scalafixSettings)

//
// Instrumentation
//

lazy val `instrumentation-metrics` = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Full)
.in(file("instrumentation/metrics"))
.dependsOn(`core-metrics`, `core-common` % "test->test", `sdk-metrics-testkit` % Test)
.settings(munitDependencies)
.settings(
name := "otel4s-instrumentation-metrics",
startYear := Some(2024),
libraryDependencies ++= Seq(
"org.typelevel" %%% "scalacheck-effect-munit" % MUnitScalaCheckEffectVersion % Test
)
)
.settings(scalafixSettings)

//
// SDK
//
Expand Down Expand Up @@ -883,6 +902,7 @@ lazy val docs = project
oteljava,
`oteljava-context-storage`,
`oteljava-testkit`,
`instrumentation-metrics`.jvm,
sdk.jvm,
`sdk-exporter`.jvm,
`sdk-exporter-prometheus`.jvm,
Expand Down Expand Up @@ -954,6 +974,7 @@ lazy val unidocs = project
`core-metrics`.jvm,
`core-trace`.jvm,
core.jvm,
`instrumentation-metrics`.jvm,
`sdk-common`.jvm,
`sdk-metrics`.jvm,
`sdk-metrics-testkit`.jvm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import cats.effect.IOLocal
import cats.effect.LiftIO
import cats.effect.MonadCancelThrow
import cats.mtl.Local
import org.typelevel.otel4s.instances.local._

/** A utility class to simplify the creation of the [[cats.mtl.Local Local]].
*
Expand Down Expand Up @@ -73,15 +72,9 @@ object LocalProvider extends LocalProviderLowPriority {
* @tparam Ctx
* the type of the context
*/
def fromIOLocal[F[_]: MonadCancelThrow: LiftIO, Ctx](
ioLocal: IOLocal[Ctx]
): LocalProvider[F, Ctx] =
def fromIOLocal[F[_]: MonadCancelThrow: LiftIO, Ctx](ioLocal: IOLocal[Ctx]): LocalProvider[F, Ctx] =
new LocalProvider[F, Ctx] {
val local: F[Local[F, Ctx]] =
MonadCancelThrow[F].pure(
localForIOLocal[F, Ctx](implicitly, implicitly, ioLocal)
)

val local: F[Local[F, Ctx]] = MonadCancelThrow[F].pure(localForIOLocal[F, Ctx](ioLocal))
override def toString: String = "LocalProvider.fromIOLocal"
}

Expand All @@ -96,9 +89,7 @@ object LocalProvider extends LocalProviderLowPriority {
* @tparam Ctx
* the type of the context
*/
def fromLocal[F[_]: Applicative, Ctx](
l: Local[F, Ctx]
): LocalProvider[F, Ctx] =
def fromLocal[F[_]: Applicative, Ctx](l: Local[F, Ctx]): LocalProvider[F, Ctx] =
new LocalProvider[F, Ctx] {
val local: F[Local[F, Ctx]] = Applicative[F].pure(l)
override def toString: String = "LocalProvider.fromLocal"
Expand All @@ -118,16 +109,11 @@ object LocalProvider extends LocalProviderLowPriority {
* @tparam Ctx
* the type of the context
*/
def fromLiftIO[
F[_]: MonadCancelThrow: LiftIO,
Ctx: Contextual
]: LocalProvider[F, Ctx] =
def fromLiftIO[F[_]: MonadCancelThrow: LiftIO, Ctx: Contextual]: LocalProvider[F, Ctx] =
new LocalProvider[F, Ctx] {
def local: F[Local[F, Ctx]] =
IOLocal(Contextual[Ctx].root)
.map { implicit ioLocal: IOLocal[Ctx] =>
localForIOLocal[F, Ctx](implicitly, implicitly, ioLocal)
}
.map(ioLocal => localForIOLocal[F, Ctx](ioLocal))
.to[F]

override def toString: String = "LocalProvider.fromLiftIO"
Expand All @@ -139,19 +125,25 @@ object LocalProvider extends LocalProviderLowPriority {
](implicit ioLocal: IOLocal[Ctx]): LocalProvider[F, Ctx] =
LocalProvider.fromIOLocal(ioLocal)

implicit def liftFromLocal[
F[_]: Applicative,
Ctx
](implicit local: Local[F, Ctx]): LocalProvider[F, Ctx] =
implicit def liftFromLocal[F[_]: Applicative, Ctx](implicit local: Local[F, Ctx]): LocalProvider[F, Ctx] =
LocalProvider.fromLocal(local)

/** Cats Effect 3.6 introduced `IOLocal#asLocal`. However, we need a variation for a polymorphic type.
*/
private def localForIOLocal[F[_]: MonadCancelThrow: LiftIO, Ctx](ioLocal: IOLocal[Ctx]): Local[F, Ctx] =
new Local[F, Ctx] {
def applicative: Applicative[F] =
Applicative[F]
def ask[E2 >: Ctx]: F[E2] =
MonadCancelThrow[F].widen[Ctx, E2](ioLocal.get.to[F])
def local[A](fa: F[A])(f: Ctx => Ctx): F[A] =
MonadCancelThrow[F].bracket(ioLocal.modify(e => (f(e), e)).to[F])(_ => fa)(ioLocal.set(_).to[F])
}
}

sealed trait LocalProviderLowPriority { self: LocalProvider.type =>

implicit def liftFromLiftIO[
F[_]: MonadCancelThrow: LiftIO,
Ctx: Contextual
]: LocalProvider[F, Ctx] =
implicit def liftFromLiftIO[F[_]: MonadCancelThrow: LiftIO, Ctx: Contextual]: LocalProvider[F, Ctx] =
LocalProvider.fromLiftIO

}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class LocalProviderSuite extends CatsEffectSuite {

test("lift LocalProvider from implicit Local (1)") {
IOLocal(VaultContext.root).map { ioLocal =>
import org.typelevel.otel4s.instances.local.localForIOLocal
implicit val local: Local[IO, VaultContext] =
localForIOLocal(implicitly, implicitly, ioLocal)
implicit val local: Local[IO, VaultContext] = ioLocal.asLocal

assertEquals(
LocalProvider[IO, VaultContext].toString,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ trait BatchCallback[F[_]] {
* }}}
*
* @param callback
* the callback to to observe values on-demand
* the callback to observe values on-demand
*
* @param observable
* the instrument for which the callback may observe values
Expand Down
1 change: 1 addition & 0 deletions docs/instrumentation/directory.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ laika.title = Instrumentation

laika.navigationOrder = [
metrics.md
metrics-cats-effect-io-runtime.md
tracing.md
tracing-cross-service-propagation.md
]
Loading

0 comments on commit 333fd4e

Please sign in to comment.