telemetry-dev 0.3.6__tar.gz → 0.3.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/PKG-INFO +7 -5
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/README.md +6 -4
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/pyproject.toml +1 -1
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/pyproject.toml.orig +1 -1
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_api.py +30 -21
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/LICENSE +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/__init__.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_capture.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_ci.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_client.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_config.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_context.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_experiments.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_export.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_logs.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_metrics.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_observe.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_process_lock.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_processor.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_prompts.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_scores.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_semconv.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_serialize.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/_spans.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/otel.py +0 -0
- {telemetry_dev-0.3.6 → telemetry_dev-0.3.7}/src/telemetry_dev/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: telemetry-dev
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.7
|
|
4
4
|
Summary: telemetry.dev SDK for Python — OpenTelemetry-native GenAI tracing, logs, and metrics
|
|
5
5
|
Keywords: telemetry,opentelemetry,llm,genai,tracing,observability
|
|
6
6
|
Author: telemetry.dev
|
|
@@ -414,10 +414,12 @@ result = telemetry_dev.run_experiment(
|
|
|
414
414
|
`missing_api_key`, or `timeout`. A read of the dataset or the result, a post of outputs, and the
|
|
415
415
|
completion go again up to 2 times after a timeout, a network error, a 429, or a 5xx. The server
|
|
416
416
|
skips an item run that it has. The request that makes the experiment goes again only after a
|
|
417
|
-
429, thus a lost response or a 503 cannot make a second experiment.
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
417
|
+
429, thus a lost response or a 503 cannot make a second experiment. No request goes again after
|
|
418
|
+
a 429 `quota_exceeded`, which a cap of the plan gives, or after a 429 whose `Retry-After` is
|
|
419
|
+
more than 60 seconds: `run_experiment` raises at once with the message of the server. When the
|
|
420
|
+
run stops after it made the experiment, also after Ctrl-C or a cancellation, `run_experiment`
|
|
421
|
+
sends the completion before it raises: telemetry.dev then ends the experiment with the item runs
|
|
422
|
+
that it got, or fails it when it got none.
|
|
421
423
|
- The key needs Run experiments in its Access on the API keys page (the `datasets:read` and
|
|
422
424
|
`experiments:write` scopes). `run_experiment` uses the same
|
|
423
425
|
API key and base URL as `get_prompt`, or its own `api_key` and `base_url`.
|
|
@@ -387,10 +387,12 @@ result = telemetry_dev.run_experiment(
|
|
|
387
387
|
`missing_api_key`, or `timeout`. A read of the dataset or the result, a post of outputs, and the
|
|
388
388
|
completion go again up to 2 times after a timeout, a network error, a 429, or a 5xx. The server
|
|
389
389
|
skips an item run that it has. The request that makes the experiment goes again only after a
|
|
390
|
-
429, thus a lost response or a 503 cannot make a second experiment.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
390
|
+
429, thus a lost response or a 503 cannot make a second experiment. No request goes again after
|
|
391
|
+
a 429 `quota_exceeded`, which a cap of the plan gives, or after a 429 whose `Retry-After` is
|
|
392
|
+
more than 60 seconds: `run_experiment` raises at once with the message of the server. When the
|
|
393
|
+
run stops after it made the experiment, also after Ctrl-C or a cancellation, `run_experiment`
|
|
394
|
+
sends the completion before it raises: telemetry.dev then ends the experiment with the item runs
|
|
395
|
+
that it got, or fails it when it got none.
|
|
394
396
|
- The key needs Run experiments in its Access on the API keys page (the `datasets:read` and
|
|
395
397
|
`experiments:write` scopes). `run_experiment` uses the same
|
|
396
398
|
API key and base URL as `get_prompt`, or its own `api_key` and `base_url`.
|
|
@@ -20,7 +20,8 @@ from ._client import get_client
|
|
|
20
20
|
from ._config import SDK_VERSION, resolve_config
|
|
21
21
|
from ._serialize import json_dumps
|
|
22
22
|
|
|
23
|
-
#
|
|
23
|
+
# The longest wait before a retry: the API counts requests by the minute. A 429 with a longer
|
|
24
|
+
# Retry-After fails at once, and a 503 with a longer one waits only this long.
|
|
24
25
|
_MAX_RETRY_AFTER_S = 60.0
|
|
25
26
|
# IMF-fixdate, the HTTP date that servers send: Sun, 06 Nov 1994 08:49:37 GMT.
|
|
26
27
|
_HTTP_DATE = re.compile(r"[A-Z][a-z]{2}, \d{2} [A-Z][a-z]{2} \d{4} \d{2}:\d{2}:\d{2} GMT", re.ASCII)
|
|
@@ -52,6 +53,7 @@ def resolve_api(api_key: str | None, base_url: str | None) -> Api:
|
|
|
52
53
|
@dataclass(frozen=True)
|
|
53
54
|
class _Failure:
|
|
54
55
|
error: Exception
|
|
56
|
+
code: str | None
|
|
55
57
|
status: int | None
|
|
56
58
|
retry_after: float | None
|
|
57
59
|
|
|
@@ -74,7 +76,8 @@ def request(
|
|
|
74
76
|
``http_<status>``. With ``idempotent``, the server takes a repeat at most once, so a timeout, a
|
|
75
77
|
network error, or a 5xx tries again. Other requests try again only after a 429, which the rate
|
|
76
78
|
limit answers before the server does any work: a 503 can come after the work committed. A
|
|
77
|
-
retry waits for the Retry-After of the response, or for 1 and then 2 seconds.
|
|
79
|
+
retry waits for the Retry-After of the response, or for 1 and then 2 seconds. A 429
|
|
80
|
+
``quota_exceeded``, or a 429 with a Retry-After past 60 seconds, raises at once. The timeout
|
|
78
81
|
applies to each socket operation of urllib.
|
|
79
82
|
"""
|
|
80
83
|
url = f"{api.base_url}{path}"
|
|
@@ -92,7 +95,7 @@ def request(
|
|
|
92
95
|
result = _send(error_type, method, url, path, data, headers, timeout_s)
|
|
93
96
|
if not isinstance(result, _Failure):
|
|
94
97
|
return result
|
|
95
|
-
if attempt >= attempts or not _retryable(result
|
|
98
|
+
if attempt >= attempts or not _retryable(result, idempotent):
|
|
96
99
|
raise result.error
|
|
97
100
|
time.sleep(min(result.retry_after or float(attempt), _MAX_RETRY_AFTER_S))
|
|
98
101
|
attempt += 1
|
|
@@ -128,18 +131,7 @@ opener = urllib.request.build_opener(NoRedirect)
|
|
|
128
131
|
|
|
129
132
|
def api_error(error_type: Callable[[str, str, int | None], E], status: int, body: bytes) -> E:
|
|
130
133
|
"""The error of a response that is not 2xx: its API code and message, or ``http_<status>``."""
|
|
131
|
-
|
|
132
|
-
error = json.loads(body).get("error")
|
|
133
|
-
except (ValueError, AttributeError):
|
|
134
|
-
error = None
|
|
135
|
-
fields = cast("dict[str, Any]", error) if isinstance(error, dict) else {}
|
|
136
|
-
code = fields.get("code")
|
|
137
|
-
message = fields.get("message")
|
|
138
|
-
return error_type(
|
|
139
|
-
code if isinstance(code, str) else f"http_{status}",
|
|
140
|
-
message if isinstance(message, str) else f"telemetry.dev returned {status}",
|
|
141
|
-
status,
|
|
142
|
-
)
|
|
134
|
+
return error_type(*_code_and_message(status, body), status)
|
|
143
135
|
|
|
144
136
|
|
|
145
137
|
def retry_after(status: int, value: str | None) -> float | None:
|
|
@@ -175,8 +167,10 @@ def _send(
|
|
|
175
167
|
body: bytes = response.read()
|
|
176
168
|
except urllib.error.HTTPError as exc:
|
|
177
169
|
with exc:
|
|
170
|
+
code, message = _code_and_message(exc.code, exc.read())
|
|
178
171
|
return _Failure(
|
|
179
|
-
|
|
172
|
+
error_type(code, message, exc.code),
|
|
173
|
+
code,
|
|
180
174
|
exc.code,
|
|
181
175
|
retry_after(exc.code, exc.headers.get("Retry-After")),
|
|
182
176
|
)
|
|
@@ -190,14 +184,29 @@ def _send(
|
|
|
190
184
|
else error_type("network_error", "Could not reach telemetry.dev", None)
|
|
191
185
|
)
|
|
192
186
|
error.__cause__ = exc
|
|
193
|
-
return _Failure(error, None, None)
|
|
187
|
+
return _Failure(error, None, None, None)
|
|
194
188
|
try:
|
|
195
189
|
return json.loads(body)
|
|
196
190
|
except ValueError:
|
|
197
191
|
return None
|
|
198
192
|
|
|
199
193
|
|
|
200
|
-
def
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
194
|
+
def _code_and_message(status: int, body: bytes) -> tuple[str, str]:
|
|
195
|
+
try:
|
|
196
|
+
error = json.loads(body).get("error")
|
|
197
|
+
except (ValueError, AttributeError):
|
|
198
|
+
error = None
|
|
199
|
+
fields = cast("dict[str, Any]", error) if isinstance(error, dict) else {}
|
|
200
|
+
code = fields.get("code")
|
|
201
|
+
message = fields.get("message")
|
|
202
|
+
return (
|
|
203
|
+
code if isinstance(code, str) else f"http_{status}",
|
|
204
|
+
message if isinstance(message, str) else f"telemetry.dev returned {status}",
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def _retryable(failure: _Failure, idempotent: bool) -> bool:
|
|
209
|
+
if failure.status == 429:
|
|
210
|
+
# A monthly quota resets at the start of next month, and a gift budget never resets.
|
|
211
|
+
return failure.code != "quota_exceeded" and (failure.retry_after or 0) <= _MAX_RETRY_AFTER_S
|
|
212
|
+
return idempotent and (failure.status is None or failure.status >= 500)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|