raygun-apm 1.1.15.pre3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 169ec3c65a1da8b111da8d8243528c5872e393e297ff0217f819f2552197803a
4
+ data.tar.gz: 24c62f1e9eb639b01867815ea1e04c62f91a2e7237fefc3ab7ccf0dd2266d04a
5
+ SHA512:
6
+ metadata.gz: a598b36d21fdb353ab900e3cfef05e1cb2f54c0b8d8608ab9623061c62fd015f51bff58d38fb39a261095ba705561ca44e3aa71a08355cd7285bc2400d502baa
7
+ data.tar.gz: ee7b78f9715fa35821c6b5216c059abd7926502b204e48697cd8f67b20c2646f6b295fefd17636c4b44599ba79799c194f1994c3ead7676435a2cc8352cd1be1
data/COPYING.rax ADDED
@@ -0,0 +1,9 @@
1
+ Copyright (c) 2017, Salvatore Sanfilippo <antirez@gmail.com>
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Raygun Limited
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ This software bundles Rax, an open source project, released under the BSD two
24
+ clause license here https://github.com/antirez/rax/blob/master/COPYING
25
+
26
+ This software also bundles bipbuffer, an open source project, released under
27
+ the BSD license here https://github.com/willemt/bipbuffer/blob/master/LICENSE
data/LICENSE.bipbuffer ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2011, Willem-Hendrik Thiart
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * The names of its contributors may not be used to endorse or promote
12
+ products derived from this software without specific prior written
13
+ permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL WILLEM-HENDRIK THIART BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.rdoc ADDED
@@ -0,0 +1,118 @@
1
+ = Raygun Application Performance Monitoring
2
+
3
+ Ruby Profiler for {Raygun Application Performance Monitoring}[https://raygun.com/documentation/language-guides/ruby/apm/installation/].
4
+
5
+ Distributed as a precompiled native gem.
6
+
7
+ == Supported platforms
8
+
9
+ * x86-mingw32
10
+ * x64-mingw32
11
+ * x86-linux
12
+ * x86_64-linux
13
+ * universal-darwin
14
+
15
+ {Contact us}[https://raygun.com/about/contact] to support other platforms.
16
+
17
+ == Supported Ruby versions
18
+
19
+ The profiler only supports CRuby, also known as Matz's Ruby Interpreter (MRI).
20
+
21
+ * 2.5.x
22
+ * 2.6.x
23
+ * 2.7.x
24
+ * 3.0.x
25
+
26
+ {Contact us}[https://raygun.com/about/contact] to support other Ruby versions.
27
+
28
+ == Agent Setup
29
+
30
+ The Profiler needs to be able to access the Raygun Agent over UDP.
31
+
32
+ === Dockerized Agent
33
+
34
+ The {Dockerized Agent}[https://raygun.com/documentation/product-guides/apm/agent/installation] is supported on all Ruby profiler platforms. We recommend
35
+ this deployment model if your production infrastructure already depends on Docker.
36
+
37
+ Also a great way to explore on your Mac.
38
+
39
+ The <code>RAYGUN_AGENT_TOKEN</code> needs to be supplied as an argument and is available under "Application Settings" within the {Raygun Application Performance Monitoring}[https://raygun.com/platform/apm] UI
40
+
41
+ To launch Raygun Agent using docker
42
+ docker pull raygunowner/raygun-apm
43
+ docker run -v raygun-agent:/usr/share/Raygun -e "RAYGUN_AGENT_TOKEN=<token>" -p 2790:2790 -p 2788:2788 -p 2799:2799/udp -it raygunowner/raygun-apm:latest
44
+
45
+ === Linux Agent
46
+
47
+ The Linux version can be installed either using {systemd}[https://raygun.com/documentation/product-guides/apm/agent/installation/#installing-on-linux-using-systemd] or via {terminal}[https://raygun.com/documentation/product-guides/apm/agent/installation/#installing-on-linux-using-terminal]
48
+
49
+ === Windows Agent
50
+
51
+ On windows the agent can be installed either via {MSI installer}[https://raygun.com/documentation/product-guides/apm/agent/installation/#installing-on-linux-using-terminal] or on {.NET core}[https://raygun.com/documentation/product-guides/apm/agent/installation/#installing-on-windows-net-core]
52
+
53
+ == Ruby on Rails
54
+
55
+ For Rails support see {documentation}[https://www.rubydoc.info/gems/raygun-apm-rails/0.1.0] of the railgun-apm-rails gem.
56
+
57
+ == Profiler Setup
58
+
59
+ Include the gem in your Gemfile
60
+
61
+ gem 'raygun-apm'
62
+
63
+ Run <code>bundle</code> to install the gem.
64
+
65
+ Alternatively install using rubygems <code>gem install raygun-apm</code>.
66
+
67
+ === Profiler configration
68
+
69
+ ==== Multiple applications, one Agent
70
+
71
+ Set the `PROTON_API_KEY` environment variable to your API key, which is available under "Application Settings" within the {Raygun Application Performance Monitoring}[https://raygun.com/platform/apm] UI.
72
+
73
+ === Standalone ruby script / custom framework
74
+
75
+ For standalone scripts, context start-end needs to be marked specifically and optionally extended events can be called.
76
+
77
+ #!/usr/bin/env ruby
78
+ require 'raygun/apm'
79
+
80
+ class Hello
81
+ def rdoc
82
+ sleep 0.5
83
+ end
84
+ end
85
+
86
+ tracer = Raygun::Apm::Tracer.new
87
+ tracer.udp_sink!
88
+ tracer.start_trace
89
+ Hello.new.rdoc
90
+ tracer.end_trace
91
+ tracer.process_ended
92
+
93
+ Extended events can be sent where appropiate
94
+
95
+ <code>HTTP incoming event</code>
96
+
97
+ event = Raygun::Apm::Event::HttpIn.new
98
+ event[:pid] = Process.pid
99
+ event[:tid] = 0
100
+ event[:timestamp] = tracer.now
101
+ event[:url] = 'https://google.com/'
102
+ event[:verb] = 'GET'
103
+ event[:status] = 200
104
+ event[:duration] = 1000
105
+ tracer.emit(event)
106
+
107
+ <code>SQL query</code>
108
+
109
+ event = Raygun::Apm::Event::Sql.new
110
+ event[:pid] = Process.pid
111
+ event[:tid] = 0
112
+ event[:timestamp] = tracer.now
113
+ event[:provider] = 'postgres'
114
+ event[:host] = 'localhost'
115
+ event[:database] = 'rails'
116
+ event[:query] = 'SELECT * from FOO;'
117
+ event[:duration] = 1000
118
+ tracer.emit(event)
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "raygun/apm"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/rake ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("rake", "rake")
data/bin/rake.cmd ADDED
@@ -0,0 +1,30 @@
1
+ @ruby -x "%~f0" %*
2
+ @exit /b %ERRORLEVEL%
3
+
4
+ #!/usr/bin/env ruby
5
+ # frozen_string_literal: true
6
+
7
+ #
8
+ # This file was generated by Bundler.
9
+ #
10
+ # The application 'rake' is installed as part of a gem, and
11
+ # this file is here to facilitate running it.
12
+ #
13
+
14
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
15
+
16
+ bundle_binstub = File.expand_path("bundle", __dir__)
17
+
18
+ if File.file?(bundle_binstub)
19
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
20
+ load(bundle_binstub)
21
+ else
22
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
23
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
24
+ end
25
+ end
26
+
27
+ require "rubygems"
28
+ require "bundler/setup"
29
+
30
+ load Gem.bin_path("rake", "rake")
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "raygun/apm"
5
+
6
+ tracer = Raygun::Apm::Tracer.new
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,114 @@
1
+ # encoding: utf-8
2
+
3
+ # Makefile generator helper - from standard library
4
+ require 'mkmf'
5
+
6
+ # References core headers extracted by Ruby minor version in https://github.com/os97673/debase-ruby_core_source
7
+ # Required for some of the lower level profiler features (vm_core.h, rb_thread_t, etc.)
8
+ begin
9
+ require 'debase/ruby_core_source'
10
+ rescue LoadError => e
11
+ STDERR.puts "=" * 70
12
+ STDERR.puts "Raygun APM: Failed to load debase-ruby_core_source"
13
+ STDERR.puts ""
14
+ STDERR.puts "This gem is required to compile the native extension against Ruby VM internals."
15
+ STDERR.puts "Please ensure debase-ruby_core_source >= 3.3.6 is installed:"
16
+ STDERR.puts ""
17
+ STDERR.puts " gem install debase-ruby_core_source"
18
+ STDERR.puts ""
19
+ STDERR.puts "Error: #{e.message}"
20
+ STDERR.puts "=" * 70
21
+ exit(1)
22
+ end
23
+
24
+ # Verify we have headers for the current Ruby version
25
+ ruby_version = "#{RUBY_VERSION}"
26
+ STDERR.puts "[Raygun APM] Building native extension for Ruby #{ruby_version}"
27
+
28
+ headers = proc do
29
+ have_header('ruby.h') &&
30
+ have_header('ruby/debug.h') &&
31
+ have_header("vm_core.h")
32
+ end
33
+
34
+ dir_config('raygun')
35
+
36
+ # To allow for swapping out the compiler - clang in favour of gcc for example
37
+ RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
38
+
39
+ # Pedantic about all the things
40
+ append_cflags '-pedantic'
41
+ append_cflags '-Wall'
42
+ append_cflags '-std=c99'
43
+ append_cflags '-std=gnu99'
44
+ append_cflags '-fdeclspec'
45
+ append_cflags '-fms-extensions'
46
+ append_cflags '-ggdb3'
47
+
48
+ # Check if using clang (supports more warning flags)
49
+ is_clang = RbConfig::CONFIG['CC'] =~ /clang/ || `#{RbConfig::CONFIG['CC']} --version 2>/dev/null`.include?('clang')
50
+
51
+ if is_clang
52
+ # Clang-specific warning suppressions
53
+ append_cflags '-Wno-shorten-64-to-32'
54
+ append_cflags '-Wno-unknown-warning-option'
55
+ append_cflags '-Wno-incompatible-pointer-types-discards-qualifiers'
56
+ append_cflags '-Wno-self-assign'
57
+ append_cflags '-Wno-parentheses-equality'
58
+ append_cflags '-Wno-constant-logical-operand'
59
+ else
60
+ # GCC 12+ use-after-free false positive in third-party rax.c
61
+ append_cflags '-Wno-use-after-free'
62
+ end
63
+
64
+ # Only use -Werror in CI/development, not in production builds
65
+ if ENV['WERROR'] || ENV['CI']
66
+ append_cflags '-Werror'
67
+ end
68
+
69
+ # Enables additional flags, stack protection and debug symbols
70
+ if ENV['DEBUG']
71
+ have_library 'ssp'
72
+ have_func '__stack_chk_guard'
73
+ have_func '__stack_chk_fail'
74
+ append_cflags '-ggdb3'
75
+ # Needed reduced -On levels for SSP to do its job.
76
+ # Used to be -O0 but switched to -Og since -O0 disables
77
+ # some optimizations that debug tools need.
78
+ # https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
79
+ append_cflags '-Og'
80
+ append_cflags '-fstack-protector-all'
81
+ append_cflags '-DRB_RG_DEBUG'
82
+ else
83
+ append_cflags '-O3'
84
+ end
85
+
86
+ # Renders an ASCII presentation of the shadow stack at runtime
87
+ if ENV['DEBUG_SHADOW_STACK']
88
+ append_cflags '-DRB_RG_DEBUG_SHADOW_STACK'
89
+ end
90
+
91
+ unless create_header
92
+ STDERR.print("extconf.h creation failed\n")
93
+ exit(1)
94
+ end
95
+
96
+ # Check for the presence of headers in ruby_core_headers for the version currently compiled for
97
+ unless Debase::RubyCoreSource.create_makefile_with_core(headers, 'raygun_ext')
98
+ STDERR.puts "=" * 70
99
+ STDERR.puts "Raygun APM: Makefile creation failed"
100
+ STDERR.puts ""
101
+ STDERR.puts "One or more Ruby VM headers (vm_core.h) were not found for Ruby #{ruby_version}."
102
+ STDERR.puts ""
103
+ STDERR.puts "This usually means debase-ruby_core_source does not yet have headers"
104
+ STDERR.puts "for your Ruby version. Please try updating the gem:"
105
+ STDERR.puts ""
106
+ STDERR.puts " gem update debase-ruby_core_source"
107
+ STDERR.puts ""
108
+ STDERR.puts "If the problem persists, please report this issue at:"
109
+ STDERR.puts " https://github.com/MindscapeHQ/raygun-apm-ruby/issues"
110
+ STDERR.puts "=" * 70
111
+ exit(1)
112
+ end
113
+
114
+ STDERR.puts "[Raygun APM] Native extension configured successfully"
@@ -0,0 +1,49 @@
1
+ module Raygun
2
+ module Apm
3
+ module Blacklist
4
+ class Parser
5
+ COMMENT = /^#[^<].*/
6
+ ANONYMOUS = /^#<.*:.*>?/
7
+
8
+ def initialize(tracer)
9
+ @tracer = tracer
10
+ @translator = Blacklist::Translator.new
11
+ end
12
+
13
+ def add_filters(filters)
14
+ filters.each do |filter|
15
+ filter.strip!
16
+ add_filter(filter)
17
+ end
18
+ show_filters
19
+ end
20
+
21
+ private
22
+ def add_filter(filter)
23
+ if filter =~ COMMENT && filter !~ ANONYMOUS
24
+ return
25
+ end
26
+ if filter.start_with?('+')
27
+ @tracer.add_whitelist(*translate(filter[1..-1]))
28
+ elsif filter.start_with?('-')
29
+ @tracer.add_blacklist(*translate(filter[1..-1]))
30
+ elsif filter.start_with?('L-')
31
+ @tracer.add_blacklist(*translate(filter[2..-1]))
32
+ elsif filter.size > 0
33
+ @tracer.add_blacklist(*translate(filter))
34
+ end
35
+ rescue => e
36
+ puts "Failed to add line '#{filter}' to the blacklist (#{e}) #{e.backtrace.join("\n")}"
37
+ end
38
+
39
+ def show_filters
40
+ @tracer.show_filters if @tracer.config.loglevel == Tracer::LOG_BLACKLIST
41
+ end
42
+
43
+ def translate(filter)
44
+ @translator.translate(filter)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,79 @@
1
+ module Raygun
2
+ module Apm
3
+ module Blacklist
4
+ class Translator
5
+ class RubyTranslator
6
+ # Foo::Bar#baz
7
+ # Foo::Bar.baz
8
+ # Foo::Bar::baz
9
+ COMMENT = /^#.*/
10
+ ANONYMOUS = /^#<.*>?/
11
+ NAMESPACE = /::/
12
+ NAMESPACE_ONLY = /::$/
13
+ METHOD = /#|\./
14
+ LETTER_CASE = /^[A-Z]/
15
+ LOWER_CASE = /^[a-z]/
16
+
17
+ def translate(filter)
18
+ path, method = nil, nil
19
+ if filter !~ COMMENT && filter !~ ANONYMOUS
20
+ if filter.end_with?("#")
21
+ path = filter
22
+ else
23
+ path, method = filter.split(METHOD)
24
+ end
25
+ # .NET fallback
26
+ return if method =~ LETTER_CASE && !method.start_with?("Ruby")
27
+ if path == path.downcase
28
+ method = path
29
+ path = nil
30
+ end
31
+
32
+ # .NET fallback
33
+ return if method =~ NAMESPACE
34
+ if path && (_method = path.split(NAMESPACE).last) =~ LOWER_CASE
35
+ method = _method
36
+ path.gsub!(Regexp.compile("::#{method}$"), "")
37
+ end
38
+ [path, method]
39
+ elsif filter =~ ANONYMOUS
40
+ _, klass, method = filter.split(METHOD)
41
+ ["##{klass}", method]
42
+ else
43
+ nil
44
+ end
45
+ end
46
+ end
47
+
48
+ # References https://raygun.com/documentation/product-guides/apm/blacklist/
49
+ class DotnetTranslator
50
+ # Foo.Bar::Baz
51
+ COMMENT = /^#/
52
+ NAMESPACE = /\./
53
+ METHOD = /::/
54
+
55
+ def translate(filter)
56
+ if filter !~ COMMENT
57
+ path, method = nil, nil
58
+ path, method = filter.split(METHOD)
59
+ path.gsub!(NAMESPACE, "::")
60
+ [path, method]
61
+ else
62
+ nil
63
+ end
64
+ end
65
+ end
66
+
67
+ def initialize
68
+ @ruby = RubyTranslator.new
69
+ @dotnet = DotnetTranslator.new
70
+ end
71
+
72
+ def translate(filter)
73
+ translated = @ruby.translate(filter)
74
+ translated ? translated : @dotnet.translate(filter)
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end