startback 0.11.0 → 0.11.3

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
  SHA256:
3
- metadata.gz: fe59e5315c100c9f8c83a100e0a9f538d50946dabdd504db2b5d17ba41738a23
4
- data.tar.gz: 8e12f2e1571e80afe5acc8049e719fb8a06aecfdcb2ba9ed2b1a05fe0941244d
3
+ metadata.gz: 83733eb966d9d9679a15840dfa76f717aacaacc5c3eb417c6bf518a3eea1e3cd
4
+ data.tar.gz: f13815553606f4567e136beb86fc19a066720a3bcdf520c3781c12a732808f47
5
5
  SHA512:
6
- metadata.gz: 7f7e1f0aa41d8ca9a1fcdd11a3fcca551b061bbe8dd7bff1dfe03ecad9b3e39f43a6be3abcd3f3915a98ee101979092e376c076d98e6d87e5ce402373d0c9867
7
- data.tar.gz: d06499ef6a32fd68fce71a240649b32e991d8c0b704a6f848ad126f8577a1d707411d781620790cdc3943694ad79153eb364cd96a988184480cc339878df7bf4
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?(:to_trail, false)
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
@@ -1,2 +1,3 @@
1
+ require_relative 'audit/shared'
1
2
  require_relative 'audit/trailer'
2
3
  require_relative 'audit/prometheus'
@@ -2,7 +2,7 @@ module Startback
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 11
5
- TINY = 0
5
+ TINY = 3
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -6,6 +6,7 @@ module Startback
6
6
 
7
7
  set :raise_errors, true
8
8
  set :show_exceptions, false
9
+ set :dump_errors, false
9
10
 
10
11
  protected
11
12
 
@@ -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 to_trail in priority if provided' do
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.0
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-04-21 00:00:00.000000000 Z
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