From 3b9300348e09a86b811acf6f9dbfabc76ffa31bb Mon Sep 17 00:00:00 2001 From: Dustin Ngo Date: Tue, 14 Jan 2025 00:35:33 +0900 Subject: [PATCH] Add duplicate config definitions --- .../phoenix-otel/src/phoenix/otel/settings.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/phoenix-otel/src/phoenix/otel/settings.py b/packages/phoenix-otel/src/phoenix/otel/settings.py index 285bbb3f59..d679dbb317 100644 --- a/packages/phoenix-otel/src/phoenix/otel/settings.py +++ b/packages/phoenix-otel/src/phoenix/otel/settings.py @@ -8,10 +8,16 @@ # Environment variables specific to the subpackage ENV_PHOENIX_COLLECTOR_ENDPOINT = "PHOENIX_COLLECTOR_ENDPOINT" +ENV_PHOENIX_GRPC_PORT = "PHOENIX_GRPC_PORT" ENV_PHOENIX_PROJECT_NAME = "PHOENIX_PROJECT_NAME" ENV_PHOENIX_CLIENT_HEADERS = "PHOENIX_CLIENT_HEADERS" ENV_PHOENIX_API_KEY = "PHOENIX_API_KEY" +GRPC_PORT = 4317 +"""The port the gRPC server will run on after launch_app is called. +The default network port for OTLP/gRPC is 4317. +See https://opentelemetry.io/docs/specs/otlp/#otlpgrpc-default-port""" + def get_env_collector_endpoint() -> Optional[str]: return os.getenv(ENV_PHOENIX_COLLECTOR_ENDPOINT) @@ -35,6 +41,17 @@ def get_env_phoenix_auth_header() -> Optional[Dict[str, str]]: return None +def get_env_grpc_port() -> int: + if not (port := os.getenv(ENV_PHOENIX_GRPC_PORT)): + return GRPC_PORT + if port.isnumeric(): + return int(port) + raise ValueError( + f"Invalid value for environment variable {ENV_PHOENIX_GRPC_PORT}: " + f"{port}. Value must be an integer." + ) + + # Optional whitespace _OWS = r"[ \t]*" # A key contains printable US-ASCII characters except: SP and "(),/:;<=>?@[\]{}