forked from instana/python-sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspan_context.py
33 lines (28 loc) · 829 Bytes
/
span_context.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2019
class SpanContext():
def __init__(
self,
trace_id=None,
span_id=None,
baggage=None,
sampled=True,
level=1,
synthetic=False):
self.level = level
self.trace_id = trace_id
self.span_id = span_id
self.sampled = sampled
self.synthetic = synthetic
self._baggage = baggage or {}
@property
def baggage(self):
return self._baggage
def with_baggage_item(self, key, value):
new_baggage = self._baggage.copy()
new_baggage[key] = value
return SpanContext(
trace_id=self.trace_id,
span_id=self.span_id,
sampled=self.sampled,
baggage=new_baggage)