File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -607,6 +607,7 @@ private void setScoreSpanAttributes(
607607 Map <String , Object > scoreSpanAttrs = new LinkedHashMap <>();
608608 scoreSpanAttrs .put ("type" , "score" );
609609 scoreSpanAttrs .put ("name" , scorerName );
610+ scoreSpanAttrs .put ("purpose" , "scorer" );
610611 if (braintrustGeneration != null ) {
611612 scoreSpanAttrs .put ("generation" , braintrustGeneration );
612613 }
Original file line number Diff line number Diff line change @@ -230,6 +230,7 @@ private void recordScores(
230230 Map <String , Object > spanAttrs = new LinkedHashMap <>();
231231 spanAttrs .put ("type" , "score" );
232232 spanAttrs .put ("name" , scorer .getName ());
233+ spanAttrs .put ("purpose" , "scorer" );
233234 scoreSpan .setAttribute ("braintrust.span_attributes" , toJson (spanAttrs ));
234235 var scoresJson = toJson (scorerScores );
235236 scoreSpan .setAttribute ("braintrust.output_json" , scoresJson );
Original file line number Diff line number Diff line change @@ -433,6 +433,7 @@ void testStreamingEval() throws Exception {
433433 assertNotNull (spanAttrsJson , "Score span should have span_attributes" );
434434 JsonNode spanAttrs = JSON_MAPPER .readTree (spanAttrsJson );
435435 assertEquals ("score" , spanAttrs .get ("type" ).asText ());
436+ assertEquals ("scorer" , spanAttrs .get ("purpose" ).asText ());
436437 assertEquals ("test-gen-1" , spanAttrs .get ("generation" ).asText ());
437438
438439 // Scorer name should be either simple_scorer or the remote scorer
Original file line number Diff line number Diff line change @@ -104,6 +104,30 @@ public void evalOtelTraceWithProperAttributes() {
104104 numRootSpans .get () * 4 ,
105105 spans .size (),
106106 "each eval case should make four spans (one per scorer)" );
107+
108+ // All score spans should have purpose=scorer in span_attributes
109+ var scoreSpans =
110+ spans .stream ()
111+ .filter (
112+ s -> {
113+ var attrs =
114+ s .getAttributes ()
115+ .get (
116+ AttributeKey .stringKey (
117+ "braintrust.span_attributes" ));
118+ return attrs != null && attrs .contains ("\" type\" :\" score\" " );
119+ })
120+ .toList ();
121+ assertFalse (scoreSpans .isEmpty (), "should have score spans" );
122+ for (var scoreSpan : scoreSpans ) {
123+ var spanAttrsJson =
124+ scoreSpan
125+ .getAttributes ()
126+ .get (AttributeKey .stringKey ("braintrust.span_attributes" ));
127+ assertTrue (
128+ spanAttrsJson .contains ("\" purpose\" :\" scorer\" " ),
129+ "score span should have purpose=scorer in span_attributes: " + spanAttrsJson );
130+ }
107131 }
108132
109133 boolean isFruitOrVegetable (String str ) {
You can’t perform that action at this time.
0 commit comments