Skip to content

v0.5.0-RC1

Pre-release
Pre-release
Compare
Choose a tag to compare
@iRevive iRevive released this 27 Feb 19:09
· 497 commits to main since this release
567c711

We are happy to announce the first candidate for the upcoming 0.5.0 release.
This release brings significant API improvements and breaking changes.

Warning

This version has several breaking changes and is binary incompatible with the 0.4.0 lineage.

Note

Public Scala Steward will rename the artifacts automatically (see the changes below).

Tip

Use the scalafix rule to simplify the migration:

$ sbt "scalafix dependency:[email protected]:otel4s-scalafix:0.5.0-RC1"

Artifacts replacement and package changes

For better clarity, we decided to rename the following artifacts:

  1. otel4s-java to otel4s-oteljava
  2. otel4s-testkit-metrics to otel4s-oteljava-metrics-testkit
- libraryDependencies += "org.typelevel" %% "otel4s-java" % "0.4.0"
+ libraryDependencies += "org.typelevel" %% "otel4s-oteljava" % "0.5.0-RC1"

- libraryDependencies += "org.typelevel" %% "otel4s-testkit-metrics" % "0.4.0"
+ libraryDependencies += "org.typelevel" %% "otel4s-oteljava-metrics-testkit" % "0.5.0-RC1"

The package is renamed, too:

- import org.typelevel.otel4s.java._
+ import org.typelevel.otel4s.oteljava._

The localForIOLocal is moved to a new package

- import org.typelevel.otel4s.java.instances._
+ import org.typelevel.otel4s.instances.local._

Trace Status is renamed to the StatusCode

- import org.typelevel.otel4s.trace.Status
+ import org.typelevel.otel4s.trace.StatusCode

Notable API changes

Metrics. New generic instrument builders

The instrument builders now require an explicit instrument type:

- val counter = Meter[F].counter("counter").create
+ val counter = Meter[F].counter[Long]("counter").create

- val histogram = Meter[F].histogram("histogram").create
+ val histogram = Meter[F].histogram[Double]("histogram").create

While there is a drawback, this approach allows us to provide a flexible API:

val longCounter: F[Counter[F, Long]] = Meter[F].counter[Long]("counter").create
val doubleCounter: F[Counter[F, Double]] = Meter[F].counter[Double]("counter").create
val longHistogram: F[Histogram[F, Long]] = Meter[F].histogram[Long]("histogram").create
val doubleHistogram: F[Histogram[F, Double]] = Meter[F].histogram[Double]("histogram").create

val doubleGauge: Resource[F, ObservableGauge] =
  Meter[F].observableGauge[Double]("double-gauge").create(Sync[F].delay(List(Measurement(1.0))))

val longGauge: Resource[F, ObservableGauge] =
  Meter[F].observableGauge[Long]("long-gauge").create(Sync[F].delay(List(Measurement(1L))))

As a result, instruments are also available for (almost) any type now.
The underlying type still denotes to either Long or Double. But you can still use a wrapper type:

final case class OpaqueWrapper(value: Long)
implicit val measurementValue: MeasurementValue[OpaqueWrapper] = MeasurementValue[Long].contramap(_.value)

for {
  counter <- Meter[F].counter[OpaqueWrapper]("counter").create
  _       <- counter.add(OpaqueWrapper(42L))
} yield ()

Metrics. Custom bucket boundaries can be configured via the histogram builder

Meter[F]
  .histogram("service.latency")
  .withExplicitBucketBoundaries(BucketBoundaries(Vector(0.005, 0.05, 0.5, 1.0, 1.5)))
  .create

New OtelJava.autoConfigured API

A handy option to get an autoconfigured which can be customized:

val otelJava: Resource[F, OtelJava[F]] = OtelJava.autoConfigured[F] { builder =>
  builder.addTracerProviderCustomizer((b, _) => b.setSampler(Sampler.alwaysOn()))
}

New LocalProvider

LocalProvider simplifies the creation of the Local[F, Context]. It automatically detects an available instance or creates a new one. The priorities are the following:

  1. Uses Local[F, Context] available in the scope
  2. Creates Local from IOLocal[Context] and LiftIO[F] available in the scope
  3. Creates new Local[F, Context] by creating IOLocal[Context]

In most cases, you will be unaffected by this change.

OtelJava.localContext provides access to the Local[F, Context]

Now you can access the Local[F, Context] that OtelJava uses for context propagation.
For example, you can inject a baggage:

val otel4s: OtelJava[F] = ???
val program: F[Unit] = ??? 
val baggage = Baggage.builder().put("key", "value").build()

otel4s.localContext.local(program)(ctx => Context.wrap(ctx.underlying.`with`(baggage)))

Improved Tracer API

There are overloaded alternatives that take varargs and a collection:

Tracer[F].span("span", Attribute("key", "value")) // varargs
Tracer[F].span("span", List(Attribute("key", "value"))) // collection

What's Changed

Improvements and enhancements

sdk module - unpublished yet

  • sdk-trace: add SdkTraceScope by @iRevive in #400
  • sdk-trace: add SdkSpanBuilder by @iRevive in #403
  • sdk-trace: add BatchSpanProcessor by @iRevive in #390
  • sdk-trace: add SdkTracer, SdkTracerBuilder, SdkTracerProvider by @iRevive in #418
  • sdk-trace: add B3Propagator by @iRevive in #440
  • sdk-trace: add W3CTraceContextPropagator by @iRevive in #442
  • sdk-trace: enable W3C propagators tests by @iRevive in #460
  • sdk-trace: move W3CTraceContextPropagator to the context.propagation package by @iRevive in #461
  • sdk-trace: add W3CBaggagePropagator by @iRevive in #462
  • sdk-trace: add JaegerPropagator by @iRevive in #463
  • sdk-trace: add ContextPropagatorsAutoConfigure by @iRevive in #469
  • sdk-trace: ContextPropagatorsAutoConfigure - cleanup, add more tests by @iRevive in #476
  • sdk-trace: add SamplerAutoConfigure by @iRevive in #471
  • sdk-trace: make SamplerAutoConfigure extendable by @iRevive in #492
  • sdk-trace: add SpanExportersAutoConfigure by @iRevive in #477
  • sdk-trace: add TracerProviderAutoConfigure by @iRevive in #498
  • sdk-trace: add SdkTraces by @iRevive in #500
  • sdk-common: add Baggage by @iRevive in #452
  • sdk-common: AutoConfigure - use config keys in the error message by @iRevive in #472
  • sdk: add OpenTelemetrySdk by @iRevive in #501
  • sdk: add AutoConfigure and Config by @iRevive in #445
  • SdkSpanBackendSuite: use unique extra attributes in tests by @iRevive in #444
  • Fix SdkSpanBackendSuite by @NthPortal in #438
  • Logging span exporter by @scott-thomson239 in #517
  • sdk-exporter: add BatchSpanProcessorAutoConfigure by @iRevive in #485
  • sdk-exporter: update opentelemetry proto to 1.1.0-alpha by @iRevive in #479
  • sdk-exporter-trace: add OtlpHttpSpanExporter by @iRevive in #421
  • sdk-exporter-trace: add OtlpHttpClientAutoConfigure by @iRevive in #478
  • sdk-exporter-trace: switch to CrossType.Pure by @iRevive in #483
  • sdk-exporter-trace: add OtlpSpanExporterAutoConfigure by @iRevive in #484
  • sdk-exporter-trace: move OtlpSpanExporterAutoConfigure to the src folder by @iRevive in #486

Internal

  • Tests: reuse existing Arbitrary, Gen, and Cogen instances by @iRevive in #423
  • Use no-op cats.effect.std.Console in tests by @iRevive in #443
  • oteljava - fix compilation issue by @iRevive in #497
  • Share TraceScope between sdk and oteljava modules by @iRevive in #482
  • Share TracerSuite between oteljava and sdk modules by @iRevive in #490
  • scalafix migration rules: publish rules using Scala 2.12 by @iRevive in #508
  • Use .to(Attributes) instead of .fromSpecific by @iRevive in #516
  • Documentation: replace otel4s-java -> otel4s-oteljava by @iRevive in #525
  • Remove @threadUnsafe annotation by @armanbilge in #425
  • AttributesProps: use unique keys to compare the size by @iRevive in #447
  • Implement scalafix migration rules by @iRevive in #426
  • scalafix-rule: reformat input/output by @iRevive in #470
  • Remove SDK dependency from otel4s-java-common by @armanbilge in #410

Upgrades

  • Update sbt-protoc to 1.0.7 by @typelevel-steward in #467
  • Update scalafmt-core to 3.8.0 by @typelevel-steward in #514
  • Update compilerplugin, scalapb-runtime to 0.11.15 by @typelevel-steward in #468
  • Update opentelemetry-api, ... to 1.35.0 by @typelevel-steward in #493
  • Update sbt-typelevel, ... to 0.6.7 by @typelevel-steward in #519
  • Update cats-effect, cats-effect-kernel, ... to 3.5.3 by @typelevel-steward in #437
  • Update opentelemetry-javaagent to 2.1.0 by @typelevel-steward in #506
  • Update pekko-http to 1.0.1 by @typelevel-steward in #489
  • Update nscplugin, sbt-scala-native, ... to 0.4.17 by @typelevel-steward in #446
  • Update sbt-scalajs, scalajs-compiler, ... to 1.15.0 by @typelevel-steward in #428
  • Update opentelemetry-instrumentation-annotations to 2.1.0 by @typelevel-steward in #505
  • Update sbt to 1.9.9 by @typelevel-steward in #518
  • Update fs2-core to 3.9.4 by @typelevel-steward in #450
  • Update munit, munit-scalacheck to 1.0.0-M11 by @typelevel-steward in #473

New Contributors

Full Changelog: v0.4.0...v0.5.0-RC1