Skip to content

Commit 74cf6d2

Browse files
committed
fix(example): load ruby recorder gem in selective_tracing
Add require 'codetracer_ruby_recorder' after computing the gem base path and switch recorder control calls to start/stop. Example now locates the library via the gem's lib directory and runs successfully once the native extension is built.
1 parent 111c5b3 commit 74cf6d2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update example selective_tracing.rb to require codetracer_ruby_recorder after computing ext_base, replace enable_tracing/disable_tracing with start/stop, confirm example runs

examples/selective_tracing.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/usr/bin/env ruby
22

3-
ext_base = File.expand_path('../gems/codetracer-ruby-recorder/ext/native_tracer/target/release/libcodetracer_ruby_recorder', __dir__)
4-
require ext_base
3+
ext_base = File.expand_path('../gems/codetracer-ruby-recorder/lib', __dir__)
4+
$LOAD_PATH.unshift(ext_base) unless $LOAD_PATH.include?(ext_base)
5+
require 'codetracer_ruby_recorder'
56

67
recorder = CodeTracer::RubyRecorder.new
78

89
puts 'start trace'
9-
recorder.disable_tracing
10+
recorder.stop
1011
puts 'this will not be traced'
11-
recorder.enable_tracing
12+
recorder.start
1213
puts 'this will be traced'
13-
recorder.disable_tracing
14+
recorder.stop
1415
puts 'tracing disabled'
1516
recorder.flush_trace(Dir.pwd)

0 commit comments

Comments
 (0)