@@ -496,3 +496,55 @@ def dataclass_workflow(data: TestDataClass):
496496 assert task_span .parent .span_id == workflow_span .context .span_id
497497 assert workflow_span .attributes [SpanAttributes .TRACELOOP_ENTITY_NAME ] == "dataclass_workflow"
498498 assert task_span .attributes [SpanAttributes .TRACELOOP_ENTITY_NAME ] == "dataclass_task"
499+
500+
501+ class FakeAsyncRequest :
502+ async def json (self ):
503+ return {"ok" : True }
504+
505+
506+ class FakeSyncRequest :
507+ def json (self ):
508+ return {"ok" : True }
509+
510+
511+ @pytest .mark .asyncio
512+ async def test_async_workflow_with_async_json_method_argument (exporter , recwarn ):
513+ @workflow (name = "request_workflow" )
514+ async def request_workflow (request : FakeAsyncRequest ):
515+ return {"ok" : True }
516+
517+ await request_workflow (FakeAsyncRequest ())
518+
519+ assert not any (
520+ w .category is RuntimeWarning and "was never awaited" in str (w .message )
521+ for w in recwarn
522+ )
523+
524+ spans = exporter .get_finished_spans ()
525+ assert [span .name for span in spans ] == ["request_workflow.workflow" ]
526+
527+ workflow_span = spans [0 ]
528+ assert json .loads (workflow_span .attributes [SpanAttributes .TRACELOOP_ENTITY_INPUT ]) == {
529+ "args" : ["FakeAsyncRequest" ],
530+ "kwargs" : {},
531+ }
532+ assert json .loads (workflow_span .attributes [SpanAttributes .TRACELOOP_ENTITY_OUTPUT ]) == {"ok" : True }
533+
534+
535+ def test_workflow_with_sync_json_method_argument (exporter ):
536+ @workflow (name = "request_workflow" )
537+ def request_workflow (request : FakeSyncRequest ):
538+ return {"ok" : True }
539+
540+ request_workflow (FakeSyncRequest ())
541+
542+ spans = exporter .get_finished_spans ()
543+ assert [span .name for span in spans ] == ["request_workflow.workflow" ]
544+
545+ workflow_span = spans [0 ]
546+ assert json .loads (workflow_span .attributes [SpanAttributes .TRACELOOP_ENTITY_INPUT ]) == {
547+ "args" : [{"ok" : True }],
548+ "kwargs" : {},
549+ }
550+ assert json .loads (workflow_span .attributes [SpanAttributes .TRACELOOP_ENTITY_OUTPUT ]) == {"ok" : True }
0 commit comments