usdt_marker 0.1.0
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 +7 -0
- data/.gitignore +13 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +23 -0
- data/README.md +118 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ext/usdt_marker/extconf.rb +5 -0
- data/ext/usdt_marker/usdt_marker.c +39 -0
- data/ext/usdt_marker/usdt_marker.h +6 -0
- data/lib/usdt_marker.rb +7 -0
- data/lib/usdt_marker/version.rb +3 -0
- data/usdt_marker.gemspec +23 -0
- metadata +71 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a52c971244aa67756a460f5696813fc3e7dc6cf9aa6339512b36a1028989a97d
|
|
4
|
+
data.tar.gz: 6181803757c4dd53d4bece09ecf013ea49f436106151421df89600b6053a7b39
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d5beafc4f4224cfc7fb96e546ba66840a675e0645501da6d4f5f52705d05fb7b666bf6451f1eac797e03c3fbf08bfb8f0af3483975802c31db16f840b9f02bf4
|
|
7
|
+
data.tar.gz: 5883823bb5a7b283b348f927474c90d7f43d3a69650e8b7b15298fc6cfee4d842195dd72e151457e88da704bb6adaf4ae30107d4257a83556a593c15ebb944fe
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
usdt_marker (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
rake (13.0.1)
|
|
10
|
+
rake-compiler (1.1.0)
|
|
11
|
+
rake
|
|
12
|
+
|
|
13
|
+
PLATFORMS
|
|
14
|
+
ruby
|
|
15
|
+
|
|
16
|
+
DEPENDENCIES
|
|
17
|
+
bundler (>= 1.6)
|
|
18
|
+
rake (~> 13.0)
|
|
19
|
+
rake-compiler
|
|
20
|
+
usdt_marker!
|
|
21
|
+
|
|
22
|
+
BUNDLED WITH
|
|
23
|
+
2.0.2
|
data/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# UsdtMarker
|
|
2
|
+
|
|
3
|
+
(BADGE)
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'usdt_marker'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle install
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install usdt_marker
|
|
20
|
+
|
|
21
|
+
### Limitations
|
|
22
|
+
|
|
23
|
+
* This is tested only against Linux system; My environment uses kernel 5.0.0 :)
|
|
24
|
+
* Extention requires a package named `systemtap-sdt-dev` or something alike
|
|
25
|
+
* I know some of UNIX systems also has `<sys/sdt.h>` header file, but I'm not going to test.
|
|
26
|
+
* Your supports are welcomed!
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Very simple tutorial.
|
|
31
|
+
|
|
32
|
+
Install those tools to your system:
|
|
33
|
+
|
|
34
|
+
* package `systemtap-sdt-dev` or something alike.
|
|
35
|
+
* `bpftrace`. We recommend via OS package, binary or self-build, because snap version of bpftrace cannot recognize uprobe/usdt for now.
|
|
36
|
+
* Ruby. Some systems may require `ruby-dev` package.
|
|
37
|
+
|
|
38
|
+
Then invoke your irb, e.g. in the bundle environment with usdt_marker.
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
irb(main):001:0> require 'usdt_marker'
|
|
42
|
+
irb(main):002:0> puts $$
|
|
43
|
+
19644
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
On onother terminal, hit `bpftrace` to find the name of USDT; USDT may be defined in gem's shared object:
|
|
47
|
+
|
|
48
|
+
```console
|
|
49
|
+
$ sudo bpftrace -p 19644 -l 'usdt:*' | grep ruby
|
|
50
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:array__create
|
|
51
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:raise
|
|
52
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:gc__sweep__end
|
|
53
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:gc__sweep__begin
|
|
54
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:gc__mark__end
|
|
55
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:gc__mark__begin
|
|
56
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:hash__create
|
|
57
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:load__entry
|
|
58
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:load__return
|
|
59
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:find__require__return
|
|
60
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:require__entry
|
|
61
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:find__require__entry
|
|
62
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:require__return
|
|
63
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:object__create
|
|
64
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:parse__begin
|
|
65
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:parse__end
|
|
66
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:string__create
|
|
67
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:symbol__create
|
|
68
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:method__cache__clear
|
|
69
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:cmethod__entry
|
|
70
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:cmethod__return
|
|
71
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:method__return
|
|
72
|
+
usdt:/root/.rbenv/versions/2.6.5/lib/libruby.so.2.6.5:ruby:method__entry
|
|
73
|
+
usdt:/usr/local/ghq/github.com/udzura/usdt_marker/lib/usdt_marker/usdt_marker.so:rubygem:usdt_marker_i1s1
|
|
74
|
+
usdt:/usr/local/ghq/github.com/udzura/usdt_marker/lib/usdt_marker/usdt_marker.so:rubygem:usdt_marker_i2
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Then start tracing:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
$ sudo bpftrace -p 19644 -e \
|
|
81
|
+
'usdt:/usr/local/ghq/github.com/udzura/usdt_marker/lib/usdt_marker/usdt_marker.so:rubygem:usdt_marker_i1s1 {
|
|
82
|
+
printf("Fire!: %d, %s\n", arg0, str(arg1));
|
|
83
|
+
}'
|
|
84
|
+
Attaching 1 probe...
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Return to irb, hit probe methods:
|
|
88
|
+
|
|
89
|
+
```ruby
|
|
90
|
+
irb(main):003:0> UsdtMarker.probe_i1s1(2020, "hello, world!")
|
|
91
|
+
=> true
|
|
92
|
+
irb(main):004:0> UsdtMarker.probe_i1s1(2020, "hello, world! again")
|
|
93
|
+
=> true
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
After all bpftrace process traces these events:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
...
|
|
100
|
+
Fire!: 2020, hello, world!
|
|
101
|
+
Fire!: 2020, hello, world! again
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Method-USDT counterparts:
|
|
105
|
+
|
|
106
|
+
* `UsdtMarker.probe_i1s1(<Integer>, <String>)` - `rubygem:usdt_marker_i1s1`
|
|
107
|
+
* `UsdtMarker.probe_i2(<Integer>, <Integer>)` - `rubygem:usdt_marker_i2`
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
112
|
+
|
|
113
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
114
|
+
|
|
115
|
+
## Contributing
|
|
116
|
+
|
|
117
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/udzura/usdt_marker.
|
|
118
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "usdt_marker"
|
|
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/setup
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#include <sys/sdt.h>
|
|
2
|
+
#include "usdt_marker.h"
|
|
3
|
+
|
|
4
|
+
VALUE rb_mUsdtMarker;
|
|
5
|
+
|
|
6
|
+
#ifndef __APPLE__
|
|
7
|
+
static VALUE
|
|
8
|
+
rb_probe_i2 (VALUE mod, VALUE arg0, VALUE arg1) {
|
|
9
|
+
DTRACE_PROBE2(rubygem, usdt_marker_i2, NUM2LONG(arg0), NUM2LONG(arg1));
|
|
10
|
+
return Qtrue;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static VALUE
|
|
14
|
+
rb_probe_i1s1 (VALUE mod, VALUE arg0, VALUE arg1) {
|
|
15
|
+
DTRACE_PROBE2(rubygem, usdt_marker_i1s1, NUM2LONG(arg0), StringValuePtr(arg1));
|
|
16
|
+
return Qtrue;
|
|
17
|
+
}
|
|
18
|
+
#else
|
|
19
|
+
#include <err.h>
|
|
20
|
+
static VALUE
|
|
21
|
+
rb_probe_i2 (VALUE mod, VALUE arg0, VALUE arg1) {
|
|
22
|
+
warn("MacOS is never supported, because they would not have DTRACE_PROBE*\n");
|
|
23
|
+
return Qtrue;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static VALUE
|
|
27
|
+
rb_probe_i1s1 (VALUE mod, VALUE arg0, VALUE arg1) {
|
|
28
|
+
warn("MacOS is never supported, because they would not have DTRACE_PROBE*\n");
|
|
29
|
+
return Qtrue;
|
|
30
|
+
}
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
void
|
|
34
|
+
Init_usdt_marker(void)
|
|
35
|
+
{
|
|
36
|
+
rb_mUsdtMarker = rb_define_module("UsdtMarker");
|
|
37
|
+
rb_define_module_function(rb_mUsdtMarker, "probe_i2", rb_probe_i2, 2);
|
|
38
|
+
rb_define_module_function(rb_mUsdtMarker, "probe_i1s1", rb_probe_i1s1, 2);
|
|
39
|
+
}
|
data/lib/usdt_marker.rb
ADDED
data/usdt_marker.gemspec
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require_relative 'lib/usdt_marker/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "usdt_marker"
|
|
5
|
+
spec.version = UsdtMarker::VERSION
|
|
6
|
+
spec.authors = ["Uchio Kondo"]
|
|
7
|
+
spec.email = ["udzura@udzura.jp"]
|
|
8
|
+
|
|
9
|
+
spec.summary = %q{Event marker using USDT}
|
|
10
|
+
spec.description = %q{Event marker using USDT. You can trace those user-defined events from eBPF.}
|
|
11
|
+
spec.homepage = "https://github.com/udzura/usdt_marker"
|
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
|
13
|
+
|
|
14
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
15
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
16
|
+
end
|
|
17
|
+
spec.bindir = "exe"
|
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
spec.extensions = ["ext/usdt_marker/extconf.rb"]
|
|
21
|
+
|
|
22
|
+
spec.add_development_dependency "bundler", ">= 1.6"
|
|
23
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: usdt_marker
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Uchio Kondo
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-03-02 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: '1.6'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.6'
|
|
27
|
+
description: Event marker using USDT. You can trace those user-defined events from
|
|
28
|
+
eBPF.
|
|
29
|
+
email:
|
|
30
|
+
- udzura@udzura.jp
|
|
31
|
+
executables: []
|
|
32
|
+
extensions:
|
|
33
|
+
- ext/usdt_marker/extconf.rb
|
|
34
|
+
extra_rdoc_files: []
|
|
35
|
+
files:
|
|
36
|
+
- ".gitignore"
|
|
37
|
+
- Gemfile
|
|
38
|
+
- Gemfile.lock
|
|
39
|
+
- README.md
|
|
40
|
+
- Rakefile
|
|
41
|
+
- bin/console
|
|
42
|
+
- bin/setup
|
|
43
|
+
- ext/usdt_marker/extconf.rb
|
|
44
|
+
- ext/usdt_marker/usdt_marker.c
|
|
45
|
+
- ext/usdt_marker/usdt_marker.h
|
|
46
|
+
- lib/usdt_marker.rb
|
|
47
|
+
- lib/usdt_marker/version.rb
|
|
48
|
+
- usdt_marker.gemspec
|
|
49
|
+
homepage: https://github.com/udzura/usdt_marker
|
|
50
|
+
licenses: []
|
|
51
|
+
metadata: {}
|
|
52
|
+
post_install_message:
|
|
53
|
+
rdoc_options: []
|
|
54
|
+
require_paths:
|
|
55
|
+
- lib
|
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: 2.3.0
|
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
|
+
requirements:
|
|
63
|
+
- - ">="
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '0'
|
|
66
|
+
requirements: []
|
|
67
|
+
rubygems_version: 3.0.6
|
|
68
|
+
signing_key:
|
|
69
|
+
specification_version: 4
|
|
70
|
+
summary: Event marker using USDT
|
|
71
|
+
test_files: []
|