fix(observability): Phoenix 는 OTLP protobuf 만 받음(JSON 415) — opentelemetry-proto 로 직렬화, 로컬 Phoenix 실측 통과

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
lee-hyeon-cheol
2026-09-22 15:43:26 +09:00
co-authored by Claude Fable 5.1
parent e60c5bc273
commit 68b55907f0
4 changed files with 47 additions and 9 deletions
+10 -2
View File
@@ -18,7 +18,15 @@ def lf_server(monkeypatch):
got: list[dict] = []
def handler(req: httpx.Request) -> httpx.Response:
got.append({"url": str(req.url), "auth": req.headers.get("authorization"), "body": json.loads(req.content)})
if req.headers.get("content-type", "").startswith("application/x-protobuf"):
from google.protobuf.json_format import MessageToDict
from opentelemetry.proto.collector.trace.v1.trace_service_pb2 import ExportTraceServiceRequest
m = ExportTraceServiceRequest(); m.ParseFromString(req.content)
body = MessageToDict(m) # bytes 필드는 base64 로 나옴
else:
body = json.loads(req.content)
got.append({"url": str(req.url), "auth": req.headers.get("authorization"), "body": body, "ctype": req.headers.get("content-type", "")})
return httpx.Response(200, json={})
monkeypatch.setattr(langfuse, "TRANSPORT", httpx.MockTransport(handler))
@@ -115,7 +123,7 @@ async def test_phoenix_target_no_auth_and_openinference_attrs(lf_server):
tool = langfuse.tool_span("t9", "read", parent=root, input={"filePath": "a.md"}, output="본문")
assert await langfuse.send([root, tool]) and len(lf_server) == 1
req = lf_server[0]
assert req["url"] == "http://px.test/v1/traces" and req["auth"] is None
assert req["url"] == "http://px.test/v1/traces" and req["auth"] is None and req["ctype"].startswith("application/x-protobuf")
res = {a["key"]: a["value"]["stringValue"] for a in req["body"]["resourceSpans"][0]["resource"]["attributes"]}
assert res["openinference.project.name"] == "codeassist"
r, tl = _attrs(req["body"]["resourceSpans"][0]["scopeSpans"][0]["spans"][0]), _attrs(req["body"]["resourceSpans"][0]["scopeSpans"][0]["spans"][1])