File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff 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
735738def _construct_phoenix_cloud_endpoint (parsed_endpoint : ParseResult ) -> ParseResult :
Original file line number Diff line number Diff line change 11import os
22from typing import Optional
33from unittest .mock import patch
4+ from urllib .parse import urlparse
45
56import pytest
67
8+ from phoenix .otel .otel import _construct_http_endpoint
79from phoenix .otel .settings import get_env_collector_endpoint
810
911
2527def 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
You can’t perform that action at this time.
0 commit comments