Skip to content

Commit 1ced609

Browse files
authored
Merge pull request #3801 from DataDog/ivoanjo/profiler-adopt-standard
[NO-TICKET] RFC: Adopt standardrb for Profiler
2 parents 5296456 + d99542d commit 1ced609

34 files changed

+397
-155
lines changed

.circleci/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ step_rubocop: &step_rubocop
159159
# The workaround is to use `cpu.shares / 1024`:
160160
# https://discuss.circleci.com/t/environment-variable-set-to-the-number-of-available-cpus/32670/4
161161
command: PARALLEL_PROCESSOR_COUNT=$((`cat /sys/fs/cgroup/cpu/cpu.shares` / 1024)) bundle exec rake rubocop
162+
step_standardrb: &step_standardrb
163+
run:
164+
name: Delint with Standardrb
165+
# There's no straightforward way to get the number of available processors & CPU threads in CircleCI.
166+
# Currently it always return 18 physical processors and 36 threads, regardless of executor size.
167+
# The workaround is to use `cpu.shares / 1024`:
168+
# https://discuss.circleci.com/t/environment-variable-set-to-the-number-of-available-cpus/32670/4
169+
command: PARALLEL_PROCESSOR_COUNT=$((`cat /sys/fs/cgroup/cpu/cpu.shares` / 1024)) bundle exec rake standard
162170
step_appraisal_install: &step_appraisal_install
163171
run:
164172
name: Install Appraisal gems
@@ -377,6 +385,7 @@ orbs:
377385
keys:
378386
- bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<<parameters.ruby_version>>-{{ checksum "lib/datadog/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }}
379387
- *step_rubocop
388+
- *step_standardrb
380389
coverage:
381390
<<: *test_job_default
382391
steps:

.git-blame-ignore-revs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,20 @@
33
372f7c20696e30f319cf20622758f7f0ef585875
44
# First multi-line argument has line break
55
6e8ae58d320d6a48f6c1d21db894d414bdf140b2
6+
# Profiling migration to standardrb
7+
ac6824dce79859fd8de45f3f0f6bf7a8924af9ec
8+
41851227391f27f0c1d4dd3c1c9ee6b472eca868
9+
1e575a7fe35f7ce3d4527d794c7a21e70b5da75b
10+
6af85872506508d1530bdd2fb27c1f892b399a71
11+
871794d8316e41f81a34137115f23f1f4e968436
12+
5a05ec39937d3166efaf735aec3dcb57fd864cb3
13+
4acf1e5cbf88c51b69025357ce3effc0a3ea3d9c
14+
dd4db277900ffe6826f5bd45f475340f7978fc38
15+
b16a6530321eae11f8456981892c36f3847026e6
16+
cc84721645bc75fc76a62bc6228c8b730ed3a30f
17+
74542fc1aab3b58606b91a89e4268d2fbb340a1d
18+
f89961150051276ea21bbca3fa00bda9b3cf4f1d
19+
9e7648e1bcce370ff7cf6aeaa1c32bf9ecacf0a6
20+
6924556fc9e38c244e2ff3d429d581819f275ee9
21+
aba860197ce4f708e917e27323884d8efe3692ca
22+
464dd7177b72d6fe2c7f6e1aba0e4a6d3826f0d9

.rubocop.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ AllCops:
2727
NewCops: disable # Don't allow new cops to be enabled implicitly.
2828
SuggestExtensions: false # Stop pushing suggestions constantly.
2929

30+
# Profiling has migrated to standard and is not managed by rubocop:
31+
Style:
32+
Exclude:
33+
- 'lib/datadog/profiling*'
34+
- 'lib/datadog/profiling/**/*'
35+
- 'spec/datadog/profiling*'
36+
- 'spec/datadog/profiling/**/*'
37+
- 'ext/datadog_profiling_*/**/*'
38+
Layout:
39+
Exclude:
40+
- 'lib/datadog/profiling/*'
41+
- 'lib/datadog/profiling/**/**'
42+
- 'spec/datadog/profiling/*'
43+
- 'spec/datadog/profiling/**/**'
44+
- 'ext/datadog_profiling_*/**/*'
45+
3046
Layout/LineLength:
3147
Max: 124
3248
Exclude:

.standard.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# For available configuration options, see:
2+
# https://github.com/testdouble/standard
3+
ruby_version: 2.5

.standard_todo.yml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# This file is used to ignore specific rules for specific files or directories.
2+
---
3+
ignore:
4+
5+
# After quite some discussion on the team, we decided to make an exception to the
6+
# "standard-isn't-supposed-to-be-configured" thing to allow for trailing comma, see
7+
# https://github.com/standardrb/standard/issues/611 for a discussion
8+
- '**/**':
9+
- Style/TrailingCommaInArguments
10+
- Style/TrailingCommaInArrayLiteral
11+
- Style/TrailingCommaInHashLiteral
12+
13+
# This disables standardrb for the rest of dd-trace-rb (other than profiling)
14+
- .pryrc
15+
- .simplecov
16+
- Appraisals
17+
- datadog.gemspec
18+
- Gemfile
19+
- Rakefile
20+
- Steepfile
21+
- appraisal/**/**
22+
- benchmarks/**/**
23+
- gemfiles/**/**
24+
- integration/**/**
25+
- lib-injection/**/**
26+
- ext/libdatadog_extconf_helpers.rb
27+
- ext/libdatadog_api/**/**
28+
- lib/*
29+
- lib/datadog/*
30+
- lib/datadog/appsec/**/**
31+
- lib/datadog/core/**/**
32+
- lib/datadog/kit/**/**
33+
- lib/datadog/opentelemetry/**/**
34+
- lib/datadog/tracing/**/**
35+
- spec/*
36+
- spec/datadog/*
37+
- spec/datadog/appsec/**/**
38+
- spec/datadog/benchmark/**/**
39+
- spec/datadog/core/**/**
40+
- spec/datadog/kit/**/**
41+
- spec/datadog/tracing/**/**
42+
- spec/support/**/**
43+
- tasks/**/**
44+
- yard/**/**
45+
46+
# These profiling ignores are ALL going to be fixed in separate PRs
47+
- lib/datadog/profiling/collectors/code_provenance.rb:
48+
- Style/StringLiterals
49+
- Layout/SpaceInsideHashLiteralBraces
50+
- lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb:
51+
- Style/StringLiterals
52+
- Style/RedundantBegin
53+
- lib/datadog/profiling/collectors/idle_sampling_helper.rb:
54+
- Style/RedundantBegin
55+
- Style/StringLiterals
56+
- lib/datadog/profiling/collectors/info.rb:
57+
- Style/StringLiterals
58+
- lib/datadog/profiling/component.rb:
59+
- Layout/SpaceInsideHashLiteralBraces
60+
- Style/StringLiterals
61+
- lib/datadog/profiling/crashtracker.rb:
62+
- Style/StringLiterals
63+
- Style/RedundantBegin
64+
- lib/datadog/profiling/exporter.rb:
65+
- Style/StringLiterals
66+
- lib/datadog/profiling/ext.rb:
67+
- Style/StringLiterals
68+
- lib/datadog/profiling/ext/dir_monkey_patches.rb:
69+
- Style/StringLiterals
70+
- lib/datadog/profiling/ext/forking.rb:
71+
- Style/StringLiterals
72+
- lib/datadog/profiling/flush.rb:
73+
- Style/StringLiterals
74+
- lib/datadog/profiling/http_transport.rb:
75+
- Style/StringLiterals
76+
- lib/datadog/profiling/load_native_extension.rb:
77+
- Style/StringLiterals
78+
- lib/datadog/profiling/preload.rb:
79+
- Style/StringLiterals
80+
- lib/datadog/profiling/profiler.rb:
81+
- Style/StringLiterals
82+
- lib/datadog/profiling/scheduler.rb:
83+
- Style/StringLiterals
84+
- Style/RedundantBegin
85+
- lib/datadog/profiling/tag_builder.rb:
86+
- Style/StringLiterals
87+
- lib/datadog/profiling/tasks/exec.rb:
88+
- Style/StringLiterals
89+
- lib/datadog/profiling/tasks/setup.rb:
90+
- Style/StringLiterals
91+
- Style/RedundantBegin
92+
- lib/datadog/profiling.rb:
93+
- Style/StringLiterals
94+
- Style/RedundantBegin
95+
- spec/datadog/profiling/collectors/code_provenance_spec.rb:
96+
- Style/StringLiterals
97+
- spec/datadog/profiling/collectors/cpu_and_wall_time_worker_spec.rb:
98+
- Style/StringLiterals
99+
- Layout/SpaceInsideHashLiteralBraces
100+
- Style/QuotedSymbols
101+
- Style/RedundantBegin
102+
- spec/datadog/profiling/collectors/discrete_dynamic_sampler_spec.rb:
103+
- Style/StringLiterals
104+
- spec/datadog/profiling/collectors/dynamic_sampling_rate_spec.rb:
105+
- Style/StringLiterals
106+
- spec/datadog/profiling/collectors/idle_sampling_helper_spec.rb:
107+
- Style/StringLiterals
108+
- spec/datadog/profiling/collectors/info_spec.rb:
109+
- Style/StringLiterals
110+
- Layout/SpaceInsideHashLiteralBraces
111+
- spec/datadog/profiling/collectors/stack_spec.rb:
112+
- Style/StringLiterals
113+
- Layout/SpaceInsideHashLiteralBraces
114+
- spec/datadog/profiling/collectors/thread_context_spec.rb:
115+
- Style/StringLiterals
116+
- Style/QuotedSymbols
117+
- Style/RedundantBegin
118+
- Layout/SpaceInsideHashLiteralBraces
119+
- spec/datadog/profiling/component_spec.rb:
120+
- Style/StringLiterals
121+
- Layout/SpaceInsideHashLiteralBraces
122+
- spec/datadog/profiling/crashtracker_spec.rb:
123+
- Style/StringLiterals
124+
- Layout/SpaceInsideHashLiteralBraces
125+
- Style/QuotedSymbols
126+
- spec/datadog/profiling/exporter_spec.rb:
127+
- Style/StringLiterals
128+
- Layout/SpaceInsideHashLiteralBraces
129+
- spec/datadog/profiling/ext/dir_monkey_patches_spec.rb:
130+
- Style/StringLiterals
131+
- Style/RedundantBegin
132+
- spec/datadog/profiling/ext/forking_spec.rb:
133+
- Style/StringLiterals
134+
- spec/datadog/profiling/flush_spec.rb:
135+
- Style/StringLiterals
136+
- Layout/SpaceInsideHashLiteralBraces
137+
- spec/datadog/profiling/http_transport_spec.rb:
138+
- Style/StringLiterals
139+
- Layout/SpaceInsideHashLiteralBraces
140+
- Style/RedundantBegin
141+
- spec/datadog/profiling/load_native_extension_spec.rb:
142+
- Style/StringLiterals
143+
- spec/datadog/profiling/native_extension_helpers_spec.rb:
144+
- Style/StringLiterals
145+
- spec/datadog/profiling/native_extension_spec.rb:
146+
- Style/StringLiterals
147+
- spec/datadog/profiling/pprof/pprof_pb.rb:
148+
- Style/StringLiterals
149+
- spec/datadog/profiling/preload_spec.rb:
150+
- Style/StringLiterals
151+
- spec/datadog/profiling/profiler_spec.rb:
152+
- Style/StringLiterals
153+
- spec/datadog/profiling/scheduler_spec.rb:
154+
- Style/StringLiterals
155+
- Layout/SpaceInsideHashLiteralBraces
156+
- spec/datadog/profiling/spec_helper.rb:
157+
- Style/StringLiterals
158+
- Style/QuotedSymbols
159+
- spec/datadog/profiling/stack_recorder_spec.rb:
160+
- Style/StringLiterals
161+
- Layout/SpaceInsideHashLiteralBraces
162+
- Style/QuotedSymbols
163+
- Style/RedundantBegin
164+
- spec/datadog/profiling/tag_builder_spec.rb:
165+
- Style/StringLiterals
166+
- Layout/SpaceInsideHashLiteralBraces
167+
- spec/datadog/profiling/tasks/exec_spec.rb:
168+
- Style/StringLiterals
169+
- spec/datadog/profiling/tasks/help_spec.rb:
170+
- Style/StringLiterals
171+
- spec/datadog/profiling/tasks/setup_spec.rb:
172+
- Style/StringLiterals
173+
- spec/datadog/profiling/validate_benchmarks_spec.rb:
174+
- Style/StringLiterals
175+
- spec/datadog/profiling_spec.rb:
176+
- Style/StringLiterals
177+
- Style/RedundantBegin
178+
- ext/datadog_profiling_loader/extconf.rb:
179+
- Style/StringLiterals
180+
- ext/datadog_profiling_native_extension/extconf.rb:
181+
- Style/StringLiterals
182+
- ext/datadog_profiling_native_extension/native_extension_helpers.rb:
183+
- Style/StringLiterals
184+
- Layout/SpaceInsideHashLiteralBraces
185+
- Style/RedundantBegin

Appraisals

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ REMOVED_GEMS = {
1616
:check => [
1717
'rbs',
1818
'steep',
19+
'standard',
1920
],
2021
:dev => [
2122
'ruby-lsp',

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ group :check do
8282
gem 'rbs', '~> 3.2.0', require: false
8383
gem 'steep', '~> 1.6.0', require: false
8484
end
85+
gem 'standard', require: false
8586
end
8687

8788
group :dev do

Rakefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'bundler/gem_tasks'
22
require 'datadog/version'
33
require 'rubocop/rake_task' if Gem.loaded_specs.key? 'rubocop'
4+
require 'standard/rake' if Gem.loaded_specs.key? 'standard'
45
require 'rspec/core/rake_task'
56
require 'rake/extensiontask'
67
require 'yard'
@@ -421,7 +422,7 @@ namespace :native_dev do
421422
end
422423

423424
desc 'Runs rubocop + main test suite'
424-
task default: ['rubocop', 'typecheck', 'spec:main']
425+
task default: ['rubocop', 'standard', 'typecheck', 'spec:main']
425426

426427
desc 'Runs the default task in parallel'
427-
multitask fastdefault: ['rubocop', 'typecheck', 'spec:main']
428+
multitask fastdefault: ['rubocop', 'standard', 'typecheck', 'spec:main']

ext/datadog_profiling_native_extension/extconf.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
SKIPPED_REASON_FILE = "#{__dir__}/skipped_reason.txt".freeze
88
# Not a problem if the file doesn't exist or we can't delete it
9-
File.delete(SKIPPED_REASON_FILE) rescue nil
9+
begin
10+
File.delete(SKIPPED_REASON_FILE)
11+
rescue
12+
nil
13+
end
1014

1115
def skip_building_extension!(reason)
1216
fail_install_if_missing_extension =
@@ -67,7 +71,7 @@ def skip_building_extension!(reason)
6771
require 'mkmf'
6872

6973
Logging.message("[datadog] Using compiler:\n")
70-
xsystem("#{CONFIG['CC']} -v")
74+
xsystem("#{CONFIG["CC"]} -v")
7175
Logging.message("[datadog] End of compiler information\n")
7276

7377
# mkmf on modern Rubies actually has an append_cflags that does something similar
@@ -191,8 +195,8 @@ def add_compiler_flag(flag)
191195
$defs << '-DNO_THREAD_INVOKE_ARG' if RUBY_VERSION < '2.6'
192196

193197
# If we got here, libdatadog is available and loaded
194-
ENV['PKG_CONFIG_PATH'] = "#{ENV['PKG_CONFIG_PATH']}:#{Libdatadog.pkgconfig_folder}"
195-
Logging.message("[datadog] PKG_CONFIG_PATH set to #{ENV['PKG_CONFIG_PATH'].inspect}\n")
198+
ENV['PKG_CONFIG_PATH'] = "#{ENV["PKG_CONFIG_PATH"]}:#{Libdatadog.pkgconfig_folder}"
199+
Logging.message("[datadog] PKG_CONFIG_PATH set to #{ENV["PKG_CONFIG_PATH"].inspect}\n")
196200
$stderr.puts("Using libdatadog #{Libdatadog::VERSION} from #{Libdatadog.pkgconfig_folder}")
197201

198202
unless pkg_config('datadog_profiling_with_rpath')

ext/datadog_profiling_native_extension/native_extension_helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def self.render_skipped_reason_file(reason:, suggested:)
232232
'platform variant.',
233233
"(Your platform: `#{Libdatadog.current_platform}`)",
234234
'(Available binaries:',
235-
"`#{Libdatadog.available_binaries.join('`, `')}`)",
235+
"`#{Libdatadog.available_binaries.join("`, `")}`)",
236236
suggested: CONTACT_SUPPORT,
237237
)
238238

0 commit comments

Comments
 (0)