fix: telemetry tests no longer reference old telemetry system

This commit is contained in:
Emilio Garcia 2025-11-24 10:42:36 -05:00
parent df137d8ca7
commit f3f4b2a6b5
2 changed files with 3 additions and 5 deletions

View file

@ -15,11 +15,10 @@ from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
import llama_stack.core.telemetry.telemetry as telemetry_module
from .base import BaseTelemetryCollector, MetricStub, SpanStub from .base import BaseTelemetryCollector, MetricStub, SpanStub
# TODO: Fix thi to work with Automatic Instrumentation
class InMemoryTelemetryCollector(BaseTelemetryCollector): class InMemoryTelemetryCollector(BaseTelemetryCollector):
"""In-memory telemetry collector for library-client tests. """In-memory telemetry collector for library-client tests.
@ -75,13 +74,10 @@ class InMemoryTelemetryManager:
meter_provider = MeterProvider(metric_readers=[metric_reader]) meter_provider = MeterProvider(metric_readers=[metric_reader])
metrics.set_meter_provider(meter_provider) metrics.set_meter_provider(meter_provider)
telemetry_module._TRACER_PROVIDER = tracer_provider
self.collector = InMemoryTelemetryCollector(span_exporter, metric_reader) self.collector = InMemoryTelemetryCollector(span_exporter, metric_reader)
self._tracer_provider = tracer_provider self._tracer_provider = tracer_provider
self._meter_provider = meter_provider self._meter_provider = meter_provider
def shutdown(self) -> None: def shutdown(self) -> None:
telemetry_module._TRACER_PROVIDER = None
self._tracer_provider.shutdown() self._tracer_provider.shutdown()
self._meter_provider.shutdown() self._meter_provider.shutdown()

View file

@ -15,6 +15,7 @@ from tests.integration.fixtures.common import instantiate_llama_stack_client
from tests.integration.telemetry.collectors import InMemoryTelemetryManager, OtlpHttpTestCollector from tests.integration.telemetry.collectors import InMemoryTelemetryManager, OtlpHttpTestCollector
# TODO: Fix this to work with Automatic Instrumentation
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def telemetry_test_collector(): def telemetry_test_collector():
stack_mode = os.environ.get("LLAMA_STACK_TEST_STACK_CONFIG_TYPE", "library_client") stack_mode = os.environ.get("LLAMA_STACK_TEST_STACK_CONFIG_TYPE", "library_client")
@ -48,6 +49,7 @@ def telemetry_test_collector():
manager.shutdown() manager.shutdown()
# TODO: Fix this to work with Automatic Instrumentation
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def llama_stack_client(telemetry_test_collector, request): def llama_stack_client(telemetry_test_collector, request):
"""Ensure telemetry collector is ready before initializing the stack client.""" """Ensure telemetry collector is ready before initializing the stack client."""