telemetry-dev 0.3.8__tar.gz → 0.3.10__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.8 → telemetry_dev-0.3.10}/PKG-INFO +9 -4
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/README.md +8 -3
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/pyproject.toml +1 -1
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/pyproject.toml.orig +1 -1
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_semconv.py +1 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_spans.py +81 -1
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/LICENSE +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/__init__.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_api.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_capture.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_ci.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_client.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_config.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_context.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_experiments.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_export.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_logs.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_metrics.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_observe.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_process_lock.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_processor.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_prompts.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_scores.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/_serialize.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/src/telemetry_dev/otel.py +0 -0
- {telemetry_dev-0.3.8 → telemetry_dev-0.3.10}/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.10
|
|
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
|
|
@@ -209,9 +209,14 @@ single record larger than the bound is still queued when its queue is empty.
|
|
|
209
209
|
|
|
210
210
|
`capture_input=False` and `capture_output=False` omit captured content. Provider integrations may
|
|
211
211
|
still record non-content metadata such as response IDs and models, finish reasons, usage, timing,
|
|
212
|
-
and error types. Capture flags do not gate stop sequences, tool
|
|
213
|
-
(`gen_ai.tool.description
|
|
214
|
-
|
|
212
|
+
and error types. Capture flags do not gate stop sequences, a tool span's description
|
|
213
|
+
(`gen_ai.tool.description`), or caller-supplied metadata or raw attributes; redact those separately
|
|
214
|
+
when needed. The one exception is `gen_ai.tool.definitions`, the tools offered to a model: with
|
|
215
|
+
input capture off it keeps only each tool's type and name, and with it on it passes through the
|
|
216
|
+
mask. Tool descriptions and input schemas are prompt content. Like other content, a list longer
|
|
217
|
+
than `max_attribute_length`, 0 included, keeps only the types and names, so that it stays JSON. The
|
|
218
|
+
names follow the limit of raw attributes, where 0 sets no limit, and are left out when they do
|
|
219
|
+
not fit.
|
|
215
220
|
|
|
216
221
|
`mask` receives input and output content, system instructions, log messages, captured exception
|
|
217
222
|
messages and stack traces, and content that
|
|
@@ -182,9 +182,14 @@ single record larger than the bound is still queued when its queue is empty.
|
|
|
182
182
|
|
|
183
183
|
`capture_input=False` and `capture_output=False` omit captured content. Provider integrations may
|
|
184
184
|
still record non-content metadata such as response IDs and models, finish reasons, usage, timing,
|
|
185
|
-
and error types. Capture flags do not gate stop sequences, tool
|
|
186
|
-
(`gen_ai.tool.description
|
|
187
|
-
|
|
185
|
+
and error types. Capture flags do not gate stop sequences, a tool span's description
|
|
186
|
+
(`gen_ai.tool.description`), or caller-supplied metadata or raw attributes; redact those separately
|
|
187
|
+
when needed. The one exception is `gen_ai.tool.definitions`, the tools offered to a model: with
|
|
188
|
+
input capture off it keeps only each tool's type and name, and with it on it passes through the
|
|
189
|
+
mask. Tool descriptions and input schemas are prompt content. Like other content, a list longer
|
|
190
|
+
than `max_attribute_length`, 0 included, keeps only the types and names, so that it stays JSON. The
|
|
191
|
+
names follow the limit of raw attributes, where 0 sets no limit, and are left out when they do
|
|
192
|
+
not fit.
|
|
188
193
|
|
|
189
194
|
`mask` receives input and output content, system instructions, log messages, captured exception
|
|
190
195
|
messages and stack traces, and content that
|
|
@@ -71,6 +71,7 @@ ATTR_OUTPUT_MESSAGES = "gen_ai.output.messages"
|
|
|
71
71
|
ATTR_TOOL_NAME = "gen_ai.tool.name"
|
|
72
72
|
ATTR_TOOL_CALL_ID = "gen_ai.tool.call.id"
|
|
73
73
|
ATTR_TOOL_DESCRIPTION = "gen_ai.tool.description"
|
|
74
|
+
ATTR_TOOL_DEFINITIONS = "gen_ai.tool.definitions"
|
|
74
75
|
ATTR_TOOL_ARGUMENTS = "gen_ai.tool.call.arguments"
|
|
75
76
|
ATTR_TOOL_RESULT = "gen_ai.tool.call.result"
|
|
76
77
|
ATTR_AGENT_NAME = "gen_ai.agent.name"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import json
|
|
3
4
|
import math
|
|
4
5
|
import sys
|
|
5
6
|
import threading
|
|
@@ -48,6 +49,7 @@ from ._semconv import (
|
|
|
48
49
|
ATTR_SYSTEM_INSTRUCTIONS,
|
|
49
50
|
ATTR_TIME_TO_FIRST_CHUNK,
|
|
50
51
|
ATTR_TOOL_CALL_ID,
|
|
52
|
+
ATTR_TOOL_DEFINITIONS,
|
|
51
53
|
ATTR_TOOL_DESCRIPTION,
|
|
52
54
|
ATTR_TOOL_NAME,
|
|
53
55
|
DURATION_BUCKETS,
|
|
@@ -61,7 +63,13 @@ from ._semconv import (
|
|
|
61
63
|
input_key,
|
|
62
64
|
output_key,
|
|
63
65
|
)
|
|
64
|
-
from ._serialize import
|
|
66
|
+
from ._serialize import (
|
|
67
|
+
AttributeValue,
|
|
68
|
+
coerce_attr_value,
|
|
69
|
+
json_dumps,
|
|
70
|
+
serialize_content,
|
|
71
|
+
utf16_length,
|
|
72
|
+
)
|
|
65
73
|
|
|
66
74
|
|
|
67
75
|
class _NotGiven:
|
|
@@ -377,6 +385,15 @@ def _fields_to_attributes(
|
|
|
377
385
|
# The variables are input, also when the app passes them from prompt_attributes_for().
|
|
378
386
|
if key == ATTR_PROMPT_VARIABLES and not state.capture_input:
|
|
379
387
|
continue
|
|
388
|
+
if key == ATTR_TOOL_DEFINITIONS:
|
|
389
|
+
definitions = _tool_list(value)
|
|
390
|
+
if definitions is not None:
|
|
391
|
+
kept = _tool_definitions(client, state, value, definitions)
|
|
392
|
+
if kept is not None:
|
|
393
|
+
attrs[key] = kept
|
|
394
|
+
continue
|
|
395
|
+
if not state.capture_input or client.mask is not None:
|
|
396
|
+
continue
|
|
380
397
|
attr = coerce_attr_value(
|
|
381
398
|
value,
|
|
382
399
|
max_len=sys.maxsize,
|
|
@@ -389,6 +406,69 @@ def _fields_to_attributes(
|
|
|
389
406
|
return attrs
|
|
390
407
|
|
|
391
408
|
|
|
409
|
+
def _tool_list(value: Any) -> list[Any] | None:
|
|
410
|
+
"""The tools of a ``gen_ai.tool.definitions`` value: JSON text, a list of one JSON text per
|
|
411
|
+
tool, or a list of tool objects. None for any other value."""
|
|
412
|
+
try:
|
|
413
|
+
if isinstance(value, str):
|
|
414
|
+
parsed = json.loads(value)
|
|
415
|
+
return cast("list[Any]", parsed) if isinstance(parsed, list) else None
|
|
416
|
+
if isinstance(value, (list, tuple)):
|
|
417
|
+
items = cast("Sequence[Any]", value)
|
|
418
|
+
if all(isinstance(item, str) for item in items):
|
|
419
|
+
return [json.loads(item) for item in items]
|
|
420
|
+
return list(items)
|
|
421
|
+
except (ValueError, RecursionError):
|
|
422
|
+
pass
|
|
423
|
+
return None
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
def _tool_definitions(
|
|
427
|
+
client: Client, state: _SpanState, value: Any, definitions: list[Any]
|
|
428
|
+
) -> str | None:
|
|
429
|
+
"""The ``gen_ai.tool.definitions`` that a span keeps. Tool descriptions and schemas are prompt
|
|
430
|
+
content: with input capture off only each tool's type and name stay, and with a mask the
|
|
431
|
+
definitions go through it as input does. Like other content, a list longer than
|
|
432
|
+
``max_attribute_length``, 0 included, keeps only the names, since a cut list is not JSON and
|
|
433
|
+
readers would lose every tool. The names follow the limit of raw attributes, where 0 sets no
|
|
434
|
+
limit; names that do not fit leave the attribute out."""
|
|
435
|
+
if state.capture_input:
|
|
436
|
+
if client.mask is None:
|
|
437
|
+
try:
|
|
438
|
+
full = value if isinstance(value, str) else json_dumps(definitions)
|
|
439
|
+
except (TypeError, ValueError, RecursionError):
|
|
440
|
+
full = None
|
|
441
|
+
else:
|
|
442
|
+
full = serialize_content(
|
|
443
|
+
definitions,
|
|
444
|
+
key=ATTR_TOOL_DEFINITIONS,
|
|
445
|
+
mask=client.mask,
|
|
446
|
+
max_len=sys.maxsize,
|
|
447
|
+
on_error=client.on_error,
|
|
448
|
+
)
|
|
449
|
+
if full is not None and utf16_length(full) <= client.max_attribute_length:
|
|
450
|
+
return full
|
|
451
|
+
names: list[dict[str, str]] = []
|
|
452
|
+
for definition in definitions:
|
|
453
|
+
if not isinstance(definition, dict):
|
|
454
|
+
continue
|
|
455
|
+
fields = cast("dict[str, Any]", definition)
|
|
456
|
+
kept = {key: fields[key] for key in ("type", "name") if isinstance(fields.get(key), str)}
|
|
457
|
+
# OpenAI's Chat Completions form nests the name under ``function``.
|
|
458
|
+
function = fields.get("function")
|
|
459
|
+
if "name" not in kept and isinstance(function, dict):
|
|
460
|
+
nested = cast("dict[str, Any]", function).get("name")
|
|
461
|
+
if isinstance(nested, str):
|
|
462
|
+
kept["name"] = nested
|
|
463
|
+
if kept:
|
|
464
|
+
names.append(kept)
|
|
465
|
+
if not names:
|
|
466
|
+
return None
|
|
467
|
+
text = json_dumps(names)
|
|
468
|
+
raw_limit = client.max_attribute_length or sys.maxsize
|
|
469
|
+
return text if utf16_length(text) <= raw_limit else None
|
|
470
|
+
|
|
471
|
+
|
|
392
472
|
def _apply_fields(client: Client, span: Span, state: _SpanState, fields: dict[str, Any]) -> None:
|
|
393
473
|
name = fields.get("name")
|
|
394
474
|
if name is not None:
|
|
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
|