Skip to content

Commit

Permalink
Merge branch 'master' into di-loading
Browse files Browse the repository at this point in the history
  • Loading branch information
p-datadog authored Jan 3, 2025
2 parents d3b854c + f3e66ea commit a9f892f
Show file tree
Hide file tree
Showing 198 changed files with 999 additions and 1,088 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ save_bundle_checksum: &save_bundle_checksum
command: |
if [ "$CI_BUNDLE_CACHE_HIT" != 1 ]; then
# Recompute gemfiles/*.lock checksum, as those files might have changed
cat Gemfile Gemfile.lock Appraisals gemfiles/*.gemfile gemfiles/*.gemfile.lock | md5sum > .circleci/bundle_checksum
cat Gemfile Gemfile.lock ruby-*.gemfile gemfiles/*.gemfile gemfiles/*.gemfile.lock | md5sum > .circleci/bundle_checksum
fi
cp .circleci/bundle_checksum /usr/local/bundle/bundle_checksum
step_bundle_install: &step_bundle_install
Expand Down Expand Up @@ -96,7 +96,7 @@ step_compute_bundle_checksum: &step_compute_bundle_checksum
# updating the gemset lock files produces extremely large commits.
command: |
bundle lock # Create Gemfile.lock
cat Gemfile Gemfile.lock Appraisals gemfiles/*.gemfile gemfiles/*.gemfile.lock | md5sum > .circleci/bundle_checksum
cat Gemfile Gemfile.lock ruby-*.gemfile gemfiles/*.gemfile gemfiles/*.gemfile.lock | md5sum > .circleci/bundle_checksum
step_get_test_agent_trace_check_results: &step_get_test_agent_trace_check_results
run:
name: Get APM Test Agent Trace Check Results
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-memory-leaks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.4.0-preview2 # TODO: Use stable version once 3.4 is out
ruby-version: 3.4.1
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: sudo apt-get update && (sudo apt-get install -y valgrind || sleep 5 && sudo apt-get install -y valgrind) && valgrind --version
- 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
Expand Down
1 change: 0 additions & 1 deletion Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ target :datadog do
ignore 'lib/datadog/core/buffer/thread_safe.rb'
ignore 'lib/datadog/core/chunker.rb'
ignore 'lib/datadog/core/configuration.rb'
ignore 'lib/datadog/core/configuration/agent_settings_resolver.rb'
ignore 'lib/datadog/core/configuration/base.rb'
ignore 'lib/datadog/core/configuration/components.rb'
ignore 'lib/datadog/core/configuration/dependency_resolver.rb'
Expand Down
2 changes: 0 additions & 2 deletions appraisal/ruby-3.3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@
gem 'dalli', '< 3.0.0'
gem 'presto-client', '>= 0.5.14' # Renamed to trino-client in >= 1.0
gem 'qless', '0.12.0'

gem 'racc' # Remove this once graphql resolves issue for ruby 3.3 preview. https://github.com/rmosolgo/graphql-ruby/issues/4650
end

appraise 'core-old' do
Expand Down
2 changes: 0 additions & 2 deletions appraisal/ruby-3.4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@
gem 'dalli', '< 3.0.0'
gem 'presto-client', '>= 0.5.14' # Renamed to trino-client in >= 1.0
gem 'qless', '0.12.0'

gem 'racc' # Remove this once graphql resolves issue for ruby 3.3 preview. https://github.com/rmosolgo/graphql-ruby/issues/4650
end

appraise 'core-old' do
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/profiler_gc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def create_profiler

# We take a dummy sample so that the context for the main thread is created, as otherwise the GC profiling methods do
# not create it (because we don't want to do memory allocations in the middle of GC)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample(@collector, Thread.current)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample(@collector, Thread.current, false)
end

def run_benchmark
Expand All @@ -29,7 +29,7 @@ def run_benchmark
x.report('profiler gc') do
Datadog::Profiling::Collectors::ThreadContext::Testing._native_on_gc_start(@collector)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_on_gc_finish(@collector)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample_after_gc(@collector, false)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample_after_gc(@collector, false, false)
end

x.save! "#{File.basename(__FILE__)}-results.json" unless VALIDATE_BENCHMARK_MODE
Expand All @@ -52,7 +52,7 @@ def run_benchmark
estimated_gc_per_minute.times do
Datadog::Profiling::Collectors::ThreadContext::Testing._native_on_gc_start(@collector)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_on_gc_finish(@collector)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample_after_gc(@collector, false)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample_after_gc(@collector, false, false)
end

@recorder.serialize
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/profiler_sample_gvl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize
@target_thread = thread_with_very_deep_stack

# Sample once to trigger thread context creation for all threads (including @target_thread)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample(@collector, PROFILER_OVERHEAD_STACK_THREAD)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample(@collector, PROFILER_OVERHEAD_STACK_THREAD, false)
end

def create_profiler
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/profiler_sample_loop_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run_benchmark
)

x.report("stack collector #{ENV['CONFIG']}") do
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample(@collector, PROFILER_OVERHEAD_STACK_THREAD)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample(@collector, PROFILER_OVERHEAD_STACK_THREAD, false)
end

x.save! "#{File.basename(__FILE__)}-results.json" unless VALIDATE_BENCHMARK_MODE
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/profiler_sample_serialize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run_benchmark
simulate_seconds = 60

(samples_per_second * simulate_seconds).times do
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample(@collector, PROFILER_OVERHEAD_STACK_THREAD)
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample(@collector, PROFILER_OVERHEAD_STACK_THREAD, false)
end

@recorder.serialize
Expand Down
3 changes: 2 additions & 1 deletion docs/Compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ The Ruby Datadog Trace library is open source. See the [dd-trace-rb][1] GitHub r

| Type | Documentation | Version | Support type | Gem version support |
|-------|----------------------------|-----------|---------------------------|---------------------|
| MRI | https://www.ruby-lang.org/ | 3.3 | [latest](#support-latest) | Latest |
| MRI | https://www.ruby-lang.org/ | 3.4 | [latest](#support-latest) | Latest |
| | | 3.3 | [latest](#support-latest) | Latest |
| | | 3.2 | [latest](#support-latest) | Latest |
| | | 3.1 | [latest](#support-latest) | Latest |
| | | 3.0 | [latest](#support-latest) | Latest |
Expand Down
31 changes: 25 additions & 6 deletions docs/DevelopmentGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ All tests should run in CI. When adding new `_spec.rb` files, you may need to ad
{
'foo' => {
# With default dependencies for each Ruby runtime
'' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby',
'' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby',
# or with dependency group definition `foo-on-rails`, that includes additional gems
'foo-on-rails' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby'
'foo-on-rails' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby'
},
}
```
Expand Down Expand Up @@ -98,9 +98,9 @@ Take `bundle exec rake test:redis` as example, multiple versions of `redis` from
```ruby
{
'redis' => {
'redis-3' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby',
'redis-4' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby',
'redis-5' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby'
'redis-3' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby',
'redis-4' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby',
'redis-5' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby'
}
}
```
Expand Down Expand Up @@ -223,12 +223,31 @@ https://github.com/datadog/dd-apm-test-agent#readme

**Linting**

The trace library uses Rubocop to enforce [code style](https://github.com/bbatsov/ruby-style-guide) and quality. To check, run:
Most of the library uses Rubocop to enforce [code style](https://github.com/bbatsov/ruby-style-guide) and quality. To check, run:

```
$ bundle exec rake rubocop
```

To change your code to the version that rubocop wants, run:

```
$ bundle exec rake rubocop -A
```

Profiling and Dynamic Instrumentation use [standard](https://github.com/standardrb/standard)
instead of Rubocop. To check files with standard, run:

```
$ bundle exec rake standard
```

To change your code to the version that standard wants, run:

```
$ bundle exec rake standard:fix
```

## Appendix

### Writing new integrations
Expand Down
3 changes: 1 addition & 2 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -1547,11 +1547,10 @@ Rake::Task['my_task'].invoke

| Key | Env Var| Type | Description | Default |
| -------------- | - | ------- | -------------------------------------------------------------------------------------------------------- | -------- |
| `enabled` | | `Bool` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
| `enabled` | `DD_TRACE_RAKE_ENABLED` | `Bool` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
| `quantize` | | `Hash` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
| `service_name` | | `String` | Service name used for `rake` instrumentation | `'rake'` |
| `tasks` | | `Array` | Names of the Rake tasks to instrument | `[]` |
| `enabled` | `DD_TRACE_RAKE_ENABLED` | `Bool` | Whether the integration should create spans. | `true` |

**Configuring task quantization behavior**

Expand Down
4 changes: 2 additions & 2 deletions ext/datadog_profiling_native_extension/clock_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include <ruby.h>

// Contains the operating-system specific identifier needed to fetch CPU-time, and a flag to indicate if we failed to fetch it
typedef struct thread_cpu_time_id {
typedef struct {
bool valid;
clockid_t clock_id;
} thread_cpu_time_id;

// Contains the current cpu time, and a flag to indicate if we failed to fetch it
typedef struct thread_cpu_time {
typedef struct {
bool valid;
long result_ns;
} thread_cpu_time;
Expand Down
Loading

0 comments on commit a9f892f

Please sign in to comment.