pyroscope 0.0.2

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: 67a5c91ddd8e9416619538b2600c84afa214cf0c50c752170994eb9544611bae
4
+ data.tar.gz: 7b392263f63f8c994a2a4b844d0a824fb7443bc18483e721c2fa8da2c0e74335
5
+ SHA512:
6
+ metadata.gz: b520c1f124b398e04c6e174483efbfb50bb226820ddf7548d14cc27a42aa25bbc12bd8ae72c91f2f1132ee825f585fb46c0784ab25a5f364ca3e63641ca9f3c9
7
+ data.tar.gz: b51b13f14af9ef25d4538d0ff569a24004d8b9485601dc35132ef01aaed0fa15e584d2bec83307b7183819ddbb11413c17abadeddb3235bb5dec1f3c695dadc7
data/.gitignore ADDED
@@ -0,0 +1,7 @@
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 ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wrap_c_example.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pyroscope (0.0.2)
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
+
38
+ DEPENDENCIES
39
+ bundler
40
+ pyroscope!
41
+ rake
42
+ rake-compiler
43
+ rspec
44
+ rubygems-tasks
45
+
46
+ BUNDLED WITH
47
+ 2.2.15
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # pyroscope-ruby
2
+
3
+ This is a repo for pyroscope ruby integration. It is currently under development and is not yet released.
data/Rakefile ADDED
@@ -0,0 +1,50 @@
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
+ system "rake build && gem install pkg/pyroscope-#{Pyroscope::VERSION}.gem && sudo -E ruby test.rb"
46
+ end
47
+
48
+ task :publish do
49
+ system "rake build && gem install pkg/pyroscope-#{Pyroscope::VERSION}.gem && gem push pkg/pyroscope-#{Pyroscope::VERSION}.gem"
50
+ end
@@ -0,0 +1,44 @@
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 = "7a919f4"
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
+ Net::HTTP.start("dl.pyroscope.io", 443, :use_ssl => true) do |http|
23
+ res1 = http.get(PREFIX+"/libpyroscope.rbspy.a")
24
+ raise "HTTP error: #{res1.code}" unless res1.code == "200"
25
+ lib1 = res1.body
26
+ File.binwrite(File.join(ROOT, "lib/libpyroscope.rbspy.a"), lib1)
27
+
28
+ res2 = http.get(PREFIX+"/librustdeps.a")
29
+ raise "HTTP error: #{res2.code}" unless res2.code == "200"
30
+ lib2 = res2.body
31
+ File.binwrite(File.join(ROOT, "lib/librustdeps.a"), lib2)
32
+ end
33
+
34
+ # system "cp /Users/dmitry/Dev/ps/pyroscope/out/libpyroscope.rbspy.a #{File.join(ROOT, "lib/libpyroscope.rbspy.a")}"
35
+ # system "cp /Users/dmitry/Dev/ps/pyroscope/third_party/rustdeps/target/release/librustdeps.a #{File.join(ROOT, "lib/librustdeps.a")}"
36
+
37
+ dir_config('pyroscope', HEADER_DIRS, LIB_DIRS)
38
+
39
+ libs = ['-lpyroscope.rbspy', '-lrustdeps']
40
+ libs.each do |lib|
41
+ $LOCAL_LIBS << "#{lib} "
42
+ end
43
+
44
+ create_makefile('pyroscope_c')
Binary file
@@ -0,0 +1,49 @@
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*, int, char*, char*);
10
+ int Stop(int);
11
+ int ChangeName(char*);
12
+
13
+ static VALUE
14
+ pyroscope_start(VALUE self, VALUE appName, VALUE pid, VALUE serverAddress) {
15
+ VALUE r_appName = StringValue(appName);
16
+ char *c_appName = RSTRING_PTR(r_appName);
17
+
18
+ int c_pid = FIX2INT(pid);
19
+
20
+ VALUE r_serverAddress = StringValue(serverAddress);
21
+ char *c_serverAddress = RSTRING_PTR(r_serverAddress);
22
+
23
+ int res = Start(c_appName, c_pid, "rbspy", c_serverAddress);
24
+
25
+ return INT2FIX(res);
26
+ }
27
+
28
+ static VALUE
29
+ pyroscope_stop(VALUE self, VALUE pid) {
30
+ int c_pid = FIX2INT(pid);
31
+ int res = Stop(c_pid);
32
+ return INT2FIX(res);
33
+ }
34
+
35
+ static VALUE
36
+ pyroscope_change_name(VALUE self, VALUE appName) {
37
+ VALUE r_appName = StringValue(appName);
38
+ char *c_appName = RSTRING_PTR(r_appName);
39
+ int res = ChangeName(c_appName);
40
+ return INT2FIX(res);
41
+ }
42
+
43
+ void
44
+ Init_pyroscope_c() {
45
+ rb_Pyroscope = rb_define_module("Pyroscope");
46
+ rb_define_module_function(rb_Pyroscope, "_start", pyroscope_start, 3);
47
+ rb_define_module_function(rb_Pyroscope, "_stop", pyroscope_stop, 1);
48
+ rb_define_module_function(rb_Pyroscope, "_change_name", pyroscope_change_name, 1);
49
+ }
data/lib/pyroscope.rb ADDED
@@ -0,0 +1,24 @@
1
+ require "pyroscope/version"
2
+ require_relative "./pyroscope_c"
3
+
4
+ module Pyroscope
5
+ Config = Struct.new(:app_name, :server_address)
6
+
7
+ def self.configure
8
+ @configuration = Config.new
9
+ yield @configuration
10
+ _start(
11
+ @configuration.app_name,
12
+ Process.pid,
13
+ @configuration.server_address,
14
+ )
15
+ end
16
+
17
+ def self.stop
18
+ _stop(Process.pid)
19
+ end
20
+
21
+ def self.change_name(new_name)
22
+ _change_name(new_name)
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module Pyroscope
2
+ VERSION = "0.0.2".freeze
3
+ end
data/pyroscope.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'pyroscope/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "pyroscope"
8
+ s.version = Pyroscope::VERSION
9
+ s.summary = "pyroscope"
10
+ s.description = "pyroscope client integration for ruby"
11
+ s.authors = ["Pyroscope Team"]
12
+ s.email = "contact@pyroscope.io"
13
+ s.files = `git ls-files`.split("\n")
14
+ s.files += Dir.glob("ext/**/**")
15
+ # s.files << "lib/pyroscope_c.bundle"
16
+ s.homepage = "http://rubygems.org/gems/pyroscope"
17
+ s.license = "Apache-2.0"
18
+ s.require_paths = ["lib"]
19
+ s.require_paths << "ext/pyroscope"
20
+ s.extensions << "ext/pyroscope/extconf.rb"
21
+
22
+ s.add_development_dependency "bundler"
23
+ s.add_development_dependency "rake"
24
+ s.add_development_dependency "rake-compiler"
25
+ s.add_development_dependency "rubygems-tasks"
26
+ s.add_development_dependency "rspec"
27
+ end
data/test.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'pyroscope'
2
+
3
+ puts "prestart #{Process.pid}"
4
+
5
+ Pyroscope.configure do |config|
6
+ config.app_name = "test.app.ruby2.cpu{}"
7
+ config.server_address = "http://localhost:4040/"
8
+ end
9
+
10
+ puts "start"
11
+ i=0
12
+ st = Time.new
13
+ while true
14
+ i+=1
15
+ # puts Time.new - st
16
+ if Time.new - st > 5
17
+ puts "new name " + "test.app.ruby2.cpu{iteration=#{i}}"
18
+ Pyroscope.change_name("test.app.ruby2.cpu{iteration=#{i}}")
19
+ st = Time.new
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pyroscope
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Pyroscope Team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-07-14 00:00:00.000000000 Z
12
+ dependencies:
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
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubygems-tasks
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: pyroscope client integration for ruby
84
+ email: contact@pyroscope.io
85
+ executables: []
86
+ extensions:
87
+ - ext/pyroscope/extconf.rb
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - README.md
94
+ - Rakefile
95
+ - ext/pyroscope/extconf.rb
96
+ - ext/pyroscope/lib/libpyroscope.rbspy.a
97
+ - ext/pyroscope/lib/librustdeps.a
98
+ - ext/pyroscope/pyroscope.c
99
+ - lib/pyroscope.rb
100
+ - lib/pyroscope/version.rb
101
+ - pyroscope.gemspec
102
+ - test.rb
103
+ homepage: http://rubygems.org/gems/pyroscope
104
+ licenses:
105
+ - Apache-2.0
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ - ext/pyroscope
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubygems_version: 3.2.15
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: pyroscope
127
+ test_files: []