File tree Expand file tree Collapse file tree 3 files changed +9
-20
lines changed
lib/traces/backend/open_telemetry Expand file tree Collapse file tree 3 files changed +9
-20
lines changed Original file line number Diff line number Diff line change 77
88require "covered/sus"
99include Covered ::Sus
10+
11+ require "opentelemetry/sdk"
12+ OpenTelemetry ::SDK . configure
Original file line number Diff line number Diff line change @@ -17,21 +17,7 @@ module OpenTelemetry
1717
1818 module Interface
1919 def trace ( name , attributes : nil , &block )
20- span = TRACER . start_span ( name , attributes : attributes &.transform_keys ( &:to_s ) )
21-
22- begin
23- if block . arity . zero?
24- yield
25- else
26- yield span
27- end
28- rescue Exception => error
29- span &.record_exception ( error )
30- span &.status = ::OpenTelemetry ::Trace ::Status . error ( "Unhandled exception of type: #{ error . class } " )
31- raise
32- ensure
33- span &.finish
34- end
20+ TRACER . in_span ( name , attributes : attributes &.transform_keys ( &:to_s ) , &block )
3521 end
3622
3723 def trace_context = ( context )
@@ -44,8 +30,8 @@ def trace_context=(context)
4430 )
4531
4632 span = ::OpenTelemetry ::Trace . non_recording_span ( span_context )
47-
48- return ::OpenTelemetry ::Trace . context_with_span ( span )
33+ context = :: OpenTelemetry :: Trace . context_with_span ( span )
34+ ::OpenTelemetry ::Context . attach ( context )
4935 end
5036
5137 def trace_context ( span = ::OpenTelemetry ::Trace . current_span )
Original file line number Diff line number Diff line change @@ -101,9 +101,9 @@ def my_span_and_context
101101 )
102102
103103 # It seems like OpenTelemetry doesn't really do anything in the testing environment, so we can't really check the parent_id?
104- # expect(span).to have_attributes(
105- # parent_id : be == context.parent_id
106- # )
104+ expect ( span ) . to have_attributes (
105+ parent_span_id : be == context . parent_id
106+ )
107107 end
108108 end
109109 end
You can’t perform that action at this time.
0 commit comments