pipeline: add send_initial_empty_metrics flag

This commit is contained in:
Aleix Conchillo Flaqué
2024-07-23 10:50:15 -07:00
parent 33f0865430
commit 69f64899fe
3 changed files with 10 additions and 2 deletions

View File

@@ -64,7 +64,7 @@ class Pipeline(BasePipeline):
services = []
for p in self._processors:
if isinstance(p, BasePipeline):
services += p.processors_with_metrics()
services.extend(p.processors_with_metrics())
elif p.can_generate_metrics():
services.append(p)
return services

View File

@@ -21,6 +21,7 @@ from loguru import logger
class PipelineParams(BaseModel):
allow_interruptions: bool = False
enable_metrics: bool = False
send_initial_empty_metrics: bool = True
report_only_initial_ttfb: bool = False
@@ -106,7 +107,9 @@ class PipelineTask:
report_only_initial_ttfb=self._params.report_only_initial_ttfb
)
await self._source.process_frame(start_frame, FrameDirection.DOWNSTREAM)
await self._source.process_frame(self._initial_metrics_frame(), FrameDirection.DOWNSTREAM)
if self._params.send_initial_empty_metrics:
await self._source.process_frame(self._initial_metrics_frame(), FrameDirection.DOWNSTREAM)
running = True
should_cleanup = True