pyroscope 0.2.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/scripts/docker.sh ADDED
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+ set -ex
3
+
4
+ BUILD_DIR="/work"
5
+
6
+ docker run \
7
+ -w /work/pyroscope_ffi/ruby/elflib/rbspy \
8
+ -v `pwd`:/work \
9
+ quay.io/pypa/${BUILD_ARCH} \
10
+ sh manylinux.sh
11
+
12
+ docker run \
13
+ -w /work/pyroscope_ffi/ruby/elflib/thread_id \
14
+ -v `pwd`:/work \
15
+ quay.io/pypa/${BUILD_ARCH} \
16
+ sh manylinux.sh
metadata CHANGED
@@ -1,51 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pyroscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pyroscope Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-22 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake-compiler
14
+ name: ffi
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
17
  - - ">="
46
18
  - !ruby/object:Gem::Version
47
19
  version: '0'
48
- type: :development
20
+ type: :runtime
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
@@ -53,7 +25,7 @@ dependencies:
53
25
  - !ruby/object:Gem::Version
54
26
  version: '0'
55
27
  - !ruby/object:Gem::Dependency
56
- name: rubygems-tasks
28
+ name: bundler
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - ">="
@@ -67,64 +39,77 @@ dependencies:
67
39
  - !ruby/object:Gem::Version
68
40
  version: '0'
69
41
  - !ruby/object:Gem::Dependency
70
- name: rspec
42
+ name: rake
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
- - - ">="
45
+ - - "~>"
74
46
  - !ruby/object:Gem::Version
75
- version: '0'
47
+ version: '13.0'
76
48
  type: :development
77
49
  prerelease: false
78
50
  version_requirements: !ruby/object:Gem::Requirement
79
51
  requirements:
80
- - - ">="
52
+ - - "~>"
81
53
  - !ruby/object:Gem::Version
82
- version: '0'
83
- description: pyroscope client integration for ruby
84
- email: contact@pyroscope.io
54
+ version: '13.0'
55
+ description: Pyroscope FFI Integration for Ruby
56
+ email:
57
+ - contact@pyroscope.io
85
58
  executables: []
86
59
  extensions:
87
- - ext/pyroscope/extconf.rb
60
+ - ext/rbspy/extconf.rb
61
+ - ext/thread_id/extconf.rb
88
62
  extra_rdoc_files: []
89
63
  files:
90
- - ".gitignore"
91
- - Gemfile
92
- - Gemfile.lock
93
64
  - LICENSE
94
65
  - README.md
95
- - Rakefile
96
- - ext/pyroscope/extconf.rb
97
- - ext/pyroscope/lib/.gitkeep
98
- - ext/pyroscope/lib/libpyroscope.rbspy.a
99
- - ext/pyroscope/lib/libpyroscope.rbspy.combo.a
100
- - ext/pyroscope/lib/librustdeps.a
101
- - ext/pyroscope/pyroscope.c
66
+ - elflib/rbspy/manylinux.sh
67
+ - elflib/rbspy/pyproject.toml
68
+ - elflib/rbspy/rbspy/__init__.py
69
+ - elflib/rbspy/setup.cfg
70
+ - elflib/rbspy/setup.py
71
+ - elflib/thread_id/manylinux.sh
72
+ - elflib/thread_id/pyproject.toml
73
+ - elflib/thread_id/setup.cfg
74
+ - elflib/thread_id/setup.py
75
+ - elflib/thread_id/thread_id/__init__.py
76
+ - ext/rbspy/Cargo.toml
77
+ - ext/rbspy/Rakefile
78
+ - ext/rbspy/build.rs
79
+ - ext/rbspy/cbindgen.toml
80
+ - ext/rbspy/extconf.rb
81
+ - ext/rbspy/src/lib.rs
82
+ - ext/thread_id/Cargo.toml
83
+ - ext/thread_id/Rakefile
84
+ - ext/thread_id/build.rs
85
+ - ext/thread_id/cbindgen.toml
86
+ - ext/thread_id/extconf.rb
87
+ - ext/thread_id/src/lib.rs
102
88
  - lib/pyroscope.rb
103
89
  - lib/pyroscope/version.rb
104
90
  - pyroscope.gemspec
105
- - test.rb
106
- homepage: http://rubygems.org/gems/pyroscope
91
+ - scripts/docker.sh
92
+ homepage: https://pyroscope.io
107
93
  licenses:
108
94
  - Apache-2.0
109
95
  metadata: {}
110
- post_install_message:
96
+ post_install_message:
111
97
  rdoc_options: []
112
98
  require_paths:
113
99
  - lib
114
- - ext/pyroscope
115
100
  required_ruby_version: !ruby/object:Gem::Requirement
116
101
  requirements:
117
102
  - - ">="
118
103
  - !ruby/object:Gem::Version
119
- version: '0'
104
+ version: 2.5.9
120
105
  required_rubygems_version: !ruby/object:Gem::Requirement
121
106
  requirements:
122
107
  - - ">="
123
108
  - !ruby/object:Gem::Version
124
109
  version: '0'
125
110
  requirements: []
126
- rubygems_version: 3.2.15
127
- signing_key:
111
+ rubygems_version: 3.3.7
112
+ signing_key:
128
113
  specification_version: 4
129
- summary: pyroscope
114
+ summary: Pyroscope
130
115
  test_files: []
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- *.gem
2
- .DS_Store
3
- lib/pyroscope_c.bundle
4
- /build
5
- /pkg
6
- /ext/pyroscope/lib/*.a
7
- /ext/pyroscope/lib/*.bundle
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in wrap_c_example.gemspec
4
- gemspec
data/Gemfile.lock DELETED
@@ -1,48 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- pyroscope (0.2.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.4.4)
10
- io-console (0.5.9)
11
- irb (1.3.6)
12
- reline (>= 0.2.5)
13
- rake (13.0.4)
14
- rake-compiler (1.1.1)
15
- rake
16
- reline (0.2.6)
17
- io-console (~> 0.5)
18
- rspec (3.10.0)
19
- rspec-core (~> 3.10.0)
20
- rspec-expectations (~> 3.10.0)
21
- rspec-mocks (~> 3.10.0)
22
- rspec-core (3.10.1)
23
- rspec-support (~> 3.10.0)
24
- rspec-expectations (3.10.1)
25
- diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.10.0)
27
- rspec-mocks (3.10.2)
28
- diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.10.0)
30
- rspec-support (3.10.2)
31
- rubygems-tasks (0.2.5)
32
- irb (~> 1.0)
33
-
34
- PLATFORMS
35
- arm64-darwin-20
36
- x86_64-darwin-20
37
- x86_64-linux
38
-
39
- DEPENDENCIES
40
- bundler
41
- pyroscope!
42
- rake
43
- rake-compiler
44
- rspec
45
- rubygems-tasks
46
-
47
- BUNDLED WITH
48
- 2.2.15
data/Rakefile DELETED
@@ -1,56 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rubygems/package_task"
3
- require "rake/extensiontask"
4
- require "rake/testtask"
5
- require "rspec/core/rake_task"
6
- require "rake/clean"
7
- require_relative "./lib/pyroscope/version"
8
-
9
- CLEAN.include(
10
- "ext/pyroscope/*.o",
11
- "ext/pyroscope/*.bundle"
12
- )
13
-
14
- CLOBBER.include(
15
- "ext/pyroscope/Makefile",
16
- "pkg"
17
- )
18
-
19
- BUILD_DIR = 'build'
20
-
21
- def gem_spec
22
- @gem_spec ||= Gem::Specification.load('pyroscope.gemspec')
23
- end
24
-
25
- Gem::PackageTask.new(gem_spec) do |pkg|
26
- pkg.need_zip = true
27
- pkg.need_tar = true
28
- end
29
-
30
- Rake::ExtensionTask.new("pyroscope_c", gem_spec) do |ext|
31
- # ext.name = 'pyroscope'
32
- ext.ext_dir = './ext/pyroscope'
33
- # ext.lib_dir = 'lib/pyroscope'
34
- ext.tmp_dir = BUILD_DIR
35
- ext.config_script = "extconf.rb"
36
- end
37
-
38
- RSpec::Core::RakeTask.new(:spec)
39
-
40
- task :build => [:clean, :compile]
41
-
42
- task :default => [:build, :spec]
43
-
44
- task :test do
45
- sudo = RUBY_PLATFORM =~ /darwin/ ? "sudo -E" : ""
46
- system "rake build && #{sudo} gem install pkg/pyroscope-#{Pyroscope::VERSION}.gem && #{sudo} ruby test.rb"
47
- end
48
-
49
- task :test_exec do
50
- # system "cd ../pyroscope && DOCKER_BUILDKIT=1 docker build -f Dockerfile.static-libs --output type=local,dest=out ." if RUBY_PLATFORM.include?("linux")
51
- system "sudo -E pyroscope exec ruby test.rb"
52
- end
53
-
54
- task :publish do
55
- system "rake build && gem install pkg/pyroscope-#{Pyroscope::VERSION}.gem && gem push pkg/pyroscope-#{Pyroscope::VERSION}.gem"
56
- end
@@ -1,78 +0,0 @@
1
- require "mkmf"
2
-
3
- require 'net/http'
4
-
5
- LIBDIR = RbConfig::CONFIG['libdir']
6
- INCLUDEDIR = RbConfig::CONFIG['includedir']
7
-
8
- HEADER_DIRS = [INCLUDEDIR]
9
-
10
- LIB_DIRS = [LIBDIR, File.expand_path(File.join(File.dirname(__FILE__), "lib"))]
11
-
12
- COMMIT = "e44f13d9"
13
-
14
- # TODO: this is not very accurate, but it works for now
15
- OS = RUBY_PLATFORM.include?("darwin") ? "mac" : "linux"
16
- ARCH = RUBY_PLATFORM.include?("arm64") ? "arm64" : "amd64"
17
-
18
- PREFIX = "/static-libs/#{COMMIT}/#{OS}-#{ARCH}"
19
-
20
- ROOT = File.expand_path("..", __FILE__)
21
-
22
- def run(str)
23
- system(str) || fail("command failed: #{str}")
24
- end
25
-
26
- if ENV["PYROSCOPE_RUBY_LOCAL"]
27
- puts "PYROSCOPE_RUBY_LOCAL using path #{ENV['PYROSCOPE_RUBY_LOCAL']}}"
28
- pyroscope_path = ENV["PYROSCOPE_RUBY_LOCAL"]
29
- run("rm -rf #{File.join(ROOT, "build")}")
30
- run("cd #{pyroscope_path} && make build-rust-dependencies-docker")
31
- run("cp #{pyroscope_path}/out/libpyroscope.rbspy.a #{File.join(ROOT, "lib/libpyroscope.rbspy.a")}")
32
- run("cp #{pyroscope_path}/out/librustdeps.a #{File.join(ROOT, "lib/librustdeps.a")}")
33
- else
34
- Net::HTTP.start("dl.pyroscope.io", 443, :use_ssl => true) do |http|
35
- ["libpyroscope.rbspy.a", "librustdeps.a"].each do |name|
36
- url = PREFIX+"/#{name}.gz"
37
- req = Net::HTTP::Get.new(url)
38
- http.request(req) do |resp|
39
- raise "HTTP error: #{resp.code}" unless resp.code == "200"
40
-
41
- r, w = IO.pipe
42
-
43
- t = Thread.new do
44
- zreader = Zlib::GzipReader.new(r)
45
- File.open(File.join(ROOT, "lib/#{name}"), "wb") do |f|
46
- loop do
47
- begin
48
- chunk = zreader.readpartial(32768)
49
- break if chunk.nil?
50
- rescue EOFError
51
- break
52
- end
53
- f.write(chunk)
54
- end
55
- end
56
- end
57
-
58
- resp.read_body do |chunk|
59
- w.write(chunk)
60
- end
61
-
62
- t.join
63
- end
64
- end
65
- end
66
- end
67
-
68
- # this is now done upstream
69
- # system "strip --strip-debug #{File.join(ROOT, "lib/libpyroscope.rbspy.combo.a")}"
70
-
71
- dir_config('pyroscope', HEADER_DIRS, LIB_DIRS)
72
-
73
- libs = ['-lpyroscope.rbspy', '-lrustdeps']
74
- libs.each do |lib|
75
- $LOCAL_LIBS << "#{lib} "
76
- end
77
-
78
- create_makefile('pyroscope_c')
Binary file
Binary file
@@ -1,87 +0,0 @@
1
- #include <stdlib.h>
2
- #include <ruby.h>
3
-
4
- static VALUE rb_Pyroscope;
5
-
6
- #include <stdio.h>
7
- #include <string.h>
8
-
9
- int Start(char*, char*, char*, char*, int, int, char*);
10
- int Stop();
11
- int ChangeName(char*);
12
- int SetTag(char*, char*);
13
- int TestLogger();
14
- char* BuildSummary();
15
-
16
- static VALUE
17
- pyroscope_start(VALUE self, VALUE appName, VALUE serverAddress, VALUE authToken, VALUE sampleRate, VALUE withSubprocesses, VALUE logLevel) {
18
- VALUE r_appName = StringValue(appName);
19
- char *c_appName = RSTRING_PTR(r_appName);
20
-
21
- int c_sampleRate = FIX2INT(sampleRate);
22
- int c_withSubprocesses = FIX2INT(withSubprocesses);
23
-
24
- VALUE r_serverAddress = StringValue(serverAddress);
25
- char *c_serverAddress = RSTRING_PTR(r_serverAddress);
26
-
27
- VALUE r_authToken = StringValue(authToken);
28
- char *c_authToken = RSTRING_PTR(r_authToken);
29
-
30
- VALUE r_logLevel = StringValue(logLevel);
31
- char *c_logLevel = RSTRING_PTR(r_logLevel);
32
-
33
- int res = Start(c_appName, "rbspy", c_serverAddress, c_authToken, c_sampleRate, c_withSubprocesses, c_logLevel);
34
-
35
- return INT2FIX(res);
36
- }
37
-
38
- static VALUE
39
- pyroscope_stop(VALUE self) {
40
- int res = Stop();
41
- return INT2FIX(res);
42
- }
43
-
44
- static VALUE
45
- pyroscope_change_name(VALUE self, VALUE appName) {
46
- VALUE r_appName = StringValue(appName);
47
- char *c_appName = RSTRING_PTR(r_appName);
48
-
49
- int res = ChangeName(c_appName);
50
- return INT2FIX(res);
51
- }
52
-
53
- static VALUE
54
- pyroscope_set_tag(VALUE self, VALUE key, VALUE val) {
55
- VALUE r_key = StringValue(key);
56
- char *c_key = RSTRING_PTR(r_key);
57
- VALUE r_val = StringValue(val);
58
- char *c_val = RSTRING_PTR(r_val);
59
-
60
- int res = SetTag(c_key, c_val);
61
- return INT2FIX(res);
62
- }
63
-
64
- static VALUE
65
- pyroscope_test_logger(VALUE self) {
66
- int res = TestLogger();
67
- return INT2FIX(res);
68
- }
69
-
70
- static VALUE
71
- pyroscope_build_summary(VALUE self) {
72
- char *c_summary = BuildSummary();
73
- VALUE r_summary = rb_str_new_cstr(c_summary);
74
- free(c_summary);
75
- return r_summary;
76
- }
77
-
78
- void
79
- Init_pyroscope_c() {
80
- rb_Pyroscope = rb_define_module("Pyroscope");
81
- rb_define_module_function(rb_Pyroscope, "_start", pyroscope_start, 6);
82
- rb_define_module_function(rb_Pyroscope, "_stop", pyroscope_stop, 0);
83
- rb_define_module_function(rb_Pyroscope, "_change_name", pyroscope_change_name, 1);
84
- rb_define_module_function(rb_Pyroscope, "_set_tag", pyroscope_set_tag, 2);
85
- rb_define_module_function(rb_Pyroscope, "_test_logger", pyroscope_test_logger, 0);
86
- rb_define_module_function(rb_Pyroscope, "_build_summary", pyroscope_build_summary, 0);
87
- }
data/test.rb DELETED
@@ -1,32 +0,0 @@
1
- require "pyroscope"
2
-
3
- Pyroscope.configure do |config|
4
- config.app_name = "test.ruby.app"
5
- config.server_address = "http://pyroscope:4040/"
6
- config.tags = {
7
- :region => "us-east-1",
8
- :hostname => ENV["hostname"]
9
- }
10
- end
11
-
12
- def work(n)
13
- i = 0
14
- while i < n
15
- i += 1
16
- end
17
- end
18
-
19
- def fast_function
20
- work(20000)
21
- end
22
-
23
- def slow_function
24
- work(80000)
25
- end
26
-
27
- Pyroscope.tag({ "region" => "us-east-1" })
28
-
29
- while true
30
- fast_function
31
- slow_function
32
- end