Skip to content

Commit c58774f

Browse files
committed
LCORE-1801: Wrap lightspeed-stack startup with opentelemetry-instrument
Update all LCORE startup paths to use `opentelemetry-instrument` as the process wrapper to enable automatic OpenTelemetry instrumentation of the FastAPI application. Signed-off-by: Anik Bhattacharjee <anbhatta@redhat.com>
1 parent e8459f4 commit c58774f

7 files changed

Lines changed: 21 additions & 13 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ CONTAINER_RUNTIME ?= $(shell command -v podman 2>/dev/null || command -v docker
3636
docs/models/database.svg
3737

3838
run-stack: ## Run lightspeed-stack directly, without building dependent service/s
39-
uv run src/lightspeed_stack.py -c $(CONFIG)
39+
uv run opentelemetry-instrument python3.12 src/lightspeed_stack.py -c $(CONFIG)
4040

4141
run: start-llama-stack-container ## Run the service locally with dependent services
4242
@echo "Starting Lightspeed Core Stack..."

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ ENV PATH="/app-root/.venv/bin:$PATH"
11301130
11311131
# Run the application
11321132
EXPOSE 8080
1133-
ENTRYPOINT ["python3.12", "src/lightspeed_stack.py"]
1133+
ENTRYPOINT ["opentelemetry-instrument", "python3.12", "src/lightspeed_stack.py"]
11341134
USER 1001
11351135
```
11361136

deploy/lightspeed-stack/Containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ ENV PYTHONPATH="/app-root"
135135

136136
# Run the application
137137
EXPOSE 8080
138-
ENTRYPOINT ["python3.12", "src/lightspeed_stack.py"]
138+
ENTRYPOINT ["opentelemetry-instrument", "python3.12", "src/lightspeed_stack.py"]
139139

140140
LABEL vendor="Red Hat, Inc." \
141141
name="lightspeed-core/lightspeed-stack-rhel9" \

docs/user_doc/deployment_guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ make run
468468
```
469469

470470
```
471-
uv run src/lightspeed_stack.py
471+
uv run opentelemetry-instrument python3.12 src/lightspeed_stack.py
472472
[07/29/25 15:43:35] INFO Initializing app main.py:19
473473
INFO Including routers main.py:68
474474
INFO: Started server process [1922983]
@@ -561,7 +561,7 @@ cp examples/lightspeed-stack-lls-library.yaml lightspeed-stack.yaml
561561
```
562562
1. Check the output
563563
```text
564-
uv run src/lightspeed_stack.py
564+
uv run opentelemetry-instrument python3.12 src/lightspeed_stack.py
565565
Using config run.yaml:
566566
apis:
567567
- agents

tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
key: key
3838
optional: true
3939
image: ${LIGHTSPEED_STACK_IMAGE}
40-
command: ["/bin/sh", "-c", "mkdir -p /tmp/data && exec python3.12 src/lightspeed_stack.py"]
40+
command: ["/bin/sh", "-c", "mkdir -p /tmp/data && exec opentelemetry-instrument python3.12 src/lightspeed_stack.py"]
4141
ports:
4242
- containerPort: 8080
4343
# TCP probes avoid HTTP/auth. LCS + Llama handshake and large images can take 60–120s before :8080 listens;

tests/e2e/utils/prow_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ def run_e2e_ops(
6262
)
6363

6464

65-
def wait_for_pod_health(pod_name: str, max_attempts: int = 12) -> None:
66-
"""Wait for pod to be ready in OpenShift/Prow environment."""
65+
def wait_for_pod_health(pod_name: str, max_attempts: int = 20) -> None:
66+
"""Wait for pod to be ready in OpenShift/Prow environment.
67+
68+
Generous number of attempts to account for OpenTelemetry instrumentation
69+
initialization overhead during service startup.
70+
"""
6771
actual_pod_name = get_pod_name(pod_name)
6872
try:
6973
result = run_e2e_ops("wait-for-pod", [actual_pod_name, str(max_attempts)])

tests/e2e/utils/utils.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def validate_json(message: Any, schema: Any) -> None:
181181
assert False, "The provided schema is faulty:" + str(e)
182182

183183

184-
def wait_for_container_health(container_name: str, max_attempts: int = 6) -> None:
184+
def wait_for_container_health(container_name: str, max_attempts: int = 20) -> None:
185185
"""Wait for container to be healthy.
186186
187187
Polls a Docker container until its health status becomes `healthy` or the
@@ -192,14 +192,17 @@ def wait_for_container_health(container_name: str, max_attempts: int = 6) -> Non
192192
inspect errors or timeouts are ignored and retried; the function returns
193193
after the container is observed healthy or after all attempts complete.
194194
195+
OpenTelemetry instrumentation adds initialization overhead, so the default
196+
has been set to 20 attempts (40 seconds) to prevent timeouts.
197+
195198
Returns:
196199
-------
197200
None
198201
199202
Parameters:
200203
----------
201204
container_name (str): Docker container name or ID to check.
202-
max_attempts (int): Maximum number of health check attempts (default 6).
205+
max_attempts (int): Maximum number of health check attempts (default 20).
203206
"""
204207
if is_prow_environment():
205208
wait_for_pod_health(container_name, max_attempts)
@@ -468,9 +471,10 @@ def restart_container(container_name: str) -> None:
468471

469472
# Wait for container to be healthy.
470473
# Library mode embeds llama-stack, so the container takes longer to start
471-
# (~45-60s vs ~10s in server mode). Use a generous attempt count so
472-
# MCP-auth scenarios that restart the container don't time out.
473-
wait_for_container_health(container_name, max_attempts=12)
474+
# (~45-60s vs ~10s in server mode). OpenTelemetry instrumentation adds
475+
# initialization overhead. Use a generous attempt count so MCP-auth scenarios
476+
# that restart the container don't time out.
477+
wait_for_container_health(container_name, max_attempts=20)
474478

475479
if container_name == "llama-stack":
476480
from tests.e2e.features.steps.health import (

0 commit comments

Comments
 (0)