Skip to content

Commit 95d3043

Browse files
committed
yeild on None tracer
1 parent ab31b3b commit 95d3043

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

getstream/common/telemetry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ def span_request(
173173
yield _NullSpan()
174174
return
175175
tracer = _get_tracer()
176-
if tracer is None: # pragma: no cover
176+
if tracer is None:
177+
yield _NullSpan() # pragma: no cover
177178
return
178179
with tracer.start_as_current_span(name, kind=SpanKind.CLIENT) as span: # type: ignore[arg-type]
179180
base_attrs: Dict[str, Any] = dict(attributes or {})

tests/test_client.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,22 @@ def test_incorrect_client_throws_exception(monkeypatch):
3939
with pytest.raises(ValueError):
4040
Stream(api_key="xxx", api_secret="xxx", base_url="ftp://example.com")
4141

42+
4243
def test_client_does_not_raise_exception_without_tracer(client: Stream, monkeypatch):
4344
# Monkey patch _get_tracer to always return None
4445
from getstream.common import telemetry
45-
monkeypatch.setattr(telemetry, '_get_tracer', lambda: None)
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)
4658

4759
response = client.get_app()
4860
assert response.data is not None

0 commit comments

Comments
 (0)