Skip to content

Improve optional values handling in chat model observations #1467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ThomasVitale
Copy link
Contributor

Chat model observations support several key-value pairs, coming from the Spring AI abstractions. Currently, whenever a value is not available (either because not configured by the user or not supported by the model provider), span/metrics attributes are generated anyway with value "none".

That causes several issues, including an unneeded increase in time series, challenges in alerting/monitoring (especially for integer/double attributes that suddenly are populated with a string), and non-compliance with the OpenTelemetry Semantic Conventions (according to which, attributes should be excluded altogether if there's no value).

This pull request changes the conventions for chat model observation to exclude the generation of span/metrics attributes for optional values which don't have any value.

Before:

Screenshot 2024-10-05 at 22 29 53

After:

Screenshot 2024-10-05 at 23 20 19

Chat model observations support several key-value pairs, coming from the Spring AI abstractions.
Currently, whenever a value is not available (either because not configured by the user or not supported by the model provider), a span/metrics is generated anyway with value none.
That causes several issues, including an unneeded increase in time series, challenges in alerting/monitoring (especially for integer/double attributes that suddenly are populated with a string), and incompliance with the OpenTelemetry Semantic Conventions (according to which, attributes should be excluded altogether if there's no value).
This pull request changes the conventions for chat model observation to exclude the generation of span/metrics attributes for optional values which don't have any value.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
@ThomasVitale
Copy link
Contributor Author

Additional background: initially, we went with the "none" fallback since that was the main strategy adopted in other Spring projects. But in this case, it turned out not to be efficient for the reasons I mentioned above.

@tzolov
Copy link
Contributor

tzolov commented Oct 5, 2024

Very useful. Thanks

@tzolov tzolov merged commit 3b1c68a into spring-projects:main Oct 5, 2024
1 check passed
@tzolov tzolov added this to the 1.0.0-M3 milestone Oct 5, 2024
@tzolov tzolov self-assigned this Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants