Skip to content

Commit 986fb9d

Browse files
authored
fix span icon color for realtime by sending stringified top span type (#1016)
1 parent d93599e commit 986fb9d

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

app-server/src/db/spans.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ pub enum SpanType {
2323
TOOL,
2424
}
2525

26+
impl std::fmt::Display for SpanType {
27+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28+
match self {
29+
SpanType::DEFAULT => write!(f, "DEFAULT"),
30+
SpanType::LLM => write!(f, "LLM"),
31+
SpanType::PIPELINE => write!(f, "PIPELINE"),
32+
SpanType::EXECUTOR => write!(f, "EXECUTOR"),
33+
SpanType::EVALUATOR => write!(f, "EVALUATOR"),
34+
SpanType::HUMAN_EVALUATOR => write!(f, "HUMAN_EVALUATOR"),
35+
SpanType::EVALUATION => write!(f, "EVALUATION"),
36+
SpanType::TOOL => write!(f, "TOOL"),
37+
}
38+
}
39+
}
40+
2641
impl FromStr for SpanType {
2742
type Err = anyhow::Error;
2843

app-server/src/traces/realtime.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct RealtimeTrace {
2828
top_span_id: Option<Uuid>,
2929
trace_type: String,
3030
top_span_name: Option<String>,
31-
top_span_type: Option<i16>,
31+
top_span_type: Option<String>,
3232
status: Option<String>,
3333
user_id: Option<String>,
3434
tags: Vec<String>,
@@ -136,7 +136,9 @@ impl RealtimeTrace {
136136
top_span_id: trace.top_span_id(),
137137
trace_type: trace.trace_type().to_string(),
138138
top_span_name: trace.top_span_name(),
139-
top_span_type: trace.top_span_type(),
139+
top_span_type: trace
140+
.top_span_type()
141+
.map(|t| SpanType::from(t as u8).to_string()),
140142
status: trace.status(),
141143
user_id: trace.user_id(),
142144
tags: trace.tags().clone(),

frontend/components/traces/span-type-icon.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export default function SpanTypeIcon({
7373
<div
7474
className={cn("flex items-center justify-center z-10 rounded", className)}
7575
style={{
76-
backgroundColor: status === "error" ? "rgba(204, 51, 51, 1)" : SPAN_TYPE_TO_COLOR[spanType], // Red background for errors
76+
backgroundColor: (status === "error")
77+
? "rgba(204, 51, 51, 1)" // Red background for errors
78+
: (SPAN_TYPE_TO_COLOR?.[spanType] || SPAN_TYPE_TO_COLOR[SpanType.DEFAULT]),
7779
minWidth: containerWidth,
7880
minHeight: containerHeight,
7981
width: containerWidth,

0 commit comments

Comments
 (0)