MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / _wrapped_async

Function _wrapped_async

agentops/sdk/decorators/factory.py:421–450  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

419 elif is_async:
420
421 async def _wrapped_async() -> Any:
422 with _create_as_current_span(
423 operation_name,
424 entity_kind,
425 version=version,
426 attributes={CoreAttributes.TAGS: tags} if tags else None,
427 ) as span:
428 try:
429 _record_entity_input(span, args, kwargs, entity_kind=entity_kind)
430 # Set cost attribute if tool
431 if entity_kind == "tool" and cost is not None:
432 span.set_attribute(SpanAttributes.LLM_USAGE_TOOL_COST, cost)
433 # Set spec attribute if guardrail
434 if entity_kind == "guardrail" and (spec == "input" or spec == "output"):
435 span.set_attribute(
436 SpanAttributes.AGENTOPS_DECORATOR_SPEC.format(entity_kind=entity_kind), spec
437 )
438 except Exception as e:
439 logger.warning(f"Input recording failed for '{operation_name}': {e}")
440 try:
441 result = await wrapped_func(*args, **kwargs)
442 try:
443 _record_entity_output(span, result, entity_kind=entity_kind)
444 except Exception as e:
445 logger.warning(f"Output recording failed for '{operation_name}': {e}")
446 return result
447 except Exception as e:
448 logger.error(f"Error in async function execution: {e}")
449 span.record_exception(e)
450 raise
451
452 return _wrapped_async()
453 else: # Sync function for non-SESSION kinds

Callers 1

wrapperFunction · 0.85

Calls 6

_create_as_current_spanFunction · 0.90
_record_entity_inputFunction · 0.90
_record_entity_outputFunction · 0.90
set_attributeMethod · 0.45
formatMethod · 0.45
record_exceptionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…