Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion clearwing/observability/otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _otlp_exporter() -> SpanExporter:
)
if api_key := os.environ.get("PHOENIX_API_KEY"):
if not standard_headers_configured:
kwargs["headers"] = {"api_key": api_key}
kwargs["headers"] = {"authorization": f"Bearer {api_key}"}
return OTLPSpanExporter(**kwargs)
return OTLPSpanExporter()

Expand Down
24 changes: 14 additions & 10 deletions clearwing/sourcehunt/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,19 +1233,23 @@ def _finalize_spend_ledger(self, status: str | None = None) -> dict[str, Any]:
return summary

def run(self) -> SourceHuntResult:
from clearwing.observability.otel import force_flush
from clearwing.ui.llm_activity import llm_activity_panel

self._ensure_spend_ledger()
with llm_activity_panel(
live=self._live,
budget_usd=self.budget_usd or None,
spend_ledger=self._spend_ledger,
trace_context=lambda: (
getattr(self, "_otel_trace_id", None),
getattr(self, "_otel_span_id", None),
),
):
return asyncio.run(self.arun())
try:
with llm_activity_panel(
live=self._live,
budget_usd=self.budget_usd or None,
spend_ledger=self._spend_ledger,
trace_context=lambda: (
getattr(self, "_otel_trace_id", None),
getattr(self, "_otel_span_id", None),
),
):
return asyncio.run(self.arun())
finally:
force_flush()

async def _arun_proof_flow(self) -> SourceHuntResult:
"""Run the proof-carrying engine and adapt its typed output."""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_standard_and_phoenix_environment_detection(monkeypatch):
assert otel.telemetry_configured() is False


def test_phoenix_api_key_becomes_otlp_header(monkeypatch):
def test_phoenix_api_key_becomes_bearer_header(monkeypatch):
monkeypatch.delenv("OTEL_EXPORTER_OTLP_ENDPOINT", raising=False)
monkeypatch.delenv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", raising=False)
monkeypatch.delenv("OTEL_EXPORTER_OTLP_HEADERS", raising=False)
Expand All @@ -123,7 +123,7 @@ def test_phoenix_api_key_becomes_otlp_header(monkeypatch):

exporter.assert_called_once_with(
endpoint="https://phoenix.example/v1/traces",
headers={"api_key": "secret-key"},
headers={"authorization": "Bearer secret-key"},
)


Expand Down
Loading