88from warnings import warn
99
1010import numpy as np
11+ from opentelemetry import trace
1112from tqdm .auto import tqdm
1213
1314from qcodes .dataset .data_set import DataSet , load_by_id
3334 from qcodes .dataset .data_set_protocol import DataSetProtocol
3435
3536_LOG = logging .getLogger (__name__ )
37+ _TRACER = trace .get_tracer (__name__ )
3638
3739
40+ @_TRACER .start_as_current_span (f"{ __name__ } .extract_runs_into_db" )
3841def extract_runs_into_db (
3942 source_db_path : str | Path ,
4043 target_db_path : str | Path ,
@@ -178,7 +181,7 @@ def _extract_single_dataset_into_db(
178181 source_conn , target_conn , dataset .table_name , target_table_name
179182 )
180183
181-
184+ @ _TRACER . start_as_current_span ( f" { __name__ } .export_datasets_and_create_metadata_db" )
182185def export_datasets_and_create_metadata_db (
183186 source_db_path : str | Path ,
184187 target_db_path : str | Path ,
@@ -203,6 +206,11 @@ def export_datasets_and_create_metadata_db(
203206 A dictionary mapping run_id to status ('exported', 'copied_as_is', or 'failed')
204207
205208 """
209+ span = trace .get_current_span ()
210+ span .set_attribute ("source_db_path" , str (source_db_path ))
211+ span .set_attribute ("target_db_path" , str (target_db_path ))
212+ span .set_attribute ("export_path" , str (export_path ))
213+
206214 source_db_path = Path (source_db_path )
207215
208216 if not source_db_path .exists ():
@@ -225,6 +233,8 @@ def export_datasets_and_create_metadata_db(
225233 "Please choose a different path or remove the existing file."
226234 )
227235
236+ span .set_attribute ("export_path_from_qcodes_config" , str (get_data_export_path ()))
237+
228238 if export_path is None :
229239 export_path = get_data_export_path ()
230240 else :
@@ -288,6 +298,7 @@ def export_datasets_and_create_metadata_db(
288298 return result_status
289299
290300
301+ @_TRACER .start_as_current_span (f"{ __name__ } ._process_single_dataset" )
291302def _process_single_dataset (
292303 dataset : DataSetProtocol ,
293304 source_conn : AtomicConnection ,
@@ -304,11 +315,17 @@ def _process_single_dataset(
304315 Status string indicating what was done with the dataset
305316
306317 """
318+ span = trace .get_current_span ()
319+ span .set_attribute ("guid" , dataset .guid )
320+ span .set_attribute ("given_export_path" , str (export_path ))
321+
307322 run_id = dataset .run_id
323+ span .set_attribute ("run_id" , run_id )
308324
309325 netcdf_export_path = None
310326
311327 existing_netcdf_path = dataset .export_info .export_paths .get ("nc" )
328+ span .set_attribute ("dataset_netcdf_export_path" , str (existing_netcdf_path ))
312329 if existing_netcdf_path is not None :
313330 existing_path = Path (existing_netcdf_path )
314331 # Check if the existing export path matches the desired export path
0 commit comments