oneapm_rpm 1.3.0 → 1.3.1.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDFiNGM3MmU4Nzc4YWI3NGI4ZmRkZWE0ZWE1MTZlZDcwZDY4Yjg3Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2Y1YjMwNWRkNjQ2MDJhMWMxM2VmZWY0ZmE3NTQ2NjBkMGM3YzgzZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjliZjM4NTc4ODg5N2YyOGIzZThmOGQyNjM3OGI0OTExOTFhM2IwYzJlOWM2
|
10
|
+
ODY1Y2FlNzkzZWQzYWI3N2U0ZDMwMzQ2MzA4ZTAzMjNjMTEzNWM3YjJmZjA2
|
11
|
+
OGQwNzlkM2JhOTI5NGU0YjZkZmViYjk1ZTEzYjliZWEzMTBiM2Q=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzYxOWQ5ODVjZjgyOTdhOWE3OWIwMDEyZTYzMjIyNDE1YWYzYzk4ZGRkNDYy
|
14
|
+
N2Y1M2ZjOTNlZWI4OGRhOGM4ZDUzZDUxYTcwMzVmMzg1MGMxODNmOTg5MWQw
|
15
|
+
YjczZjVhMzA5ZmQ4M2QxYmM1ZTY2ZGU4ODdhODUxNTNhYzJkODg=
|
@@ -872,6 +872,13 @@ module OneApm
|
|
872
872
|
:notified => false,
|
873
873
|
:description => 'Enable or disable insert js agent as text'
|
874
874
|
},
|
875
|
+
:'browser_monitoring.position' => {
|
876
|
+
:default => '',
|
877
|
+
:public => true,
|
878
|
+
:type => String,
|
879
|
+
:notified => true,
|
880
|
+
:description => 'position of page which is inerted JavaScript agent.'
|
881
|
+
},
|
875
882
|
:js_agent_loader => {
|
876
883
|
:default => '',
|
877
884
|
:public => false,
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module OneApm
|
4
|
+
module Agent
|
5
|
+
module Instrumentation
|
6
|
+
module ThriftHelper
|
7
|
+
|
8
|
+
def operator result_klass
|
9
|
+
namespaces = result_klass.to_s.split('::')
|
10
|
+
operator_name = 'unknown'
|
11
|
+
if namespaces.last =~ /_result/
|
12
|
+
operator_name = namespaces.last.sub('_result', '').downcase
|
13
|
+
end
|
14
|
+
operator_name
|
15
|
+
end
|
16
|
+
|
17
|
+
def thost
|
18
|
+
@thost ||= @iprot.instance_variable_get("@trans") \
|
19
|
+
.instance_variable_get("@transport") \
|
20
|
+
.instance_variable_get("@host") rescue nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def metrics operator_name
|
24
|
+
metrics = if thost.nil?
|
25
|
+
["External/Thrift/#{operator_name}"]
|
26
|
+
else
|
27
|
+
["External/#{thost}/Thrift/#{operator_name}", "External/#{thost}/all"]
|
28
|
+
end
|
29
|
+
metrics << "External/all"
|
30
|
+
if OneApm::Transaction.recording_web_transaction?
|
31
|
+
metrics << "External/allWeb"
|
32
|
+
else
|
33
|
+
metrics << "External/allOther"
|
34
|
+
end
|
35
|
+
metrics
|
36
|
+
end
|
37
|
+
|
38
|
+
def started_time op
|
39
|
+
_op_ = operations.delete(op)
|
40
|
+
(_op_ && _op_[:started_time]) or Time.now.to_f
|
41
|
+
end
|
42
|
+
|
43
|
+
def operations
|
44
|
+
@operations ||= {}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
LibraryDetection.defer do
|
52
|
+
named :thrift
|
53
|
+
|
54
|
+
depends_on do
|
55
|
+
defined?(::Thrift) && defined?(::Thrift::Client)
|
56
|
+
end
|
57
|
+
|
58
|
+
executes do
|
59
|
+
OneApm::Manager.logger.info 'Installing Thrift instrumentation'
|
60
|
+
end
|
61
|
+
|
62
|
+
executes do
|
63
|
+
::Thrift::Client.module_eval do
|
64
|
+
include OneApm::Agent::Instrumentation::ThriftHelper
|
65
|
+
|
66
|
+
def send_message_with_oneapm(name, args_class, args = {})
|
67
|
+
operations[name] = {:started_time => Time.now.to_f}
|
68
|
+
send_message_without_oneapm(name, args_class, args)
|
69
|
+
end
|
70
|
+
alias :send_message_without_oneapm :send_message
|
71
|
+
alias :send_message :send_message_with_oneapm
|
72
|
+
|
73
|
+
def send_oneway_message_with_oneapm(name, args_class, args = {})
|
74
|
+
op_started = Time.now.to_f
|
75
|
+
base, *other_metrics = metrics(name)
|
76
|
+
result = send_oneway_message_without_oneapm(name, args_class, args)
|
77
|
+
duration = Time.now.to_f - op_started
|
78
|
+
OneApm::Manager.agent.stats_engine.tl_record_scoped_and_unscoped_metrics(base, other_metrics, duration)
|
79
|
+
result
|
80
|
+
end
|
81
|
+
alias :send_oneway_message_without_oneapm :send_oneway_message
|
82
|
+
alias :send_oneway_message :send_oneway_message_with_oneapm
|
83
|
+
|
84
|
+
def receive_message_with_oneapm(result_klass)
|
85
|
+
op = operator(result_klass)
|
86
|
+
op_started = started_time(op)
|
87
|
+
base, *other_metrics = metrics(op)
|
88
|
+
result = receive_message_without_oneapm(result_klass)
|
89
|
+
duration = Time.now.to_f - op_started
|
90
|
+
OneApm::Manager.agent.stats_engine.tl_record_scoped_and_unscoped_metrics(base, other_metrics, duration)
|
91
|
+
result
|
92
|
+
end
|
93
|
+
|
94
|
+
alias :receive_message_without_oneapm :receive_message
|
95
|
+
alias :receive_message :receive_message_with_oneapm
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -64,13 +64,13 @@ module OneApm
|
|
64
64
|
base, *other_metrics = mertircs(event)
|
65
65
|
|
66
66
|
started_time = Time.now.to_f
|
67
|
-
frame = stack.push_frame(state, :mongo_tracer, started_time)
|
67
|
+
frame = stack.push_frame(state, :mongo_tracer, started_time - duration)
|
68
68
|
|
69
69
|
builder = state.transaction_sample_builder
|
70
70
|
format_sql = OneApm::Agent::Datastore::Mongo::CommandFormatter.format_sql(event, status)
|
71
71
|
OneApm::Manager.agent.transaction_sampler.send(:notice_extra_data, builder, format_sql, duration, :sql)
|
72
72
|
|
73
|
-
stack.pop_frame(state, frame, base, started_time
|
73
|
+
stack.pop_frame(state, frame, base, started_time)
|
74
74
|
end
|
75
75
|
|
76
76
|
def one_apm_notice_statement(event, status, duration)
|
@@ -80,13 +80,35 @@ module OneApm::Rack
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def autoinstrument_source(response, headers, js_to_inject)
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
begin
|
84
|
+
source = gather_source(response)
|
85
|
+
close_old_response(response)
|
86
|
+
return nil unless source
|
87
|
+
inject_js(source, headers, js_to_inject)
|
88
|
+
rescue => e
|
89
|
+
OneApm::Manager.logger.debug "Skipping RUM instrumentation on exception.", e
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
end
|
86
93
|
|
87
|
-
|
88
|
-
|
94
|
+
def inject_js source, headers, js_to_inject
|
95
|
+
position = OneApm::Manager.config[:'browser_monitoring.position']
|
96
|
+
insertion_index = (position.empty? || position.to_sym != :footer) ? header_index(source) : footer_index(source)
|
97
|
+
if insertion_index
|
98
|
+
source = source[0...insertion_index] \
|
99
|
+
<< js_to_inject \
|
100
|
+
<< source[insertion_index..-1]
|
101
|
+
if headers['Content-Length']
|
102
|
+
headers['Content-Length'] = calculate_content_length(source).to_s
|
103
|
+
end
|
104
|
+
else
|
105
|
+
OneApm::Manager.logger.debug "Skipping RUM instrumentation. Could not properly determine location to inject script."
|
106
|
+
end
|
107
|
+
source
|
108
|
+
end
|
89
109
|
|
110
|
+
def header_index source
|
111
|
+
beginning_of_source = source[0..SCAN_LIMIT]
|
90
112
|
if body_start = find_body_start(beginning_of_source)
|
91
113
|
meta_tag_positions = [
|
92
114
|
find_x_ua_compatible_position(beginning_of_source),
|
@@ -98,28 +120,24 @@ module OneApm::Rack
|
|
98
120
|
else
|
99
121
|
insertion_index = find_end_of_head_open(beginning_of_source) || body_start
|
100
122
|
end
|
101
|
-
|
102
|
-
if insertion_index
|
103
|
-
source = source[0...insertion_index] <<
|
104
|
-
js_to_inject <<
|
105
|
-
source[insertion_index..-1]
|
106
|
-
else
|
107
|
-
OneApm::Manager.logger.debug "Skipping RUM instrumentation. Could not properly determine location to inject script."
|
108
|
-
end
|
123
|
+
insertion_index
|
109
124
|
else
|
110
125
|
msg = "Skipping RUM instrumentation. Unable to find <body> tag in first #{SCAN_LIMIT} bytes of document."
|
111
126
|
OneApm::Manager.logger.log_once(:warn, :rum_insertion_failure, msg)
|
112
127
|
OneApm::Manager.logger.debug(msg)
|
128
|
+
nil
|
113
129
|
end
|
130
|
+
end
|
114
131
|
|
115
|
-
|
116
|
-
|
132
|
+
def footer_index source
|
133
|
+
if body_end = find_body_end(source)
|
134
|
+
body_end
|
135
|
+
else
|
136
|
+
msg = "Skipping RUM instrumentation. Unable to find </body> tag from document."
|
137
|
+
OneApm::Manager.logger.log_once(:warn, :rum_insertion_failure, msg)
|
138
|
+
OneApm::Manager.logger.debug(msg)
|
139
|
+
nil
|
117
140
|
end
|
118
|
-
|
119
|
-
source
|
120
|
-
rescue => e
|
121
|
-
OneApm::Manager.logger.debug "Skipping RUM instrumentation on exception.", e
|
122
|
-
nil
|
123
141
|
end
|
124
142
|
|
125
143
|
def gather_source(response)
|
@@ -140,6 +158,10 @@ module OneApm::Rack
|
|
140
158
|
beginning_of_source.index("<body")
|
141
159
|
end
|
142
160
|
|
161
|
+
def find_body_end source
|
162
|
+
source.rindex("</body>")
|
163
|
+
end
|
164
|
+
|
143
165
|
def find_x_ua_compatible_position(beginning_of_source)
|
144
166
|
match = X_UA_COMPATIBLE_RE.match(beginning_of_source)
|
145
167
|
match.end(0) if match
|
data/lib/one_apm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oneapm_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oneapm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -337,6 +337,7 @@ files:
|
|
337
337
|
- lib/one_apm/inst/http_clients/excon/middleware.rb
|
338
338
|
- lib/one_apm/inst/http_clients/httpclient.rb
|
339
339
|
- lib/one_apm/inst/http_clients/net.rb
|
340
|
+
- lib/one_apm/inst/http_clients/thrift.rb
|
340
341
|
- lib/one_apm/inst/http_clients/typhoeus.rb
|
341
342
|
- lib/one_apm/inst/nosql/memcache.rb
|
342
343
|
- lib/one_apm/inst/nosql/mongo.rb
|