@@ -333,6 +333,46 @@ async def poll_for_detection(
333333 return await self .logs_resource .poll_for_detection (
334334 log_id , timeout , poll_interval
335335 )
336+
337+ class AsyncQuotientTracer :
338+ """
339+ Tracer interface that wraps the underlying tracing resource for asynchronous operations.
340+ """
341+
342+ def __init__ (self , tracing_resource ):
343+ self .tracing_resource = tracing_resource
344+
345+ self .app_name : Optional [str ] = None
346+ self .environment : Optional [str ] = None
347+ self .instruments : Optional [list ] = None
348+ self ._configured = False
349+
350+ def init (self , app_name : str , environment : str , instruments : Optional [list ] = None ):
351+ """
352+ Configure the tracer with the provided parameters and return self.
353+ This method must be called before using trace().
354+ """
355+ self .app_name = app_name
356+ self .environment = environment
357+ self .instruments = instruments
358+
359+ self .tracing_resource .configure (app_name = app_name , environment = environment , instruments = instruments )
360+
361+ self ._configured = True
362+
363+ return self
364+
365+ def trace (self ):
366+ """
367+ Trace a function asynchronously.
368+ """
369+ if not self ._configured :
370+ logger .error (
371+ "Tracer is not configured. Please call init() before using trace()."
372+ )
373+ return None
374+
375+ return self .tracing_resource .trace ()
336376
337377
338378class AsyncQuotientAI :
@@ -359,11 +399,11 @@ def __init__(self, api_key: Optional[str] = None):
359399 self ._client = _AsyncQuotientClient (self .api_key )
360400 self .auth = AsyncAuthResource (self ._client )
361401 self .logs = resources .AsyncLogsResource (self ._client )
362- self .tracing = resources .AsyncTracingResource (self ._client )
363- self .trace = self .tracing .trace
402+ self .tracing = resources .TracingResource (self ._client )
364403
365404 # Create an unconfigured logger instance.
366405 self .logger = AsyncQuotientLogger (self .logs )
406+ self .tracer = AsyncQuotientTracer (self .tracing )
367407
368408 try :
369409 self .auth .authenticate ()
@@ -419,3 +459,28 @@ async def log(
419459 inconsistency_detection = inconsistency_detection ,
420460 )
421461 return result
462+
463+ def trace (self ):
464+ """
465+ Trace a function asynchronously.
466+ """
467+ return self .tracer .trace ()
468+
469+ async def poll_for_detection (
470+ self , log_id : str , timeout : int = 300 , poll_interval : float = 2.0
471+ ):
472+ """
473+ Get Detection results for a log asynchronously.
474+ """
475+ if not self .logger ._configured :
476+ logger .error (
477+ "Logger is not configured. Please call init() before using poll_for_detection()."
478+ )
479+ return None
480+
481+ if not log_id :
482+ logger .error ("Log ID is required for Detection" )
483+ return None
484+
485+ detection = await self .logger .poll_for_detection (log_id = log_id , timeout = timeout , poll_interval = poll_interval )
486+ return detection
0 commit comments