telemetry-dev 0.3.2__tar.gz → 0.3.4__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.
Files changed (28) hide show
  1. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/PKG-INFO +101 -30
  2. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/README.md +98 -29
  3. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/pyproject.toml +3 -1
  4. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/pyproject.toml.orig +7 -1
  5. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/__init__.py +2 -0
  6. telemetry_dev-0.3.4/src/telemetry_dev/_capture.py +390 -0
  7. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_client.py +93 -20
  8. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_experiments.py +77 -10
  9. telemetry_dev-0.3.4/src/telemetry_dev/_export.py +710 -0
  10. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_metrics.py +26 -26
  11. telemetry_dev-0.3.4/src/telemetry_dev/_process_lock.py +41 -0
  12. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_processor.py +26 -2
  13. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_prompts.py +86 -33
  14. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_serialize.py +75 -1
  15. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_spans.py +10 -6
  16. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/otel.py +52 -15
  17. telemetry_dev-0.3.2/src/telemetry_dev/_capture.py +0 -189
  18. telemetry_dev-0.3.2/src/telemetry_dev/_export.py +0 -100
  19. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/LICENSE +0 -0
  20. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_api.py +0 -0
  21. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_ci.py +0 -0
  22. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_config.py +0 -0
  23. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_context.py +0 -0
  24. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_logs.py +0 -0
  25. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_observe.py +0 -0
  26. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_scores.py +0 -0
  27. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/src/telemetry_dev/_semconv.py +0 -0
  28. {telemetry_dev-0.3.2 → telemetry_dev-0.3.4}/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.2
3
+ Version: 0.3.4
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
@@ -17,6 +17,8 @@ Classifier: Typing :: Typed
17
17
  Requires-Dist: opentelemetry-api>=1.39.0,<2
18
18
  Requires-Dist: opentelemetry-sdk>=1.39.0,<2
19
19
  Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.39.0,<2
20
+ Requires-Dist: googleapis-common-protos>=1.63.1,<2
21
+ Requires-Dist: requests>=2.28,<3
20
22
  Requires-Dist: rfc8785>=0.1.4
21
23
  Requires-Python: >=3.10
22
24
  Project-URL: Homepage, https://telemetry.dev
@@ -99,6 +101,11 @@ initialization. Explicit and propagated session IDs take precedence, and valid p
99
101
  context is preserved. The generated session ends when the client is shut down or replaced; a
100
102
  later `init()` generates a new ID. It is not persisted across processes.
101
103
 
104
+ The root spans of a session join one trace for each API key, and the trace keeps the environment
105
+ of its first turn. When one key sends turns of the same session id from two environments, the
106
+ later turns show under the first environment, or get a 403 when the key may not send that
107
+ environment. Use a key for each environment, or give each environment its own session ids.
108
+
102
109
  ## API reference
103
110
 
104
111
  | Name | Description |
@@ -128,10 +135,6 @@ metric readers, so supplying `metric_reader=` disables this histogram. Duration,
128
135
  time-to-first-chunk metrics remain available; the first accepted streamed span with two or more
129
136
  recorded chunks reports this limitation once through `on_error` and the SDK logger.
130
137
 
131
- Provider integrations feature-detect `record_output_chunk`. Older core SDKs without that method
132
- continue delivering streams and tracing normally, but do not emit chunk-interval metrics. Upgrade
133
- the core SDK with provider integrations to enable the new metric.
134
-
135
138
  ### Span types
136
139
 
137
140
  `type=` maps to `gen_ai.operation.name`:
@@ -183,14 +186,27 @@ metadata, identifiers, resource attributes, or events written directly through r
183
186
  | `log_level` | `"warn"` | SDK diagnostics level: `debug`/`info`/`warn`/`error`/`silent`. |
184
187
  | `capture_input`, `capture_output` | `True` | Global content-capture defaults. |
185
188
  | `mask` | `None` | `Callable[[Any, MaskContext], Any]` redaction hook, runs before JSON serialization on input/output/log messages and `SpanHandle.serialize_content` (`MaskContext.key` is the attribute being written). Not applied to correlation identifiers. |
186
- | `max_attribute_length` | `65536` | Non-negative integer per-content-attribute cap. Invalid values call `on_error`, do not raise into application code, and install a disabled client; truncated values use the ASCII `...[truncated]` marker, or its prefix when the cap is shorter than the marker. The cap also applies, with the marker, to string metadata and log attributes; any other string attribute is cut at the cap without a marker, except that a cap of `0` leaves those at 65536. |
189
+ | `max_attribute_length` | `None` | Per-content-attribute cap in UTF-16 units, the marker included: `None` (no cap, each value is sent whole) or a non-negative integer. Invalid values call `on_error`, do not raise into application code, and install a disabled client; truncated values use the ASCII `...[truncated]` marker, or its prefix when the cap is shorter than the marker. The cap also applies, with the marker, to string metadata and log attributes; any other string attribute is cut at the cap without a marker, except that a cap of `0` leaves those whole. |
190
+ | `max_stream_bytes` | `67108864` (64 MiB) | Maximum output, across the process, that provider integrations keep for streams that have not ended, in UTF-8 bytes of JSON. Each stream keeps at most `MAX_RECORD_BYTES` (16 MiB); while no other stream holds bytes in it, not even the few bytes a started stream holds before any output, a stream may grow to 16 MiB even past this bound. Output past either bound is not kept, and its span gets `telemetry.dev.capture.truncated`. `None` selects the default; other values that are not non-negative integers or `math.inf` call `on_error` and install a disabled client. The bound counts UTF-8 bytes, not Python memory, so each streamed text buffer holds more than it counts: up to 255 of its latest deltas as separate strings, at most about 22 KB, and either about 1.5% of its text on Python 3.10 and 3.11 or, on 3.12 and later, the room `StringIO` reserves to grow, up to about 25% of its text (50% on Windows). Text with a character outside Latin-1, such as an emoji, is stored at up to 4 bytes per character, so its buffer can hold up to about 4 times the bytes counted. |
187
191
  | `span_filter` | `None` | Export predicate `Callable[[ReadableSpan], bool]`. |
188
192
  | `sampler` | OTel environment configuration | OTel `Sampler` that overrides environment settings. Session roots use its root policy. Real parents keep their sampling decisions. |
189
- | `on_error` | `None` | Receives internal SDK errors; repeated instrumentation failures from one stream may be coalesced into one report. The SDK never raises them into application code. A series of failed exports, for example during an ingest outage, is one report to `on_error` and the `telemetry_dev` logger. After an export reaches the ingest, the next failure is a new report. |
193
+ | `on_error` | `None` | Receives internal SDK errors; repeated instrumentation failures from one stream may be coalesced into one report. The SDK never raises them into application code. A series of failed exports, for example during an ingest outage, is one report to `on_error` and the `telemetry_dev` logger. After an export reaches the ingest, the next failure is a new report. A `flush()` or `shutdown()` that `on_error` calls during an export returns at once, before it sends anything, and runs on a new thread, because a batch processor or the metric reader holds a lock during its export that the call needs; the thread waits for that export to end. With `export_mode="immediate"` the span and log exports hold no lock, so the call starts at once, but it still returns before it sends anything: in a serverless handler, call `flush()` after the work, outside `on_error`. The process does not wait for a deferred flush before it exits; the shutdown at exit sends what is left, unless `disable_atexit=True`, where the application must call `shutdown()`. After a deferred `shutdown()`, the client is already gone, and the process waits for the shutdown before it exits; if its thread cannot start, it runs when the process exits, unless the process is already exiting. |
190
194
  | `disable_atexit` | `False` | Skip the automatic atexit shutdown. |
191
- | `timeout` | `10.0` | OTLP HTTP timeout in seconds. |
195
+ | `timeout` | `10.0` | Timeout of each OTLP HTTP export request in seconds. No wait before a retry starts after it, but a request whose connection fails is sent again at once with the same limit, so an ingest that does not answer can take up to twice this time. The limit applies to each wait for the server, so a response that keeps arriving can also take longer. A batch split into several requests gives each request this timeout. |
192
196
  | `span_exporter`, `log_exporter`, `metric_reader` | `None` | Test seams / offline mode; any of them enables the client without an API key. |
193
197
 
198
+ Each export request is at most 16 MiB, the ingest's limit, so a larger batch is sent in several
199
+ requests. A span or log record that is larger than 16 MiB by itself is still sent: its longest
200
+ string values (attributes, or a log record's message) are cut to fit and end with `...[truncated]`,
201
+ the record gets `telemetry.dev.capture.truncated = true`, and `on_error` receives a report. A record
202
+ that still does not fit, because its events or array attributes hold the excess, is dropped and
203
+ reported. `create_telemetry_span_exporter` and `TelemetrySpanProcessor` follow the same rules.
204
+
205
+ In `"batched"` mode, the spans and the log records that wait for export are each bounded to 2048
206
+ records (for logs, `OTEL_BLRP_MAX_QUEUE_SIZE` when it is set) and 64 MiB of string values, each character counted as one byte. A record that arrives
207
+ when its queue is full is dropped, and the first drop of a series is reported to `on_error`. A
208
+ single record larger than the bound is still queued when its queue is empty.
209
+
194
210
  `capture_input=False` and `capture_output=False` omit captured content. Provider integrations may
195
211
  still record non-content metadata such as response IDs and models, finish reasons, usage, timing,
196
212
  and error types. Capture flags do not gate stop sequences, tool descriptions and definitions
@@ -246,13 +262,13 @@ pinned = telemetry_dev.get_prompt("support/reply", version=13)
246
262
  call returns it at once and fetches a new copy in a background thread. Only a call with no copy
247
263
  waits for a fetch, for 10 seconds at most, also when the network stops. Calls for the same
248
264
  prompt share one fetch. `get_prompt_async` runs the same function in a worker thread.
249
- - A process that `os.fork()` makes keeps the copies of its parent. This includes a process of
250
- `multiprocessing` with the `fork` start method. A call that starts in the child does not wait
251
- for a fetch of the parent. If the call must fetch, it starts a new fetch.
252
- - If a signal handler forks while a call waits for a fetch, that call continues in the child. No
253
- thread of the child completes that fetch. Thus the call waits until 10 seconds after the start
254
- of the fetch. Then the call returns the `fallback`, or raises `PromptError` with the code
255
- `timeout`.
265
+ - A forked process keeps the copies of its parent: a process that `os.fork()` makes, one that
266
+ `multiprocessing` makes with the `fork` start method, or one that C code forks without running
267
+ fork hooks. A call that starts in the child does not wait for a fetch of the parent, or for a
268
+ lock that a thread of the parent held. If the call must fetch, it starts a new fetch.
269
+ - If a signal handler forks while a call waits for a fetch, that call continues in the child,
270
+ where no thread completes that fetch. Thus the call looks at the cache again, and starts a new
271
+ fetch if it must, which it waits for up to 10 seconds more.
256
272
  - If a fetch fails, `get_prompt` returns the last copy that it fetched and reports the error
257
273
  through `on_error`. With no copy, it returns the `fallback` (`version` is `None` and
258
274
  `is_fallback` is `True`). With no fallback, it raises `PromptError` whose `code` tells why, for
@@ -276,7 +292,10 @@ pinned = telemetry_dev.get_prompt("support/reply", version=13)
276
292
  `td.prompt.name`, `td.prompt.version`, and `td.prompt.label` (only for a prompt fetched by label).
277
293
  When input capture is on, `td.prompt.variables` holds the JSON of the variables of the last
278
294
  `compile()` of that prompt object before `with_prompt` starts, or of the last `compile()` inside
279
- it, after `mask` and truncation. If threads or tasks that run at the same time share one prompt
295
+ it, after `mask`. Past `max_attribute_length` the longest values are cut one by one, each to a text
296
+ that ends with `...[truncated]`, when the keys and a marker for each cut value fit; the JSON then
297
+ keeps every variable. Otherwise the whole attribute is cut, so it can lose variables and stop being
298
+ valid JSON. If threads or tasks that run at the same time share one prompt
280
299
  object, call `compile()` in `with_prompt`, or call `get_prompt` in each thread or task.
281
300
  `get_prompt` returns a new object from the cache. If you do not, a thread can record the variables
282
301
  of a different thread. Inside one `with_prompt`, an asyncio task records the last `compile()` that
@@ -384,9 +403,12 @@ result = telemetry_dev.run_experiment(
384
403
  - `run_experiment` sends the outputs in batches of 100 items at most, and then waits up to 30
385
404
  minutes for the server evaluators. Then it prints the scores and returns an `ExperimentResult`:
386
405
  `status`, `check_status`, item counts, `scores` with the value, the baseline value, the change,
387
- and the pass mark of each score, and the `url` of the experiment page.
406
+ the pass mark, and the failed runs (`items_failed`) of each score, and the `url` of the
407
+ experiment page.
388
408
  - `min_scores` sets a pass mark for each score name: the lowest pass rate (0 to 1) of a pass/fail
389
- score, or the lowest mean of a number score. A score under its mark fails the check.
409
+ score, or the lowest mean of a number score. A score under its mark fails the check. A run whose
410
+ task raises has no score, so the value of a score leaves it out, and with pass marks a failed
411
+ run fails the check.
390
412
  - A failed request raises `ExperimentError` whose `code` tells why, for example
391
413
  `dataset_not_found`, `dataset_empty`, `evaluator_not_found`, `insufficient_scope`,
392
414
  `missing_api_key`, or `timeout`. A read of the dataset or the result, a post of outputs, and the
@@ -396,11 +418,18 @@ result = telemetry_dev.run_experiment(
396
418
  made the experiment, also after Ctrl-C or a cancellation, `run_experiment` sends the completion
397
419
  before it raises: telemetry.dev then ends the experiment with the item runs that it got, or fails
398
420
  it when it got none.
399
- - The key needs the `datasets:read` and `experiments:write` scopes. `run_experiment` uses the same
400
- API key and base URL as `get_prompt`, or its own `api_key` and `base_url`. With
401
- `environment="experiment"`, the key of the telemetry client must be for all environments or for
402
- `experiment`: a key for another environment cannot send the traces of the items, and the items
403
- then have no trace and no cost.
421
+ - The key needs Run experiments in its Access on the API keys page (the `datasets:read` and
422
+ `experiments:write` scopes). `run_experiment` uses the same
423
+ API key and base URL as `get_prompt`, or its own `api_key` and `base_url`.
424
+ - The items send their traces with the key of the telemetry client, which needs Send telemetry. A
425
+ key for one environment also sends the `experiment` environment when it has Run experiments.
426
+ Without a client, without Send telemetry, with a key for another environment and no Run
427
+ experiments, or when Accept telemetry is off in the project settings, the items have no trace
428
+ and no cost. The export error says why, and the job summary of the experiment action says that
429
+ the runs have no traces, with the reason of the ingest.
430
+ - When the ingest refuses a trace export because the key is not valid (401), for example after
431
+ the key was revoked or its project was deleted, and the client sends with the key and the base
432
+ URL of the run, `run_experiment` starts no more items and raises `ExperimentError` with `invalid_api_key`.
404
433
 
405
434
  The outputs, the exceptions of failed tasks, the scorer reasons, and `metadata` go to telemetry.dev
406
435
  and stay with the experiment, because they are its result. `capture_output`, `mask`, and the
@@ -419,7 +448,9 @@ The [experiment action](../../actions/experiment) runs your eval script in a wor
419
448
  the result on the pull request. It gives `run_experiment` the `dataset` input in
420
449
  `TELEMETRY_DEV_EXPERIMENT_DATASET`, which must agree with the `dataset` of the script, and the
421
450
  `min-scores` input in `TELEMETRY_DEV_EXPERIMENT_MIN_SCORES`, which wins over `min_scores` for the
422
- same name.
451
+ same name. Use the action as `telemetry-dev/telemetry/actions/experiment@experiment-action-v1`, a
452
+ tag that moves to each 1.x release of the action. In the action, a failed experiment with `ci=False`
453
+ shows its result but does not fail the job.
423
454
 
424
455
  ## Scores
425
456
 
@@ -429,24 +460,37 @@ user on a reply:
429
460
  ```python
430
461
  import telemetry_dev
431
462
 
432
- # When the app replies, keep the trace id of the reply with the message:
463
+ # When the app replies, keep the trace id and the span id of the reply with the message:
433
464
  with telemetry_dev.start_span("reply") as span:
434
465
  text = reply_to_customer(message)
435
- trace_id = f"{span.span.get_span_context().trace_id:032x}"
466
+ context = span.span.get_span_context()
467
+ trace_id, span_id = f"{context.trace_id:032x}", f"{context.span_id:016x}"
436
468
 
437
469
  # Later, when the user clicks thumbs down:
438
- telemetry_dev.score(name="user_feedback", trace_id=trace_id, value=0, comment="Wrong amount")
470
+ telemetry_dev.score(
471
+ name="user_feedback", trace_id=trace_id, span_id=span_id, value=0, comment="Wrong amount"
472
+ )
439
473
  ```
440
474
 
441
475
  - Give `trace_id`, `session_id`, or the two, and a `span_id` of the trace for a score on one span.
476
+ With a `trace_id`, the score belongs to that trace and shows in the session of the trace, even
477
+ when the `session_id` names another session.
442
478
  Give `value`, `label`, or the two. `user_feedback` takes the value 1 for up or 0 for down, and
443
479
  no label. A pass/fail score has the label `pass` with the value 1, or `fail` with 0.
444
480
  - Like the telemetry functions, `score` never raises. It returns the id of the score, or `None`
445
481
  after it sends a `ScoreError` to `on_error`. It checks the score before it sends it
446
482
  (`invalid_score`). The trace id of a span from a client that is not enabled is all zeros, and
447
483
  `score` reports it as `invalid_score`.
484
+ - Give the `span_id` of the reply for feedback on one reply. The SDK puts all the turns of a session
485
+ in one trace, so feedback with only a `trace_id` counts for the turn that started last before the
486
+ feedback came, which can be a later turn than the reply.
487
+ - The rates of the dashboard count one `user_feedback` vote for each span, turn, or session: a
488
+ later `user_feedback` score on the same span (on the same turn, for feedback with only a trace,
489
+ or on the same session, for feedback with no trace) replaces the earlier one. The SDK sends
490
+ feedback with no author, so all the feedback that the SDK sends on one span or one turn counts as
491
+ one vote: the newest.
448
492
  - `score` makes one request, with no retry. `score_async` runs it in a worker thread. The key
449
- needs the `scores:write` scope.
493
+ needs Run experiments in its Access on the API keys page (the `scores:write` scope).
450
494
 
451
495
  ## Auto-metrics
452
496
 
@@ -474,6 +518,27 @@ telemetry_dev.init(export_mode="immediate")
474
518
  telemetry_dev.flush() # force-flush traces + logs + metrics
475
519
  ```
476
520
 
521
+ ## Forking servers
522
+
523
+ A server that forks its workers from the process that called `init()`, as gunicorn,
524
+ `multiprocessing` with the `fork` start method, or `os.fork()`, needs no setup. Python runs the
525
+ fork hooks of the SDK and of OpenTelemetry in each worker, and the SDK does not wait in a worker
526
+ for a lock that a thread of the parent held at the fork.
527
+
528
+ uWSGI loads the app before it forks its workers, and by default it runs no Python fork hooks in
529
+ them. Traces and logs still go out, but the OpenTelemetry metric reader starts its thread again
530
+ only in a fork hook, so a worker sends metrics only when it calls `telemetry_dev.flush()`. Set one
531
+ of these uWSGI options:
532
+
533
+ - `lazy-apps = true`: each worker loads the app, and thus calls `init()` itself.
534
+ - `py-call-uwsgi-fork-hooks = true` (uWSGI 2.0.21 and later): uWSGI runs the Python fork hooks
535
+ around each fork. Before 2.0.27, it runs only the hooks of the child, which is enough for the
536
+ SDK.
537
+
538
+ Before uWSGI 2.0.27, Python threads run only with `enable-threads = true` or more than one
539
+ `threads`. The SDK sends telemetry from its own threads, so set one of them too, also with
540
+ `lazy-apps`.
541
+
477
542
  ## Bring your own OTel (`telemetry_dev.otel`)
478
543
 
479
544
  If you already run an OpenTelemetry SDK, attach the telemetry.dev processor to your provider
@@ -495,6 +560,10 @@ span_exporter = create_telemetry_span_exporter()
495
560
  your_tracer_provider.add_span_processor(BatchSpanProcessor(span_exporter))
496
561
  ```
497
562
 
563
+ `create_telemetry_span_exporter` takes `api_key`, `base_url`, and `timeout`, in seconds (default
564
+ `10.0`). The timeout works as the `timeout` option of `init` describes, also for each request of a
565
+ batch that is split.
566
+
498
567
  `TelemetrySpanProcessor` remains available from the package root for compatibility:
499
568
 
500
569
  ```python
@@ -509,12 +578,14 @@ from telemetry_dev import TelemetrySpanProcessor
509
578
  | `max_export_batch_size` | `64` | BatchSpanProcessor export batch size. |
510
579
  | `schedule_delay_millis` | `1000` | BatchSpanProcessor schedule delay. |
511
580
  | `max_queue_size` | `2048` | BatchSpanProcessor queue size. |
512
- | `export_timeout_millis` | `30000` | BatchSpanProcessor export timeout. |
581
+ | `max_queue_bytes` | `67108864` (64 MiB) | Maximum size of the queued spans, counting each character of their string attribute values as one byte. A span is still queued when the queue is empty. Spans over the bound are dropped and reported to `on_error`. |
582
+ | `max_stream_bytes` | `67108864` (64 MiB) | Maximum output that provider integrations keep, across the process, for streams that have not ended (UTF-8 bytes of JSON). Each stream keeps at most `MAX_RECORD_BYTES` (16 MiB); while no other stream holds bytes in it, not even the few bytes a started stream holds before any output, a stream may grow to 16 MiB even past this bound. The bound is process-wide, so the span processor started last sets it. `None` selects the default; other values that are not non-negative integers or `math.inf` are reported to `on_error`, and the processor exports nothing. Output past either bound is not kept, and its span gets `telemetry.dev.capture.truncated`. The bound counts UTF-8 bytes, not Python memory, so each streamed text buffer holds more than it counts: up to 255 of its latest deltas as separate strings, at most about 22 KB, and either about 1.5% of its text on Python 3.10 and 3.11 or, on 3.12 and later, the room `StringIO` reserves to grow, up to about 25% of its text (50% on Windows). Text with a character outside Latin-1, such as an emoji, is stored at up to 4 bytes per character, so its buffer can hold up to about 4 times the bytes counted. |
583
+ | `export_timeout_millis` | `30000` | Passed to BatchSpanProcessor, which does not apply it. The telemetry.dev exporter applies a 10-second `timeout` to each request, as the `init` option describes. |
513
584
  | `span_filter` | `None` | Export predicate `Callable[[ReadableSpan], bool]`; failures export the span. |
514
585
  | `metrics` | `True` | Auto-record GenAI duration/token histograms for exported spans when an API key is available. |
515
586
  | `service_name` | `OTEL_SERVICE_NAME` or `unknown_service` | `service.name` on the metrics resource. |
516
587
  | `environment` | `TELEMETRY_DEV_ENVIRONMENT` or `production` | `deployment.environment.name` on the metrics resource. |
517
- | `on_error` | `None` | Receives export errors of the telemetry.dev exporters and internal processor errors; errors are never raised into your code. A series of failed exports is one report. After an export reaches the ingest, the next failure is a new report. |
588
+ | `on_error` | `None` | Receives export errors of the telemetry.dev exporters and internal processor errors; errors are never raised into your code. A series of failed exports is one report. After an export reaches the ingest, the next failure is a new report. A `force_flush()` or `shutdown()` of the processor that `on_error` calls during an export returns at once (`force_flush()` returns `False`) and runs on a new thread. The process waits for a deferred `shutdown()` before it exits, and runs it at exit if its thread cannot start, unless the process is already exiting; it does not wait for a deferred `force_flush()`. |
518
589
  | `span_exporter` | `None` | Advanced/test seam replacing the telemetry.dev OTLP trace exporter. |
519
590
 
520
591
  Without an API key and without `span_exporter`, `TelemetrySpanProcessor()` is an inert no-op:
@@ -74,6 +74,11 @@ initialization. Explicit and propagated session IDs take precedence, and valid p
74
74
  context is preserved. The generated session ends when the client is shut down or replaced; a
75
75
  later `init()` generates a new ID. It is not persisted across processes.
76
76
 
77
+ The root spans of a session join one trace for each API key, and the trace keeps the environment
78
+ of its first turn. When one key sends turns of the same session id from two environments, the
79
+ later turns show under the first environment, or get a 403 when the key may not send that
80
+ environment. Use a key for each environment, or give each environment its own session ids.
81
+
77
82
  ## API reference
78
83
 
79
84
  | Name | Description |
@@ -103,10 +108,6 @@ metric readers, so supplying `metric_reader=` disables this histogram. Duration,
103
108
  time-to-first-chunk metrics remain available; the first accepted streamed span with two or more
104
109
  recorded chunks reports this limitation once through `on_error` and the SDK logger.
105
110
 
106
- Provider integrations feature-detect `record_output_chunk`. Older core SDKs without that method
107
- continue delivering streams and tracing normally, but do not emit chunk-interval metrics. Upgrade
108
- the core SDK with provider integrations to enable the new metric.
109
-
110
111
  ### Span types
111
112
 
112
113
  `type=` maps to `gen_ai.operation.name`:
@@ -158,14 +159,27 @@ metadata, identifiers, resource attributes, or events written directly through r
158
159
  | `log_level` | `"warn"` | SDK diagnostics level: `debug`/`info`/`warn`/`error`/`silent`. |
159
160
  | `capture_input`, `capture_output` | `True` | Global content-capture defaults. |
160
161
  | `mask` | `None` | `Callable[[Any, MaskContext], Any]` redaction hook, runs before JSON serialization on input/output/log messages and `SpanHandle.serialize_content` (`MaskContext.key` is the attribute being written). Not applied to correlation identifiers. |
161
- | `max_attribute_length` | `65536` | Non-negative integer per-content-attribute cap. Invalid values call `on_error`, do not raise into application code, and install a disabled client; truncated values use the ASCII `...[truncated]` marker, or its prefix when the cap is shorter than the marker. The cap also applies, with the marker, to string metadata and log attributes; any other string attribute is cut at the cap without a marker, except that a cap of `0` leaves those at 65536. |
162
+ | `max_attribute_length` | `None` | Per-content-attribute cap in UTF-16 units, the marker included: `None` (no cap, each value is sent whole) or a non-negative integer. Invalid values call `on_error`, do not raise into application code, and install a disabled client; truncated values use the ASCII `...[truncated]` marker, or its prefix when the cap is shorter than the marker. The cap also applies, with the marker, to string metadata and log attributes; any other string attribute is cut at the cap without a marker, except that a cap of `0` leaves those whole. |
163
+ | `max_stream_bytes` | `67108864` (64 MiB) | Maximum output, across the process, that provider integrations keep for streams that have not ended, in UTF-8 bytes of JSON. Each stream keeps at most `MAX_RECORD_BYTES` (16 MiB); while no other stream holds bytes in it, not even the few bytes a started stream holds before any output, a stream may grow to 16 MiB even past this bound. Output past either bound is not kept, and its span gets `telemetry.dev.capture.truncated`. `None` selects the default; other values that are not non-negative integers or `math.inf` call `on_error` and install a disabled client. The bound counts UTF-8 bytes, not Python memory, so each streamed text buffer holds more than it counts: up to 255 of its latest deltas as separate strings, at most about 22 KB, and either about 1.5% of its text on Python 3.10 and 3.11 or, on 3.12 and later, the room `StringIO` reserves to grow, up to about 25% of its text (50% on Windows). Text with a character outside Latin-1, such as an emoji, is stored at up to 4 bytes per character, so its buffer can hold up to about 4 times the bytes counted. |
162
164
  | `span_filter` | `None` | Export predicate `Callable[[ReadableSpan], bool]`. |
163
165
  | `sampler` | OTel environment configuration | OTel `Sampler` that overrides environment settings. Session roots use its root policy. Real parents keep their sampling decisions. |
164
- | `on_error` | `None` | Receives internal SDK errors; repeated instrumentation failures from one stream may be coalesced into one report. The SDK never raises them into application code. A series of failed exports, for example during an ingest outage, is one report to `on_error` and the `telemetry_dev` logger. After an export reaches the ingest, the next failure is a new report. |
166
+ | `on_error` | `None` | Receives internal SDK errors; repeated instrumentation failures from one stream may be coalesced into one report. The SDK never raises them into application code. A series of failed exports, for example during an ingest outage, is one report to `on_error` and the `telemetry_dev` logger. After an export reaches the ingest, the next failure is a new report. A `flush()` or `shutdown()` that `on_error` calls during an export returns at once, before it sends anything, and runs on a new thread, because a batch processor or the metric reader holds a lock during its export that the call needs; the thread waits for that export to end. With `export_mode="immediate"` the span and log exports hold no lock, so the call starts at once, but it still returns before it sends anything: in a serverless handler, call `flush()` after the work, outside `on_error`. The process does not wait for a deferred flush before it exits; the shutdown at exit sends what is left, unless `disable_atexit=True`, where the application must call `shutdown()`. After a deferred `shutdown()`, the client is already gone, and the process waits for the shutdown before it exits; if its thread cannot start, it runs when the process exits, unless the process is already exiting. |
165
167
  | `disable_atexit` | `False` | Skip the automatic atexit shutdown. |
166
- | `timeout` | `10.0` | OTLP HTTP timeout in seconds. |
168
+ | `timeout` | `10.0` | Timeout of each OTLP HTTP export request in seconds. No wait before a retry starts after it, but a request whose connection fails is sent again at once with the same limit, so an ingest that does not answer can take up to twice this time. The limit applies to each wait for the server, so a response that keeps arriving can also take longer. A batch split into several requests gives each request this timeout. |
167
169
  | `span_exporter`, `log_exporter`, `metric_reader` | `None` | Test seams / offline mode; any of them enables the client without an API key. |
168
170
 
171
+ Each export request is at most 16 MiB, the ingest's limit, so a larger batch is sent in several
172
+ requests. A span or log record that is larger than 16 MiB by itself is still sent: its longest
173
+ string values (attributes, or a log record's message) are cut to fit and end with `...[truncated]`,
174
+ the record gets `telemetry.dev.capture.truncated = true`, and `on_error` receives a report. A record
175
+ that still does not fit, because its events or array attributes hold the excess, is dropped and
176
+ reported. `create_telemetry_span_exporter` and `TelemetrySpanProcessor` follow the same rules.
177
+
178
+ In `"batched"` mode, the spans and the log records that wait for export are each bounded to 2048
179
+ records (for logs, `OTEL_BLRP_MAX_QUEUE_SIZE` when it is set) and 64 MiB of string values, each character counted as one byte. A record that arrives
180
+ when its queue is full is dropped, and the first drop of a series is reported to `on_error`. A
181
+ single record larger than the bound is still queued when its queue is empty.
182
+
169
183
  `capture_input=False` and `capture_output=False` omit captured content. Provider integrations may
170
184
  still record non-content metadata such as response IDs and models, finish reasons, usage, timing,
171
185
  and error types. Capture flags do not gate stop sequences, tool descriptions and definitions
@@ -221,13 +235,13 @@ pinned = telemetry_dev.get_prompt("support/reply", version=13)
221
235
  call returns it at once and fetches a new copy in a background thread. Only a call with no copy
222
236
  waits for a fetch, for 10 seconds at most, also when the network stops. Calls for the same
223
237
  prompt share one fetch. `get_prompt_async` runs the same function in a worker thread.
224
- - A process that `os.fork()` makes keeps the copies of its parent. This includes a process of
225
- `multiprocessing` with the `fork` start method. A call that starts in the child does not wait
226
- for a fetch of the parent. If the call must fetch, it starts a new fetch.
227
- - If a signal handler forks while a call waits for a fetch, that call continues in the child. No
228
- thread of the child completes that fetch. Thus the call waits until 10 seconds after the start
229
- of the fetch. Then the call returns the `fallback`, or raises `PromptError` with the code
230
- `timeout`.
238
+ - A forked process keeps the copies of its parent: a process that `os.fork()` makes, one that
239
+ `multiprocessing` makes with the `fork` start method, or one that C code forks without running
240
+ fork hooks. A call that starts in the child does not wait for a fetch of the parent, or for a
241
+ lock that a thread of the parent held. If the call must fetch, it starts a new fetch.
242
+ - If a signal handler forks while a call waits for a fetch, that call continues in the child,
243
+ where no thread completes that fetch. Thus the call looks at the cache again, and starts a new
244
+ fetch if it must, which it waits for up to 10 seconds more.
231
245
  - If a fetch fails, `get_prompt` returns the last copy that it fetched and reports the error
232
246
  through `on_error`. With no copy, it returns the `fallback` (`version` is `None` and
233
247
  `is_fallback` is `True`). With no fallback, it raises `PromptError` whose `code` tells why, for
@@ -251,7 +265,10 @@ pinned = telemetry_dev.get_prompt("support/reply", version=13)
251
265
  `td.prompt.name`, `td.prompt.version`, and `td.prompt.label` (only for a prompt fetched by label).
252
266
  When input capture is on, `td.prompt.variables` holds the JSON of the variables of the last
253
267
  `compile()` of that prompt object before `with_prompt` starts, or of the last `compile()` inside
254
- it, after `mask` and truncation. If threads or tasks that run at the same time share one prompt
268
+ it, after `mask`. Past `max_attribute_length` the longest values are cut one by one, each to a text
269
+ that ends with `...[truncated]`, when the keys and a marker for each cut value fit; the JSON then
270
+ keeps every variable. Otherwise the whole attribute is cut, so it can lose variables and stop being
271
+ valid JSON. If threads or tasks that run at the same time share one prompt
255
272
  object, call `compile()` in `with_prompt`, or call `get_prompt` in each thread or task.
256
273
  `get_prompt` returns a new object from the cache. If you do not, a thread can record the variables
257
274
  of a different thread. Inside one `with_prompt`, an asyncio task records the last `compile()` that
@@ -359,9 +376,12 @@ result = telemetry_dev.run_experiment(
359
376
  - `run_experiment` sends the outputs in batches of 100 items at most, and then waits up to 30
360
377
  minutes for the server evaluators. Then it prints the scores and returns an `ExperimentResult`:
361
378
  `status`, `check_status`, item counts, `scores` with the value, the baseline value, the change,
362
- and the pass mark of each score, and the `url` of the experiment page.
379
+ the pass mark, and the failed runs (`items_failed`) of each score, and the `url` of the
380
+ experiment page.
363
381
  - `min_scores` sets a pass mark for each score name: the lowest pass rate (0 to 1) of a pass/fail
364
- score, or the lowest mean of a number score. A score under its mark fails the check.
382
+ score, or the lowest mean of a number score. A score under its mark fails the check. A run whose
383
+ task raises has no score, so the value of a score leaves it out, and with pass marks a failed
384
+ run fails the check.
365
385
  - A failed request raises `ExperimentError` whose `code` tells why, for example
366
386
  `dataset_not_found`, `dataset_empty`, `evaluator_not_found`, `insufficient_scope`,
367
387
  `missing_api_key`, or `timeout`. A read of the dataset or the result, a post of outputs, and the
@@ -371,11 +391,18 @@ result = telemetry_dev.run_experiment(
371
391
  made the experiment, also after Ctrl-C or a cancellation, `run_experiment` sends the completion
372
392
  before it raises: telemetry.dev then ends the experiment with the item runs that it got, or fails
373
393
  it when it got none.
374
- - The key needs the `datasets:read` and `experiments:write` scopes. `run_experiment` uses the same
375
- API key and base URL as `get_prompt`, or its own `api_key` and `base_url`. With
376
- `environment="experiment"`, the key of the telemetry client must be for all environments or for
377
- `experiment`: a key for another environment cannot send the traces of the items, and the items
378
- then have no trace and no cost.
394
+ - The key needs Run experiments in its Access on the API keys page (the `datasets:read` and
395
+ `experiments:write` scopes). `run_experiment` uses the same
396
+ API key and base URL as `get_prompt`, or its own `api_key` and `base_url`.
397
+ - The items send their traces with the key of the telemetry client, which needs Send telemetry. A
398
+ key for one environment also sends the `experiment` environment when it has Run experiments.
399
+ Without a client, without Send telemetry, with a key for another environment and no Run
400
+ experiments, or when Accept telemetry is off in the project settings, the items have no trace
401
+ and no cost. The export error says why, and the job summary of the experiment action says that
402
+ the runs have no traces, with the reason of the ingest.
403
+ - When the ingest refuses a trace export because the key is not valid (401), for example after
404
+ the key was revoked or its project was deleted, and the client sends with the key and the base
405
+ URL of the run, `run_experiment` starts no more items and raises `ExperimentError` with `invalid_api_key`.
379
406
 
380
407
  The outputs, the exceptions of failed tasks, the scorer reasons, and `metadata` go to telemetry.dev
381
408
  and stay with the experiment, because they are its result. `capture_output`, `mask`, and the
@@ -394,7 +421,9 @@ The [experiment action](../../actions/experiment) runs your eval script in a wor
394
421
  the result on the pull request. It gives `run_experiment` the `dataset` input in
395
422
  `TELEMETRY_DEV_EXPERIMENT_DATASET`, which must agree with the `dataset` of the script, and the
396
423
  `min-scores` input in `TELEMETRY_DEV_EXPERIMENT_MIN_SCORES`, which wins over `min_scores` for the
397
- same name.
424
+ same name. Use the action as `telemetry-dev/telemetry/actions/experiment@experiment-action-v1`, a
425
+ tag that moves to each 1.x release of the action. In the action, a failed experiment with `ci=False`
426
+ shows its result but does not fail the job.
398
427
 
399
428
  ## Scores
400
429
 
@@ -404,24 +433,37 @@ user on a reply:
404
433
  ```python
405
434
  import telemetry_dev
406
435
 
407
- # When the app replies, keep the trace id of the reply with the message:
436
+ # When the app replies, keep the trace id and the span id of the reply with the message:
408
437
  with telemetry_dev.start_span("reply") as span:
409
438
  text = reply_to_customer(message)
410
- trace_id = f"{span.span.get_span_context().trace_id:032x}"
439
+ context = span.span.get_span_context()
440
+ trace_id, span_id = f"{context.trace_id:032x}", f"{context.span_id:016x}"
411
441
 
412
442
  # Later, when the user clicks thumbs down:
413
- telemetry_dev.score(name="user_feedback", trace_id=trace_id, value=0, comment="Wrong amount")
443
+ telemetry_dev.score(
444
+ name="user_feedback", trace_id=trace_id, span_id=span_id, value=0, comment="Wrong amount"
445
+ )
414
446
  ```
415
447
 
416
448
  - Give `trace_id`, `session_id`, or the two, and a `span_id` of the trace for a score on one span.
449
+ With a `trace_id`, the score belongs to that trace and shows in the session of the trace, even
450
+ when the `session_id` names another session.
417
451
  Give `value`, `label`, or the two. `user_feedback` takes the value 1 for up or 0 for down, and
418
452
  no label. A pass/fail score has the label `pass` with the value 1, or `fail` with 0.
419
453
  - Like the telemetry functions, `score` never raises. It returns the id of the score, or `None`
420
454
  after it sends a `ScoreError` to `on_error`. It checks the score before it sends it
421
455
  (`invalid_score`). The trace id of a span from a client that is not enabled is all zeros, and
422
456
  `score` reports it as `invalid_score`.
457
+ - Give the `span_id` of the reply for feedback on one reply. The SDK puts all the turns of a session
458
+ in one trace, so feedback with only a `trace_id` counts for the turn that started last before the
459
+ feedback came, which can be a later turn than the reply.
460
+ - The rates of the dashboard count one `user_feedback` vote for each span, turn, or session: a
461
+ later `user_feedback` score on the same span (on the same turn, for feedback with only a trace,
462
+ or on the same session, for feedback with no trace) replaces the earlier one. The SDK sends
463
+ feedback with no author, so all the feedback that the SDK sends on one span or one turn counts as
464
+ one vote: the newest.
423
465
  - `score` makes one request, with no retry. `score_async` runs it in a worker thread. The key
424
- needs the `scores:write` scope.
466
+ needs Run experiments in its Access on the API keys page (the `scores:write` scope).
425
467
 
426
468
  ## Auto-metrics
427
469
 
@@ -449,6 +491,27 @@ telemetry_dev.init(export_mode="immediate")
449
491
  telemetry_dev.flush() # force-flush traces + logs + metrics
450
492
  ```
451
493
 
494
+ ## Forking servers
495
+
496
+ A server that forks its workers from the process that called `init()`, as gunicorn,
497
+ `multiprocessing` with the `fork` start method, or `os.fork()`, needs no setup. Python runs the
498
+ fork hooks of the SDK and of OpenTelemetry in each worker, and the SDK does not wait in a worker
499
+ for a lock that a thread of the parent held at the fork.
500
+
501
+ uWSGI loads the app before it forks its workers, and by default it runs no Python fork hooks in
502
+ them. Traces and logs still go out, but the OpenTelemetry metric reader starts its thread again
503
+ only in a fork hook, so a worker sends metrics only when it calls `telemetry_dev.flush()`. Set one
504
+ of these uWSGI options:
505
+
506
+ - `lazy-apps = true`: each worker loads the app, and thus calls `init()` itself.
507
+ - `py-call-uwsgi-fork-hooks = true` (uWSGI 2.0.21 and later): uWSGI runs the Python fork hooks
508
+ around each fork. Before 2.0.27, it runs only the hooks of the child, which is enough for the
509
+ SDK.
510
+
511
+ Before uWSGI 2.0.27, Python threads run only with `enable-threads = true` or more than one
512
+ `threads`. The SDK sends telemetry from its own threads, so set one of them too, also with
513
+ `lazy-apps`.
514
+
452
515
  ## Bring your own OTel (`telemetry_dev.otel`)
453
516
 
454
517
  If you already run an OpenTelemetry SDK, attach the telemetry.dev processor to your provider
@@ -470,6 +533,10 @@ span_exporter = create_telemetry_span_exporter()
470
533
  your_tracer_provider.add_span_processor(BatchSpanProcessor(span_exporter))
471
534
  ```
472
535
 
536
+ `create_telemetry_span_exporter` takes `api_key`, `base_url`, and `timeout`, in seconds (default
537
+ `10.0`). The timeout works as the `timeout` option of `init` describes, also for each request of a
538
+ batch that is split.
539
+
473
540
  `TelemetrySpanProcessor` remains available from the package root for compatibility:
474
541
 
475
542
  ```python
@@ -484,12 +551,14 @@ from telemetry_dev import TelemetrySpanProcessor
484
551
  | `max_export_batch_size` | `64` | BatchSpanProcessor export batch size. |
485
552
  | `schedule_delay_millis` | `1000` | BatchSpanProcessor schedule delay. |
486
553
  | `max_queue_size` | `2048` | BatchSpanProcessor queue size. |
487
- | `export_timeout_millis` | `30000` | BatchSpanProcessor export timeout. |
554
+ | `max_queue_bytes` | `67108864` (64 MiB) | Maximum size of the queued spans, counting each character of their string attribute values as one byte. A span is still queued when the queue is empty. Spans over the bound are dropped and reported to `on_error`. |
555
+ | `max_stream_bytes` | `67108864` (64 MiB) | Maximum output that provider integrations keep, across the process, for streams that have not ended (UTF-8 bytes of JSON). Each stream keeps at most `MAX_RECORD_BYTES` (16 MiB); while no other stream holds bytes in it, not even the few bytes a started stream holds before any output, a stream may grow to 16 MiB even past this bound. The bound is process-wide, so the span processor started last sets it. `None` selects the default; other values that are not non-negative integers or `math.inf` are reported to `on_error`, and the processor exports nothing. Output past either bound is not kept, and its span gets `telemetry.dev.capture.truncated`. The bound counts UTF-8 bytes, not Python memory, so each streamed text buffer holds more than it counts: up to 255 of its latest deltas as separate strings, at most about 22 KB, and either about 1.5% of its text on Python 3.10 and 3.11 or, on 3.12 and later, the room `StringIO` reserves to grow, up to about 25% of its text (50% on Windows). Text with a character outside Latin-1, such as an emoji, is stored at up to 4 bytes per character, so its buffer can hold up to about 4 times the bytes counted. |
556
+ | `export_timeout_millis` | `30000` | Passed to BatchSpanProcessor, which does not apply it. The telemetry.dev exporter applies a 10-second `timeout` to each request, as the `init` option describes. |
488
557
  | `span_filter` | `None` | Export predicate `Callable[[ReadableSpan], bool]`; failures export the span. |
489
558
  | `metrics` | `True` | Auto-record GenAI duration/token histograms for exported spans when an API key is available. |
490
559
  | `service_name` | `OTEL_SERVICE_NAME` or `unknown_service` | `service.name` on the metrics resource. |
491
560
  | `environment` | `TELEMETRY_DEV_ENVIRONMENT` or `production` | `deployment.environment.name` on the metrics resource. |
492
- | `on_error` | `None` | Receives export errors of the telemetry.dev exporters and internal processor errors; errors are never raised into your code. A series of failed exports is one report. After an export reaches the ingest, the next failure is a new report. |
561
+ | `on_error` | `None` | Receives export errors of the telemetry.dev exporters and internal processor errors; errors are never raised into your code. A series of failed exports is one report. After an export reaches the ingest, the next failure is a new report. A `force_flush()` or `shutdown()` of the processor that `on_error` calls during an export returns at once (`force_flush()` returns `False`) and runs on a new thread. The process waits for a deferred `shutdown()` before it exits, and runs it at exit if its thread cannot start, unless the process is already exiting; it does not wait for a deferred `force_flush()`. |
493
562
  | `span_exporter` | `None` | Advanced/test seam replacing the telemetry.dev OTLP trace exporter. |
494
563
 
495
564
  Without an API key and without `span_exporter`, `TelemetrySpanProcessor()` is an inert no-op:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "telemetry-dev"
3
- version = "0.3.2"
3
+ version = "0.3.4"
4
4
  description = "telemetry.dev SDK for Python — OpenTelemetry-native GenAI tracing, logs, and metrics"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -28,6 +28,8 @@ dependencies = [
28
28
  "opentelemetry-api>=1.39.0,<2",
29
29
  "opentelemetry-sdk>=1.39.0,<2",
30
30
  "opentelemetry-exporter-otlp-proto-http>=1.39.0,<2",
31
+ "googleapis-common-protos>=1.63.1,<2",
32
+ "requests>=2.28,<3",
31
33
  "rfc8785>=0.1.4",
32
34
  ]
33
35
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "telemetry-dev"
3
- version = "0.3.2"
3
+ version = "0.3.4"
4
4
  description = "telemetry.dev SDK for Python — OpenTelemetry-native GenAI tracing, logs, and metrics"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -22,6 +22,12 @@ dependencies = [
22
22
  "opentelemetry-api>=1.39.0,<2",
23
23
  "opentelemetry-sdk>=1.39.0,<2",
24
24
  "opentelemetry-exporter-otlp-proto-http>=1.39.0,<2",
25
+ # The OTLP exporter sends with requests, and the ingest answers a refused export with a
26
+ # google.rpc.Status. The exporter requires both; the SDK reads the Status of the response.
27
+ # 1.63.1 is the first release that imports with protobuf 5, which opentelemetry-proto needs.
28
+ # The requests floor of the exporter, 2.7, does not import on Python 3.10; 2.28 does.
29
+ "googleapis-common-protos>=1.63.1,<2",
30
+ "requests>=2.28,<3",
25
31
  "rfc8785>=0.1.4",
26
32
  ]
27
33
 
@@ -29,6 +29,7 @@ from ._experiments import (
29
29
  run_experiment,
30
30
  run_experiment_async,
31
31
  )
32
+ from ._export import MAX_RECORD_BYTES
32
33
  from ._logs import log
33
34
  from ._observe import observe
34
35
  from ._prompts import (
@@ -55,6 +56,7 @@ from ._spans import (
55
56
  from .otel import TelemetrySpanProcessor
56
57
 
57
58
  __all__ = [
59
+ "MAX_RECORD_BYTES",
58
60
  "NOT_GIVEN",
59
61
  "AsyncScorer",
60
62
  "AttributeValue",