startback 0.11.0 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/startback/audit/prometheus.rb +2 -9
- data/lib/startback/audit/shared.rb +17 -0
- data/lib/startback/audit/trailer.rb +5 -9
- data/lib/startback/audit.rb +1 -0
- data/lib/startback/version.rb +1 -1
- data/lib/startback/web/api.rb +1 -0
- data/spec/unit/audit/test_trailer.rb +18 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83733eb966d9d9679a15840dfa76f717aacaacc5c3eb417c6bf518a3eea1e3cd
|
4
|
+
data.tar.gz: f13815553606f4567e136beb86fc19a066720a3bcdf520c3781c12a732808f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a2c80c7c65fbe845784a6ee1326bed2a1d6f89eed591580800e1ee9f403fea24b61e92b1f1ad13356f612308a30c6ecc17f6c6a16fadb9c82ae6dec61b68d31
|
7
|
+
data.tar.gz: 18dc6c715ba6ed1715c6d838421476959942611a120ba04eed7a72d40d505e53c60b64ecbf4e877d2a99d2c46300cfa8e83f6cb70960bb72ad599d7d5802509f
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative 'shared'
|
1
2
|
require 'prometheus/client'
|
2
3
|
|
3
4
|
module Startback
|
@@ -23,6 +24,7 @@ module Startback
|
|
23
24
|
# input at construction time.
|
24
25
|
#
|
25
26
|
class Prometheus
|
27
|
+
include Shared
|
26
28
|
|
27
29
|
def initialize(options = {})
|
28
30
|
@prefix = options[:prefix] || "startback"
|
@@ -62,7 +64,6 @@ module Startback
|
|
62
64
|
def ignore_safely
|
63
65
|
yield
|
64
66
|
rescue => ex
|
65
|
-
puts ex.class.to_s + "\n" + ex.message + "\n" + ex.backtrace.join("\n")
|
66
67
|
nil
|
67
68
|
end
|
68
69
|
|
@@ -81,14 +82,6 @@ module Startback
|
|
81
82
|
Startback::VERSION
|
82
83
|
end
|
83
84
|
|
84
|
-
def op_name(op)
|
85
|
-
case op
|
86
|
-
when String then op
|
87
|
-
when Class then op.name
|
88
|
-
else op.class.name
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
85
|
end # class Prometheus
|
93
86
|
end # module Audit
|
94
87
|
end # module Startback
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Startback
|
2
|
+
module Audit
|
3
|
+
module Shared
|
4
|
+
|
5
|
+
def op_name(op)
|
6
|
+
return op.op_name if op.respond_to?(:op_name)
|
7
|
+
|
8
|
+
case op
|
9
|
+
when String then op
|
10
|
+
when Class then op.name
|
11
|
+
else op.class.name
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end # module Shared
|
16
|
+
end # module Audit
|
17
|
+
end # module Startback
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative 'shared'
|
1
2
|
require 'forwardable'
|
2
3
|
module Startback
|
3
4
|
module Audit
|
@@ -45,6 +46,7 @@ module Startback
|
|
45
46
|
# input at construction time.
|
46
47
|
#
|
47
48
|
class Trailer
|
49
|
+
include Shared
|
48
50
|
extend Forwardable
|
49
51
|
def_delegators :@logger, :debug, :info, :warn, :error, :fatal
|
50
52
|
|
@@ -85,20 +87,14 @@ module Startback
|
|
85
87
|
log_msg
|
86
88
|
end
|
87
89
|
|
88
|
-
def op_name(op)
|
89
|
-
case op
|
90
|
-
when String then op
|
91
|
-
when Class then op.name
|
92
|
-
else op.class.name
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
90
|
def op_context(op)
|
97
91
|
sanitize(op.respond_to?(:context, false) ? op.context.to_h : {})
|
98
92
|
end
|
99
93
|
|
100
94
|
def op_data(op)
|
101
|
-
data = if op.respond_to?(:
|
95
|
+
data = if op.respond_to?(:op_data, false)
|
96
|
+
op.op_data
|
97
|
+
elsif op.respond_to?(:to_trail, false)
|
102
98
|
op.to_trail
|
103
99
|
elsif op.respond_to?(:input, false)
|
104
100
|
op.input
|
data/lib/startback/audit.rb
CHANGED
data/lib/startback/version.rb
CHANGED
data/lib/startback/web/api.rb
CHANGED
@@ -8,13 +8,30 @@ module Startback
|
|
8
8
|
Trailer.new("/tmp/trail.log")
|
9
9
|
}
|
10
10
|
|
11
|
+
describe "op_name" do
|
12
|
+
|
13
|
+
def op_name(op, trailer = self.trailer)
|
14
|
+
trailer.send(:op_name, op)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'uses op_name in priority if provided' do
|
18
|
+
op = OpenStruct.new(op_name: "foo")
|
19
|
+
expect(op_name(op)).to eql("foo")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
11
23
|
describe "op_data" do
|
12
24
|
|
13
25
|
def op_data(op, trailer = self.trailer)
|
14
26
|
trailer.send(:op_data, op)
|
15
27
|
end
|
16
28
|
|
17
|
-
it 'uses
|
29
|
+
it 'uses op_data in priority if provided' do
|
30
|
+
op = OpenStruct.new(op_data: { foo: "bar" }, input: 12, request: 13)
|
31
|
+
expect(op_data(op)).to eql({ foo: "bar" })
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'uses to_trail then' do
|
18
35
|
op = OpenStruct.new(to_trail: { foo: "bar" }, input: 12, request: 13)
|
19
36
|
expect(op_data(op)).to eql({ foo: "bar" })
|
20
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: startback
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -383,6 +383,7 @@ files:
|
|
383
383
|
- lib/startback.rb
|
384
384
|
- lib/startback/audit.rb
|
385
385
|
- lib/startback/audit/prometheus.rb
|
386
|
+
- lib/startback/audit/shared.rb
|
386
387
|
- lib/startback/audit/trailer.rb
|
387
388
|
- lib/startback/bus.rb
|
388
389
|
- lib/startback/bus/bunny.rb
|