File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 2
2
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
3
// See the LICENSE file in the project root for more information
4
4
5
- using System ;
6
5
using System . Collections . Generic ;
7
6
using System . Diagnostics ;
8
7
using System . Linq ;
@@ -66,13 +65,16 @@ private void CheckAndCaptureBaggage(Transaction transaction)
66
65
67
66
//if context was not set prior we set it now to ensure we capture baggage for errors
68
67
//occuring during unsampled transactions
69
- Context ??= transaction . Context . DeepCopy ( ) ;
68
+ Context ??= transaction ? . Context . DeepCopy ( ) ;
70
69
71
70
foreach ( var baggage in Activity . Current . Baggage )
72
71
{
73
72
if ( ! WildcardMatcher . IsAnyMatch ( Configuration . BaggageToAttach , baggage . Key ) )
74
73
continue ;
75
74
75
+ // The context is created only if there is a baggage value to insert.
76
+ Context ??= new Context ( ) ;
77
+
76
78
var newKey = $ "baggage.{ baggage . Key } ";
77
79
var labels = Context . InternalLabels . Value ;
78
80
labels [ newKey ] = baggage . Value ;
You can’t perform that action at this time.
0 commit comments