File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
src/simcore_service_autoscaling/modules/instrumentation Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ async def on_shutdown() -> None: ...
3535
3636
3737def get_instrumentation (app : FastAPI ) -> AutoscalingInstrumentation :
38- if not app .state . instrumentation :
38+ if not hasattr ( app .state , " instrumentation" ) :
3939 raise ConfigurationError (
4040 msg = "Instrumentation not setup. Please check the configuration."
4141 )
Original file line number Diff line number Diff line change 1+ import pytest
2+ from fastapi import FastAPI
3+ from pytest_simcore .helpers .typing_env import EnvVarsDict
4+ from simcore_service_autoscaling .core .errors import ConfigurationError
5+ from simcore_service_autoscaling .modules .instrumentation ._core import (
6+ get_instrumentation ,
7+ has_instrumentation ,
8+ )
9+
10+
11+ @pytest .fixture
12+ def disabled_instrumentation (
13+ app_environment : EnvVarsDict , monkeypatch : pytest .MonkeyPatch
14+ ) -> None :
15+ monkeypatch .setenv ("AUTOSCALING_PROMETHEUS_INSTRUMENTATION_ENABLED" , "false" )
16+
17+
18+ async def test_disabled_instrumentation (
19+ disabled_rabbitmq : None ,
20+ disabled_ec2 : None ,
21+ disabled_ssm : None ,
22+ disabled_instrumentation : None ,
23+ mocked_redis_server : None ,
24+ initialized_app : FastAPI ,
25+ ):
26+ # instrumentation disabled by default
27+ assert not has_instrumentation (initialized_app )
28+
29+ with pytest .raises (ConfigurationError ):
30+ get_instrumentation (initialized_app )
You can’t perform that action at this time.
0 commit comments