Skip to content

Commit b128fe2

Browse files
committed
improve fixtures to mock tracing
1 parent 78f2200 commit b128fe2

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

packages/pytest-simcore/src/pytest_simcore/tracing.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,34 @@
55

66

77
@pytest.fixture
8-
async def mock_otel_collector_fastapi(mocker: MockerFixture) -> InMemorySpanExporter:
8+
async def setup_tracing_fastapi(
9+
mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch
10+
) -> InMemorySpanExporter:
911
memory_exporter = InMemorySpanExporter()
1012
span_processor = SimpleSpanProcessor(memory_exporter)
1113
mocker.patch(
1214
"servicelib.fastapi.tracing._create_span_processor", return_value=span_processor
1315
)
16+
17+
monkeypatch.setenv(
18+
"TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT", "http://opentelemetry-collector"
19+
)
20+
monkeypatch.setenv("TRACING_OPENTELEMETRY_COLLECTOR_PORT", "4318")
21+
return memory_exporter
22+
23+
24+
@pytest.fixture
25+
async def setup_tracing_aiohttp(
26+
mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch
27+
) -> InMemorySpanExporter:
28+
memory_exporter = InMemorySpanExporter()
29+
span_processor = SimpleSpanProcessor(memory_exporter)
30+
mocker.patch(
31+
"servicelib.aiohttp.tracing._create_span_processor", return_value=span_processor
32+
)
33+
34+
monkeypatch.setenv(
35+
"TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT", "http://opentelemetry-collector"
36+
)
37+
monkeypatch.setenv("TRACING_OPENTELEMETRY_COLLECTOR_PORT", "4318")
1438
return memory_exporter

services/storage/tests/conftest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,9 @@ def disabled_rabbitmq(app_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPa
194194
def enable_tracing(
195195
app_environment: EnvVarsDict,
196196
monkeypatch: pytest.MonkeyPatch,
197-
mock_otel_collector_fastapi: InMemorySpanExporter,
197+
setup_tracing_fastapi: InMemorySpanExporter,
198198
):
199199
monkeypatch.setenv("STORAGE_TRACING", "{}")
200-
monkeypatch.setenv(
201-
"TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT", "http://opentelemetry-collector"
202-
)
203-
monkeypatch.setenv("TRACING_OPENTELEMETRY_COLLECTOR_PORT", "4318")
204200

205201

206202
@pytest.fixture

0 commit comments

Comments
 (0)