Skip to content

Commit

Permalink
flush_now flag
Browse files Browse the repository at this point in the history
Signed-off-by: Teo <[email protected]>
  • Loading branch information
teocns committed Nov 23, 2024
1 parent 9b54cdb commit c9d52da
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions agentops/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def endpoint(self):
def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
try:
events = []
breakpoint()
for span in spans:
# Convert span to AgentOps event format
assert hasattr(span, "attributes")
Expand Down Expand Up @@ -376,7 +377,7 @@ def set_tags(self, tags):
self.tags = tags
self._update_session()

def record(self, event: Union[Event, ErrorEvent]):
def record(self, event: Union[Event, ErrorEvent], flush_now=False):
"""Record an event using OpenTelemetry spans"""
if not self.is_running:
return
Expand Down Expand Up @@ -408,8 +409,7 @@ def record(self, event: Union[Event, ErrorEvent]):
event.end_timestamp = get_ISO_time()
span.set_attribute("event.end_timestamp", event.end_timestamp)

# Force flush to ensure events are sent immediately in tests
if getattr(self.config, "testing", False):
if flush_now:
for processor in SessionExporter.get_tracer_provider().span_processors:
processor.force_flush()

Expand Down

0 comments on commit c9d52da

Please sign in to comment.