v0.5.0-RC1
Pre-releaseWe 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:
otel4s-java
tootel4s-oteljava
otel4s-testkit-metrics
tootel4s-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:
- Uses
Local[F, Context]
available in the scope - Creates
Local
fromIOLocal[Context]
andLiftIO[F]
available in the scope - Creates new
Local[F, Context]
by creatingIOLocal[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
- Rename
java
tooteljava
by @NthPortal in #412 - Move
Attributes
to core-common by @NthPortal in #411 - Move
instances
to thecore-common
package by @iRevive in #414 - Add
Attributes#{updated,concat}
by @NthPortal in #416 - Add
OtelJava.autoConfigured()
by @NthPortal in #420 - Rename
Resource
->TelemetryResource
by @iRevive in #439 - Expose
OtelJava
'sLocalContext
by @NthPortal in #464 - Add
Attributes#{removed,removedAll,-,--}
by @NthPortal in #465 - Add
LocalProvider
by @iRevive in #441 - Replace
otel4s-testkit
withotel4s-oteljava-testkit
by @iRevive in #475 - Add
sdk-trace-testkit
module by @iRevive in #487 - Add
oteljava-trace-testkit
module by @iRevive in #488 - Enhance core APIs to support
Attributes
by @NthPortal in #494 - oteljava-testkit: add
OtelJavaTestkit
by @iRevive in #491 - examples: add
SdkTracingExample
by @iRevive in #509 - Add transformName to Attribute by @rossabaker in #503
- trace: rename
Status
toStatusCode
by @iRevive in #521 - metrics: use independent
Builder
trait forCounter
andUpDownCounter
by @iRevive in #436 - metrics: make
Meter
API generic by @iRevive in #449 - metrics: improve Scaladoc regarding supported measurement values by @iRevive in #454
- metrics: redefine
Measurement
as a sealed trait by @iRevive in #455 - metrics: make
Meter[F].observableGauge
generic by @iRevive in #453 - metrics: make
Meter[F].observableCounter
generic by @iRevive in #456 - metrics: make
Meter[F].observableUpDownCounter
generic by @iRevive in #457 - metrics: remove
ObservableInstrumentBuilder
by @iRevive in #458 - metrics: add
Meter[F].batchCallback
by @iRevive in #459 - Histogram builder: add
withExplicitBucketBoundaries
by @iRevive in #435
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 thecontext.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
andConfig
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 thesrc
folder by @iRevive in #486
Internal
- Tests: reuse existing
Arbitrary
,Gen
, andCogen
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
betweensdk
andoteljava
modules by @iRevive in #482 - Share
TracerSuite
betweenoteljava
andsdk
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
- @scott-thomson239 made their first contribution in #517
Full Changelog: v0.4.0...v0.5.0-RC1