Skip to content

Re-enable injectK / traceK / liftTrace / TracedProducer.create on fs2-kafka 4.1.0 - #293

Merged
alejandrohdezma merged 2 commits into
trace4cats:mainfrom
sideeffffect:reenable-tracing-fs2-kafka-4.1
Sep 28, 2026
Merged

alejandrohdezma merged 2 commits into
trace4cats:mainfrom
sideeffffect:reenable-tracing-fs2-kafka-4.1

Conversation

@sideeffffect

Copy link
Copy Markdown
Contributor

fs2-kafka 4.1.0 is out on Maven Central, and it ships the two pieces that 0.15.0-RC1 was waiting on from typelevel/fs2-kafka#1522: mapK on the committable consumer types and imapK on KafkaProducer. With those available, the four areas that had to be temporarily disabled during the fs2-kafka 4.x migration can come back, which unblocks the final 0.15.0.

What this restores

  • TracedConsumer.injectK — lifts the traced stream into G and rebuilds each record with CommittableConsumerRecord#mapK, which replaces the old package-private CommittableOffset reconstruction.
  • TracedProducer.create — wraps the producer in G via KafkaProducer#imapK, including the transactional methods that 4.x folded into KafkaProducer.
  • the injectK / traceK stream syntax and the liftTrace producer syntax in Fs2KafkaSyntax, plus their imports.

Dependency bump

fs2-kafka goes from 4.0.0 to 4.1.0 in project/dependencies.conf. That is the release that makes mapK / imapK available.

Signature note

TracedProducer.create keeps the intended shape from the sketch, with one small change: the Monad[G] context bound is dropped because the implicit MonadCancelThrow[G] already implies Monad[G], and leaving it in trips -Werror as an unused implicit. Everything else matches the commented-out signatures that were left in main.

The consumer.group span attribute stays dropped — CommittableOffset.consumerGroupId is genuinely gone in fs2-kafka 4.x, so there is nothing to restore there.

Checks

sbt ci-test is green locally: scalafmt / scalafix, versionPolicyCheck, mdoc, publishLocal, and +test all pass, cross-built on Scala 2.13.18 and 3.3.8.

…on fs2-kafka 4.1.0

fs2-kafka 4.1.0 ships `mapK` on the committable types and `imapK` on
`KafkaProducer` (typelevel/fs2-kafka#1522), so the four areas disabled in
0.15.0-RC1 can be restored:

- `TracedConsumer.injectK`
- the `injectK` / `traceK` stream syntax in `Fs2KafkaSyntax`
- `TracedProducer.create`
- the `liftTrace` producer syntax in `Fs2KafkaSyntax`

Bump fs2-kafka from 4.0.0 to 4.1.0. `TracedProducer.create` drops the
redundant `Monad[G]` context bound, since the implicit `MonadCancelThrow[G]`
already implies it, so the method compiles cleanly under -Werror.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@alejandrohdezma alejandrohdezma added the 📈 dependency-update Dependency update (possibly bot-automated) label Sep 28, 2026
4.1.0 starts polling at subscribe time instead of when the stream is consumed
(typelevel/fs2-kafka#1524), which surfaces as `NoOffsetForPartitionException`
restart loops. 4.1.1 reverts that and still ships `CommittableConsumerRecord#mapK`
and `KafkaProducer#imapK`, which this branch builds on.
@alejandrohdezma
alejandrohdezma marked this pull request as ready for review September 28, 2026 15:49
@alejandrohdezma
alejandrohdezma merged commit 524f0a1 into trace4cats:main Sep 28, 2026
5 checks passed
scala-steward pushed a commit to scala-steward/trace4cats-kafka that referenced this pull request Oct 1, 2026
fs2-kafka 4 removed `CommittableOffset#consumerGroupId`, so the migration
in trace4cats#293 dropped the `consumer.group` attribute from `kafka.receive` spans.
The group id is still reachable through `KafkaCommitter#metadata`, which
calls the blocking `groupMetadata()` on the underlying consumer, so it is
fetched once per committer and cached for the rest of the stream. A
failing fetch (no `group.id` configured) falls back to an empty string,
as before.
@sideeffffect
sideeffffect deleted the reenable-tracing-fs2-kafka-4.1 branch October 14, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📈 dependency-update Dependency update (possibly bot-automated)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants