Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Karafka integration #4147

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
dd02868
Add Karafka integration
nvh0412 Nov 15, 2024
10645a7
chore: Add karafka mapping
nvh0412 Nov 22, 2024
ecb1897
chore: remove redudnant changes
nvh0412 Nov 22, 2024
f9b6e36
chore: Add karafka getting started properly
nvh0412 Nov 22, 2024
41cb65f
chore: Address feedbacks
nvh0412 Nov 26, 2024
9dd469c
chore: correct monitor require position
nvh0412 Nov 26, 2024
fbbbcb0
Merge branch 'master' into karafka-tracing
nvh0412 Nov 26, 2024
f79c7fb
chore: Fix typo
nvh0412 Nov 28, 2024
27e5711
chore: fix wrong config
nvh0412 Dec 1, 2024
e19fcd7
Update lib/datadog/tracing/contrib/karafka/monitor.rb
nvh0412 Jan 28, 2025
21128e9
Update lib/datadog/tracing/contrib/karafka/patcher.rb
nvh0412 Jan 28, 2025
c88a710
Update docs/GettingStarted.md
nvh0412 Jan 28, 2025
a00244d
Merge branch 'master' into karafka-tracing
nvh0412 Jan 28, 2025
9007248
chore: Adding a few standard tags for messaging system spans
nvh0412 Jan 29, 2025
a808800
Merge branch 'master' into karafka-tracing
marcotc Jan 31, 2025
babd3c9
Merge branch 'master' into karafka-tracing
nvh0412 Feb 4, 2025
2dc03a2
chore: add rbs and fix lintings
nvh0412 Feb 12, 2025
a5e99e7
Merge branch 'master' into karafka-tracing
marcotc Feb 19, 2025
60b9968
Merge branch 'master' into karafka-tracing
nvh0412 Feb 20, 2025
a61f6e3
chore: address feedbacks on rakefile and matrixfile
nvh0412 Feb 19, 2025
e021064
Merge branch 'master' into karafka-tracing
nvh0412 Feb 20, 2025
b402802
Merge branch 'master' into karafka-tracing
marcotc Feb 20, 2025
f2e663a
Update test matrix
marcotc Feb 21, 2025
f870297
Add more rbs typying
marcotc Feb 21, 2025
6251dc7
Sacrifice for the linting gods ☠️
marcotc Feb 21, 2025
fa1c996
fix flaly tests as Module name resolver
nvh0412 Feb 26, 2025
761e5b0
Fix failed specs
nvh0412 Feb 26, 2025
531403e
chore: correct rspec specs
nvh0412 Feb 26, 2025
c35d62d
chore: ignore Ruby 2.5 and 2.6 due to break changes in metadata.headers
nvh0412 Feb 26, 2025
4f557fa
Merge branch 'master' into karafka-tracing
TonyCTHsu Feb 26, 2025
b4166cc
Fix coverage matrix for karafka
TonyCTHsu Feb 26, 2025
b6a95d9
Skip Ruby 2.5 for karfka-min
TonyCTHsu Feb 26, 2025
ba51ce6
[🤖] Lock Dependency: https://github.com/DataDog/dd-trace-rb/actions/r…
TonyCTHsu Feb 27, 2025
e34c2cb
Fix min version
TonyCTHsu Feb 27, 2025
5446aaa
Change to pull request target
TonyCTHsu Mar 10, 2025
c3607a6
Merge branch 'tonycthsu/karafka-community-support' into karafka-tracing
TonyCTHsu Mar 10, 2025
4ab2fcf
Revert "Change to pull request target"
TonyCTHsu Mar 11, 2025
8f945ac
Merge branch 'master' into karafka-tracing
TonyCTHsu Mar 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Matrixfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
'kafka' => {
'activesupport' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby'
},
'karafka' => {
'karafka-latest' => '❌ 2.5 / ❌ 2.6 / ❌ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby',
# karafka 2.0.41 contains broken dependency of karafka-core 2.2.4, which depends on Ruby (>= 2.6.0)
'karafka-min' => '❌ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby',
},
'lograge' => {
'activesupport' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby'
},
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ namespace :spec do
:httpclient,
:httprb,
:kafka,
:karafka,
:lograge,
:mongodb,
:mysql2,
Expand Down
4 changes: 4 additions & 0 deletions appraisal/jruby-9.3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@
build_coverage_matrix('mongo', min: '2.1.0')
build_coverage_matrix('dalli', [2])

appraise 'karafka-min' do
gem 'karafka', '= 2.0.41'
end

appraise 'relational_db' do
gem 'activerecord', '~> 6.0.0'
gem 'delayed_job'
Expand Down
1 change: 1 addition & 0 deletions appraisal/jruby-9.4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
build_coverage_matrix('rest-client')
build_coverage_matrix('mongo', min: '2.1.0')
build_coverage_matrix('dalli', [2])
build_coverage_matrix('karafka', min: '2.0.41')

appraise 'relational_db' do
gem 'activerecord', '~> 6.1.0'
Expand Down
4 changes: 4 additions & 0 deletions appraisal/ruby-2.6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@
build_coverage_matrix('mongo', min: '2.1.0')
build_coverage_matrix('dalli', [2])

appraise 'karafka-min' do
gem 'karafka', '= 2.0.41'
end

appraise 'relational_db' do
gem 'activerecord', '~> 6.0.0'
gem 'delayed_job'
Expand Down
5 changes: 4 additions & 1 deletion appraisal/ruby-2.7.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@
build_coverage_matrix('mongo', min: '2.1.0')
build_coverage_matrix('dalli', [2])

appraise 'karafka-min' do
gem 'karafka', '= 2.0.41'
end

appraise 'relational_db' do
gem 'activerecord', '~> 6.1.0'
gem 'delayed_job'
Expand All @@ -203,7 +207,6 @@
appraise 'contrib' do
gem 'concurrent-ruby'
gem 'grpc'

gem 'rack-test' # Dev dependencies for testing rack-based code
gem 'rake', '>= 12.3'
gem 'resque'
Expand Down
2 changes: 1 addition & 1 deletion appraisal/ruby-3.0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
build_coverage_matrix('rest-client')
build_coverage_matrix('mongo', min: '2.1.0')
build_coverage_matrix('dalli', [2])
build_coverage_matrix('karafka', min: '2.0.41')

appraise 'relational_db' do
gem 'activerecord', '~> 7'
Expand Down Expand Up @@ -125,7 +126,6 @@
appraise 'contrib' do
gem 'concurrent-ruby'
gem 'grpc', '>= 1.38.0', platform: :ruby # Minimum version with Ruby 3.0 support

gem 'rack-test' # Dev dependencies for testing rack-based code
gem 'rake', '>= 12.3'
gem 'resque'
Expand Down
2 changes: 1 addition & 1 deletion appraisal/ruby-3.1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
build_coverage_matrix('rest-client')
build_coverage_matrix('mongo', min: '2.1.0')
build_coverage_matrix('dalli', [2])
build_coverage_matrix('karafka', min: '2.0.41')

appraise 'relational_db' do
gem 'activerecord', '~> 7'
Expand Down Expand Up @@ -125,7 +126,6 @@
appraise 'contrib' do
gem 'concurrent-ruby'
gem 'grpc', '>= 1.38.0', platform: :ruby # Minimum version with Ruby 3.0 support

gem 'rack-test' # Dev dependencies for testing rack-based code
gem 'rake', '>= 12.3'
gem 'resque'
Expand Down
2 changes: 1 addition & 1 deletion appraisal/ruby-3.2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
build_coverage_matrix('rest-client')
build_coverage_matrix('mongo', min: '2.1.0')
build_coverage_matrix('dalli', [2])
build_coverage_matrix('karafka', min: '2.0.41')

appraise 'relational_db' do
gem 'activerecord', '~> 7'
Expand Down Expand Up @@ -125,7 +126,6 @@
appraise 'contrib' do
gem 'concurrent-ruby'
gem 'grpc', '>= 1.38.0', platform: :ruby # Minimum version with Ruby 3.0 support

gem 'rack-test' # Dev dependencies for testing rack-based code
gem 'rake', '>= 12.3'
gem 'resque'
Expand Down
2 changes: 1 addition & 1 deletion appraisal/ruby-3.3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
build_coverage_matrix('rest-client')
build_coverage_matrix('mongo', min: '2.1.0')
build_coverage_matrix('dalli', [2])
build_coverage_matrix('karafka', min: '2.0.41')

appraise 'relational_db' do
gem 'activerecord', '~> 7'
Expand Down Expand Up @@ -125,7 +126,6 @@
appraise 'contrib' do
gem 'concurrent-ruby'
gem 'grpc', '>= 1.38.0', platform: :ruby # Minimum version with Ruby 3.0 support

gem 'rack-test' # Dev dependencies for testing rack-based code
gem 'rake', '>= 12.3'
gem 'resque'
Expand Down
2 changes: 1 addition & 1 deletion appraisal/ruby-3.4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
build_coverage_matrix('rest-client')
build_coverage_matrix('mongo', min: '2.1.0')
build_coverage_matrix('dalli', [2])
build_coverage_matrix('karafka', min: '2.0.41')

appraise 'relational_db' do
# ActiveRecord locked because tests are failing with 7.1, which was attempted as a part of Ruby 3.4 testing in CI.
Expand Down Expand Up @@ -133,7 +134,6 @@
gem 'concurrent-ruby'
# Temporarily disable for Ruby 3.4: No binaries causing build time takes more than 10 minutes
# gem 'grpc', '>= 1.38.0', platform: :ruby

gem 'rack-test' # Dev dependencies for testing rack-based code
gem 'rake', '>= 12.3'
gem 'resque'
Expand Down
3 changes: 3 additions & 0 deletions docs/Compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ For a list of available integrations, and their configuration options, refer to
| httpclient | `httpclient` | `>= 2.2` | `>= 2.2` | [Link][23] | [Link](https://github.com/nahi/httpclient) |
| httpx | `httpx` | `>= 0.11` | `>= 0.11` | [Link][24] | [Link](https://gitlab.com/honeyryderchuck/httpx) |
| Kafka | `ruby-kafka` | `>= 0.7.10` | `>= 0.7.10` | [Link][25] | [Link](https://github.com/zendesk/ruby-kafka) |
| Karafka | `karafka` | `>= 2.0.41` | `>= 2.0.41` | [Link][55] | [Link](https://karafka.io/) |
| Makara (via Active Record) | `makara` | `>= 0.3.5` | `>= 0.3.5` | [Link][8] | [Link](https://github.com/instacart/makara) |
| MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | [Link][26] | [Link](https://github.com/mongodb/mongo-ruby-driver) |
| MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | [Link][27] | [Link](https://github.com/brianmario/mysql2) |
Expand Down Expand Up @@ -269,3 +270,5 @@ new release of 1.21.0 (or 1.20.1). Those bugfixes will not be backported as patc
[53]: https://docs.datadoghq.com/agent/basic_agent_usage/?tab=agentv6v7

[54]: https://docs.datadoghq.com/agent/basic_agent_usage/?tab=agentv5

[55]: https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/#karafka
21 changes: 21 additions & 0 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,27 @@ end
| --------- | ------------------------------- | ------ | -------------------------------------------- | ------- |
| `enabled` | `DD_TRACE_KAFKA_ENABLED` | `Bool` | Whether the integration should create spans. | `true` |

### Karafka

The karafka integration provides tracing of the `karafka` gem.
You can enable it through `Datadog.configure`:

```ruby
require 'karafka'
require 'datadog'

Datadog.configure do |c|
c.tracing.instrument :karafka, **options
end

```
`options` are the following keyword arguments:

| Key | Env Var | Type | Description | Default |
| --------------------- | ------------------------ | ------ | --------------------------------------------------- | ------- |
| `enabled` | `DD_TRACE_KARAFKA_ENABLED` | `Bool` | Specifies whether the integration should create spans. | `true` |
| `distributed_tracing` | | `Bool` | Enables [distributed tracing](#distributed-tracing). | `false` |

### MongoDB

The integration traces any `Command` that is sent from the [MongoDB Ruby Driver](https://github.com/mongodb/mongo-ruby-driver) to a MongoDB cluster. By extension, Object Document Mappers (ODM) such as Mongoid are automatically instrumented if they use the official Ruby driver. To activate the integration, simply:
Expand Down
35 changes: 35 additions & 0 deletions gemfiles/jruby_9.3_karafka_min.gemfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

137 changes: 137 additions & 0 deletions gemfiles/jruby_9.3_karafka_min.gemfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading