Observability
provide.foundation.observability
¶
Observability module for Foundation.
Provides integration with observability platforms like OpenObserve. Only available when OpenTelemetry dependencies are installed.
Classes¶
OpenObserveClient
¶
OpenObserveClient(
url: str,
username: str,
password: str,
organization: str = "default",
timeout: int = 30,
)
Bases: SearchOperationsMixin, MetricsOperationsMixin, OpenObserveClientBase
Async client for interacting with OpenObserve API.
Uses Foundation's transport system for all HTTP operations. Combines search/streams operations and Prometheus metrics API.
Source code in provide/foundation/integrations/openobserve/client_base.py
Functions¶
is_openobserve_available
¶
Check if OpenObserve integration is available.
Returns:
| Type | Description |
|---|---|
bool
|
True if OpenTelemetry and OpenObserve are available |
search_logs
async
¶
search_logs(
sql: str,
start_time: str | int | None = None,
end_time: str | int | None = None,
size: int = 100,
client: OpenObserveClient | None = None,
) -> SearchResponse
Search logs in OpenObserve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sql
|
str
|
SQL query to execute |
required |
start_time
|
str | int | None
|
Start time (relative like "-1h" or microseconds) |
None
|
end_time
|
str | int | None
|
End time (relative like "now" or microseconds) |
None
|
size
|
int
|
Number of results to return |
100
|
client
|
OpenObserveClient | None
|
OpenObserve client (creates new if not provided) |
None
|
Returns:
| Type | Description |
|---|---|
SearchResponse
|
SearchResponse with results |
Source code in provide/foundation/integrations/openobserve/search.py
stream_logs
¶
stream_logs(
sql: str,
start_time: str | int | None = None,
poll_interval: int = 5,
client: OpenObserveClient | None = None,
) -> Generator[dict[str, Any], None, None]
Stream logs from OpenObserve with polling.
Continuously polls for new logs and yields them as they arrive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sql
|
str
|
SQL query to execute |
required |
start_time
|
str | int | None
|
Initial start time |
None
|
poll_interval
|
int
|
Seconds between polls |
5
|
client
|
OpenObserveClient | None
|
OpenObserve client |
None
|
Yields:
| Type | Description |
|---|---|
dict[str, Any]
|
Log entries as they arrive |