Class: Raygun::Apm::Tracer

Inherits:
Object
  • Object
show all
Defined in:
lib/raygun/apm/tracer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env = ENV) ⇒ Tracer

Returns a new instance of Tracer.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/raygun/apm/tracer.rb', line 20

def initialize(env=ENV)
  configure(env)
  initialize_blacklist
  register_known_library_paths
  run_agent_connectivity_diagnostics
  ObjectSpace.define_finalizer(self, proc{ disable_tracepoints })
# Any fails here is kamikaze for the tracer
rescue => e
  # XXX works for the middleware wrapped case, not for standalone - revisit
  raise Raygun::Apm::FatalError, "Raygun APM tracer could not be initialized: #{e.message} #{e.backtrace.join("\n")}"
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



18
19
20
# File 'lib/raygun/apm/tracer.rb', line 18

def config
  @config
end

Class Method Details

.instanceObject



9
10
11
# File 'lib/raygun/apm/tracer.rb', line 9

def instance
  @__pids[Process.pid]
end

.instance=(tracer) ⇒ Object



13
14
15
# File 'lib/raygun/apm/tracer.rb', line 13

def instance=(tracer)
  @__pids[Process.pid] = tracer
end

Instance Method Details

#udp_sink!Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/raygun/apm/tracer.rb', line 32

def udp_sink!
  require "socket"
  sock = UDPSocket.new
  # For UDP sockets, SO_SNDBUF is the max packet size and NOT send buffer as with a connection oriented transport
  sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, Tracer::BATCH_PACKET_SIZE)
  self.udp_sink(
    socket: sock,
    host: config.proton_udp_host,
    port: config.proton_udp_port,
    receive_buffer_size: sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_RCVBUF).int
  )
# Any fails here is kamikaze for the tracer
rescue => e
  # XXX works for the middleware wrapped case, not for standalone - revisit
  raise Raygun::Apm::FatalError, "Raygun APM UDP sink could not be initialized: #{e.message} #{e.backtrace.join("\n")}"
end