Skip to content

Commit 1015813

Browse files
committed
do not remove endpoint prefix before /v1/traces
1 parent 2430655 commit 1015813

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/phoenix-otel/src/phoenix/otel/otel.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,10 @@ def _construct_http_endpoint(parsed_endpoint: ParseResult) -> ParseResult:
729729
Returns:
730730
ParseResult: Modified endpoint with "/v1/traces" path.
731731
"""
732-
return parsed_endpoint._replace(path="/v1/traces")
732+
traces_suffix = "/v1/traces"
733+
if parsed_endpoint.path.endswith(traces_suffix):
734+
return parsed_endpoint
735+
return parsed_endpoint._replace(path=traces_suffix)
733736

734737

735738
def _construct_phoenix_cloud_endpoint(parsed_endpoint: ParseResult) -> ParseResult:

packages/phoenix-otel/tests/test_settings.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import os
22
from typing import Optional
33
from unittest.mock import patch
4+
from urllib.parse import urlparse
45

56
import pytest
67

8+
from phoenix.otel.otel import _construct_http_endpoint
79
from phoenix.otel.settings import get_env_collector_endpoint
810

911

@@ -25,3 +27,17 @@
2527
def test_get_env_collector_endpoint(env: dict[str, str], expected: Optional[str]) -> None:
2628
with patch.dict(os.environ, env, clear=True):
2729
assert get_env_collector_endpoint() == expected
30+
31+
32+
@pytest.mark.parametrize(
33+
"endpoint, expected",
34+
[
35+
("http://localhost:6006", "http://localhost:6006/v1/traces"),
36+
("http://localhost:6006/v1/traces", "http://localhost:6006/v1/traces"),
37+
("http://localhost:6006/prefix/v1/traces", "http://localhost:6006/prefix/v1/traces"),
38+
],
39+
)
40+
def test_construct_http_endpoint(endpoint: str, expected: str) -> None:
41+
parsed = urlparse(endpoint)
42+
result = _construct_http_endpoint(parsed)
43+
assert result.geturl() == expected

0 commit comments

Comments
 (0)