Class: DTracer::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/dtracer/builder.rb

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



3
4
5
# File 'lib/dtracer/builder.rb', line 3

def initialize
  @content = []
end

Instance Method Details

#add_begin_probeObject



13
14
15
16
17
18
# File 'lib/dtracer/builder.rb', line 13

def add_begin_probe
  @content << 'BEGIN {'
  @content << '  printf("Tracing started\n");'
  @content << '}'
  @content << ''
end

#add_custom_probeObject



28
29
30
# File 'lib/dtracer/builder.rb', line 28

def add_custom_probe
  add_probe("custom")
end

#add_options(is_quite, string_size = 102400) ⇒ Object



7
8
9
10
11
# File 'lib/dtracer/builder.rb', line 7

def add_options(is_quite, string_size = 102400)
  @content << "#pragma D option quiet" if is_quite
  @content << "#pragma D option strsize=#{string_size}"
  @content << ''
end

#add_probe(probe_type) ⇒ Object



36
37
38
39
40
41
# File 'lib/dtracer/builder.rb', line 36

def add_probe(probe_type)
  @content << "oadprobe*:::#{probe_type} {"
  @content << '  printf("%s\n\n", copyinstr(arg0));'
  @content << '}'
  @content << ''
end

#add_request_probeObject



20
21
22
# File 'lib/dtracer/builder.rb', line 20

def add_request_probe
  add_probe("request")
end

#add_response_probeObject



24
25
26
# File 'lib/dtracer/builder.rb', line 24

def add_response_probe
  add_probe("response")
end

#buildObject



32
33
34
# File 'lib/dtracer/builder.rb', line 32

def build
  @content.join("\n")
end