Skip to content

Commit

Permalink
Merge branch 'master' into zachg/fix_circ_import_for_lazy_sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
ZStriker19 committed Dec 18, 2024
2 parents 7396654 + 7fd1feb commit eba85d9
Show file tree
Hide file tree
Showing 1,248 changed files with 8,963 additions and 11,432 deletions.
2 changes: 0 additions & 2 deletions .github/dependency_filters.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
dependencies:
- Gemfile
- '*.gemfile'
- Appraisals
- datadog.gemspec
- tasks/appraisal.rake
- tasks/dependency.rake
- .github/workflows/lock-dependency.yml
- lib/datadog/version.rb
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -40,7 +40,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/ensure-changelog-entry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const regex = /\*\*Change log entry\*\*\s+(?:(?<answer_yes>yes|yep|yeah)(?:\.\s*(?<yes_message>[^\r\n<!-]+))?|(?<answer_no>no|nope|none)\.?)\s*/mi
const regex = /\*\*Change log entry\*\*\s+(?:<!--.*?-->\s*)?(?:(?<answer_yes>yes|yep|yeah)(?:\s?[.,:-]\s?(?<yes_message>[^\r\n<!-]+))?|(?<answer_no>no|nope|none)\.?.*?)/ims
const entry = context.payload.pull_request.body.match(regex)
const isWriteComment =
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,7 @@ jobs:
scenario: DEBUGGER_PROBES_STATUS
- library: ruby
app: rails70
scenario: DEBUGGER_METHOD_PROBES_SNAPSHOT
- library: ruby
app: rails70
scenario: DEBUGGER_LINE_PROBES_SNAPSHOT
- library: ruby
app: rails70
scenario: DEBUGGER_MIX_LOG_PROBE
scenario: DEBUGGER_PROBES_SNAPSHOT
- library: ruby
app: rails70
scenario: DEBUGGER_PII_REDACTION
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/test-memory-leaks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ jobs:
- run: gem update --system 3.5.23 # TODO: This is a workaround for a buggy rubygems in 3.4.0-preview2; remove once stable version 3.4 is out
- run: bundle exec rake compile spec:profiling:memcheck
test-asan:
# Temporarily ruby-asan builds changes
# from: `ruby 3.4.0dev (2024-11-07T14:35:19Z :detached: fca07d73e3) +PRISM [x86_64-linux]`
# To: `ruby 3.4.0dev (2024-11-11T18:38:40Z :detached: 8672e88cd2) +PRISM [x86_64-linux]`
if: false
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
Expand All @@ -27,5 +23,5 @@ jobs:
ruby-version: asan
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
bundler: latest
cache-version: v1 # bump this to invalidate cache
cache-version: v2 # bump this to invalidate cache
- run: env RUBY_FREE_AT_EXIT=1 LSAN_OPTIONS=verbosity=0:log_threads=1:suppressions=`pwd`/suppressions/lsan.supp ASAN_OPTIONS=detect_leaks=1 bundle exec rake spec:profiling:main
95 changes: 0 additions & 95 deletions Appraisals

This file was deleted.

35 changes: 34 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

## [Unreleased]

## [2.8.0] - 2024-12-10

### Added

* DI: Dynamic instrumentation is now available in Ruby as a Preview
* AppSec: Add SQL injection detection for ActiveRecord for following adapters: `mysql2`, `postgresql`, and `sqlite3` ([#4167][])
* Telemetry: Add environment variable to disable logs ([#4153][])
* Integrations: Add configuration option `on_error` to Elasticsearch tracing ([#4066][])

### Changed

* Upgrade libdatadog dependency to 14.3.1 ([#4196][])
* Profiling: Require Ruby 3.1+ for heap profiling ([#4178][])
* AppSec: Update libddwaf to 1.18.0.0.0 ([#4164][])
* Single-step: Lower SSI GLIBC requirements down to 2.17 ([#4137][])

### Fixed

* Integrations: Avoid loading `ActiveSupport::Cache::RedisCacheStore`, which tries to load `redis >= 4.0.1` regardless of the version of Redis the host application has installed ([#4197][])
* Profiling: Fix unsafe initialization when using profiler with otel tracing ([#4195][])
* Single-step: Add safe NOOP injection script for very old rubies ([#4140][])

## [2.7.1] - 2024-11-28

### Fixed
Expand Down Expand Up @@ -3035,7 +3057,8 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v2.7.0...master
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v2.8.0...master
[2.8.0]: https://github.com/DataDog/dd-trace-rb/compare/v2.7.1...v2.8.0
[2.7.0]: https://github.com/DataDog/dd-trace-rb/compare/v2.6.0...v2.7.0
[2.6.0]: https://github.com/DataDog/dd-trace-rb/compare/v2.5.0...v2.6.0
[2.5.0]: https://github.com/DataDog/dd-trace-rb/compare/v2.4.0...v2.5.0
Expand Down Expand Up @@ -4480,12 +4503,22 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
[#4027]: https://github.com/DataDog/dd-trace-rb/issues/4027
[#4033]: https://github.com/DataDog/dd-trace-rb/issues/4033
[#4065]: https://github.com/DataDog/dd-trace-rb/issues/4065
[#4066]: https://github.com/DataDog/dd-trace-rb/issues/4066
[#4075]: https://github.com/DataDog/dd-trace-rb/issues/4075
[#4078]: https://github.com/DataDog/dd-trace-rb/issues/4078
[#4082]: https://github.com/DataDog/dd-trace-rb/issues/4082
[#4083]: https://github.com/DataDog/dd-trace-rb/issues/4083
[#4085]: https://github.com/DataDog/dd-trace-rb/issues/4085
[#4137]: https://github.com/DataDog/dd-trace-rb/issues/4137
[#4140]: https://github.com/DataDog/dd-trace-rb/issues/4140
[#4153]: https://github.com/DataDog/dd-trace-rb/issues/4153
[#4161]: https://github.com/DataDog/dd-trace-rb/issues/4161
[#4164]: https://github.com/DataDog/dd-trace-rb/issues/4164
[#4167]: https://github.com/DataDog/dd-trace-rb/issues/4167
[#4178]: https://github.com/DataDog/dd-trace-rb/issues/4178
[#4195]: https://github.com/DataDog/dd-trace-rb/issues/4195
[#4196]: https://github.com/DataDog/dd-trace-rb/issues/4196
[#4197]: https://github.com/DataDog/dd-trace-rb/issues/4197
[@AdrianLC]: https://github.com/AdrianLC
[@Azure7111]: https://github.com/Azure7111
[@BabyGroot]: https://github.com/BabyGroot
Expand Down
3 changes: 3 additions & 0 deletions Matrixfile
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@
'rails6-semantic-logger' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ❌ 3.0 / ❌ 3.1 / ❌ 3.2 / ❌ 3.3 / ❌ 3.4 / ✅ jruby',
'rails61-semantic-logger' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby'
},
'rails_old_redis' => {
'rails-old-redis' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby',
},
'action_cable' => {
# FIXME: Enable the test for JRuby after fixing `log writing failed. closed stream` in CircleCI.
'rails5-mysql2' => '✅ 2.5 / ✅ 2.6 / ❌ 2.7 / ❌ 3.0 / ❌ 3.1 / ❌ 3.2 / ❌ 3.3 / ❌ 3.4 / ❌ jruby',
Expand Down
9 changes: 9 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ namespace :spec do
t.rspec_opts = args.to_a.join(' ')
end

# Tests if Datadog::Tracing::Contrib::ActiveSupport::Cache::Redis::Patcher does not eager load
# ActiveSupport::Cache::RedisCacheStore when the version of Redis present is too old to be compatible.
# @see Datadog::Tracing::Contrib::ActiveSupport::Cache::Redis::Patcher#patch_redis_cache_store?
desc '' # "Explicitly hiding from `rake -T`"
RSpec::Core::RakeTask.new(:rails_old_redis) do |t, args|
t.pattern = 'spec/datadog/tracing/contrib/rails/cache_spec.rb'
t.rspec_opts = args.to_a.join(' ')
end

desc '' # "Explicitly hiding from `rake -T`"
RSpec::Core::RakeTask.new(:hanami) do |t, args|
t.pattern = 'spec/datadog/tracing/contrib/hanami/**/*_spec.rb'
Expand Down
40 changes: 40 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,48 @@
# Declare shortcuts for Steep::Signature::Ruby to make this file easier to read
# as well as facilitating the findability of violation types emitted by the CLI
# (e.g. the CLI emits `Diagnostic ID: Ruby::UnknownConstant` when finding errors).
Ruby = Steep::Diagnostic::Ruby

target :datadog do
signature 'sig'

check 'lib/'

# This makes Steep check the codebase with the strictest settings.
# We are free to disable checks if needed inside the block.
#
# The default level is `Ruby.default`, and there's an even stricter level called `Ruby.all_error`.
configure_code_diagnostics(Ruby.strict) do |hash|
# These checks can be gradually enabled as the codebase cleans up.
# The reporting levels are:
# * `:error`, `:warning`: These will fail `rake typecheck` and are always reported by default.
# * `:information`, `:hint`: To see these, run `rake 'typecheck[--severity-level=information]'`
# or `rake 'typecheck[--severity-level=hint]'`

# These first checks are likely the easiest to fix, given they capture a mismatch
# between the already declared type in `.rbs` and the actual type inferred by Steep.
hash[Ruby::DifferentMethodParameterKind] = :information
hash[Ruby::IncompatibleAssignment] = :information

# These checks are a bit harder, because they represent the lack of sufficient type information.
hash[Ruby::FallbackAny] = :information
hash[Ruby::UnknownInstanceVariable] = :information
hash[Ruby::UnknownRecordKey] = :information

# This check asks you to type every empty collection used in
# local variables with an inline type annotation (e.g. `ret = {} #: Hash[Symbol,untyped]`).
# This pollutes the code base, and demands seemingly unnecessary typing of internal variables.
# Ideally, these empty collections automatically assume a signature based on its usage inside its method.
# @see https://github.com/soutaro/steep/pull/1338
hash[Ruby::UnannotatedEmptyCollection] = :information

# This one is funny: it is raised whenever we use `super` from a method in a Module.
# Since there's no guarantee that the module will be included in a class with the matching method,
# Steep cannot know if the `super` call will be valid.
# But this is very common in the codebase, as such module are used for monkey-patching.
hash[Ruby::UnexpectedSuper] = :information
end

ignore 'lib/datadog/appsec.rb'
ignore 'lib/datadog/appsec/component.rb'
# Excluded due to https://github.com/soutaro/steep/issues/1232
Expand Down
22 changes: 10 additions & 12 deletions appraisal/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,38 @@
#
# Usage: `bundle exec ruby appraisal/generate.rb`

require 'bundler'
require "appraisal/appraisal"

require_relative "../tasks/appraisal_conversion"

gemfile = Appraisal::Gemfile.new.tap do |g|
# Support `eval_gemfile` for `Bundler::DSL`
g.define_singleton_method(:eval_gemfile) {|file| load(file) }
g.load(ENV["BUNDLE_GEMFILE"] || "Gemfile")
g.load(Bundler.default_gemfile)
end

appraisals = []

REMOVED_GEMS = {
:check => [
'rbs',
'steep',
'standard',
],
:dev => [
'ruby-lsp',
],
}
definition = Bundler.definition
to_remove = Hash.new { |hash, key| hash[key] = definition.dependencies_for([key]).map(&:name) }

# Register groups to be removed
[:dev, :check].each { |g| to_remove[g] }

define_singleton_method(:appraise) do |name, &block|
# Customize name
name = "#{AppraisalConversion.runtime_identifier}_#{name}"
appraisal = Appraisal::Appraisal.new(name, gemfile)
appraisal.instance_eval(&block)

# Customize callback for removal
REMOVED_GEMS.each do |group_name, gems|
to_remove.each do |group_name, gems|
appraisal.group(group_name) do
gems.each { |gem_name| remove_gem gem_name }
end
end

appraisals << appraisal
end

Expand Down
10 changes: 10 additions & 0 deletions appraisal/jruby-9.2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@
gem 'i18n', '1.8.7', platform: :jruby # Removal pending: https://github.com/ruby-i18n/i18n/issues/555#issuecomment-772112169
end

appraise 'rails-old-redis' do
# All dependencies except Redis < 4 are not important, they are just required to run Rails tests.
gem 'redis', '< 4'
gem 'rails', '~> 6.1.0'
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
gem 'sprockets', '< 4'
gem 'lograge', '~> 0.11'
gem 'net-smtp'
end

appraise 'resque2-redis3' do
gem 'redis', '< 4.0'
gem 'resque', '>= 2.0'
Expand Down
10 changes: 10 additions & 0 deletions appraisal/jruby-9.3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@
gem 'rails_semantic_logger', '~> 4.0'
end

appraise 'rails-old-redis' do
# All dependencies except Redis < 4 are not important, they are just required to run Rails tests.
gem 'redis', '< 4'
gem 'rails', '~> 6.1.0'
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
gem 'sprockets', '< 4'
gem 'lograge', '~> 0.11'
gem 'net-smtp'
end

appraise 'resque2-redis3' do
gem 'redis', '~> 3.0'
gem 'resque', '>= 2.0'
Expand Down
Loading

0 comments on commit eba85d9

Please sign in to comment.