@@ -11,7 +11,7 @@ use tokio_stream::StreamExt;
1111use tracing:: warn;
1212
1313// Import tracing constants and signals
14- use crate :: tracing:: { llm, error} ;
14+ use crate :: tracing:: { llm, error, signals as signal_constants } ;
1515use crate :: signals:: signals:: { SignalAnalyzer , InteractionQuality , FLAG_MARKER } ;
1616use hermesllm:: apis:: openai:: Message ;
1717
@@ -153,12 +153,29 @@ impl StreamProcessor for ObservableStreamProcessor {
153153
154154 // Add overall quality
155155 self . span . attributes . push ( Attribute {
156- key : "signals.quality" . to_string ( ) ,
156+ key : signal_constants :: QUALITY . to_string ( ) ,
157157 value : AttributeValue {
158158 string_value : Some ( format ! ( "{:?}" , report. overall_quality) ) ,
159159 } ,
160160 } ) ;
161161
162+ // Add repair/follow-up metrics if concerning
163+ if report. follow_up . is_concerning || report. follow_up . repair_count > 0 {
164+ self . span . attributes . push ( Attribute {
165+ key : signal_constants:: REPAIR_COUNT . to_string ( ) ,
166+ value : AttributeValue {
167+ string_value : Some ( report. follow_up . repair_count . to_string ( ) ) ,
168+ } ,
169+ } ) ;
170+
171+ self . span . attributes . push ( Attribute {
172+ key : signal_constants:: REPAIR_RATIO . to_string ( ) ,
173+ value : AttributeValue {
174+ string_value : Some ( format ! ( "{:.3}" , report. follow_up. repair_ratio) ) ,
175+ } ,
176+ } ) ;
177+ }
178+
162179 // Add flag marker to operation name if any concerning signal is detected
163180 let should_flag = report. frustration . has_frustration
164181 || report. repetition . has_looping
@@ -176,13 +193,13 @@ impl StreamProcessor for ObservableStreamProcessor {
176193 // Add key signal metrics
177194 if report. frustration . has_frustration {
178195 self . span . attributes . push ( Attribute {
179- key : "signals.frustration.count" . to_string ( ) ,
196+ key : signal_constants :: FRUSTRATION_COUNT . to_string ( ) ,
180197 value : AttributeValue {
181198 string_value : Some ( report. frustration . frustration_count . to_string ( ) ) ,
182199 } ,
183200 } ) ;
184201 self . span . attributes . push ( Attribute {
185- key : "signals.frustration.severity" . to_string ( ) ,
202+ key : signal_constants :: FRUSTRATION_SEVERITY . to_string ( ) ,
186203 value : AttributeValue {
187204 string_value : Some ( report. frustration . severity . to_string ( ) ) ,
188205 } ,
@@ -191,7 +208,7 @@ impl StreamProcessor for ObservableStreamProcessor {
191208
192209 if report. repetition . has_looping {
193210 self . span . attributes . push ( Attribute {
194- key : "signals.repetition.count" . to_string ( ) ,
211+ key : signal_constants :: REPETITION_COUNT . to_string ( ) ,
195212 value : AttributeValue {
196213 string_value : Some ( report. repetition . repetition_count . to_string ( ) ) ,
197214 } ,
@@ -200,7 +217,7 @@ impl StreamProcessor for ObservableStreamProcessor {
200217
201218 if report. escalation . escalation_requested {
202219 self . span . attributes . push ( Attribute {
203- key : "signals.escalation.requested" . to_string ( ) ,
220+ key : signal_constants :: ESCALATION_REQUESTED . to_string ( ) ,
204221 value : AttributeValue {
205222 string_value : Some ( "true" . to_string ( ) ) ,
206223 } ,
@@ -209,7 +226,7 @@ impl StreamProcessor for ObservableStreamProcessor {
209226
210227 if report. positive_feedback . has_positive_feedback {
211228 self . span . attributes . push ( Attribute {
212- key : "signals.positive_feedback.count" . to_string ( ) ,
229+ key : signal_constants :: POSITIVE_FEEDBACK_COUNT . to_string ( ) ,
213230 value : AttributeValue {
214231 string_value : Some ( report. positive_feedback . positive_count . to_string ( ) ) ,
215232 } ,
0 commit comments