File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -170,9 +170,11 @@ def span_request(
170170 """
171171 include_bodies = INCLUDE_BODIES if include_bodies is None else include_bodies
172172 if not _HAS_OTEL : # pragma: no cover
173+ yield _NullSpan ()
173174 return
174175 tracer = _get_tracer ()
175- if tracer is None : # pragma: no cover
176+ if tracer is None :
177+ yield _NullSpan () # pragma: no cover
176178 return
177179 with tracer .start_as_current_span (name , kind = SpanKind .CLIENT ) as span : # type: ignore[arg-type]
178180 base_attrs : Dict [str , Any ] = dict (attributes or {})
Original file line number Diff line number Diff line change @@ -38,3 +38,23 @@ def test_incorrect_client_throws_exception(monkeypatch):
3838
3939 with pytest .raises (ValueError ):
4040 Stream (api_key = "xxx" , api_secret = "xxx" , base_url = "ftp://example.com" )
41+
42+
43+ def test_client_does_not_raise_exception_without_tracer (client : Stream , monkeypatch ):
44+ # Monkey patch _get_tracer to always return None
45+ from getstream .common import telemetry
46+
47+ monkeypatch .setattr (telemetry , "_get_tracer" , lambda : None )
48+
49+ response = client .get_app ()
50+ assert response .data is not None
51+
52+
53+ def test_client_works_with_no_otel (client : Stream , monkeypatch ):
54+ # Monkey patch _get_tracer to always return None
55+ from getstream .common import telemetry
56+
57+ monkeypatch .setattr (telemetry , "_HAS_OTEL" , False )
58+
59+ response = client .get_app ()
60+ assert response .data is not None
You can’t perform that action at this time.
0 commit comments