Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion javascript/src/agents/judge/judge-span-collector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SpanProcessor, ReadableSpan } from "@opentelemetry/sdk-trace-base";
import { attributes } from "langwatch/observability";

/**
* Collects OpenTelemetry spans for judge evaluation.
Expand Down Expand Up @@ -37,7 +38,7 @@ export class JudgeSpanCollector implements SpanProcessor {

// Check if span or any ancestor belongs to thread
const belongsToThread = (span: ReadableSpan): boolean => {
if (span.attributes["langwatch.thread.id"] === threadId) {
if (span.attributes[attributes.ATTR_LANGWATCH_THREAD_ID] === threadId) {
return true;
}
const parentId = span.parentSpanContext?.spanId;
Expand Down
3 changes: 2 additions & 1 deletion python/scenario/_tracing/judge_span_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import List, Dict, Optional
from opentelemetry.context import Context
from opentelemetry.sdk.trace import SpanProcessor, ReadableSpan
from langwatch.attributes import AttributeKey


class JudgeSpanCollector(SpanProcessor):
Expand Down Expand Up @@ -65,7 +66,7 @@ def get_spans_for_thread(self, thread_id: str) -> List[ReadableSpan]:
def belongs_to_thread(span: ReadableSpan) -> bool:
"""Check if span or any ancestor belongs to thread."""
attrs = span.attributes or {}
if attrs.get("langwatch.thread.id") == thread_id:
if attrs.get(AttributeKey.LangWatchThreadId) == thread_id:
return True

parent_ctx = span.parent
Expand Down
5 changes: 4 additions & 1 deletion python/scenario/scenario_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import concurrent.futures

from scenario.config import ScenarioConfig
from langwatch.attributes import AttributeKey
from scenario._utils import (
convert_agent_return_types_to_openai_messages,
check_valid_return_type,
Expand Down Expand Up @@ -531,7 +532,9 @@ async def _call_agent(
with self._trace.span(
type="agent", name=f"{agent.__class__.__name__}.call"
) as span:
span.set_attributes({"langwatch.thread.id": self._state.thread_id})
span.set_attributes(
{AttributeKey.LangWatchThreadId: self._state.thread_id}
)
with show_spinner(
text=(
"Judging..."
Expand Down
Loading