diff --git a/libs/kest-core/python/src/kest/core/telemetry/telemetry.py b/libs/kest-core/python/src/kest/core/telemetry/telemetry.py index 13d823a5..e8451404 100644 --- a/libs/kest-core/python/src/kest/core/telemetry/telemetry.py +++ b/libs/kest-core/python/src/kest/core/telemetry/telemetry.py @@ -95,9 +95,9 @@ def _init_db(self): def export(self, spans): """Inserts a batch of spans into the SQLite database.""" with sqlite3.connect(self.db_path) as conn: - for span in spans: - conn.execute( - "INSERT OR REPLACE INTO spans (id, trace_id, name, start_time, end_time, attributes) VALUES (?, ?, ?, ?, ?, ?)", + conn.executemany( + "INSERT OR REPLACE INTO spans (id, trace_id, name, start_time, end_time, attributes) VALUES (?, ?, ?, ?, ?, ?)", + ( ( str(span.context.span_id), str(span.context.trace_id), @@ -105,8 +105,10 @@ def export(self, spans): span.start_time, span.end_time, json.dumps(dict(span.attributes) if span.attributes else {}), - ), - ) + ) + for span in spans + ), + ) return True def shutdown(self):