Skip to content

Commit d1a0892

Browse files
committed
modify span batch, duration name
1 parent dd832d1 commit d1a0892

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

cozeloop/internal/trace/exporter.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import base64
55
import logging
6+
import time
67
from typing import Dict, List, Optional, Tuple, Callable, Any
78

89
from cozeloop.spec.tracespce import ModelInput, ModelMessagePart, ModelMessagePartType, ModelImageURL, ModelFileURL, ModelOutput
@@ -94,7 +95,7 @@ class UploadSpan(BaseModel):
9495
span_id: str
9596
parent_id: str
9697
trace_id: str
97-
duration: int
98+
duration_micros: int
9899
workspace_id: str
99100
span_name: str
100101
span_type: str
@@ -138,7 +139,7 @@ def transfer_to_upload_span_and_file(spans: List['Span']) -> (List[UploadSpan],
138139
span_id=span.span_id,
139140
parent_id=span.parent_span_id,
140141
trace_id=span.trace_id,
141-
duration=span.get_duration(),
142+
duration_micros=span.get_duration(),
142143
workspace_id=span.get_space_id(),
143144
span_name=span.get_span_name(),
144145
span_type=span.get_span_type(),

cozeloop/internal/trace/queue_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ def _do_export(self):
105105
while not self.queue.empty():
106106
item = self.queue.get()
107107
self.batch.append(item)
108+
if len(self.batch) == self.options.max_export_batch_length:
109+
break
108110
logger.debug(
109111
f"{self.options.queue_name} queue _do_export_end, len: {len(self.batch)}")
110112
self._do_export_batch()

cozeloop/internal/trace/span_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from cozeloop.internal.trace.span import Span
1616

1717
DEFAULT_MAX_QUEUE_LENGTH = 2048
18-
DEFAULT_MAX_EXPORT_BATCH_LENGTH = 512
18+
DEFAULT_MAX_EXPORT_BATCH_LENGTH = 100
1919
DEFAULT_MAX_EXPORT_BATCH_BYTE_SIZE = 4 * 1024 * 1024 # 4MB
2020
MAX_RETRY_EXPORT_BATCH_LENGTH = 50
2121
DEFAULT_SCHEDULE_DELAY = 1000 # millisecond

tests/internal/trace/test_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ def benchmark(qps, duration):
9090

9191

9292
def test_trace_benchmark():
93-
benchmark(qps=1000, duration=20)
93+
benchmark(qps=500, duration=20)

0 commit comments

Comments
 (0)