File tree Expand file tree Collapse file tree 1 file changed +24
-9
lines changed
src/OpenTracing.Contrib.Grpc Expand file tree Collapse file tree 1 file changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,16 @@ internal class GrpcTraceLogger<TRequest, TResponse>
15
15
private IScope _scope ;
16
16
private bool _isFinished ;
17
17
18
- private ISpan ScopeSpan => _scope ? . Span ?? _span ;
18
+ private ISpan ScopeSpan
19
+ {
20
+ get
21
+ {
22
+ lock ( this )
23
+ {
24
+ return _scope ? . Span ?? _span ;
25
+ }
26
+ }
27
+ }
19
28
20
29
public GrpcTraceLogger ( ISpan span , TracingConfiguration configuration )
21
30
{
@@ -55,11 +64,14 @@ public void BeginOutputScope(string operationName)
55
64
56
65
private void BeginScope ( string operationName )
57
66
{
58
- if ( _scope != null ) EndScope ( ) ;
67
+ lock ( this )
68
+ {
69
+ if ( _scope != null ) EndScope ( ) ;
59
70
60
- _scope = _configuration . Tracer . BuildSpan ( operationName )
61
- . AsChildOf ( _span . Context )
62
- . StartActive ( false ) ;
71
+ _scope = _configuration . Tracer . BuildSpan ( operationName )
72
+ . AsChildOf ( _span . Context )
73
+ . StartActive ( false ) ;
74
+ }
63
75
}
64
76
65
77
public void EndInputScope ( )
@@ -78,11 +90,14 @@ public void EndOutputScope()
78
90
79
91
private void EndScope ( )
80
92
{
81
- if ( _scope == null ) return ;
93
+ lock ( this )
94
+ {
95
+ if ( _scope == null ) return ;
82
96
83
- _scope . Span . Finish ( ) ;
84
- _scope . Dispose ( ) ;
85
- _scope = null ;
97
+ _scope . Span . Finish ( ) ;
98
+ _scope . Dispose ( ) ;
99
+ _scope = null ;
100
+ }
86
101
}
87
102
88
103
public void Request ( TRequest req )
You can’t perform that action at this time.
0 commit comments