Skip to content

v2.2.0 - Future Instrumentation Rollback

Compare
Choose a tag to compare
@ivantopo ivantopo released this 04 Jun 14:46
· 225 commits to master since this release
e0844b7

🚨 This release changes the instrumentation behavior for Scala Futures 🚨

This release changes the way Kamon instruments Scala Futures, going back to the same behavior we had in Kamon 1.x. This change is going to be transparent for most users because most of them only use the automatic instrumentation, but there might be a small difference in how Spans and Context are related to each other after. Broadly speaking:

  • In Kamon 2.x, a Scala Future and all the transformations applied to them (.map/.flatmap/etc) would form a "chain", and changes to the current context in any of the transformations would be carried on to the next transformation, as long as those changes are performed with the functions included in the ScalaFutureInstrumentation companion object. This change brought two challenges:
    • It makes it impossible to cache Future values because the Future itself was tied to the context available when the Future was created for the first time. This would manifest as traces with Spans that don't belong to them.
    • It is possible to leave dirty threads or get unexpected relationships between Spans when not using the helper functions from the ScalaFutureInstrumentation companion object.
  • In Kamon 1.x, a Scala Future would only be tied to its "execution context", making it possible to cache Future values and create Spans without concerns of leaving dirty threads, but context updates cannot be propagated through all transformations.

There is more information about the motivations for this change on #1021.

The Future Chaining instrumentation is still included in Kamon 2.2.0, but it is marked as deprecated and disabled by default. If you need to, you can bring it back with these configuration settings:

kanela.modules {
  executor-service {
    exclude += "scala.concurrent.impl.*"
  }

  scala-future {
    enabled = true
  }
  
  akka-http {
    instrumentations += "kamon.instrumentation.akka.http.FastFutureInstrumentation"
  }  
}

The Future Chaining instrumentation will be fully removed with Kamon 2.3.0.

Changes

  • Rollback the Scala Future instrumentation to the same behavior we had in Kamon 1.x. Contributed by @ivantopo via #1035.