opera 0.3.4 → 0.3.5

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: 5d44889b440322513ca1bb949f4d57d317141196e76bb56a67447b200d8dac47
4
- data.tar.gz: fdd2f513da963271101a5f9f5bcf9f3d4d8c65ea9a15d743c804cc97b764e501
3
+ metadata.gz: bc70b6a1f69200a0b37229ed04034c3bcc12c66c94dc9a5d0c066ceaf9971cdb
4
+ data.tar.gz: 7b369d14c001a62b07d91c43efd52e23ddb65749aae9a1a19e3cf49105e190a7
5
5
  SHA512:
6
- metadata.gz: d744526b9a983f73f2f5560f62938794bbf10b8dab9e2564c9916ec921aa9509489ff6c6611256502085c6f7b9f5c2a631e90e31f2cebc89bf5a3df2bd7e7ce8
7
- data.tar.gz: 3b7a366e473983a416fcb4b22ed01791d1f89b5cc06fb9daf1f6af244df158e8891de9def6233654611217787cb16417d55d5a3b117ac47b8f2dcd7a60faf360
6
+ metadata.gz: 8ae2fc0df4e8969215716157838de9ce26b4bfc66007c2c62b57e7a2ffd0b918be8974b7513f28d81c14593b41ecff1d573e4fca2ea4502761b9306abc273b4b
7
+ data.tar.gz: 6abf3cb52cd156ae7e458772842e62b1dbca0e2f93dde5af040e68c8c426c75088ae2ef2f11a164372a6d7535e4a0f6516643a78955a67f5040bf53f81ed6485
data/.gitignore CHANGED
@@ -7,5 +7,8 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ #macos
11
+ .DS_Store
12
+
10
13
  # rspec failure tracking
11
14
  .rspec_status
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Opera Changelog
2
2
 
3
+ ### 0.3.5 - February 24, 2025
4
+
5
+ - Simplify instrumentation configuration
6
+ - Allow instrumentation logic to be defined at the source
7
+
3
8
  ### 0.3.4 - February 19, 2025
4
9
 
5
10
  - Add support for `benchmark` label
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opera (0.3.4)
4
+ opera (0.3.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -33,7 +33,7 @@ module Opera
33
33
  def call(args = {})
34
34
  operation = new(params: args.fetch(:params, {}), dependencies: args.fetch(:dependencies, {}))
35
35
  executor = Executor.new(operation)
36
- Instrumentation.new(config).instrument(name: self.name, level: :operation) do
36
+ Instrumentation.new(operation).instrument(name: self.name, level: :operation) do
37
37
  executor.evaluate_instructions(instructions)
38
38
  end
39
39
  executor.result
@@ -6,8 +6,8 @@ module Opera
6
6
  DEVELOPMENT_MODE = :development
7
7
  PRODUCTION_MODE = :production
8
8
 
9
- attr_accessor :transaction_class, :transaction_method, :transaction_options,
10
- :instrumentation_class, :instrumentation_method, :instrumentation_options, :mode, :reporter
9
+ attr_accessor :transaction_class, :transaction_method, :transaction_options, :instrumentation_class,
10
+ :mode, :reporter
11
11
 
12
12
  def initialize
13
13
  @transaction_class = self.class.transaction_class
@@ -15,8 +15,6 @@ module Opera
15
15
  @transaction_options = self.class.transaction_options
16
16
 
17
17
  @instrumentation_class = self.class.instrumentation_class
18
- @instrumentation_method = self.class.instrumentation_method || :instrument
19
- @instrumentation_options = self.class.instrumentation_options || {}
20
18
 
21
19
  @mode = self.class.mode || DEVELOPMENT_MODE
22
20
  @reporter = custom_reporter || self.class.reporter
@@ -41,8 +39,8 @@ module Opera
41
39
  end
42
40
 
43
41
  class << self
44
- attr_accessor :transaction_class, :transaction_method, :transaction_options,
45
- :instrumentation_class, :instrumentation_method, :instrumentation_options, :mode, :reporter
42
+ attr_accessor :transaction_class, :transaction_method, :transaction_options, :instrumentation_class,
43
+ :mode, :reporter
46
44
 
47
45
  def configure
48
46
  yield self
@@ -8,7 +8,7 @@ module Opera
8
8
  def call(instruction)
9
9
  method = instruction[:method]
10
10
 
11
- Instrumentation.new(config).instrument(name: "##{method}", level: :step) do
11
+ Instrumentation.new(operation).instrument(name: "##{method}", level: :step) do
12
12
  operation.result.add_execution(method) unless production_mode?
13
13
  operation.send(method)
14
14
  end
@@ -3,29 +3,31 @@
3
3
  module Opera
4
4
  module Operation
5
5
  class Instrumentation
6
- attr_reader :config
6
+ class Base
7
+ def self.instrument(operation, name:, level: :operation)
8
+ raise NotImplementedError, "#{self.class} must implement #instrument"
9
+ end
10
+ end
11
+
12
+ attr_reader :operation
7
13
 
8
- def initialize(config)
9
- @config = config
14
+ def initialize(operation)
15
+ @operation = operation
10
16
  end
11
17
 
12
18
  def instrument(name:, level: :operation)
13
19
  return yield if !instrumentation_enabled?
14
- return yield if level == :step && instrumentation_level != :step
20
+ return yield if !instrumentation_compatible?
15
21
 
16
- instrumentation_class.send(instrumentation_method, name, **instrumentation_options.except(:level)) do
22
+ instrumentation_class.instrument(operation, name: name, level: level) do
17
23
  yield
18
24
  end
19
25
  end
20
26
 
21
27
  private
22
28
 
23
- def instrumentation_options
24
- config.instrumentation_options
25
- end
26
-
27
- def instrumentation_method
28
- config.instrumentation_method
29
+ def config
30
+ operation.config
29
31
  end
30
32
 
31
33
  def instrumentation_class
@@ -36,8 +38,8 @@ module Opera
36
38
  !!config.instrumentation_class
37
39
  end
38
40
 
39
- def instrumentation_level
40
- instrumentation_options[:level] || :operation
41
+ def instrumentation_compatible?
42
+ config.instrumentation_class.ancestors.include?(Opera::Operation::Instrumentation::Base)
41
43
  end
42
44
  end
43
45
  end
data/lib/opera/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Opera
4
- VERSION = '0.3.4'
4
+ VERSION = '0.3.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opera
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ProFinda Development Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-21 00:00:00.000000000 Z
11
+ date: 2025-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-validation