()
| 315 | elif is_async: |
| 316 | |
| 317 | async def _wrapped_session_async() -> Any: |
| 318 | trace_context: Optional[TraceContext] = None |
| 319 | try: |
| 320 | trace_context = tracer.start_trace(trace_name=operation_name, tags=tags) |
| 321 | if not trace_context: |
| 322 | logger.error( |
| 323 | f"Failed to start trace for @trace '{operation_name}'. Executing without trace." |
| 324 | ) |
| 325 | return await wrapped_func(*args, **kwargs) |
| 326 | try: |
| 327 | _record_entity_input(trace_context.span, args, kwargs) |
| 328 | except Exception as e: |
| 329 | logger.warning(f"Input recording failed for @trace '{operation_name}': {e}") |
| 330 | result = await wrapped_func(*args, **kwargs) |
| 331 | try: |
| 332 | _record_entity_output(trace_context.span, result) |
| 333 | except Exception as e: |
| 334 | logger.warning(f"Output recording failed for @trace '{operation_name}': {e}") |
| 335 | tracer.end_trace(trace_context, "Success") |
| 336 | return result |
| 337 | except Exception: |
| 338 | if trace_context: |
| 339 | tracer.end_trace(trace_context, "Indeterminate") |
| 340 | raise |
| 341 | finally: |
| 342 | if trace_context and trace_context.span.is_recording(): |
| 343 | logger.warning( |
| 344 | f"Trace for @trace '{operation_name}' not explicitly ended. Ending as 'Unknown'." |
| 345 | ) |
| 346 | tracer.end_trace(trace_context, "Unknown") |
| 347 | |
| 348 | return _wrapped_session_async() |
| 349 | else: # Sync function for SpanKind.SESSION |
no test coverage detected
searching dependent graphs…