Skip to content

Client base

provide.foundation.integrations.openobserve.client_base

Base OpenObserve client with core functionality.

Classes

OpenObserveClientBase

OpenObserveClientBase(
    url: str,
    username: str,
    password: str,
    organization: str = "default",
    timeout: int = 30,
)

Base OpenObserve client with core HTTP functionality.

Uses Foundation's transport system for all HTTP operations.

Initialize OpenObserve client.

Parameters:

Name Type Description Default
url str

Base URL for OpenObserve API

required
username str

Username for authentication

required
password str

Password for authentication

required
organization str

Organization name (default: "default")

'default'
timeout int

Request timeout in seconds

30
Note

Retry logic is handled automatically by UniversalClient's middleware.

Source code in provide/foundation/integrations/openobserve/client_base.py
def __init__(
    self,
    url: str,
    username: str,
    password: str,
    organization: str = "default",
    timeout: int = 30,
) -> None:
    """Initialize OpenObserve client.

    Args:
        url: Base URL for OpenObserve API
        username: Username for authentication
        password: Password for authentication
        organization: Organization name (default: "default")
        timeout: Request timeout in seconds

    Note:
        Retry logic is handled automatically by UniversalClient's middleware.

    """
    self.url = url.rstrip("/")
    self.username, self.password = validate_credentials(username, password)
    self.organization = organization

    # Create UniversalClient with auth headers and timeout
    self._client = UniversalClient(
        hub=get_hub(),
        default_headers=get_auth_headers(self.username, self.password),
        default_timeout=float(timeout),
    )
Functions
from_config classmethod
from_config() -> OpenObserveClientBase

Create client from OpenObserveConfig.

Returns:

Type Description
OpenObserveClientBase

Configured OpenObserveClient instance

Raises:

Type Description
OpenObserveConfigError

If configuration is missing

Source code in provide/foundation/integrations/openobserve/client_base.py
@classmethod
def from_config(cls) -> OpenObserveClientBase:
    """Create client from OpenObserveConfig.

    Returns:
        Configured OpenObserveClient instance

    Raises:
        OpenObserveConfigError: If configuration is missing

    """
    from provide.foundation.integrations.openobserve.config import OpenObserveConfig

    config = OpenObserveConfig.from_env()

    if not config.url:
        raise OpenObserveConfigError(
            "OpenObserve URL not configured. Set OPENOBSERVE_URL environment variable.",
        )

    if not config.user or not config.password:
        raise OpenObserveConfigError(
            "OpenObserve credentials not configured. "
            "Set OPENOBSERVE_USER and OPENOBSERVE_PASSWORD environment variables.",
        )

    return cls(
        url=config.url,
        username=config.user,
        password=config.password,
        organization=config.org or "default",
    )

Functions