appoptics_apm 4.6.0 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.yardopts +1 -0
- data/README.md +2 -2
- data/Rakefile +2 -2
- data/examples/SDK/01_basic_tracing.rb +2 -0
- data/ext/oboe_metal/extconf.rb +12 -2
- data/ext/oboe_metal/src/VERSION +1 -1
- data/lib/appoptics_apm/api.rb +2 -0
- data/lib/appoptics_apm/frameworks/rails.rb +1 -0
- data/lib/appoptics_apm/frameworks/rails/inst/logger_formatters.rb +27 -0
- data/lib/appoptics_apm/inst/grpc_client.rb +0 -3
- data/lib/appoptics_apm/inst/logger_formatter.rb +49 -0
- data/lib/appoptics_apm/inst/logging_log_event.rb +28 -0
- data/lib/appoptics_apm/inst/lumberjack_formatter.rb +13 -0
- data/lib/appoptics_apm/logger.rb +0 -30
- data/lib/appoptics_apm/noop/context.rb +1 -1
- data/lib/appoptics_apm/sdk/current_trace.rb +81 -0
- data/lib/appoptics_apm/sdk/logging.rb +37 -0
- data/lib/appoptics_apm/version.rb +1 -1
- data/lib/appoptics_apm/xtrace.rb +20 -7
- data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +32 -9
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dbff2f2eda2d2c65cf7dbac060957eb6505b3eba743f11dc415f6b06c67217cb
|
4
|
+
data.tar.gz: 6008d6151ab8eb3b29aa465ebb131eef38139d159587e35d5d68dd07de716104
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1247aa650e5ff98074d479248c01ff11c8b18f0c63dac47987f79b75efe7518987f43af8ce9adf63cf50df7b9f8d9024deb59da1b9d4b3bd9be56c9d70252114
|
7
|
+
data.tar.gz: 7196764529dfde97d4ca10871d9506a21e411454e5acdd0218945241de2acb22b1ece9e38876ed054d586ed695b276d602ebe116b1f08ff2cf5a98c9537fd5de
|
data/.yardopts
CHANGED
data/README.md
CHANGED
@@ -372,9 +372,9 @@ manually build this C extension for the gem to function.
|
|
372
372
|
To make this simpler, we've included a few rake tasks to automate this process:
|
373
373
|
|
374
374
|
```bash
|
375
|
+
rake clean # make sure no old stuff is around
|
376
|
+
rake fetch_ext_deps # download c-files
|
375
377
|
rake compile # Build the gem's c extension
|
376
|
-
rake distclean # Remove all built files and extensions
|
377
|
-
rake recompile # Rebuild the gem's c extension
|
378
378
|
```
|
379
379
|
|
380
380
|
To see the code related to the C extension, take a look at `ext/oboe_metal/extconf.rb` for details.
|
data/Rakefile
CHANGED
@@ -63,13 +63,13 @@ end
|
|
63
63
|
desc "Run all test suites defined by travis"
|
64
64
|
task "docker_tests" do
|
65
65
|
Dir.chdir('test/run_tests')
|
66
|
-
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh test')
|
66
|
+
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh test --remove-orphans')
|
67
67
|
end
|
68
68
|
|
69
69
|
desc "Start docker container for testing and debugging"
|
70
70
|
task "docker" do
|
71
71
|
Dir.chdir('test/run_tests')
|
72
|
-
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh bash')
|
72
|
+
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh bash --remove-orphans')
|
73
73
|
end
|
74
74
|
|
75
75
|
desc "Stop all containers that were started for testing and debugging"
|
data/ext/oboe_metal/extconf.rb
CHANGED
@@ -24,7 +24,18 @@ if ENV['APPOPTICS_FROM_S3'].to_s.downcase == 'true'
|
|
24
24
|
else
|
25
25
|
ao_path = File.join('https://files.appoptics.com/c-lib', version)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
|
+
ao_arch = 'x86_64'
|
29
|
+
if File.exist?('/etc/alpine-release')
|
30
|
+
version = open('/etc/alpine-release').read.chomp
|
31
|
+
ao_arch =
|
32
|
+
if Gem::Version.new(version) < Gem::Version.new('3.9')
|
33
|
+
'alpine-libressl-x86_64'
|
34
|
+
else # openssl
|
35
|
+
'alpine-x86_64'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
28
39
|
ao_clib = "liboboe-1.0-#{ao_arch}.so.0.0.0"
|
29
40
|
ao_item = File.join(ao_path, ao_clib)
|
30
41
|
ao_checksum_item = "#{ao_item}.sha256"
|
@@ -88,7 +99,6 @@ if success
|
|
88
99
|
create_makefile('oboe_noop', 'noop')
|
89
100
|
|
90
101
|
elsif have_library('oboe', 'oboe_config_get_revision', 'oboe.h')
|
91
|
-
|
92
102
|
$libs = append_library($libs, 'oboe')
|
93
103
|
$libs = append_library($libs, 'stdc++')
|
94
104
|
|
data/ext/oboe_metal/src/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.0
|
1
|
+
4.1.0
|
data/lib/appoptics_apm/api.rb
CHANGED
@@ -12,6 +12,8 @@ module AppOpticsAPM
|
|
12
12
|
|
13
13
|
require_relative './sdk/tracing'
|
14
14
|
require_relative './sdk/custom_metrics'
|
15
|
+
require_relative './sdk/current_trace'
|
16
|
+
require_relative './sdk/logging' # to make sure it is loaded <- not very elegant
|
15
17
|
|
16
18
|
extend AppOpticsAPM::SDK::Tracing
|
17
19
|
extend AppOpticsAPM::SDK::CustomMetrics
|
@@ -50,6 +50,7 @@ module AppOpticsAPM
|
|
50
50
|
require 'appoptics_apm/frameworks/rails/inst/action_view'
|
51
51
|
require 'appoptics_apm/frameworks/rails/inst/action_view_30'
|
52
52
|
require 'appoptics_apm/frameworks/rails/inst/active_record'
|
53
|
+
require 'appoptics_apm/frameworks/rails/inst/logger_formatters'
|
53
54
|
|
54
55
|
AppOpticsAPM.logger.info "[appoptics_apm/rails] AppOpticsAPM gem #{AppOpticsAPM::Version::STRING} successfully loaded."
|
55
56
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Copyright (c) 2019 SolarWinds, LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
if AppOpticsAPM.loaded && defined?(ActiveSupport::Logger::SimpleFormatter)
|
5
|
+
module ActiveSupport
|
6
|
+
class Logger
|
7
|
+
class SimpleFormatter
|
8
|
+
# even though SimpleFormatter inherits from Logger,
|
9
|
+
# this will not append traceId twice,
|
10
|
+
# because SimpleFormatter#call does not call super
|
11
|
+
prepend AppOpticsAPM::Logger::Formatter
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
if AppOpticsAPM.loaded && defined?(ActiveSupport::TaggedLogging::Formatter)
|
19
|
+
module ActiveSupport
|
20
|
+
module TaggedLogging
|
21
|
+
module Formatter
|
22
|
+
# TODO figure out ancestors situation
|
23
|
+
prepend AppOpticsAPM::Logger::Formatter
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -38,7 +38,6 @@ module AppOpticsAPM
|
|
38
38
|
@tags = grpc_tags('SERVER_STREAMING', metadata[:method] || metadata_to_send[:method])
|
39
39
|
AppOpticsAPM::API.log_entry('grpc-client', @tags)
|
40
40
|
metadata['x-trace'] = AppOpticsAPM::Context.toString if AppOpticsAPM::Context.isValid
|
41
|
-
AppOpticsAPM::SDK.set_transaction_name(metadata[:method]) if AppOpticsAPM.transaction_name.nil?
|
42
41
|
|
43
42
|
patch_receive_and_check_status # need to patch this so that log_exit can be called after the enum is consumed
|
44
43
|
|
@@ -58,7 +57,6 @@ module AppOpticsAPM
|
|
58
57
|
@tags = grpc_tags('BIDI_STREAMING', metadata[:method] || metadata_to_send[:method])
|
59
58
|
AppOpticsAPM::API.log_entry('grpc-client', @tags)
|
60
59
|
metadata['x-trace'] = AppOpticsAPM::Context.toString if AppOpticsAPM::Context.isValid
|
61
|
-
AppOpticsAPM::SDK.set_transaction_name(metadata[:method]) if AppOpticsAPM.transaction_name.nil?
|
62
60
|
|
63
61
|
patch_set_input_stream_done
|
64
62
|
|
@@ -79,7 +77,6 @@ module AppOpticsAPM
|
|
79
77
|
tags = grpc_tags(type, metadata[:method] || metadata_to_send[:method])
|
80
78
|
AppOpticsAPM::SDK.trace('grpc-client', tags) do
|
81
79
|
metadata['x-trace'] = AppOpticsAPM::Context.toString if AppOpticsAPM::Context.isValid
|
82
|
-
AppOpticsAPM::SDK.set_transaction_name(metadata[:method]) if AppOpticsAPM.transaction_name.nil?
|
83
80
|
begin
|
84
81
|
send(without, req, metadata: metadata)
|
85
82
|
ensure
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright (c) 2019 SolarWinds, LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
require 'logger'
|
5
|
+
|
6
|
+
module AppOpticsAPM
|
7
|
+
module Logger
|
8
|
+
module Formatter
|
9
|
+
|
10
|
+
def call(severity, time, progname, msg)
|
11
|
+
return super if AppOpticsAPM::Config[:log_traceId] == :never
|
12
|
+
|
13
|
+
msg = insert_trace_id(msg)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def insert_trace_id(msg)
|
20
|
+
return msg if msg =~ /ao(=>{:|\.){1}traceId/
|
21
|
+
|
22
|
+
current_trace = AppOpticsAPM::SDK.current_trace
|
23
|
+
if current_trace.log?
|
24
|
+
case msg
|
25
|
+
when ::String
|
26
|
+
msg.strip.empty? ? msg : insert_before_empty_lines(msg, current_trace.for_log)
|
27
|
+
when ::Exception
|
28
|
+
# conversion to String copied from Logger::Formatter private method #msg2str
|
29
|
+
"#{msg.message} (#{msg.class}) #{current_trace.for_log}\n" <<
|
30
|
+
(msg.backtrace || []).join("\n")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def insert_before_empty_lines(msg, for_log)
|
36
|
+
stripped = msg.rstrip
|
37
|
+
"#{stripped} #{for_log}#{msg[stripped.length..-1]}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
if AppOpticsAPM.loaded
|
44
|
+
class Logger
|
45
|
+
class Formatter
|
46
|
+
prepend AppOpticsAPM::Logger::Formatter
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (c) 2019 SolarWinds, LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
require_relative 'logger_formatter'
|
5
|
+
|
6
|
+
module AppOpticsAPM
|
7
|
+
module Logging
|
8
|
+
module LogEvent
|
9
|
+
include AppOpticsAPM::Logger::Formatter # provides #insert_trace_id
|
10
|
+
|
11
|
+
def initialize(logger, level, data, caller_tracing )
|
12
|
+
return super if AppOpticsAPM::Config[:log_traceId] == :never
|
13
|
+
|
14
|
+
data = insert_trace_id(data)
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if AppOpticsAPM.loaded && defined?(Logging::LogEvent)
|
23
|
+
module Logging
|
24
|
+
class LogEvent
|
25
|
+
prepend AppOpticsAPM::Logging::LogEvent
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Copyright (c) 2019 SolarWinds, LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
require_relative 'logger_formatter'
|
5
|
+
|
6
|
+
if AppOpticsAPM.loaded && defined?(Lumberjack::Formatter)
|
7
|
+
module Lumberjack
|
8
|
+
class Formatter
|
9
|
+
prepend AppOpticsAPM::Logger::Formatter
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
data/lib/appoptics_apm/logger.rb
CHANGED
@@ -7,38 +7,8 @@ module AppOpticsAPM
|
|
7
7
|
class << self
|
8
8
|
attr_accessor :logger
|
9
9
|
end
|
10
|
-
|
11
|
-
# TODO ME currently unused, keeping it around for xtrace logging epic
|
12
|
-
# class Logger
|
13
|
-
# # Fatal message
|
14
|
-
# def fatal(msg, exception = nil)
|
15
|
-
# AppOpticsAPM.logger.fatal(msg) if AppOpticsAPM.logger
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# # Error message
|
19
|
-
# def error(msg, exception = nil)
|
20
|
-
# AppOpticsAPM.logger.error(msg) if AppOpticsAPM.logger
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
# # Warn message
|
24
|
-
# def warn(msg, exception = nil)
|
25
|
-
# AppOpticsAPM.logger.warn(msg) if AppOpticsAPM.logger
|
26
|
-
# end
|
27
|
-
#
|
28
|
-
# # Info message
|
29
|
-
# def info(msg, exception = nil)
|
30
|
-
# AppOpticsAPM.logger.info(msg) if AppOpticsAPM.logger
|
31
|
-
# end
|
32
|
-
#
|
33
|
-
# # Debug message
|
34
|
-
# def debug(msg, exception = nil)
|
35
|
-
# AppOpticsAPM.logger.debug(msg) if AppOpticsAPM.logger
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
# end
|
39
10
|
end
|
40
11
|
|
41
|
-
# Using the currently defined Logger, e.g. the Rails logger
|
42
12
|
AppOpticsAPM.logger = Logger.new(STDERR)
|
43
13
|
# set log level to INFO to be consistent with the c-lib, DEBUG would be default
|
44
14
|
AppOpticsAPM.logger.level = Logger::INFO
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2019 SolarWinds, LLC.
|
3
|
+
# All rights reserved.
|
4
|
+
#++
|
5
|
+
|
6
|
+
module AppOpticsAPM
|
7
|
+
module SDK
|
8
|
+
|
9
|
+
module CurrentTrace
|
10
|
+
|
11
|
+
# Creates an instance of {TraceId} with instance methods {TraceId#id}, {TraceId#for_log}
|
12
|
+
# and {TraceId#hash_for_log}.
|
13
|
+
#
|
14
|
+
# === Example:
|
15
|
+
#
|
16
|
+
# trace = AppOpticsAPM::SDK.current_trace
|
17
|
+
# trace.id # '7435A9FE510AE4533414D425DADF4E180D2B4E36-0'
|
18
|
+
# trace.for_log # 'ao.traceId=7435A9FE510AE4533414D425DADF4E180D2B4E36-0' or '' depends on Config
|
19
|
+
# trace.hash_for_log # { ao: { traceId: '7435A9FE510AE4533414D425DADF4E180D2B4E36-0 } } or {} depends on Config
|
20
|
+
#
|
21
|
+
# Configure traceId injection with lograge:
|
22
|
+
#
|
23
|
+
# Lograge.custom_options = lambda do |event|
|
24
|
+
# AppOpticsAPM::SDK.current_trace.hash_for_log
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
def current_trace
|
28
|
+
TraceId.new
|
29
|
+
end
|
30
|
+
|
31
|
+
# @attr id the current traceId, it looks like: '7435A9FE510AE4533414D425DADF4E180D2B4E36-0'
|
32
|
+
# and ends in '-1' if the request is sampled and '-0' otherwise.
|
33
|
+
# Results in '0000000000000000000000000000000000000000-0'
|
34
|
+
# if the CurrentTrace instance was created outside of the context
|
35
|
+
# of a request.
|
36
|
+
class TraceId
|
37
|
+
attr_reader :id
|
38
|
+
|
39
|
+
def initialize
|
40
|
+
if AppOpticsAPM::Config[:log_traceId] == :never
|
41
|
+
@id = '0000000000000000000000000000000000000000-0'
|
42
|
+
else
|
43
|
+
@xtrace = AppOpticsAPM::Context.toString
|
44
|
+
task_id = AppOpticsAPM::XTrace.task_id(@xtrace)
|
45
|
+
sampled = AppOpticsAPM::XTrace.sampled?(@xtrace)
|
46
|
+
@id = "#{task_id}-#{sampled ? 1 : 0}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# for_log returns a string in the format 'traceId=<current_trace.id>' or ''.
|
51
|
+
# An empty string is returned depending on the setting for
|
52
|
+
# <tt>AppOpticsAPM::Config[:log_traceId]</tt>, which can be :never,
|
53
|
+
# :sampled, :traced, or :always.
|
54
|
+
#
|
55
|
+
def for_log
|
56
|
+
@for_log ||= log? ? "ao.traceId=#{@id}" : ''
|
57
|
+
end
|
58
|
+
|
59
|
+
def hash_for_log
|
60
|
+
@hash_for_log ||= log? ? { ao: { traceId: @id } } : {}
|
61
|
+
end
|
62
|
+
|
63
|
+
def log? # should the traceId be added to the log?
|
64
|
+
case AppOpticsAPM::Config[:log_traceId]
|
65
|
+
when :never, nil
|
66
|
+
false
|
67
|
+
when :always
|
68
|
+
AppOpticsAPM::XTrace.ok?(@xtrace)
|
69
|
+
when :traced
|
70
|
+
AppOpticsAPM::XTrace.valid?(@xtrace)
|
71
|
+
when :sampled
|
72
|
+
AppOpticsAPM::XTrace.sampled?(@xtrace)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
extend CurrentTrace
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Copyright (c) 2019 SolarWinds, LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
|
5
|
+
module AppOpticsAPM
|
6
|
+
module SDK
|
7
|
+
module Logging
|
8
|
+
|
9
|
+
# Log an information event in the current span
|
10
|
+
#
|
11
|
+
# a possible use-case is to collect extra information during the execution of a request
|
12
|
+
#
|
13
|
+
# === Arguments:
|
14
|
+
# * +opts+ - (optional) hash containing key/value pairs that will be reported with this span.
|
15
|
+
#
|
16
|
+
def log_info(opts)
|
17
|
+
AppOpticsAPM::API.log_info(AppOpticsAPM.layer, opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Log an exception/error event in the current span
|
21
|
+
#
|
22
|
+
# this may be helpful to track problems when an exception is rescued
|
23
|
+
#
|
24
|
+
# === Arguments:
|
25
|
+
# * +exception+ - an exception, must respond to :message and :backtrace
|
26
|
+
# * +opts+ - (optional) hash containing key/value pairs that will be reported with this span.
|
27
|
+
#
|
28
|
+
def log_exception(exception, opts)
|
29
|
+
AppOpticsAPM::API.log_exception(AppOpticsAPM.layer, exception, opts)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
extend Logging
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/appoptics_apm/xtrace.rb
CHANGED
@@ -5,12 +5,15 @@ module AppOpticsAPM
|
|
5
5
|
##
|
6
6
|
# Methods to act on, manipulate or investigate an X-Trace
|
7
7
|
# value
|
8
|
+
#
|
9
|
+
# TODO add unit tests
|
8
10
|
module XTrace
|
9
11
|
class << self
|
10
12
|
##
|
11
13
|
# AppOpticsAPM::XTrace.valid?
|
12
14
|
#
|
13
|
-
# Perform basic validation on a potential X-Trace
|
15
|
+
# Perform basic validation on a potential X-Trace Id
|
16
|
+
# returns true if it is from a valid context
|
14
17
|
#
|
15
18
|
def valid?(xtrace)
|
16
19
|
# Shouldn't be nil
|
@@ -20,9 +23,7 @@ module AppOpticsAPM
|
|
20
23
|
return false if (xtrace =~ /^2b0000000/i) == 0
|
21
24
|
|
22
25
|
# Valid X-Trace IDs have a length of 60 bytes and start with '2b'
|
23
|
-
|
24
|
-
|
25
|
-
true
|
26
|
+
xtrace.length == 60 && (xtrace =~ /^2b/i) == 0
|
26
27
|
rescue StandardError => e
|
27
28
|
AppOpticsAPM.logger.debug "[appoptics_apm/xtrace] #{e.message}"
|
28
29
|
AppOpticsAPM.logger.debug e.backtrace
|
@@ -33,12 +34,23 @@ module AppOpticsAPM
|
|
33
34
|
valid?(xtrace) && xtrace[59].to_i & 1 == 1
|
34
35
|
end
|
35
36
|
|
37
|
+
def ok?(xtrace)
|
38
|
+
# Valid X-Trace IDs have a length of 60 bytes and start with '2b'
|
39
|
+
xtrace && xtrace.length == 60 && (xtrace =~ /^2b/i) == 0
|
40
|
+
rescue StandardError => e
|
41
|
+
AppOpticsAPM.logger.debug "[appoptics_apm/xtrace] #{e.message}"
|
42
|
+
AppOpticsAPM.logger.debug e.backtrace
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
36
46
|
def set_sampled(xtrace)
|
37
47
|
xtrace[59] = (xtrace[59].hex | 1).to_s(16).upcase
|
48
|
+
xtrace
|
38
49
|
end
|
39
50
|
|
40
51
|
def unset_sampled(xtrace)
|
41
52
|
xtrace[59] = (~(~xtrace[59].hex | 1)).to_s(16).upcase
|
53
|
+
xtrace
|
42
54
|
end
|
43
55
|
|
44
56
|
##
|
@@ -47,7 +59,7 @@ module AppOpticsAPM
|
|
47
59
|
# Extract and return the task_id portion of an X-Trace ID
|
48
60
|
#
|
49
61
|
def task_id(xtrace)
|
50
|
-
return nil unless
|
62
|
+
return nil unless ok?(xtrace)
|
51
63
|
|
52
64
|
xtrace[2..41]
|
53
65
|
rescue StandardError => e
|
@@ -79,7 +91,7 @@ module AppOpticsAPM
|
|
79
91
|
# across servers and applications.
|
80
92
|
#
|
81
93
|
# Remote requests can return a X-Trace header in which case we want
|
82
|
-
# to pickup
|
94
|
+
# to pickup and continue the context in most cases.
|
83
95
|
#
|
84
96
|
# +start+ is the context just before the outgoing request
|
85
97
|
# +finish+ is the context returned to us (as an HTTP response header
|
@@ -90,7 +102,8 @@ module AppOpticsAPM
|
|
90
102
|
|
91
103
|
# Assure that we received back a valid X-Trace with the same task_id
|
92
104
|
# and the sampling bit is set, otherwise it is a response from a non-sampling service
|
93
|
-
if AppOpticsAPM::XTrace.task_id(start) == AppOpticsAPM::XTrace.task_id(finish) &&
|
105
|
+
if AppOpticsAPM::XTrace.task_id(start) == AppOpticsAPM::XTrace.task_id(finish) &&
|
106
|
+
AppOpticsAPM::XTrace.sampled?(finish)
|
94
107
|
AppOpticsAPM::Context.fromString(finish)
|
95
108
|
else
|
96
109
|
AppOpticsAPM.logger.debug "[XTrace] Sampling flag unset or mismatched start and finish ids:\n#{start}\n#{finish}"
|
@@ -54,17 +54,37 @@ if defined?(AppOpticsAPM::Config)
|
|
54
54
|
#
|
55
55
|
# By default tracing is set to :enabled, the other option is :disabled.
|
56
56
|
# :enabled means that sampling will be done according to the current
|
57
|
-
# sampling rate
|
57
|
+
# sampling rate and metrics are reported.
|
58
|
+
# :disabled means that there is no sampling and metrics are not reported.
|
58
59
|
#
|
59
60
|
# The values :always and :never are deprecated
|
60
61
|
#
|
61
62
|
AppOpticsAPM::Config[:tracing_mode] = :enabled
|
62
63
|
|
64
|
+
#
|
65
|
+
# Trace Context in Logs
|
66
|
+
#
|
67
|
+
# Configure if and when the traceId should be included in application logs.
|
68
|
+
# Common Ruby and Rails loggers are auto-instrumented, so that they can include
|
69
|
+
# the current traceId in log messages.
|
70
|
+
#
|
71
|
+
# The added string will look like: "ao.traceId=7435A9FE510AE4533414D425DADF4E180D2B4E36-0"
|
72
|
+
# It ends in '-1' if the request is sampled and in '-0' otherwise.
|
73
|
+
#
|
74
|
+
# The following options are available:
|
75
|
+
# :never (default)
|
76
|
+
# :sampled only include the traceId of sampled requests
|
77
|
+
# :traced include the traceId for all traced requests
|
78
|
+
# :always always add a traceId, it will be '0000000000000000000000000000000000000000-0'
|
79
|
+
# when there is no tracing context.
|
80
|
+
#
|
81
|
+
AppOpticsAPM::Config[:log_traceId] = :never
|
82
|
+
|
63
83
|
#
|
64
84
|
# Prepend domain to transaction name
|
65
85
|
#
|
66
86
|
# If this is set to `true` transaction names will be composed as `my.host.com/controller.action` instead of
|
67
|
-
# `controller.action`. This configuration applies to all transaction names, whether
|
87
|
+
# `controller.action`. This configuration applies to all transaction names, whether deduced by the instrumentation
|
68
88
|
# or implicitly set.
|
69
89
|
#
|
70
90
|
AppOpticsAPM::Config[:transaction_name][:prepend_domain] = false
|
@@ -87,9 +107,8 @@ if defined?(AppOpticsAPM::Config)
|
|
87
107
|
# Please comment out if no filtering is desired, e.g. your static
|
88
108
|
# assets are served by the web server and not the application
|
89
109
|
#
|
90
|
-
# This configuration allows creating a regexp for paths
|
91
|
-
#
|
92
|
-
# with outbound calls, for which metrics and traces aren't desired either.
|
110
|
+
# This configuration allows creating a regexp for paths that should be excluded
|
111
|
+
# from appoptics processing.
|
93
112
|
#
|
94
113
|
# For example:
|
95
114
|
# - static assets that aren't served by the web server, or
|
@@ -120,10 +139,14 @@ if defined?(AppOpticsAPM::Config)
|
|
120
139
|
# The matching of settings to urls happens before routes are applied.
|
121
140
|
# The url is extracted from the env argument passed to rack: `env['PATH_INFO']`
|
122
141
|
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
# :
|
126
|
-
#
|
142
|
+
# and the hashes within the :url list either:
|
143
|
+
# :extensions takes an array of strings for filtering (not regular expressions!)
|
144
|
+
# :tracing defaults to :disabled, can be set to :enabled to override
|
145
|
+
# the global :disabled setting
|
146
|
+
# or:
|
147
|
+
# :regexp is a regular expression that is applied to the incoming path
|
148
|
+
# :opts (optional) nil(default) or Regexp::IGNORECASE (options for regexp)
|
149
|
+
# :tracing defaults to :disabled, can be set to :enabled to override
|
127
150
|
# the global :disabled setting
|
128
151
|
#
|
129
152
|
# Be careful not to add too many :regexp configurations as they will slow
|
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.7.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: 2019-
|
13
|
+
date: 2019-04-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- lib/appoptics_apm/frameworks/rails/inst/connection_adapters/postgresql.rb
|
171
171
|
- lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils.rb
|
172
172
|
- lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x.rb
|
173
|
+
- lib/appoptics_apm/frameworks/rails/inst/logger_formatters.rb
|
173
174
|
- lib/appoptics_apm/frameworks/sinatra.rb
|
174
175
|
- lib/appoptics_apm/inst/bunny-client.rb
|
175
176
|
- lib/appoptics_apm/inst/bunny-consumer.rb
|
@@ -183,6 +184,9 @@ files:
|
|
183
184
|
- lib/appoptics_apm/inst/grpc_server.rb
|
184
185
|
- lib/appoptics_apm/inst/http.rb
|
185
186
|
- lib/appoptics_apm/inst/httpclient.rb
|
187
|
+
- lib/appoptics_apm/inst/logger_formatter.rb
|
188
|
+
- lib/appoptics_apm/inst/logging_log_event.rb
|
189
|
+
- lib/appoptics_apm/inst/lumberjack_formatter.rb
|
186
190
|
- lib/appoptics_apm/inst/memcached.rb
|
187
191
|
- lib/appoptics_apm/inst/mongo.rb
|
188
192
|
- lib/appoptics_apm/inst/mongo2.rb
|
@@ -205,7 +209,9 @@ files:
|
|
205
209
|
- lib/appoptics_apm/noop/context.rb
|
206
210
|
- lib/appoptics_apm/noop/metadata.rb
|
207
211
|
- lib/appoptics_apm/ruby.rb
|
212
|
+
- lib/appoptics_apm/sdk/current_trace.rb
|
208
213
|
- lib/appoptics_apm/sdk/custom_metrics.rb
|
214
|
+
- lib/appoptics_apm/sdk/logging.rb
|
209
215
|
- lib/appoptics_apm/sdk/tracing.rb
|
210
216
|
- lib/appoptics_apm/support/transaction_metrics.rb
|
211
217
|
- lib/appoptics_apm/support/transaction_settings.rb
|
@@ -248,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
254
|
version: '0'
|
249
255
|
requirements: []
|
250
256
|
rubyforge_project:
|
251
|
-
rubygems_version: 2.
|
257
|
+
rubygems_version: 2.7.3
|
252
258
|
signing_key:
|
253
259
|
specification_version: 4
|
254
260
|
summary: AppOptics APM performance instrumentation gem for Ruby
|