bitfab 0.12.5 → 0.14.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a66f64bbe867d0adeafbebc9984413802c8ecf8ae47007078b8a3e9d336e5bd0
4
- data.tar.gz: 726943a84542d9bc5ead1cc54b0c66d726edaf57ed03703588f63fd41fb67ecd
3
+ metadata.gz: d6264d16b3fdf093418d97c43141db5a83e890d0b5e8993f255498c01548c31b
4
+ data.tar.gz: 158be7664defce737b4b6e3a1db39f6bf13fee37aee9f9948fb63f7b2dd2a254
5
5
  SHA512:
6
- metadata.gz: fb26e2388ac5585d8a74aeb8de4f2b8af12df1d6abf4c882560a96107de46afd6fa9a8c1fd99482ae5af6c49234f058f473338c00b91502494e0c078c65a052f
7
- data.tar.gz: 9eedf94be719b11b2456ed0002eaeb01afc0b1ef42099850dcc4507096072efb593975a5fa92cef8a99fa224cb1873d0f6c41bfa9d343782f70989b542303da4
6
+ metadata.gz: cb6a19c8fcfd500c58e0bbf7a1332fb27b6701282cc859bf2590477bae8fd4aaf871e37e15fc9eb0f70cbe7c121b5550f1d7ce536d771992282e0484eb545d1e
7
+ data.tar.gz: b6ab4f9aa78b82b8a14d993e1357ae9db9fd09447a16ea8e5ff301998504548f7d54339923f238e4065661fcc61e8ae3db2171a8b4c00f30b1695d20f87d7546
data/lib/bitfab/client.rb CHANGED
@@ -39,8 +39,10 @@ module Bitfab
39
39
  # @param receiver [Object, Class] an instance for instance methods, or a Class for class methods
40
40
  # @param method_name [Symbol] the method to replay
41
41
  # @param trace_function_key [String] the trace function key for this method
42
- # @param limit [Integer] maximum number of traces to replay (default: 5)
43
- # @param trace_ids [Array<String>, nil] optional list of trace IDs to filter
42
+ # @param limit [Integer, nil] maximum number of traces to replay (default: 5).
43
+ # Mutually exclusive with trace_ids: an explicit ID list already
44
+ # determines how many traces replay, so passing both raises.
45
+ # @param trace_ids [Array<String>, nil] optional list of trace IDs to replay (max 100)
44
46
  # @param max_concurrency [Integer, nil] max threads for parallel replay (default: 10)
45
47
  # @param code_change_description [String, nil] optional rationale for the
46
48
  # code change being tested in this replay (stored on the experiment)
@@ -52,7 +54,7 @@ module Bitfab
52
54
  # "all", or "marked". "all" mocks every child span; "marked" only mocks
53
55
  # spans declared with mock_on_replay: true.
54
56
  # @return [Hash] with :items, :test_run_id, :test_run_url
55
- def replay(receiver, method_name, trace_function_key:, limit: 5, trace_ids: nil, max_concurrency: 10,
57
+ def replay(receiver, method_name, trace_function_key:, limit: nil, trace_ids: nil, max_concurrency: 10,
56
58
  code_change_description: nil, code_change_files: nil, experiment_group_id: nil, mock: "none")
57
59
  Replay.run(
58
60
  self, receiver, method_name,
@@ -108,9 +108,11 @@ module Bitfab
108
108
  def start_replay(trace_function_key, limit, trace_ids: nil, code_change_description: nil,
109
109
  code_change_files: nil, experiment_group_id: nil)
110
110
  payload = {
111
- "traceFunctionKey" => trace_function_key,
112
- "limit" => limit
111
+ "traceFunctionKey" => trace_function_key
113
112
  }
113
+ # limit is only meaningful without trace_ids (an explicit ID list
114
+ # already determines the count), so it's omitted when nil.
115
+ payload["limit"] = limit unless limit.nil?
114
116
  payload["traceIds"] = trace_ids if trace_ids
115
117
  payload["codeChangeDescription"] = code_change_description unless code_change_description.nil?
116
118
  payload["codeChangeFiles"] = normalize_code_change_files(code_change_files) unless code_change_files.nil?
data/lib/bitfab/replay.rb CHANGED
@@ -56,8 +56,10 @@ module Bitfab
56
56
  # @param receiver [Object, Class] an instance for instance methods, or a Class for class methods
57
57
  # @param method_name [Symbol] the method to replay
58
58
  # @param trace_function_key [String] the trace function key for this method
59
- # @param limit [Integer] maximum number of traces to replay (default: 5)
60
- # @param trace_ids [Array<String>, nil] optional list of trace IDs to filter
59
+ # @param limit [Integer, nil] maximum number of traces to replay (default: 5).
60
+ # Mutually exclusive with trace_ids: an explicit ID list already
61
+ # determines how many traces replay, so passing both raises.
62
+ # @param trace_ids [Array<String>, nil] optional list of trace IDs to replay (max 100)
61
63
  # @param max_concurrency [Integer, nil] max threads for parallel replay (default: 10)
62
64
  # @param code_change_description [String, nil] optional rationale for the
63
65
  # code change being tested in this replay (stored on the experiment)
@@ -69,17 +71,31 @@ module Bitfab
69
71
  # "all", or "marked". "all" mocks every child span; "marked" only mocks
70
72
  # spans declared with mock_on_replay: true.
71
73
  # @return [Hash] with :items, :test_run_id, :test_run_url
72
- def run(client, receiver, method_name, trace_function_key:, limit: 5, trace_ids: nil, max_concurrency: 10,
74
+ def run(client, receiver, method_name, trace_function_key:, limit: nil, trace_ids: nil, max_concurrency: 10,
73
75
  code_change_description: nil, code_change_files: nil, experiment_group_id: nil, mock: "none")
74
76
  unless MOCK_STRATEGIES.include?(mock.to_s)
75
77
  raise ArgumentError, "Invalid mock strategy '#{mock}'. Must be one of: #{MOCK_STRATEGIES.join(", ")}"
76
78
  end
79
+ if trace_ids
80
+ raise ArgumentError, "trace_ids must contain at least one trace ID." if trace_ids.empty?
81
+ if trace_ids.length > 100
82
+ raise ArgumentError, "trace_ids supports at most 100 trace IDs per replay (got #{trace_ids.length})."
83
+ end
84
+ end
85
+ if limit && trace_ids
86
+ raise ArgumentError,
87
+ "Pass either limit or trace_ids, not both: an explicit trace ID list already determines how many traces replay."
88
+ end
77
89
 
78
90
  http_client = client.instance_variable_get(:@http_client)
79
91
 
92
+ # limit is meaningless with explicit trace_ids (the ID list determines
93
+ # the count), so it's omitted from the request entirely.
94
+ effective_limit = trace_ids ? nil : (limit || 5)
95
+
80
96
  replay_data = http_client.start_replay(
81
97
  trace_function_key,
82
- limit,
98
+ effective_limit,
83
99
  trace_ids:,
84
100
  code_change_description:,
85
101
  code_change_files:,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.12.5"
4
+ VERSION = "0.14.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitfab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.5
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team