Skip to content

Docs say WaterDrop "activates automatically with the Karafka framework" — but I can't reproduce that in 2.34.0? #6156

Description

@olivia-gusto

Hi! I might be missing something here, so wanted to check before assuming this is a bug.

docs/GettingStarted.md says:

The WaterDrop integration provides tracing of the waterdrop gem (a dependency of karafka, but also can be used standalone). This integration activates automatically with the Karafka framework.

I was debugging why Data Streams Monitoring wasn't showing a producer node for our Kafka topic, even with c.tracing.instrument :karafka enabled and DD_DATA_STREAMS_ENABLED=true set. Digging into lib/datadog/tracing/contrib/karafka/patcher.rb, the only WaterDrop-related thing it does is:

if Contrib::WaterDrop::Integration.compatible?
  ::Karafka.monitor.subscribe('app.initialized') do |event|
    ...
    Contrib::WaterDrop::Patcher.add_middleware(::Karafka.producer)
  end
end

That calls add_middleware directly, but never calls Contrib::WaterDrop::Patcher.patch — which is the method that does ::WaterDrop::Producer.prepend(Producer) and subscribes to 'producer.configured' (the thing that eventually attaches the message.acknowledgedtrack_kafka_produce listener DSM needs).

I wrote a small repro to check rather than just read the source:

require 'datadog'
require 'karafka'
require 'waterdrop'

Datadog.configure do |c|
  c.tracing.instrument :karafka, service_name: 'test-karafka'
  # no :waterdrop instrument call here
end

registry = Datadog::Tracing::Contrib::REGISTRY
puts registry[:waterdrop].patcher.patched?   # => false
puts registry[:karafka].patcher.patched?     # => true

On version 2.34.0, that prints false / true. Adding c.tracing.instrument :waterdrop, **options alongside :karafka flips it to true, and a freshly-created WaterDrop::Producer then actually has a message.acknowledged listener attached (confirmed via producer.monitor introspection).

So: is c.tracing.instrument :waterdrop supposed to be required separately even when using Karafka, and the docs just need updating? Or is there a different/newer activation path I'm not hitting (e.g. via Karafka::App.setup's own producer config, or some auto-instrument setting) that I'm missing in my repro? Happy to be wrong here — just didn't want to file a "docs are broken" issue without checking first.

Repro gem versions: datadog 2.34.0, karafka 2.5.8, waterdrop 2.8.16, Ruby 3.4.10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions