Use invoke_workflow as the AI operation type - #6789
Open
kycasdzxc wants to merge 1 commit into
Open
Conversation
The gen_ai.operation.name attribute has a closed set of allowed values in the OpenTelemetry GenAI semantic conventions, and framework is not one of them. The chat client span and every advisor span carry it today, so consumers validating against the convention skip or flag the attribute. Add AiOperationType.INVOKE_WORKFLOW, which the conventions define as "Invoke GenAI workflow", and use it in ChatClientObservationContext and DefaultAdvisorObservationConvention. Deprecate AiOperationType.FRAMEWORK rather than remove it, since the enum is public API. This changes an emitted attribute value: filters on gen_ai.operation.name = framework for those spans need to move to invoke_workflow. See spring-projects#6750 Signed-off-by: Yermi <kycasdzxc@naver.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
gen_ai.operation.namehas a closed set of allowed values in the OpenTelemetry GenAI semantic conventions. Spring AI emitsframeworkon the chat client span and on every advisor span, andframeworkis not one of them. The registry currently allows:chat,generate_content,text_completion,embeddings,retrieval,fetch_response,create_agent,invoke_agent,execute_tool,invoke_workflow,plan,search_memory,create_memory,update_memory,upsert_memory,delete_memory,create_memory_store,delete_memory_storeinvoke_workflow("Invoke GenAI workflow") is the closest fit, and it matches how the code already describes these spans. The javadoc onChatClientObservationContextreads "Context used to store metadata for chat client workflows."The practical effect is that consumers validating against the convention skip or flag the attribute, so the chat client and advisor spans stay outside GenAI-aware tooling even though the model spans are picked up.
What this changes
AiOperationType.INVOKE_WORKFLOWand deprecatesAiOperationType.FRAMEWORK, which no longer has a valid value to represent.ChatClientObservationContextandDefaultAdvisorObservationConventionuse the new value.AiOperationTypeis public API, soFRAMEWORKis deprecated rather than removed, withforRemoval = false. Happy to change that if you have a target version in mind.One caveat on scope, since it is the weaker half of this change.
invoke_workflowfits the chat client span cleanly: that span wraps the advisor chain, the model calls and the tool calls, which is what the conventions describe as a workflow. It is a looser fit for the individual advisor spans, which are steps within that workflow rather than workflows themselves. I applied it to both because leaving the advisor spans onframeworkwould keep a value that is not in the registry at all, but scoping this to the chat client span, or droppinggen_ai.operation.namefrom the advisor spans entirely, are both easy changes if you prefer either.Compatibility
This changes an emitted attribute value. Dashboards or alerts that filter on
gen_ai.operation.name = frameworkfor chat client or advisor spans would need to move toinvoke_workflow. Calling it out because it is telemetry-visible rather than internal.Keeping
frameworkis also a legitimate choice. The GenAI conventions are still at Development stability, and declining to track a moving spec is a reasonable position for a released version. If that is where you land, say so and I will close this.How this was found
Comparing two copies of the same Spring AI and MCP application, identical except for the OpenTelemetry instrumentation: one on
spring-boot-starter-opentelemetry, one on Arconia. Arconia's GenAI convention already reportsinvoke_workflowfor the chat client span, while the advisor spans keepframeworkbecause that value is set below the layer Arconia replaces.Captured spans and the full comparison: https://github.com/kycasdzxc/spring-ai-otel-example/blob/main/FINDINGS.md
Not included
The chat client span's contextual name is built from the provider rather than the operation:
That yields
spring_ai chat_client, where the span naming rule in the same conventions would suggestinvoke_workflow chat_client. Left out to keep this focused on the attribute value. Happy to follow up separately if you want it changed.See #6750