Skip to content

Commit

Permalink
Merge pull request #2610 from DataDog/ivoanjo/minor-dont-actually-sta…
Browse files Browse the repository at this point in the history
…rt-profiling-in-core-specs

Minor: Don't actually start profiling in core specs
  • Loading branch information
ivoanjo committed Feb 14, 2023
2 parents 35053cd + e6d163f commit 8022e0e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
11 changes: 7 additions & 4 deletions spec/datadog/core/diagnostics/environment_logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,25 +298,28 @@
end

context 'with MRI' do
before { skip unless PlatformHelpers.mri? }
before { skip('Spec only runs on MRI') unless PlatformHelpers.mri? }

it { is_expected.to include vm: start_with('ruby') }
end

context 'with JRuby' do
before { skip unless PlatformHelpers.jruby? }
before { skip('Spec only runs on JRuby') unless PlatformHelpers.jruby? }

it { is_expected.to include vm: start_with('jruby') }
end

context 'with TruffleRuby' do
before { skip unless PlatformHelpers.truffleruby? }
before { skip('Spec only runs on TruffleRuby') unless PlatformHelpers.truffleruby? }

it { is_expected.to include vm: start_with('truffleruby') }
end

context 'with profiling enabled' do
before { Datadog.configure { |c| c.profiling.enabled = true } }
before do
allow_any_instance_of(Datadog::Profiling::Profiler).to receive(:start) if PlatformHelpers.mri?
Datadog.configure { |c| c.profiling.enabled = true }
end

it { is_expected.to include profiling_enabled: true }
end
Expand Down
4 changes: 4 additions & 0 deletions spec/datadog/core/telemetry/collector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
Datadog.configuration.appsec.enabled = false
stub_const('Datadog::Core::Environment::Ext::TRACER_VERSION', '4.2')
end

after do
Datadog.configuration.profiling.send(:reset!)
Datadog.configuration.appsec.send(:reset!)
Expand All @@ -99,11 +100,13 @@
require 'datadog/appsec'

before do
allow_any_instance_of(Datadog::Profiling::Profiler).to receive(:start) if PlatformHelpers.mri?
Datadog.configure do |c|
c.profiling.enabled = true
c.appsec.enabled = true
end
end

after do
Datadog.configuration.profiling.send(:reset!)
Datadog.configuration.appsec.send(:reset!)
Expand Down Expand Up @@ -223,6 +226,7 @@
context 'when profiling is enabled' do
before do
stub_const('Datadog::Core::Environment::Ext::TRACER_VERSION', '4.2')
allow_any_instance_of(Datadog::Profiling::Profiler).to receive(:start)
Datadog.configure do |c|
c.profiling.enabled = true
end
Expand Down
3 changes: 3 additions & 0 deletions spec/datadog/profiling/profiler_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# typed: false

require 'spec_helper'
require 'datadog/profiling/spec_helper'

require 'datadog/profiling'
require 'datadog/profiling/profiler'
require 'datadog/profiling/collectors/old_stack'
require 'datadog/profiling/scheduler'

RSpec.describe Datadog::Profiling::Profiler do
before { skip_if_profiling_not_supported(self) }

subject(:profiler) { described_class.new(collectors, scheduler) }

let(:collectors) { Array.new(2) { instance_double(Datadog::Profiling::Collectors::OldStack) } }
Expand Down

0 comments on commit 8022e0e

Please sign in to comment.