11using OpenTracing ;
22using OpenTracing . Tag ;
33
4- namespace Pyroscope . Tracing . OpenTracing ;
4+ namespace Pyroscope . OpenTracing ;
55
66public class PyroscopeSpanBuilder : ISpanBuilder
77{
88 private const string ProfileIdSpanTagKey = "pyroscope.profile.id" ;
99
1010 private readonly ISpanBuilder _delegate ;
11- private readonly Config _config ;
1211 private ISpanContext ? _parent ;
1312
14- internal PyroscopeSpanBuilder ( Config config , ISpanBuilder spanBuilder , ISpanContext ? parent )
13+ internal PyroscopeSpanBuilder ( ISpanBuilder spanBuilder , ISpanContext ? parent )
1514 {
16- _config = config ;
1715 _delegate = spanBuilder ;
1816 _parent = parent ;
1917 }
@@ -29,19 +27,19 @@ public IScope StartActive()
2927 {
3028 var scope = _delegate . StartActive ( ) ;
3129 ConnectSpanWithProfiling ( scope . Span ) ;
32- return new PyroscopeScope ( _config , scope , _parent ) ;
30+ return new PyroscopeScope ( scope , _parent ) ;
3331 }
3432
3533 public IScope StartActive ( bool finishSpanOnDispose )
3634 {
3735 var scope = _delegate . StartActive ( finishSpanOnDispose ) ;
3836 ConnectSpanWithProfiling ( scope . Span ) ;
39- return new PyroscopeScope ( _config , scope , _parent ) ;
37+ return new PyroscopeScope ( scope , _parent ) ;
4038 }
4139
4240 private void ConnectSpanWithProfiling ( ISpan span )
4341 {
44- if ( _parent != null && _config . RootSpanOnly )
42+ if ( _parent != null )
4543 {
4644 return ;
4745 }
@@ -139,15 +137,13 @@ public ISpanBuilder IgnoreActiveSpan()
139137
140138 class PyroscopeScope : IScope
141139 {
142- private readonly Config _config ;
143140 private readonly IScope _delegate ;
144141 private readonly ISpanContext ? _parent ;
145142
146143 public ISpan Span => _delegate . Span ;
147144
148- internal PyroscopeScope ( Config _config , IScope _delegate , ISpanContext ? _parent )
145+ internal PyroscopeScope ( IScope _delegate , ISpanContext ? _parent )
149146 {
150- this . _config = _config ;
151147 this . _delegate = _delegate ;
152148 this . _parent = _parent ;
153149 }
@@ -160,21 +156,6 @@ public void Dispose()
160156 Profiler . Instance . SetProfileId ( 0 ) ; // TODO: Replace with ResetContext()
161157 return ;
162158 }
163- if ( _config . RootSpanOnly )
164- {
165- return ;
166- }
167- try
168- {
169- var spanId = _parent . SpanId ;
170- var spanIdLong = Convert . ToUInt64 ( spanId . ToUpper ( ) , 16 ) ;
171-
172- Profiler . Instance . SetProfileId ( spanIdLong ) ;
173- }
174- catch ( Exception ex )
175- {
176- Console . WriteLine ( $ "Caught exception while setting profile id in profiler instance: { ex . Message } ") ;
177- }
178159 }
179160 }
180161}
0 commit comments