Skip to content

Commit fbba8a8

Browse files
committed
start_span fix baggage
1 parent 62b390f commit fbba8a8

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cozeloop/_client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
_default_client = None
4040
_client_lock = threading.Lock()
4141

42+
4243
class APIBasePath:
4344
def __init__(
4445
self,
@@ -73,7 +74,7 @@ def new_client(
7374
api_base_path: Optional[APIBasePath] = None,
7475
trace_queue_conf: Optional[QueueConf] = None,
7576
) -> Client:
76-
cache_key = _generate_cache_key( # all args are used to generate cache key
77+
cache_key = _generate_cache_key( # all args are used to generate cache key
7778
api_base_url,
7879
workspace_id,
7980
api_token,
@@ -191,6 +192,7 @@ def __init__(
191192
def combined_processor(event_info: FinishEventInfo):
192193
default_finish_event_processor(event_info)
193194
trace_finish_event_processor(event_info)
195+
194196
finish_pro = combined_processor
195197
span_upload_path = None
196198
file_upload_path = None
@@ -283,9 +285,14 @@ def start_span(
283285
return self._trace_provider.start_span(name=name, span_type=span_type, start_time=start_time,
284286
start_new_trace=start_new_trace)
285287
else:
288+
baggage = {}
289+
if isinstance(child_of.baggage, dict): # SpanContext
290+
baggage = child_of.baggage
291+
else:
292+
baggage = child_of.baggage() # Span
286293
return self._trace_provider.start_span(name=name, span_type=span_type, start_time=start_time,
287294
parent_span_id=child_of.span_id, trace_id=child_of.trace_id,
288-
baggage=child_of.baggage(), start_new_trace=start_new_trace)
295+
baggage=baggage, start_new_trace=start_new_trace)
289296
except Exception as e:
290297
logger.warning(f"Start span failed, returning noop span. Error: {e}")
291298
return NOOP_SPAN

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "cozeloop"
3-
version = "0.1.10"
3+
version = "0.1.11"
44
description = "coze loop sdk"
55
authors = ["JiangQi715 <jiangqi.rrt@bytedance.com>"]
66
license = "MIT"

0 commit comments

Comments
 (0)