Skip to content

Commit 549d663

Browse files
feat: add timeout configuration for Openlayer tracer
1 parent 5030f6e commit 549d663

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/openlayer/lib/tracing/tracer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def configure(
4040
api_key: Optional[str] = None,
4141
inference_pipeline_id: Optional[str] = None,
4242
base_url: Optional[str] = None,
43+
timeout: Optional[int] = None,
4344
) -> None:
4445
"""Configure the Openlayer tracer with custom settings.
4546
@@ -52,6 +53,7 @@ def configure(
5253
If not provided, falls back to OPENLAYER_INFERENCE_PIPELINE_ID environment variable.
5354
base_url: The base URL for the Openlayer API. If not provided, falls back to
5455
OPENLAYER_BASE_URL environment variable or the default.
56+
timeout: The timeout for the Openlayer API. Defaults to 1 minute.
5557
5658
Examples:
5759
>>> import openlayer.lib.tracing.tracer as tracer
@@ -62,11 +64,12 @@ def configure(
6264
>>> def my_function():
6365
... return "result"
6466
"""
65-
global _configured_api_key, _configured_pipeline_id, _configured_base_url, _client
67+
global _configured_api_key, _configured_pipeline_id, _configured_base_url, _configured_timeout, _client
6668

6769
_configured_api_key = api_key
6870
_configured_pipeline_id = inference_pipeline_id
6971
_configured_base_url = base_url
72+
_configured_timeout = timeout
7073

7174
# Reset the client so it gets recreated with new configuration
7275
_client = None
@@ -90,6 +93,9 @@ def _get_client() -> Optional[Openlayer]:
9093
if _configured_base_url is not None:
9194
client_kwargs["base_url"] = _configured_base_url
9295

96+
if _configured_timeout is not None:
97+
client_kwargs["timeout"] = _configured_timeout
98+
9399
if _verify_ssl:
94100
_client = Openlayer(**client_kwargs)
95101
else:

0 commit comments

Comments
 (0)