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 support for the kicks gem #4253

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Add support for the kicks gem #4253

wants to merge 14 commits into from

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Jan 2, 2025

Fixes #4191

Kicks is a fork/continuation of the sneakers gem (announcement).

Change log entry
Yes. Add support for the kicks gem

Additional Notes:

They kept everything the same, even the file paths (require 'sneakers') and module names (::Sneakers).

I created an alias for instrument :kicks to instrument :sneakers, to allow users to use the name that matches their installed gem name. They share the same internal objects and configuration settings.

How to test the change?

@github-actions github-actions bot added integrations Involves tracing integrations tracing labels Jan 2, 2025
Copy link

github-actions bot commented Jan 2, 2025

Thank you for updating Change log entry section 👏

Visited at: 2025-01-09 11:52:07 UTC

@datadog-datadog-prod-us1
Copy link
Contributor

datadog-datadog-prod-us1 bot commented Jan 3, 2025

Datadog Report

Branch report: kicks
Commit report: 265d516
Test service: dd-trace-rb

✅ 0 Failed, 22124 Passed, 1477 Skipped, 5m 39.56s Total Time

@pr-commenter
Copy link

pr-commenter bot commented Jan 3, 2025

Benchmarks

Benchmark execution time: 2025-01-08 19:59:51

Comparing candidate commit 265d516 in PR branch kicks with baseline commit e3ea38f in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 31 metrics, 2 unstable metrics.

@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.73%. Comparing base (9440c03) to head (265d516).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4253      +/-   ##
==========================================
- Coverage   97.73%   97.73%   -0.01%     
==========================================
  Files        1352     1352              
  Lines       82409    82464      +55     
  Branches     4224     4229       +5     
==========================================
+ Hits        80545    80595      +50     
- Misses       1864     1869       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marcotc marcotc marked this pull request as ready for review January 8, 2025 21:45
@marcotc marcotc requested review from a team as code owners January 8, 2025 21:45
@@ -1112,6 +1112,32 @@ end
| --------- | ------------------------------- | ------ | -------------------------------------------- | ------- |
| `enabled` | `DD_TRACE_KAFKA_ENABLED` | `Bool` | Whether the integration should create spans. | `true` |

### Kicks

The Kicks integration is a server-side middleware which will trace job executions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Kicks integration is a server-side middleware which will trace job executions.
The Kicks integration is a server-side middleware that traces job executions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I noticed most of these were copy-pasted from the sneakers docs, so we should probably propagate the improvements to both)

The Kicks integration is a server-side middleware which will trace job executions.

<div class="alert alert-warning">
Kicks is a continuation of Sneakers and both cannot be active at the same time, as they share their Ruby class namespace. Configurations to the Sneakers integration will be safely merged with any Kicks configuration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Kicks is a continuation of Sneakers and both cannot be active at the same time, as they share their Ruby class namespace. Configurations to the Sneakers integration will be safely merged with any Kicks configuration.
Kicks is a continuation of Sneakers. Because Kicks and Sneakers share a Ruby class namespace, they cannot both be active at the same time. Configurations to the Sneakers integration is safely merged with any Kicks configuration.

| ---------- | - | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| `enabled` | `DD_TRACE_SNEAKERS_ENABLED` | `Bool` | Whether the integration should create spans. | `true` |
| `tag_body` | | `Bool` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
| `on_error` | | `Proc` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `on_error` | | `Proc` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |
| `on_error` | | `Proc` | Custom error handler invoked when a job raises an error. Provides `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |

@@ -1935,6 +1961,10 @@ end

The Sneakers integration is a server-side middleware which will trace job executions.

<div class="alert alert-warning">
Kicks is a continuation of Sneakers and both cannot be active at the same time, as they share their Ruby class namespace. Configurations to the Sneakers integration will be safely merged with any Kicks configuration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Kicks is a continuation of Sneakers and both cannot be active at the same time, as they share their Ruby class namespace. Configurations to the Sneakers integration will be safely merged with any Kicks configuration.
Kicks is a continuation of Sneakers. Because Kicks and Sneakers share a Ruby class namespace, they cannot both be active at the same time. Configurations to the Sneakers integration is safely merged with any Kicks configuration.

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM Looks really nice :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually noticed that this file was still being ignored in the Steepfile, but can safely be enabled (passes typecheck), so may be worth including that in this PR ;)

Comment on lines 20 to +22
# @public_api Changing the integration name or integration options can cause breaking changes
register_as :sneakers, auto_patch: true

register_as_alias :sneakers, :kicks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that for register_as_alias the auto_patch is always false -- is that because it reuses the auto_patch from the register_as? (If so, maybe that's a useful comment to leave somewhere, perhaps in the register_as_alias?)

@@ -1112,6 +1112,32 @@ end
| --------- | ------------------------------- | ------ | -------------------------------------------- | ------- |
| `enabled` | `DD_TRACE_KAFKA_ENABLED` | `Bool` | Whether the integration should create spans. | `true` |

### Kicks

The Kicks integration is a server-side middleware which will trace job executions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I noticed most of these were copy-pasted from the sneakers docs, so we should probably propagate the improvements to both)

@@ -131,7 +133,6 @@
gem 'roda', '>= 2.0.0'
gem 'semantic_logger', '~> 4.0'
gem 'sidekiq', '~> 7'
gem 'sneakers', '>= 2.12.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this change be propagated to the other appraisal files as well? Noticed the others still list sneakers under contrib

Copy link
Contributor

@TonyCTHsu TonyCTHsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this approach to support kicks.

However, I am a little bit concern about

  1. kicks gem decided to rename the modules and paths in the future
  2. The span data is decorated with the obsolete name sneakers can cause confusion

I am overall supportive because (1) might not happen in the future and (2) we could make the risk explicit in the documentation.

I might even push to deprecate sneakers integration and replace it completely with kicks in the next major release.

@@ -131,7 +133,6 @@
gem 'roda', '>= 2.0.0'
gem 'semantic_logger', '~> 4.0'
gem 'sidekiq', '~> 7'
gem 'sneakers', '>= 2.12.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcotc Do you struggle to remove sneakers from other runtimes? Do you need my help on this?

# The last version of Sneakers is 2.12.0.
# The first version of Kicks is 3.0.0. We currently support all versions of Kicks.
#
# @see https://github.com/jondot/sneakers/commit/9780692624c666b6db8266d2d5710f709cb0f2e2
def self.version
Copy link
Contributor

@TonyCTHsu TonyCTHsu Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They kept everything the same, even the file paths (require 'sneakers') and module names (::Sneakers).

kicks even continue the semantic version to avoid conflict with the obsolete gem.

Correct me if I am wrong. Due to this, I assume the easiest path to support kicks is to change self.version with the conditional logic of kicks from Gem.loaded_specs. Do we need register_as_alias to support kicks?

@@ -202,6 +202,8 @@
build_coverage_matrix('stripe', 7..12, min: '5.15.0')
build_coverage_matrix('opensearch', 2..3, gem: 'opensearch-ruby')
build_coverage_matrix('elasticsearch', 7..8)
build_coverage_matrix('kicks', [], min: '3.0.0')
build_coverage_matrix('sneakers', [], min: '2.12.0', latest: false) # Sneakers is not receiving updates anymore and 2.12.0 is the last version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think we don't need to invoke build_coverage_matrix with latest: false, since this method call only generate a single group.

Prefer the following for explicitness

appraisal 'sneakers-min' do 
  gem 'sneakers', '= 2.12.0'
end

# @param [Hash] meta optional, additional metadata (development dependencies, etc.) for the group
def build_coverage_matrix(integration, range, gem: integration, min: nil, latest: true, meta: {})
# Allow single version to be passed easily
range = range..range if range.is_a?(Integer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
range = range..range if range.is_a?(Integer)
range = Array(range)

@ivoanjo
Copy link
Member

ivoanjo commented Jan 9, 2025

  1. kicks gem decided to rename the modules and paths in the future

I'm guessing they would rename on a major version, so we'd probably want to support the 3.x series (with sneakers naming) for a while?

Looking at their readme, it seems the main objective was "original author was unresponsive, community had a few pending patches":

image

...so yeah doesn't look like the kind of project that will refactor just for the sake of making the name prettier ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrations Involves tracing integrations tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kicks integration
5 participants