File tree Expand file tree Collapse file tree 4 files changed +10
-1
lines changed
services/web/server/src/simcore_service_webserver Expand file tree Collapse file tree 4 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,13 @@ def app_name(self) -> str:
5050 """
5151 return self ._distribution .metadata ["Name" ]
5252
53+ @property
54+ def prometheus_friendly_app_name (self ) -> str :
55+ """
56+ Returns a version of the app name which is compatible with Prometheus metrics naming conventions (no dashes).
57+ """
58+ return self .app_name .replace ("-" , "_" )
59+
5360 @property
5461 def version (self ) -> Version :
5562 return Version (self ._distribution .version )
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ def test_app_name(
6060 info = PackageInfo (package_name = package_name )
6161 if is_correct_app_name :
6262 assert info .app_name == app_name
63+ assert info .prometheus_friendly_app_name == app_name .replace ("-" , "_" )
6364 else :
6465 with pytest .raises (ValueError ):
6566 _ = PackageInfo (package_name = package_name )
Original file line number Diff line number Diff line change 1919
2020# legacy consts
2121APP_NAME : Final [str ] = info .app_name
22+ PROMETHEUS_FRIENDLY_APP_NAME : Final [str ] = info .prometheus_friendly_app_name
2223api_version_prefix : str = API_VTAG
2324
2425
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ def setup_monitoring(app: web.Application):
5555 )
5656
5757 monitor_services .add_instrumentation (
58- app , get_collector_registry (app ), _meta .APP_NAME
58+ app , get_collector_registry (app ), _meta .PROMETHEUS_FRIENDLY_APP_NAME
5959 )
6060
6161 # on-the fly stats
You can’t perform that action at this time.
0 commit comments