File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,4 +3,5 @@ ALPHATRION_METADATA_INIT_TABLES=true
33ALPHATRION_ARTIFACT_REGISTRY_URL = localhost:5001
44ALPHATRION_ARTIFACT_INSECURE = true
55ALPHATRION_LOG_LEVEL = INFO
6- ALPHATRION_AUTO_CLEANUP = true
6+ ALPHATRION_AUTO_CLEANUP = true
7+ ALPHATRION_ENABLE_TRACING = true
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ def __init__(self, force_init: bool = False):
2222 if self ._inited and not force_init :
2323 return
2424
25+ # Reset inited flag when force_init is True
26+ if force_init :
27+ self ._inited = False
28+
2529 self ._metadb = SQLStore (
2630 os .getenv (envs .METADATA_DB_URL ),
2731 init_tables = os .getenv (envs .METADATA_INIT_TABLES , "false" ).lower () == "true" ,
@@ -67,7 +71,7 @@ def init(force_init: bool = False):
6771 """
6872
6973 global __STORAGE_RUNTIME__
70- if __STORAGE_RUNTIME__ is None :
74+ if force_init or __STORAGE_RUNTIME__ is None :
7175 __STORAGE_RUNTIME__ = StorageRuntime (force_init = force_init )
7276
7377
Original file line number Diff line number Diff line change @@ -396,6 +396,10 @@ async def create_joke():
396396
397397@pytest .mark .asyncio
398398async def test_query_single_run ():
399+ # Enable tracing for this test - MUST be set before init()
400+ os .environ ["ALPHATRION_ENABLE_TRACING" ] = "true"
401+ os .environ ["ALPHATRION_CLICKHOUSE_INIT_TABLES" ] = "true"
402+
399403 team_id = uuid .uuid4 ()
400404 user_id = uuid .uuid4 ()
401405
@@ -413,7 +417,13 @@ async def test_query_single_run():
413417 exp_id = exp .id
414418 await exp .wait ()
415419
416- # Wait a bit for spans to be flushed to ClickHouse
420+ # Force flush spans to ClickHouse
421+ from opentelemetry import trace
422+ tracer_provider = trace .get_tracer_provider ()
423+ if hasattr (tracer_provider , 'force_flush' ):
424+ tracer_provider .force_flush ()
425+
426+ # Wait a bit for spans to be written to ClickHouse
417427 await asyncio .sleep (0.5 )
418428
419429 response = schema .execute_sync (
You can’t perform that action at this time.
0 commit comments