ruby-static-tracing 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby-static-tracing.rb +0 -1
- data/lib/ruby-static-tracing/provider.rb +5 -10
- data/lib/ruby-static-tracing/tracepoint.rb +12 -0
- data/lib/ruby-static-tracing/tracer/base.rb +5 -2
- data/lib/ruby-static-tracing/tracer/latency.rb +3 -1
- data/lib/ruby-static-tracing/tracer/stack.rb +2 -1
- data/lib/ruby-static-tracing/version.rb +1 -1
- data/lib/tasks/docker.rb +84 -0
- data/lib/tasks/vagrant.rb +33 -0
- metadata +4 -3
- data/lib/ruby-static-tracing/tracepoints.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a43ab444f18179cf5d5cdcd677d5a2043a0849adaa4df605920f9869ed0191e
|
4
|
+
data.tar.gz: 49086fa125a903a9f48923ba22de6999fa01f87dde54e35dc5064941155135d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d987dcb22dd0fbcf4294f6ba33792d383c289c52a241fd2579f36669330fc6935b928de947c9e51e48f9b22f751a79cb0a22be6ec7005605ebcb2e209f6c9f5
|
7
|
+
data.tar.gz: f11c5777711c104064de7664ce784a7e84fb1924b539011cf4bde22572eb62d432f31c83b024d4fe7401753a0621ce03fcb29d1ed5e42955f00e31b5ff83c414
|
data/lib/ruby-static-tracing.rb
CHANGED
@@ -6,7 +6,6 @@ require 'ruby-static-tracing/version'
|
|
6
6
|
require 'ruby-static-tracing/platform'
|
7
7
|
require 'ruby-static-tracing/provider'
|
8
8
|
require 'ruby-static-tracing/tracepoint'
|
9
|
-
require 'ruby-static-tracing/tracepoints'
|
10
9
|
require 'ruby-static-tracing/configuration'
|
11
10
|
require 'ruby-static-tracing/tracer'
|
12
11
|
require 'ruby-static-tracing/tracers'
|
@@ -9,7 +9,7 @@ module StaticTracing
|
|
9
9
|
attr_accessor :name
|
10
10
|
|
11
11
|
# Provider couldn't be found in collection
|
12
|
-
class
|
12
|
+
class ProviderMissingError < StandardError; end
|
13
13
|
|
14
14
|
class << self
|
15
15
|
# Gets a provider by name
|
@@ -21,7 +21,7 @@ module StaticTracing
|
|
21
21
|
# Gets a provider instance by name
|
22
22
|
def fetch(namespace)
|
23
23
|
providers.fetch(namespace) do
|
24
|
-
raise
|
24
|
+
raise ProviderMissingError
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -37,11 +37,6 @@ module StaticTracing
|
|
37
37
|
providers.values.each(&:disable)
|
38
38
|
end
|
39
39
|
|
40
|
-
def clean
|
41
|
-
# FIXME: this should free first
|
42
|
-
@providers = {}
|
43
|
-
end
|
44
|
-
|
45
40
|
private
|
46
41
|
|
47
42
|
# A global collection of providers
|
@@ -58,9 +53,8 @@ module StaticTracing
|
|
58
53
|
if tracepoint.is_a?(String)
|
59
54
|
tracepoint = Tracepoint.new(namespace, tracepoint, *args)
|
60
55
|
elsif tracepoint.is_a?(Tracepoint)
|
61
|
-
@tracepoints
|
56
|
+
@tracepoints[tracepoint.name] = tracepoint
|
62
57
|
end
|
63
|
-
tracepoint
|
64
58
|
end
|
65
59
|
|
66
60
|
# Enable the provider, loading it into memory
|
@@ -82,6 +76,7 @@ module StaticTracing
|
|
82
76
|
# Only supported on systems (linux) where backed by file
|
83
77
|
def path; end
|
84
78
|
|
79
|
+
# Completely removes the provider
|
85
80
|
def destroy; end
|
86
81
|
|
87
82
|
private
|
@@ -95,7 +90,7 @@ module StaticTracing
|
|
95
90
|
StaticTracing.issue_disabled_tracepoints_warning
|
96
91
|
end
|
97
92
|
@namespace = namespace
|
98
|
-
@tracepoints =
|
93
|
+
@tracepoints = {}
|
99
94
|
end
|
100
95
|
end
|
101
96
|
end
|
@@ -2,6 +2,17 @@
|
|
2
2
|
|
3
3
|
module StaticTracing
|
4
4
|
class Tracepoint
|
5
|
+
class TracepointMissingError < StandardError; end
|
6
|
+
|
7
|
+
class << self
|
8
|
+
# Gets a trace instance by provider name and name
|
9
|
+
def fetch(provider, name)
|
10
|
+
Provider.fetch(provider).tracepoints.fetch(name.to_s) do
|
11
|
+
raise TracepointMissingError
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
5
16
|
class InvalidArgumentError < StandardError
|
6
17
|
def initialize(argument, expected_type)
|
7
18
|
error_message = <<~ERROR_MESSAGE
|
@@ -45,6 +56,7 @@ module StaticTracing
|
|
45
56
|
_fire_tracepoint(values)
|
46
57
|
end
|
47
58
|
|
59
|
+
# The provider this tracepoint is defined on
|
48
60
|
def provider
|
49
61
|
Provider.fetch(@provider_name)
|
50
62
|
end
|
@@ -12,7 +12,8 @@ module StaticTracing
|
|
12
12
|
include Tracer::Helpers
|
13
13
|
|
14
14
|
def register(klass, *method_names, provider: nil)
|
15
|
-
|
15
|
+
provider_name ||= underscore(klass.name)
|
16
|
+
provider = Provider.register(provider_name)
|
16
17
|
method_overrides = function_wrapper.new(provider, @wrapping_function, @data_types)
|
17
18
|
modified_classes[klass] ||= method_overrides
|
18
19
|
modified_classes[klass].add_override(method_names.flatten)
|
@@ -42,10 +43,12 @@ module StaticTracing
|
|
42
43
|
|
43
44
|
def add_override(methods)
|
44
45
|
methods.each do |method|
|
45
|
-
|
46
|
+
Tracepoint.new(@provider.namespace, method.to_s, *@data_types)
|
46
47
|
define_method(method.to_s, @wrapping_function)
|
47
48
|
end
|
48
49
|
end
|
50
|
+
|
51
|
+
attr_reader :provider
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
@@ -9,7 +9,9 @@ module StaticTracing
|
|
9
9
|
duration = StaticTracing.nsec - start_time
|
10
10
|
method_name = __method__.to_s
|
11
11
|
provider = Tracer::Helpers.underscore(self.class.name)
|
12
|
-
|
12
|
+
# FIXME: benchmark this, we may need to cache the provider instance on the object
|
13
|
+
# This lookup is a bit of a hack
|
14
|
+
Tracepoint.fetch(provider, method_name).fire(method_name, duration)
|
13
15
|
result
|
14
16
|
}
|
15
17
|
|
@@ -9,7 +9,8 @@ module StaticTracing
|
|
9
9
|
current_stack = send(:caller).join("\n")
|
10
10
|
method_name = __method__.to_s
|
11
11
|
provider = Tracer::Helpers.underscore(self.class.name)
|
12
|
-
|
12
|
+
Tracepoint.fetch(provider, method_name).fire(method_name, current_stack)
|
13
|
+
|
13
14
|
super(*args, &block)
|
14
15
|
}
|
15
16
|
|
data/lib/tasks/docker.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Quick helpers to get a dev env set up
|
4
|
+
namespace :docker do
|
5
|
+
desc 'Builds the development docker image'
|
6
|
+
task :build do
|
7
|
+
system("docker build -f #{File.join(DOCKER_DIR, 'Dockerfile.ci')} #{DOCKER_DIR} -t quay.io/dalehamel/ruby-static-tracing")
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Runs the development docker image'
|
11
|
+
task :run do
|
12
|
+
`docker run --privileged --name ruby-static-tracing-#{Time.now.getutc.to_i} -v $(pwd):/app -d quay.io/dalehamel/ruby-static-tracing:latest /bin/sh -c "sleep infinity"`.strip
|
13
|
+
system("docker exec -ti #{latest_running_container_id} /app/vagrant/debugfs.sh")
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Provides a shell within the development docker image'
|
17
|
+
task :shell do
|
18
|
+
system("docker exec -ti #{latest_running_container_id} bash")
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Build and install the gem'
|
22
|
+
task :install do
|
23
|
+
system("docker exec -ti #{latest_running_container_id} bash -c 'bundle install && bundle exec rake install'")
|
24
|
+
end
|
25
|
+
desc 'Runs integration tests within the development docker image'
|
26
|
+
task :integration do
|
27
|
+
system("docker exec -ti #{latest_running_container_id} bash -c 'bundle install && bundle exec rake clean && bundle exec rake build && bundle exec rake integration'")
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Wrap running test in docker'
|
31
|
+
task :test do
|
32
|
+
exit system("docker exec -ti #{latest_running_container_id} \
|
33
|
+
bash -c 'mv vendor vendor.bak; bundle install && \
|
34
|
+
bundle exec rake test; err=$?;
|
35
|
+
rm -rf vendor; mv vendor.bak vendor;
|
36
|
+
exit $err'")
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Wrap running Rubocop in docker'
|
40
|
+
task :rubocop do
|
41
|
+
exit system("docker exec -ti #{latest_running_container_id} \
|
42
|
+
bash -c 'mv vendor ../vendor.bak; bundle install && \
|
43
|
+
bundle exec rake clean;
|
44
|
+
bundle exec rake rubocop; err=$?;
|
45
|
+
rm -rf vendor; mv ../vendor.bak vendor;
|
46
|
+
exit $err'")
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'Check C files for linting issues'
|
50
|
+
task :clangfmt do
|
51
|
+
exit system("docker exec -ti #{latest_running_container_id} \
|
52
|
+
bash -c 'mv vendor vendor.bak; bundle install && \
|
53
|
+
bundle exec rake clangfmt; err=$?;
|
54
|
+
rm -rf vendor; mv vendor.bak vendor;
|
55
|
+
exit $err'")
|
56
|
+
end
|
57
|
+
|
58
|
+
desc 'Cleans up all development docker images for this project'
|
59
|
+
task :clean do
|
60
|
+
system('docker container ls --quiet --filter name=ruby-static-tracing* | xargs -I@ docker container kill @')
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'Pulls development image'
|
64
|
+
task :pull do
|
65
|
+
system('docker pull quay.io/dalehamel/ruby-static-tracing')
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'Push development image'
|
69
|
+
task :push do
|
70
|
+
system('docker push quay.io/dalehamel/ruby-static-tracing')
|
71
|
+
end
|
72
|
+
|
73
|
+
desc 'Fully set up a development docker image, and get a shell'
|
74
|
+
task up: %i[build run shell]
|
75
|
+
|
76
|
+
def latest_running_container_id
|
77
|
+
container_id = `docker container ls --latest --quiet --filter status=running --filter name=ruby-static-tracing*`.strip
|
78
|
+
if container_id.empty?
|
79
|
+
raise 'No containers running, please run rake docker:run and then retry this task'
|
80
|
+
else
|
81
|
+
container_id
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :vagrant do
|
4
|
+
desc 'Sets up a vagrant VM, needed for our development environment.'
|
5
|
+
task :up do
|
6
|
+
system('vagrant up')
|
7
|
+
end
|
8
|
+
|
9
|
+
desc 'Provides a shell within vagrant.'
|
10
|
+
task :ssh do
|
11
|
+
system('vagrant ssh')
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Enters a shell within our development docker image, within vagrant.'
|
15
|
+
task :shell do
|
16
|
+
system("vagrant ssh -c 'cd /vagrant && bundle exec rake docker:shell'")
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Runs tests within the development docker image, within vagrant'
|
20
|
+
task :tests do
|
21
|
+
system("vagrant ssh -c 'cd /vagrant && bundle exec rake docker:tests'")
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Runs integration tests within the development docker image, within vagrant'
|
25
|
+
task :integration do
|
26
|
+
system("vagrant ssh -c 'cd /vagrant && bundle exec rake docker:integration'")
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Cleans up the vagrant VM'
|
30
|
+
task :clean do
|
31
|
+
system('vagrant destroy')
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-static-tracing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dale Hamel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unmixer
|
@@ -188,7 +188,6 @@ files:
|
|
188
188
|
- lib/ruby-static-tracing/platform.rb
|
189
189
|
- lib/ruby-static-tracing/provider.rb
|
190
190
|
- lib/ruby-static-tracing/tracepoint.rb
|
191
|
-
- lib/ruby-static-tracing/tracepoints.rb
|
192
191
|
- lib/ruby-static-tracing/tracer.rb
|
193
192
|
- lib/ruby-static-tracing/tracer/base.rb
|
194
193
|
- lib/ruby-static-tracing/tracer/concerns/latency_tracer.rb
|
@@ -197,6 +196,8 @@ files:
|
|
197
196
|
- lib/ruby-static-tracing/tracer/stack.rb
|
198
197
|
- lib/ruby-static-tracing/tracers.rb
|
199
198
|
- lib/ruby-static-tracing/version.rb
|
199
|
+
- lib/tasks/docker.rb
|
200
|
+
- lib/tasks/vagrant.rb
|
200
201
|
homepage: https://github.com/dalehamel/ruby-static-tracing
|
201
202
|
licenses:
|
202
203
|
- MIT
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module StaticTracing
|
4
|
-
# FIXME: - why do we need this class? We should store tracepoints
|
5
|
-
# on providers, and get the list of all tracepoints from the list of providers
|
6
|
-
class Tracepoints
|
7
|
-
class ProviderMissingError < StandardError; end
|
8
|
-
class TracepointMissingError < StandardError; end
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def add(provider, name, data_types)
|
12
|
-
tracepoints[provider][name.to_s] ||= begin
|
13
|
-
StaticTracing::Tracepoint.new(provider, name.to_s, *data_types)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def get(provider, name)
|
18
|
-
tracepoints
|
19
|
-
.fetch(provider) { raise_error(ProviderMissingError) }
|
20
|
-
.fetch(name) { raise_error(TracepointMissingError) }
|
21
|
-
end
|
22
|
-
|
23
|
-
def clean
|
24
|
-
@tracepoints ||= Hash.new { |hash, key| hash[key] = {} }
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def tracepoints
|
30
|
-
@tracepoints ||= Hash.new { |hash, key| hash[key] = {} }
|
31
|
-
end
|
32
|
-
|
33
|
-
def raise_error(error)
|
34
|
-
raise error
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|