|
2 | 2 | Tests for traceai-livekit: enabling the Future AGI attribute mapping. |
3 | 3 |
|
4 | 4 | livekit-agents 1.8 adds a privacy filter to the tracer provider it is handed, through |
5 | | -`add_span_processor`. Before fi-instrumentation-otel 1.1.1, `fi_instrumentation.register()` marked |
6 | | -its own exporter as a default that the next `add_span_processor` call replaces, so the filter used |
7 | | -to shut the exporter down and no trace was sent. traceAI-livekit allows fi-instrumentation-otel |
8 | | -1.1.0, so `enable_*` still clears that mark itself. These tests pin that the exporter stays next to |
9 | | -LiveKit's filter, on either release. |
| 5 | +`add_span_processor`. Older fi-instrumentation-otel releases (1.1.0 and earlier, see its CHANGELOG) |
| 6 | +have `fi_instrumentation.register()` mark its own exporter as a default that the next |
| 7 | +`add_span_processor` call replaces, so the filter used to shut the exporter down and no trace was |
| 8 | +sent. traceAI-livekit still allows those releases, so `enable_*` clears that mark itself. These |
| 9 | +tests pin that the exporter stays next to LiveKit's filter, with or without the mark. |
10 | 10 |
|
11 | 11 | Two end-to-end tests send one agent turn through the real mapping and the real HTTP exporter to |
12 | 12 | a collector on 127.0.0.1, and read back what arrived: LiveKit 1.8's conversation content must reach |
|
19 | 19 |
|
20 | 20 | import asyncio |
21 | 21 | import gzip |
22 | | -import importlib.metadata |
23 | 22 | import signal |
24 | 23 | import threading |
25 | 24 | from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer |
|
28 | 27 | import pytest |
29 | 28 | from opentelemetry.sdk.trace.export import SimpleSpanProcessor, SpanExportResult |
30 | 29 | from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter |
31 | | -from packaging.version import Version |
32 | 30 |
|
33 | 31 | pytest.importorskip("livekit.agents", minversion="1.8") |
34 | 32 |
|
@@ -197,26 +195,24 @@ def test_a_processor_added_after_enabling_runs_alongside_the_exporter( |
197 | 195 | assert [s.name for s in other.get_finished_spans()] == ["after-add"] |
198 | 196 |
|
199 | 197 |
|
200 | | -# fi-instrumentation-otel 1.1.1 stopped marking register()'s exporter as a replaceable default |
201 | | -# (TH-8727). The earlier releases this package allows still mark it. |
202 | | -_FI_INSTRUMENTATION_VERSION = Version(importlib.metadata.version("fi-instrumentation-otel")) |
203 | | -_REGISTER_KEEPS_ITS_EXPORTER = _FI_INSTRUMENTATION_VERSION >= Version("1.1.1") |
204 | | - |
205 | | - |
206 | | -def test_add_span_processor_after_register_alone_matches_the_fi_instrumentation_release( |
| 198 | +def test_add_span_processor_after_register_alone_follows_the_mark_enable_clears( |
207 | 199 | make_provider: Any, |
208 | 200 | ) -> None: |
209 | 201 | provider = make_provider() |
| 202 | + # Set by register() on fi-instrumentation-otel 1.1.0 and earlier, not on releases with the |
| 203 | + # TH-8727 fix. Read from the provider, not from a version number, so the test follows the |
| 204 | + # installed release whatever version the fix ships in. |
| 205 | + register_marks_its_exporter = getattr(provider, "_default_processor", False) |
210 | 206 | future_agi_processor = _processors(provider)[0] |
211 | 207 | other_processor = SimpleSpanProcessor(InMemorySpanExporter()) |
212 | 208 |
|
213 | 209 | provider.add_span_processor(other_processor) |
214 | 210 |
|
215 | | - if _REGISTER_KEEPS_ITS_EXPORTER: |
216 | | - assert _processors(provider) == [future_agi_processor, other_processor] |
217 | | - else: |
| 211 | + if register_marks_its_exporter: |
218 | 212 | # Without enable_*, the processor replaces the exporter: why enable_* clears the mark. |
219 | 213 | assert _processors(provider) == [other_processor] |
| 214 | + else: |
| 215 | + assert _processors(provider) == [future_agi_processor, other_processor] |
220 | 216 |
|
221 | 217 |
|
222 | 218 | def test_livekit_cloud_never_receives_our_copies_of_redacted_content( |
|
0 commit comments