Skip to content

spring.ai.chat.client.*.text span tags are not captured when using messages() #2631

@asw12

Description

@asw12

Bug description
When ChatClientInputContentObservationFilter is enabled, system text and user text is captured and added as high cardinality key values (spring.ai.chat.client.system.text and spring.ai.chat.client.user.text). But as this filter does so by capturing

  • context.getRequest().getSystemText()
  • context.getRequest().getUserText()

nothing ends up getting added to the observation when the code is using messages().

Environment
spring-ai 1.0.0-M6
properties="spring.ai.chat.client.observations.include-input=true"

Steps to reproduce
Enable micrometer-observations and set the include-input option to true, as above.

chatClient.prompt()
	.messages(
			new SystemMessage("System Text"),
			new UserMessage("My question"),
			new AssistantMessage("Your answer")
	)
	.call().content();

Expected behavior
I would expect messages() to be split up and treated more similarly to the individual systemText() and userText() calls, where messages() still produces the span tags by concatenating all the systemText and userText together.

This is similar to #873 #2339, where there is a violation of principle of least surprise in that I was not expecting systemText() and userText() to work so differently from messages().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions