Skip to content

Commit

Permalink
Add duplicate config definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
anticorrelator committed Jan 13, 2025
1 parent 5657131 commit 3b93003
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/phoenix-otel/src/phoenix/otel/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 "(),/:;<=>?@[\]{}
Expand Down

0 comments on commit 3b93003

Please sign in to comment.