bitfab 0.10.5 → 0.10.6

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: b789df310c91a7e9130f3bdb6a35e6237a8ddadede4df49a5f7dc4afc0525e91
4
- data.tar.gz: 0cd79b9c9bc8bf15ef926625c0aa1aba8f3cf1798062c0d077e371d98b9f6aba
3
+ metadata.gz: f20353e1bb03affda1786ed5f8566ab1b3a401f0f9635023bae2fd350bcc7de6
4
+ data.tar.gz: 8e10f199e9d81cfdbfa2bc9172327131301dc3959307340bbe6c55e1ef2bc235
5
5
  SHA512:
6
- metadata.gz: fbf62eeabc5741c36ef1b867730f548039f20331d6591ccae7a66cc48882cd4638877edc1b80d57c3a326827edfbedff1d3ec226ed3b4e3358f9041e3405ea5f
7
- data.tar.gz: 579cb384585a42160d5f1c9941cbf0762f53d35ffda7f109cb40c4c52a291a02d446e113ca664a2c84a08916481fe86912eb386a58956fb5651ff1a6dc108771
6
+ metadata.gz: ade88c2b4d5878a3f6e0cee6f70c4a2d63b1a2f0359f425e9da6ab787806c8ef9396ca0e0a71f5ec7c75647e658419f0e9eb099fbbb4ce22a56c38adf26632e8
7
+ data.tar.gz: 9aa7b82e532a84893533b97d67d413cd4012729624d6bde8433bfdecf73c1d929269e6a1d779e50ed7d13e6dcc84a050f22fdf41282f2de4469bd0c5a6a35b30
data/lib/bitfab/client.rb CHANGED
@@ -65,10 +65,15 @@ module Bitfab
65
65
  replay_ctx = ReplayContext.current
66
66
  resolved_test_run_id = replay_ctx&.dig(:test_run_id)
67
67
  resolved_input_source_span_id = replay_ctx&.dig(:input_source_span_id)
68
+ resolved_input_source_trace_id = replay_ctx&.dig(:input_source_trace_id)
68
69
 
69
70
  # Register trace state for root spans
70
71
  if is_root_span && !TraceState.get(trace_id)
71
- TraceState.create(trace_id, test_run_id: resolved_test_run_id)
72
+ TraceState.create(
73
+ trace_id,
74
+ test_run_id: resolved_test_run_id,
75
+ input_source_trace_id: resolved_input_source_trace_id
76
+ )
72
77
  end
73
78
 
74
79
  if is_root_span
@@ -228,6 +233,9 @@ module Bitfab
228
233
  if trace_state&.dig(:contexts)
229
234
  raw_trace["contexts"] = trace_state[:contexts]
230
235
  end
236
+ if trace_state&.dig(:input_source_trace_id)
237
+ raw_trace["input_source_trace_id"] = trace_state[:input_source_trace_id]
238
+ end
231
239
 
232
240
  payload = {
233
241
  "type" => "sdk-function",
data/lib/bitfab/replay.rb CHANGED
@@ -14,11 +14,12 @@ module Bitfab
14
14
 
15
15
  # Execute a block with replay context set on the current thread.
16
16
  # The context is automatically cleared when the block completes.
17
- def with_context(test_run_id:, input_source_span_id: nil)
17
+ def with_context(test_run_id:, input_source_span_id: nil, input_source_trace_id: nil)
18
18
  previous = Thread.current[REPLAY_CONTEXT_KEY]
19
19
  Thread.current[REPLAY_CONTEXT_KEY] = {
20
20
  test_run_id:,
21
- input_source_span_id:
21
+ input_source_span_id:,
22
+ input_source_trace_id:
22
23
  }
23
24
  yield
24
25
  ensure
@@ -117,7 +118,15 @@ module Bitfab
117
118
  span = http_client.get_external_span(server_item["externalSpanId"])
118
119
  item_data = extract_span_data(span)
119
120
  metrics = extract_server_item_metrics(server_item)
120
- execute_item(item_data, receiver, method_name, test_run_id, span["id"], metrics)
121
+ execute_item(
122
+ item_data,
123
+ receiver,
124
+ method_name,
125
+ test_run_id,
126
+ span["id"],
127
+ metrics,
128
+ input_source_trace_id: span["externalTraceId"]
129
+ )
121
130
  end
122
131
 
123
132
  # Extract input/output data from an external span's rawData.
@@ -155,13 +164,14 @@ module Bitfab
155
164
  end
156
165
 
157
166
  # Execute a single replay item: deserialize inputs, call method with replay context.
158
- def execute_item(item, receiver, method_name, test_run_id, input_source_span_id = nil, metrics = {})
167
+ def execute_item(item, receiver, method_name, test_run_id, input_source_span_id = nil, metrics = {},
168
+ input_source_trace_id: nil)
159
169
  args, kwargs = Serialize.deserialize_inputs(item)
160
170
 
161
171
  fn_result = nil
162
172
  fn_error = nil
163
173
 
164
- ReplayContext.with_context(test_run_id:, input_source_span_id:) do
174
+ ReplayContext.with_context(test_run_id:, input_source_span_id:, input_source_trace_id:) do
165
175
  fn_result = if kwargs.empty?
166
176
  receiver.send(method_name, *args)
167
177
  else
@@ -131,12 +131,13 @@ module Bitfab
131
131
  @states_mutex.synchronize { @states[trace_id] }
132
132
  end
133
133
 
134
- def create(trace_id, test_run_id: nil)
134
+ def create(trace_id, test_run_id: nil, input_source_trace_id: nil)
135
135
  @states_mutex.synchronize do
136
136
  @states[trace_id] ||= {
137
137
  trace_id:,
138
138
  started_at: Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%3NZ"),
139
- test_run_id:
139
+ test_run_id:,
140
+ input_source_trace_id:
140
141
  }.compact
141
142
  end
142
143
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.10.5"
4
+ VERSION = "0.10.6"
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.10.5
4
+ version: 0.10.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team