1313
1414
1515try :
16- import pyroscope # type: ignore[import-untyped] # noqa: F401
16+ import pyroscope # type: ignore[import-untyped]
1717except ImportError : # pragma: no cover
1818 pytest .skip ("pyroscope is not installed" , allow_module_level = True )
1919
@@ -33,12 +33,16 @@ def test_not_ready(self) -> None:
3333 instrument = PyroscopeInstrument (PyroscopeConfig (pyroscope_endpoint = None ))
3434 assert not instrument .is_ready ()
3535
36- def test_opentelemetry_includes_pyroscope_2 (
36+ def test_opentelemetry_includes_pyroscope (
3737 self , monkeypatch : pytest .MonkeyPatch , minimal_opentelemetry_config : OpentelemetryConfig
3838 ) -> None :
3939 monkeypatch .setattr ("opentelemetry.sdk.trace.TracerProvider.shutdown" , Mock ())
40- monkeypatch .setattr ("pyroscope.add_thread_tag" , add_thread_tag_mock := Mock ())
41- monkeypatch .setattr ("pyroscope.remove_thread_tag" , remove_thread_tag_mock := Mock ())
40+ monkeypatch .setattr (
41+ "pyroscope.add_thread_tag" , add_thread_tag_mock := Mock (side_effect = pyroscope .add_thread_tag )
42+ )
43+ monkeypatch .setattr (
44+ "pyroscope.remove_thread_tag" , remove_thread_tag_mock := Mock (side_effect = pyroscope .remove_thread_tag )
45+ )
4246
4347 minimal_opentelemetry_config .pyroscope_endpoint = pydantic .HttpUrl ("http://localhost:4040" )
4448
@@ -53,5 +57,5 @@ async def test_handler() -> None: ...
5357 assert (
5458 add_thread_tag_mock .mock_calls
5559 == remove_thread_tag_mock .mock_calls
56- == [mock .call (mock . ANY , "span_id" , mock .ANY ), mock .call (mock . ANY , "span_name" , "GET /test-handler" )]
60+ == [mock .call ("span_id" , mock .ANY ), mock .call ("span_name" , "GET /test-handler" )]
5761 )
0 commit comments