oboe 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ module Oboe
8
8
  def report_init(layer)
9
9
  platform_info = { '__Init' => 1 }
10
10
  platform_info['RubyVersion'] = RUBY_VERSION
11
- platform_info['RailsVersion'] = Rails.version if defined?(Rails)
11
+ platform_info['RailsVersion'] = ::Rails.version if defined?(Rails)
12
12
  platform_info['OboeVersion'] = Gem.loaded_specs['oboe'].try(:version).to_s
13
13
 
14
14
  force_trace do
@@ -28,6 +28,7 @@ module Oboe
28
28
  rescue Exception => exception
29
29
  opts[:Status] = 500
30
30
  Oboe::API.log('rails', 'info', opts)
31
+ raise
31
32
  end
32
33
 
33
34
  def render(*args)
@@ -1,55 +1,116 @@
1
-
2
1
  module Oboe
3
- module Inst
4
- module Rails
5
- def self.load_initializer
6
- # Force load the tracelytics Rails initializer if there is one
7
- # Prefer oboe.rb but give priority to tracelytics.rb if it exists
8
- if ::Rails::VERSION::MAJOR > 2
9
- rails_root = "#{::Rails.root.to_s}"
10
- else
11
- rails_root = "#{RAILS_ROOT}"
12
- end
2
+ module Rails
3
+ module Helpers
4
+ extend ActiveSupport::Concern if ::Rails::VERSION::MAJOR > 2
13
5
 
14
- if File.exists?("#{rails_root}/config/initializers/tracelytics.rb")
15
- tr_initializer = "#{rails_root}/config/initializers/tracelytics.rb"
16
- else
17
- tr_initializer = "#{rails_root}/config/initializers/oboe.rb"
6
+ def oboe_rum_header
7
+ begin
8
+ return unless Oboe::Config.has_key?(:rum_id)
9
+ if Oboe::Config.tracing?
10
+ if request.xhr?
11
+ header_tmpl = File.dirname(__FILE__) + '/helpers/rum/rum_ajax_header'
12
+ else
13
+ header_tmpl = File.dirname(__FILE__) + '/helpers/rum/rum_header'
14
+ end
15
+ if ::Rails::VERSION::MAJOR > 2
16
+ render :file => header_tmpl, :formats => [:js]
17
+ else
18
+ render :file => header_tmpl + '.js.erb'
19
+ end
20
+ end
21
+ rescue Exception => e
22
+ logger.debug "oboe_rum_header: #{e.message}."
18
23
  end
19
- require tr_initializer if File.exists?(tr_initializer)
20
24
  end
21
-
22
- def self.load_instrumentation
23
- pattern = File.join(File.dirname(__FILE__), 'inst', '*.rb')
24
- Dir.glob(pattern) do |f|
25
- begin
26
- require f
27
- rescue => e
28
- $stderr.puts "[oboe/loading] Error loading rails insrumentation file '#{f}' : #{e}"
25
+
26
+ def oboe_rum_footer
27
+ begin
28
+ return unless Oboe::Config.has_key?(:rum_id)
29
+ if Oboe::Config.tracing?
30
+ footer_tmpl = File.dirname(__FILE__) + '/helpers/rum/rum_footer'
31
+ if ::Rails::VERSION::MAJOR > 2
32
+ render :file => footer_tmpl, :formats => [:js]
33
+ else
34
+ render :file => footer_tmpl + '.js.erb'
35
+ end
29
36
  end
37
+ rescue Exception => e
38
+ logger.debug "oboe_rum_footer: #{e.message}."
30
39
  end
31
- if ::Rails::VERSION::MAJOR > 2
32
- puts "Tracelytics oboe gem #{Gem.loaded_specs['oboe'].version.to_s} successfully loaded."
33
- else
34
- puts "Tracelytics oboe gem #{Oboe::Version::STRING} successfully loaded."
40
+ end
41
+ end # Helpers
42
+
43
+ def self.load_initializer
44
+ # Force load the tracelytics Rails initializer if there is one
45
+ # Prefer oboe.rb but give priority to tracelytics.rb if it exists
46
+ if ::Rails::VERSION::MAJOR > 2
47
+ rails_root = "#{::Rails.root.to_s}"
48
+ else
49
+ rails_root = "#{RAILS_ROOT}"
50
+ end
51
+
52
+ if File.exists?("#{rails_root}/config/initializers/tracelytics.rb")
53
+ tr_initializer = "#{rails_root}/config/initializers/tracelytics.rb"
54
+ else
55
+ tr_initializer = "#{rails_root}/config/initializers/oboe.rb"
56
+ end
57
+ require tr_initializer if File.exists?(tr_initializer)
58
+ end
59
+
60
+
61
+ def self.load_instrumentation
62
+ pattern = File.join(File.dirname(__FILE__), 'inst', '*.rb')
63
+ Dir.glob(pattern) do |f|
64
+ begin
65
+ require f
66
+ rescue => e
67
+ $stderr.puts "[oboe/loading] Error loading rails insrumentation file '#{f}' : #{e}"
35
68
  end
36
69
  end
70
+ if ::Rails::VERSION::MAJOR > 2
71
+ puts "Tracelytics oboe gem #{Gem.loaded_specs['oboe'].version.to_s} successfully loaded."
72
+ else
73
+ puts "Tracelytics oboe gem #{Oboe::Version::STRING} successfully loaded."
74
+ end
37
75
  end
38
- end
39
- end
76
+
77
+ def self.include_helpers
78
+ # TBD: This would make the helpers available to controllers which is occasionally desired.
79
+ # ActiveSupport.on_load(:action_controller) do
80
+ # include Oboe::Rails::Helpers
81
+ # end
82
+ if ::Rails::VERSION::MAJOR > 2
83
+ ActiveSupport.on_load(:action_view) do
84
+ include Oboe::Rails::Helpers
85
+ end
86
+ else
87
+ ActionView::Base.send :include, Oboe::Rails::Helpers
88
+ end
89
+ end
90
+
91
+ end # Rails
92
+ end # Oboe
40
93
 
41
94
  if defined?(::Rails)
42
95
  if ::Rails::VERSION::MAJOR > 2
43
96
  module Oboe
44
97
  class Railtie < ::Rails::Railtie
98
+
99
+ initializer 'oboe.helpers' do
100
+ Oboe::Rails.include_helpers
101
+ end
102
+
45
103
  config.after_initialize do
46
- Oboe::Inst::Rails.load_instrumentation
104
+ Oboe::Loading.load_access_key
105
+ Oboe::Rails.load_instrumentation
47
106
  end
48
107
  end
49
108
  end
50
109
  else
51
- Oboe::Inst::Rails.load_initializer
52
- Oboe::Inst::Rails.load_instrumentation
110
+ Oboe::Rails.load_initializer
111
+ Oboe::Loading.load_access_key
112
+ Oboe::Rails.load_instrumentation
113
+ Oboe::Rails.include_helpers
53
114
  end
54
115
  end
55
116
 
@@ -1,9 +1,50 @@
1
1
  # Copyright (c) 2012 by Tracelytics, Inc.
2
2
  # All rights reserved.
3
3
 
4
+ require 'digest/sha1'
5
+
4
6
  module Oboe
7
+ module Util
8
+ module Base64URL
9
+ module_function
10
+
11
+ def encode(bin)
12
+ c = [bin].pack('m0').gsub(/\=+\Z/, '').tr('+/', '-_').rstrip
13
+ m = c.size % 4
14
+ c += '=' * (4 - m) if m != 0
15
+ c
16
+ end
17
+
18
+ def decode(bin)
19
+ m = bin.size % 4
20
+ bin += '=' * (4 - m) if m != 0
21
+ bin.tr('-_', '+/').unpack('m0').first
22
+ end
23
+ end
24
+ end
25
+
5
26
  module Loading
6
27
 
28
+ def self.load_access_key
29
+ unless Oboe::Config.has_key?(:access_key)
30
+ config_file = '/etc/tracelytics.conf'
31
+ return unless File.exists?(config_file)
32
+
33
+ begin
34
+ File.open(config_file).each do |line|
35
+ if line =~ /^tracelyzer.access_key=/ or line =~ /^access_key/
36
+ bits = line.split(/=/)
37
+ Oboe::Config[:access_key] = bits[1].strip
38
+ Oboe::Config[:rum_id] = Oboe::Util::Base64URL.encode(Digest::SHA1.digest("RUM" + Oboe::Config[:access_key]))
39
+ break
40
+ end
41
+ end
42
+ rescue
43
+ puts "Having trouble parsing #{config_file}..."
44
+ end
45
+ end
46
+ end
47
+
7
48
  def self.require_api
8
49
  require 'oboe/version'
9
50
 
@@ -2,7 +2,7 @@ module Oboe
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 3
5
- PATCH = 0
5
+ PATCH = 1
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oboe
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 0
10
- version: 1.3.0
9
+ - 1
10
+ version: 1.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tracelytics, Inc.