ruby-usdt 0.2.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 465f1aa47fc3e1464824f95cec1bfc9ffab8fd29
4
- data.tar.gz: af101a5e965a3aa2f235b5fe7f95eff573e6d622
3
+ metadata.gz: f317c8c2e8649772970b6ecc02f34f01c6a54aea
4
+ data.tar.gz: 7a8d37a898136fbc684920926e0df8f29690ce46
5
5
  SHA512:
6
- metadata.gz: 836df20d76b44ae9e03952af0016e08bd1fbfbb46ca72624e29a9f73120499c59785b700eb900a33f8d45aa625772f9f6bb376aa7858c5a896cea8e193ace051
7
- data.tar.gz: 6844f06f4be41aa88d9b3901f3fd0b2cfe1e9ceb4e021d4edd240183512f8110239fe4d84a8dd620f89e33b4a7382bd88725824f4483e9858835422d5b669650
6
+ metadata.gz: 42b69e212820428a4b511ac9918ccb7632cda0e2e31e03b87d4eb7056d6c40996c3a83a9f04b7b28c9a14c3d877ced4c7f32a84d719aea0c1c3105c972df474f
7
+ data.tar.gz: 822f30d495eaee483624c0e877054459bce2a960ee5d5e531e7118e0b44dad46ad70b0cac4c7bbe18fe354ccc7c2b54955c3220f4c9528522befc60152be13cc
data/README.md CHANGED
@@ -70,6 +70,13 @@ probe.name => :probe
70
70
  probe.arguments => [:string, :string, :integer]
71
71
  ```
72
72
 
73
+ ## Interoperability
74
+
75
+ On systems with DTrace, this gem will compile C extensions that hook into USDT.
76
+ On systems without DTrace, the gem should install with a noop implementation,
77
+ so that probes can be added to projects without losing the ability to deploy to
78
+ non-dtraceable platforms.
79
+
73
80
  ## Additional Resources
74
81
 
75
82
  - [User-Level-Statically Defined Tracing](http://www.solarisinternals.com/wiki/index.php/DTrace_Topics_USDT#USDT)
@@ -1,9 +1,11 @@
1
1
  require 'mkmf'
2
2
 
3
- have_library("dtrace", "dtrace_open", "/usr/include/dtrace.h")
4
- system("cd ../libusdt && make")
5
- system("cp ../libusdt/usdt.h ../libusdt/*.a ./")
6
- have_library('usdt')
7
- have_header('usdt.h')
8
-
9
- create_makefile('usdt')
3
+ if have_library("dtrace", "dtrace_open", "/usr/include/dtrace.h")
4
+ system("cd ../libusdt && make")
5
+ system("cp ../libusdt/usdt.h ../libusdt/*.a ./")
6
+ have_header('usdt.h')
7
+ have_library('usdt')
8
+ create_makefile('usdt', 'real')
9
+ else
10
+ create_makefile('usdt', 'stubs')
11
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ #include <ruby.h>
2
+
3
+ void Init_usdt() {}
@@ -1,2 +1,3 @@
1
1
  require "usdt/version"
2
2
  require 'usdt/usdt'
3
+ require 'usdt/stubs' unless defined?(USDT::Provider)
@@ -0,0 +1 @@
1
+ require 'usdt/stubs/provider'
@@ -0,0 +1,19 @@
1
+ module USDT
2
+ class Probe
3
+ attr_reader :function, :name, :arguments
4
+
5
+ def initialize(function, name, *args)
6
+ @function = function.to_sym
7
+ @name = name.to_sym
8
+ @arguments = args
9
+ end
10
+
11
+ def enabled?
12
+ false
13
+ end
14
+
15
+ def fire(*args)
16
+ false
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ require 'usdt/stubs/probe'
2
+
3
+ module USDT
4
+ class Provider
5
+ attr_reader :provider, :mod
6
+
7
+ def self.create(provider, mod)
8
+ new(provider, mod)
9
+ end
10
+
11
+ def initialize(provider, mod)
12
+ @provider = provider
13
+ @mod = mod
14
+ end
15
+
16
+ def enable
17
+ true
18
+ end
19
+
20
+ def disable
21
+ true
22
+ end
23
+
24
+ def probe(*args)
25
+ USDT::Probe.new(*args)
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module USDT
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -0,0 +1 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require 'usdt/stubs/probe'
3
+
4
+ describe USDT::Probe do
5
+ let(:probe) { USDT::Probe.new(:fn, :name, :string, :integer) }
6
+
7
+ describe 'initialization' do
8
+ context 'with symbols' do
9
+ let(:probe) { USDT::Probe.new(:fn, :name, :string, :integer) }
10
+
11
+ it 'sets attributes' do
12
+ expect(probe.function).to eq(:fn)
13
+ expect(probe.name).to eq(:name)
14
+ expect(probe.arguments).to eq([:string, :integer])
15
+ end
16
+ end
17
+
18
+ context 'with strings' do
19
+ let(:probe) { USDT::Probe.new('fn', 'name', :string, :integer) }
20
+
21
+ it 'symbolizes attributes' do
22
+ expect(probe.function).to eq(:fn)
23
+ expect(probe.name).to eq(:name)
24
+ expect(probe.arguments).to eq([:string, :integer])
25
+ end
26
+ end
27
+ end
28
+
29
+ describe 'enabled?' do
30
+ it 'is false' do
31
+ expect(probe.enabled?).to be false
32
+ end
33
+ end
34
+
35
+ describe 'fire' do
36
+ it 'is false' do
37
+ expect(probe.fire('thing', 'blah', 0, 1)).to be false
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+ require 'usdt/stubs'
3
+
4
+ describe USDT::Provider do
5
+ let(:provider) { USDT::Provider.create :ruby, :test }
6
+
7
+ describe 'initialization' do
8
+ it 'sets provider' do
9
+ expect(provider.provider).to eq(:ruby)
10
+ end
11
+
12
+ it 'sets module' do
13
+ expect(provider.mod).to eq(:test)
14
+ end
15
+ end
16
+
17
+ describe 'enable' do
18
+ it 'succeeds' do
19
+ expect(provider.enable).to be true
20
+ end
21
+ end
22
+
23
+ describe 'disable' do
24
+ it 'succeeds' do
25
+ expect(provider.disable).to be true
26
+ end
27
+ end
28
+
29
+ describe 'probe' do
30
+ let(:probe) { provider.probe(:fn, :name, :string, :string) }
31
+
32
+ it 'creates a probe' do
33
+ expect(probe).to be_a(USDT::Probe)
34
+ end
35
+
36
+ it 'sets probe function' do
37
+ expect(probe.function).to eq(:fn)
38
+ end
39
+
40
+ it 'sets probe name' do
41
+ expect(probe.name).to eq(:name)
42
+ end
43
+
44
+ it 'sets probe arguments' do
45
+ expect(probe.arguments).to eq([:string, :string])
46
+ end
47
+ end
48
+ end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-usdt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Chan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-12 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
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: rspec
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'
13
41
  description:
14
42
  email:
15
43
  - kevin@yinkei.com
@@ -18,6 +46,9 @@ extensions:
18
46
  - ext/usdt/extconf.rb
19
47
  extra_rdoc_files: []
20
48
  files:
49
+ - lib/usdt/stubs/probe.rb
50
+ - lib/usdt/stubs/provider.rb
51
+ - lib/usdt/stubs.rb
21
52
  - lib/usdt/version.rb
22
53
  - lib/usdt.rb
23
54
  - ext/libusdt/LICENCE
@@ -36,10 +67,14 @@ files:
36
67
  - ext/libusdt/usdt_tracepoints_i386.s
37
68
  - ext/libusdt/usdt_tracepoints_x86_64.s
38
69
  - ext/usdt/extconf.rb
70
+ - ext/usdt/real/usdt.c
71
+ - ext/usdt/stubs/usdt.c
39
72
  - ext/usdt/test.rb
40
- - ext/usdt/usdt.c
41
73
  - README.md
42
74
  - LICENSE.md
75
+ - spec/spec_helper.rb
76
+ - spec/stubs/probe_spec.rb
77
+ - spec/stubs/provider_spec.rb
43
78
  homepage: http://github.com/kevinykchan/ruby-usdt
44
79
  licenses: []
45
80
  metadata: {}
@@ -64,5 +99,7 @@ rubygems_version: 2.0.5
64
99
  signing_key:
65
100
  specification_version: 4
66
101
  summary: Native DTrace probes for ruby.
67
- test_files: []
68
- has_rdoc:
102
+ test_files:
103
+ - spec/spec_helper.rb
104
+ - spec/stubs/probe_spec.rb
105
+ - spec/stubs/provider_spec.rb