bitfab 0.58.3 → 0.58.4
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 +4 -4
- data/lib/bitfab/client.rb +23 -2
- data/lib/bitfab/span_context.rb +2 -1
- data/lib/bitfab/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13b552211978874936f8b732245e948396758a5adf6d0485859cf98748bf4933
|
|
4
|
+
data.tar.gz: 612bbee201e37c8c425c5aa42bbcc6f713ca848e5cf43ad7eae5797beeefd660
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7150bd10acde90cfe101845b6b6da248ae4cfb57a3742d8a33ef8d045e93d0ebfa6eaf6672376304f957206801c4f0b6ae60707d881d7621dce2d61b887405d4
|
|
7
|
+
data.tar.gz: beb42456465d624c22fc12d2294011be076748011bfac9dfad6a6397083bcebf6902a2fd7f7fadbdfa2c8e88c2df6b862c3a1f1bff0afb3f947e45256c68cc28
|
data/lib/bitfab/client.rb
CHANGED
|
@@ -425,6 +425,13 @@ module Bitfab
|
|
|
425
425
|
span_id = SecureRandom.uuid
|
|
426
426
|
parent_span_id = parent&.dig(:span_id)
|
|
427
427
|
is_root_span = parent_span_id.nil?
|
|
428
|
+
ancestor_span_id = nearest_captured_ancestor_span_id
|
|
429
|
+
open_instrumentation = (surface == :trace) ? "trace" : "span"
|
|
430
|
+
sends_on_completion = lambda do
|
|
431
|
+
is_root_span || declared_node || !content_off_by_simulation_plan?(
|
|
432
|
+
trace_id:, trace_function_key:, span_name:, instrumentation: open_instrumentation
|
|
433
|
+
)
|
|
434
|
+
end
|
|
428
435
|
started_at = Bitfab.now_iso_timestamp
|
|
429
436
|
resolved_test_run_id = replay_ctx ? replay_ctx[:test_run_id] : test_run_id
|
|
430
437
|
resolved_input_source_span_id = replay_ctx&.dig(:input_source_span_id)
|
|
@@ -550,6 +557,7 @@ module Bitfab
|
|
|
550
557
|
span_data: content_off ? span_data.merge("content_off_by_simulation_plan" => true) : span_data,
|
|
551
558
|
instrumentation: recorded_instrumentation,
|
|
552
559
|
declared_node:,
|
|
560
|
+
nearest_captured_ancestor_span_id: ancestor_span_id,
|
|
553
561
|
trace_function_key:,
|
|
554
562
|
trace_id:,
|
|
555
563
|
span_id:,
|
|
@@ -618,7 +626,8 @@ module Bitfab
|
|
|
618
626
|
span_id:,
|
|
619
627
|
explicit_span_receiver:,
|
|
620
628
|
explicit_span_method_name: explicit_span_method_name&.to_sym,
|
|
621
|
-
surface:, recording_override:, content_withheld
|
|
629
|
+
surface:, recording_override:, content_withheld:,
|
|
630
|
+
sends_on_completion: sends_on_completion
|
|
622
631
|
) do
|
|
623
632
|
invoke = -> { around_body ? around_body.call { yield } : yield }
|
|
624
633
|
result = if explicit_span_receiver
|
|
@@ -683,6 +692,14 @@ module Bitfab
|
|
|
683
692
|
raise ArgumentError, "id must be a valid Bitfab span ID" unless id.is_a?(String) && UUID_PATTERN.match?(id)
|
|
684
693
|
end
|
|
685
694
|
|
|
695
|
+
def nearest_captured_ancestor_span_id
|
|
696
|
+
SpanContext.stack.reverse_each do |entry|
|
|
697
|
+
sends = entry[:sends_on_completion]
|
|
698
|
+
return entry[:span_id] if sends.nil? || sends.call
|
|
699
|
+
end
|
|
700
|
+
nil
|
|
701
|
+
end
|
|
702
|
+
|
|
686
703
|
def content_off_by_simulation_plan?(trace_id:, trace_function_key:, span_name:, instrumentation: "span")
|
|
687
704
|
return false if SimulationPlan::FRAMEWORKS.include?(instrumentation)
|
|
688
705
|
|
|
@@ -927,7 +944,8 @@ module Bitfab
|
|
|
927
944
|
def send_span(trace_function_key:, trace_id:, span_id:, parent_span_id:,
|
|
928
945
|
span_name:, span_type:, function_name:, contexts:, prompt:, args:, kwargs:, result:, error:,
|
|
929
946
|
started_at:, ended_at:, test_run_id: nil, input_source_span_id: nil, mocked: false,
|
|
930
|
-
mock_target: nil, mock_source: nil, span_data: {}, instrumentation: "span", declared_node: false
|
|
947
|
+
mock_target: nil, mock_source: nil, span_data: {}, instrumentation: "span", declared_node: false,
|
|
948
|
+
nearest_captured_ancestor_span_id: nil)
|
|
931
949
|
extra_span_data = span_data
|
|
932
950
|
# If drop() was called on this trace, suppress the span PAYLOAD upload for
|
|
933
951
|
# every span that completes after the flag was set. The trace completion
|
|
@@ -983,6 +1001,9 @@ module Bitfab
|
|
|
983
1001
|
"span_origin" => Bitfab.make_span_origin(instrumentation)
|
|
984
1002
|
}
|
|
985
1003
|
raw_span["parent_id"] = parent_span_id if parent_span_id
|
|
1004
|
+
if nearest_captured_ancestor_span_id && nearest_captured_ancestor_span_id != parent_span_id
|
|
1005
|
+
raw_span["nearest_captured_ancestor_id"] = nearest_captured_ancestor_span_id
|
|
1006
|
+
end
|
|
986
1007
|
raw_span["input_source_span_id"] = input_source_span_id if input_source_span_id
|
|
987
1008
|
|
|
988
1009
|
payload = {
|
data/lib/bitfab/span_context.rb
CHANGED
|
@@ -150,8 +150,9 @@ module Bitfab
|
|
|
150
150
|
|
|
151
151
|
# Execute a block with a new span pushed onto the stack.
|
|
152
152
|
# The span is automatically popped when the block completes.
|
|
153
|
-
def with_span(trace_id:, span_id:, explicit_span_receiver: nil, explicit_span_method_name: nil, surface: nil, recording_override: nil, content_withheld: nil)
|
|
153
|
+
def with_span(trace_id:, span_id:, explicit_span_receiver: nil, explicit_span_method_name: nil, surface: nil, recording_override: nil, content_withheld: nil, sends_on_completion: nil)
|
|
154
154
|
entry = {trace_id:, span_id:}
|
|
155
|
+
entry[:sends_on_completion] = sends_on_completion if sends_on_completion
|
|
155
156
|
entry[:surface] = surface if surface
|
|
156
157
|
entry[:recording_override] = recording_override if recording_override
|
|
157
158
|
entry[:content_withheld] = content_withheld if content_withheld
|
data/lib/bitfab/version.rb
CHANGED