appoptics_apm 4.3.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -1
- data/README.md +2 -2
- data/appoptics_apm.gemspec +1 -1
- data/ext/oboe_metal/src/VERSION +1 -1
- data/lib/appoptics_apm/api.rb +3 -1
- data/lib/appoptics_apm/config.rb +12 -5
- data/lib/appoptics_apm/inst/grpc_client.rb +11 -11
- data/lib/appoptics_apm/sdk/custom_metrics.rb +92 -0
- data/lib/appoptics_apm/{sdk.rb → sdk/tracing.rb} +3 -2
- data/lib/appoptics_apm/version.rb +2 -2
- data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +5 -5
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f55957c02fb447084c8430a6dff438ce8ff3725f1eaf755e1c0f9092f94360b0
|
4
|
+
data.tar.gz: 02a24b754db042ec253cefb0160217bb9d136a2ad360916630bc4413007b3786
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed5020f576a5ebc447bdfad639140373670cdc30ff50e5c8b379bdd3c1fab74b764eea21ef3f0e3a5670152f64daa07db6b08bf291bb0468ece448fc4f7f1399
|
7
|
+
data.tar.gz: f0d5f73b872b8d869b3308aff1180447f2a46f48039afa84f0ce8a43a2e06bdcaeb13fbca95453c9cc80988f93a85c1c534882b963e528ed0904195b6d75edb0
|
data/.yardopts
CHANGED
data/README.md
CHANGED
@@ -61,10 +61,10 @@ The appoptics_apm gem provides a Rails generator used to seed an initializer whe
|
|
61
61
|
To run the install generator run:
|
62
62
|
|
63
63
|
```bash
|
64
|
-
bundle exec rails generate
|
64
|
+
bundle exec rails generate appoptics_apm:install
|
65
65
|
```
|
66
66
|
|
67
|
-
After the prompts, this will create an initializer: `config/initializers/
|
67
|
+
After the prompts, this will create an initializer: `config/initializers/appoptics_apm.rb`.
|
68
68
|
|
69
69
|
## Sinatra
|
70
70
|
|
data/appoptics_apm.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.homepage = %q{https://www.appoptics.com/}
|
14
14
|
s.summary = %q{AppOptics APM performance instrumentation gem for Ruby}
|
15
15
|
s.description = <<-EOF
|
16
|
-
|
16
|
+
Automatic tracing and metrics for Ruby applications. Get started at appoptics.com. @AppOptics
|
17
17
|
EOF
|
18
18
|
|
19
19
|
s.metadata = {
|
data/ext/oboe_metal/src/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.3.0
|
data/lib/appoptics_apm/api.rb
CHANGED
@@ -10,9 +10,11 @@ module AppOpticsAPM
|
|
10
10
|
extend AppOpticsAPM::API::LayerInit
|
11
11
|
extend AppOpticsAPM::API::Util
|
12
12
|
|
13
|
-
require_relative './sdk'
|
13
|
+
require_relative './sdk/tracing'
|
14
|
+
require_relative './sdk/custom_metrics'
|
14
15
|
|
15
16
|
extend AppOpticsAPM::SDK::Tracing
|
17
|
+
extend AppOpticsAPM::SDK::CustomMetrics
|
16
18
|
extend AppOpticsAPM::API::Tracing
|
17
19
|
end
|
18
20
|
end
|
data/lib/appoptics_apm/config.rb
CHANGED
@@ -71,12 +71,19 @@ module AppOpticsAPM
|
|
71
71
|
# Oboe will override vars passed in if it finds an environment variable
|
72
72
|
# :debug_level and :verbose need special consideration, because they are used in Ruby
|
73
73
|
def self.check_env_vars
|
74
|
-
unless (
|
75
|
-
AppOpticsAPM::Config[:debug_level] =
|
74
|
+
unless (-1..6).include?(AppOpticsAPM::Config[:debug_level])
|
75
|
+
AppOpticsAPM::Config[:debug_level] = 3
|
76
|
+
end
|
77
|
+
|
78
|
+
# let's find and use the equivalent debug level for ruby
|
79
|
+
debug_level = ENV['APPOPTICS_DEBUG_LEVEL'] ? ENV['APPOPTICS_DEBUG_LEVEL'].to_i : AppOpticsAPM::Config[:debug_level]
|
80
|
+
if debug_level < 0
|
81
|
+
# there should be no logging if APPOPTICS_DEBUG_LEVEL == -1
|
82
|
+
# In Ruby level 5 is UNKNOWN and it can log, but level 6 is quiet
|
83
|
+
AppOpticsAPM.logger.level = 6
|
84
|
+
else
|
85
|
+
AppOpticsAPM.logger.level = [4 - debug_level, 0].max
|
76
86
|
end
|
77
|
-
# let's use the same debug level for ruby as well
|
78
|
-
debug_level = ENV['APPOPTICS_DEBUG_LEVEL'] || AppOpticsAPM::Config[:debug_level] || 3
|
79
|
-
AppOpticsAPM.logger.level = [4 - debug_level.to_i, 0].max
|
80
87
|
|
81
88
|
# the verbose setting is only relevant for ruby, ENV['APPOPTICS_GEM_VERBOSE'] overrides
|
82
89
|
if ENV.key?('APPOPTICS_GEM_VERBOSE')
|
@@ -37,7 +37,7 @@ module AppOpticsAPM
|
|
37
37
|
|
38
38
|
def server_streamer_with_appoptics(req, metadata: {}, &blk)
|
39
39
|
@tags = grpc_tags('SERVER_STREAMING', metadata[:method] || metadata_to_send[:method])
|
40
|
-
AppOpticsAPM::API.log_entry('
|
40
|
+
AppOpticsAPM::API.log_entry('grpc-client', @tags)
|
41
41
|
metadata['x-trace'] = AppOpticsAPM::Context.toString if AppOpticsAPM::Context.isValid
|
42
42
|
AppOpticsAPM::SDK.set_transaction_name(metadata[:method]) if AppOpticsAPM.transaction_name.nil?
|
43
43
|
|
@@ -49,15 +49,15 @@ module AppOpticsAPM
|
|
49
49
|
# this check is needed because the exception may have been logged in patch_receive_and_check_status
|
50
50
|
unless e.instance_variable_get(:@exn_logged)
|
51
51
|
context_from_incoming
|
52
|
-
AppOpticsAPM::API.log_exception('
|
53
|
-
AppOpticsAPM::API.log_exit('
|
52
|
+
AppOpticsAPM::API.log_exception('grpc-client', e)
|
53
|
+
AppOpticsAPM::API.log_exit('grpc-client', exit_tags(@tags))
|
54
54
|
end
|
55
55
|
raise e
|
56
56
|
end
|
57
57
|
|
58
58
|
def bidi_streamer_with_appoptics(req, metadata: {}, &blk)
|
59
59
|
@tags = grpc_tags('BIDI_STREAMING', metadata[:method] || metadata_to_send[:method])
|
60
|
-
AppOpticsAPM::API.log_entry('
|
60
|
+
AppOpticsAPM::API.log_entry('grpc-client', @tags)
|
61
61
|
metadata['x-trace'] = AppOpticsAPM::Context.toString if AppOpticsAPM::Context.isValid
|
62
62
|
AppOpticsAPM::SDK.set_transaction_name(metadata[:method]) if AppOpticsAPM.transaction_name.nil?
|
63
63
|
|
@@ -68,8 +68,8 @@ module AppOpticsAPM
|
|
68
68
|
rescue => e
|
69
69
|
unless e.instance_variable_get(:@exn_logged)
|
70
70
|
context_from_incoming
|
71
|
-
AppOpticsAPM::API.log_exception('
|
72
|
-
AppOpticsAPM::API.log_exit('
|
71
|
+
AppOpticsAPM::API.log_exception('grpc-client', e)
|
72
|
+
AppOpticsAPM::API.log_exit('grpc-client', exit_tags(@tags))
|
73
73
|
end
|
74
74
|
raise e
|
75
75
|
end
|
@@ -78,7 +78,7 @@ module AppOpticsAPM
|
|
78
78
|
|
79
79
|
def unary_response(req, type: , metadata: , without:)
|
80
80
|
tags = grpc_tags(type, metadata[:method] || metadata_to_send[:method])
|
81
|
-
AppOpticsAPM::SDK.trace('
|
81
|
+
AppOpticsAPM::SDK.trace('grpc-client', tags) do
|
82
82
|
metadata['x-trace'] = AppOpticsAPM::Context.toString if AppOpticsAPM::Context.isValid
|
83
83
|
AppOpticsAPM::SDK.set_transaction_name(metadata[:method]) if AppOpticsAPM.transaction_name.nil?
|
84
84
|
begin
|
@@ -96,10 +96,10 @@ module AppOpticsAPM
|
|
96
96
|
context_from_incoming
|
97
97
|
rescue => e
|
98
98
|
context_from_incoming
|
99
|
-
AppOpticsAPM::API.log_exception('
|
99
|
+
AppOpticsAPM::API.log_exception('grpc-client', e)
|
100
100
|
raise e
|
101
101
|
ensure
|
102
|
-
AppOpticsAPM::API.log_exit('
|
102
|
+
AppOpticsAPM::API.log_exit('grpc-client', exit_tags(@tags))
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -109,9 +109,9 @@ module AppOpticsAPM
|
|
109
109
|
return if status.nil?
|
110
110
|
context_from_incoming
|
111
111
|
if status.code > 0
|
112
|
-
AppOpticsAPM::API.log_exception('
|
112
|
+
AppOpticsAPM::API.log_exception('grpc-client', $!)
|
113
113
|
end
|
114
|
-
AppOpticsAPM::API.log_exit('
|
114
|
+
AppOpticsAPM::API.log_exit('grpc-client', exit_tags(@tags))
|
115
115
|
super
|
116
116
|
end
|
117
117
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2016 SolarWinds, LLC.
|
3
|
+
# All rights reserved.
|
4
|
+
#++
|
5
|
+
|
6
|
+
module AppOpticsAPM
|
7
|
+
module SDK
|
8
|
+
|
9
|
+
module CustomMetrics
|
10
|
+
|
11
|
+
# Send counts
|
12
|
+
#
|
13
|
+
# Use this method to report the number of times an action occurs. The metric counts reported are summed and flushed every 60 seconds.
|
14
|
+
#
|
15
|
+
# === Arguments:
|
16
|
+
#
|
17
|
+
# * +name+ (String) Name to be used for the metric. Must be 255 or fewer characters and consist only of A-Za-z0-9.:-*
|
18
|
+
# * +count+ (Integer, optional, default = 1): Count of actions being reported
|
19
|
+
# * +with_hostname+ (Boolean, optional, default = false): Indicates if the host name should be included as a tag for the metric
|
20
|
+
# * +tags_kvs+ (Hash, optional): List of key/value pairs to describe the metric. The key must be <= 64 characters, the value must be <= 255 characters, allowed characters: A-Za-z0-9.:-_
|
21
|
+
#
|
22
|
+
# === Example:
|
23
|
+
#
|
24
|
+
# class WorkTracker
|
25
|
+
# def counting(name, tags = {})
|
26
|
+
# yield # yield to where work is done
|
27
|
+
# AppOpticsAPM::SDK.increment_metric(name, 1, false, tags)
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# === Returns:
|
32
|
+
# * true on success, false on failure
|
33
|
+
#
|
34
|
+
def increment_metric(name, count = 1, with_hostname = false, tags_kvs = {})
|
35
|
+
with_hostname = with_hostname ? 1 : 0
|
36
|
+
tags, tags_count = make_tags(tags_kvs)
|
37
|
+
AppOpticsAPM::CustomMetrics.increment(name.to_s, count, with_hostname, nil, tags, tags_count) == 1
|
38
|
+
end
|
39
|
+
|
40
|
+
# Send values with counts
|
41
|
+
#
|
42
|
+
# Use this method to report a value for each or multiple counts. The metric values reported are aggregated and flushed every 60 seconds. The dashboard displays the average value per count.
|
43
|
+
#
|
44
|
+
# === Arguments:
|
45
|
+
#
|
46
|
+
# * +name+ (String) Name to be used for the metric. Must be 255 or fewer characters and consist only of A-Za-z0-9.:-*
|
47
|
+
# * +value+ (Numeric) Value to be added to the current sum
|
48
|
+
# * +count+ (Integer, optional, default = 1): Count of actions being reported
|
49
|
+
# * +with_hostname+ (Boolean, optional, default = false): Indicates if the host name should be included as a tag for the metric
|
50
|
+
# * +tags_kvs+ (Hash, optional): List of key/value pairs to describe the metric. The key must be <= 64 characters, the value must be <= 255 characters, allowed characters: A-Za-z0-9.:-_
|
51
|
+
#
|
52
|
+
# === Example:
|
53
|
+
#
|
54
|
+
# class WorkTracker
|
55
|
+
# def timing(name, tags = {})
|
56
|
+
# start = Time.now
|
57
|
+
# yield # yield to where work is done
|
58
|
+
# duration = Time.now - start
|
59
|
+
# AppOpticsAPM::SDK.increment_metric(name, duration, 1, false, tags)
|
60
|
+
# end
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
# === Returns:
|
64
|
+
# * true on success, false on failure
|
65
|
+
#
|
66
|
+
def summary_metric(name, value, count = 1, with_hostname = false, tags_kvs = {})
|
67
|
+
with_hostname = with_hostname ? 1 : 0
|
68
|
+
tags, tags_count = make_tags(tags_kvs)
|
69
|
+
AppOpticsAPM::CustomMetrics.summary(name.to_s, value, count, with_hostname, nil, tags, tags_count) == 1
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def make_tags(tags_kvs)
|
75
|
+
unless tags_kvs.is_a?(Hash)
|
76
|
+
AppOpticsAPM.logger.warn("[appoptics_apm/metrics] CustomMetrics received tags_kvs that are not a Hash (found #{tags_kvs.class}), setting tags_kvs = {}")
|
77
|
+
tags_kvs = {}
|
78
|
+
end
|
79
|
+
count = tags_kvs.size
|
80
|
+
tags = AppOpticsAPM::MetricTags.new(count)
|
81
|
+
|
82
|
+
tags_kvs.each_with_index do |(k, v), i|
|
83
|
+
tags.add(i, k.to_s, v.to_s)
|
84
|
+
end
|
85
|
+
|
86
|
+
[tags, count]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
extend CustomMetrics
|
91
|
+
end
|
92
|
+
end
|
@@ -127,7 +127,7 @@ module AppOpticsAPM
|
|
127
127
|
# end
|
128
128
|
#
|
129
129
|
# def handle_request_with_appoptics(request, response)
|
130
|
-
# start_trace('custom_trace', nil, :TransactionName => 'handle_request') do
|
130
|
+
# AppOpticsAPM::SDK.start_trace('custom_trace', nil, :TransactionName => 'handle_request') do
|
131
131
|
# handle_request(request, response)
|
132
132
|
# end
|
133
133
|
# end
|
@@ -161,7 +161,7 @@ module AppOpticsAPM
|
|
161
161
|
# end
|
162
162
|
#
|
163
163
|
# def handle_request_with_appoptics(request, response)
|
164
|
-
# start_trace_with_target('rails', request['X-Trace'], response) do
|
164
|
+
# AppOpticsAPM::SDK.start_trace_with_target('rails', request['X-Trace'], response) do
|
165
165
|
# handle_request(request, response)
|
166
166
|
# end
|
167
167
|
# end
|
@@ -307,5 +307,6 @@ module AppOpticsAPM
|
|
307
307
|
end
|
308
308
|
|
309
309
|
extend Tracing
|
310
|
+
|
310
311
|
end
|
311
312
|
end
|
@@ -27,17 +27,17 @@ if defined?(AppOpticsAPM::Config)
|
|
27
27
|
|
28
28
|
#
|
29
29
|
# Set APPOPTICS_DEBUG_LEVEL
|
30
|
-
# This
|
30
|
+
# This setting will be overridden if APPOPTICS_DEBUG_LEVEL is set as an environment variable.
|
31
31
|
#
|
32
32
|
# It sets the log level and takes the following values:
|
33
|
-
|
34
|
-
#
|
33
|
+
# -1 disabled, 0 fatal, 1 error, 2 warning, 3 info (the default), 4 debug low, 5 debug medium, 6 debug high.
|
34
|
+
# Values < -1 or > 6 will set the log level to the default (info).
|
35
35
|
#
|
36
36
|
AppOpticsAPM::Config[:debug_level] = 3
|
37
37
|
#
|
38
38
|
# :debug_level will be used in the c-extension of the gem and also mapped to the
|
39
|
-
# Ruby logger as FATAL, ERROR, WARN, INFO, or DEBUG
|
40
|
-
# The Ruby logger can afterwards be changed to a different level
|
39
|
+
# Ruby logger as DISABLED, FATAL, ERROR, WARN, INFO, or DEBUG
|
40
|
+
# The Ruby logger can afterwards be changed to a different level, e.g:
|
41
41
|
# AppOpticsAPM.logger.level = Logger::INFO
|
42
42
|
|
43
43
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appoptics_apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maia Engeli
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-11-
|
13
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -116,8 +116,10 @@ dependencies:
|
|
116
116
|
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: 1.5.0
|
119
|
-
description:
|
120
|
-
|
119
|
+
description: 'Automatic tracing and metrics for Ruby applications. Get started at
|
120
|
+
appoptics.com. @AppOptics
|
121
|
+
|
122
|
+
'
|
121
123
|
email: support@appoptics.com
|
122
124
|
executables:
|
123
125
|
- appoptics_apm_config
|
@@ -216,7 +218,8 @@ files:
|
|
216
218
|
- lib/appoptics_apm/noop/README.md
|
217
219
|
- lib/appoptics_apm/noop/context.rb
|
218
220
|
- lib/appoptics_apm/ruby.rb
|
219
|
-
- lib/appoptics_apm/sdk.rb
|
221
|
+
- lib/appoptics_apm/sdk/custom_metrics.rb
|
222
|
+
- lib/appoptics_apm/sdk/tracing.rb
|
220
223
|
- lib/appoptics_apm/support.rb
|
221
224
|
- lib/appoptics_apm/test.rb
|
222
225
|
- lib/appoptics_apm/thread_local.rb
|