Skip to content

Add support for workflow invocation in genAI utils handler#4366

Merged
aabmass merged 9 commits into
open-telemetry:mainfrom
wrisa:workflow-handler-genai-utils-2
Mar 31, 2026
Merged

Add support for workflow invocation in genAI utils handler#4366
aabmass merged 9 commits into
open-telemetry:mainfrom
wrisa:workflow-handler-genai-utils-2

Conversation

@wrisa
Copy link
Copy Markdown
Contributor

@wrisa wrisa commented Mar 26, 2026

Description

Note: Please ignore duplicate PR. Kept it open for review history, I will close it soon.

Added start, stop, fail support for workflow invocation type.

Check its example usage in langchain.

span when OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT = SPAN_ONLY

Span #1
    Trace ID       : 433d5dbee2e91ef4753fc382f4b8fbfb
    Parent ID      : 
    ID             : bd9e889d1600f77a
    Name           : invoke_workflow LangGraph
    Kind           : Internal
    Start time     : 2026-03-10 22:53:41.866887 +0000 UTC
    End time       : 2026-03-10 22:53:43.471657 +0000 UTC
    Status code    : Unset
    Status message : 
Attributes:
     -> gen_ai.operation.name: Str(invoke_workflow)
     -> gen_ai.input.messages: Str([{"role":"user","parts":[{"content":"You are a helpful assistant!","type":"text"}]},{"role":"user","parts":[{"content":"What is the capital of France?","type":"text"}]}])
     -> gen_ai.output.messages: Str([{"role":"assistant","parts":[{"content":"The capital of France is Paris.","type":"text"}],"finish_reason":"stop"}])

span when OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT = NO_CONTENT

Span #1
    Trace ID       : 433d5dbee2e91ef4753fc382f4b8fbfb
    Parent ID      : 
    ID             : bd9e889d1600f77a
    Name           : invoke_workflow LangGraph
    Kind           : Internal
    Start time     : 2026-03-10 22:53:41.866887 +0000 UTC
    End time       : 2026-03-10 22:53:43.471657 +0000 UTC
    Status code    : Unset
    Status message : 
Attributes:
     -> gen_ai.operation.name: Str(invoke_workflow)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Comment thread util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py Outdated
Comment thread util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py Outdated
Comment thread util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py Outdated
Comment thread util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py Outdated
Comment thread util/opentelemetry-util-genai/tests/test_handler_workflow.py Outdated
Copy link
Copy Markdown
Contributor

@keith-decker keith-decker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I think there's a minor rework coming with the Agent PR around SpanKind being moved to invocations, but that can be added to the Agent PR.

Thanks!

@aabmass aabmass merged commit 828138a into open-telemetry:main Mar 31, 2026
860 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants