@@ -274,6 +274,17 @@ async def test_can_run_resource_based_worker(client: Client, env: WorkflowEnviro
274
274
# Ensure we can assume defaults when specifying only some options
275
275
activity_config = ResourceBasedSlotConfig (minimum_slots = 1 ),
276
276
)
277
+ prom_addr = f"127.0.0.1:{ find_free_port ()} "
278
+ runtime = Runtime (
279
+ telemetry = TelemetryConfig (
280
+ metrics = PrometheusConfig (bind_address = prom_addr ),
281
+ )
282
+ )
283
+ client = await Client .connect (
284
+ client .service_client .config .target_host ,
285
+ namespace = client .namespace ,
286
+ runtime = runtime ,
287
+ )
277
288
async with new_worker (
278
289
client ,
279
290
WaitOnSignalWorkflow ,
@@ -285,9 +296,16 @@ async def test_can_run_resource_based_worker(client: Client, env: WorkflowEnviro
285
296
id = f"resource-based-{ uuid .uuid4 ()} " ,
286
297
task_queue = w .task_queue ,
287
298
)
299
+ # Resource metrics get emitted on a 1 second tick
300
+ await asyncio .sleep (1 )
288
301
await wf1 .signal (WaitOnSignalWorkflow .my_signal , "finish" )
289
302
await wf1 .result ()
290
303
304
+ with urlopen (url = f"http://{ prom_addr } /metrics" ) as f :
305
+ prom_str : str = f .read ().decode ("utf-8" )
306
+ # verify resource metrics are being emitted
307
+ assert "resource_slots_mem_usage" in prom_str
308
+
291
309
292
310
async def test_can_run_composite_tuner_worker (client : Client , env : WorkflowEnvironment ):
293
311
resource_based_options = ResourceBasedTunerConfig (0.5 , 0.5 )
0 commit comments