Skip to content

LCORE-1801: Wrap lightspeed-stack startup with opentelemetry-instrument#2221

Merged
tisnik merged 1 commit into
lightspeed-core:mainfrom
anik120:otel-intrumentation
Jul 24, 2026
Merged

LCORE-1801: Wrap lightspeed-stack startup with opentelemetry-instrument#2221
tisnik merged 1 commit into
lightspeed-core:mainfrom
anik120:otel-intrumentation

Conversation

@anik120

@anik120 anik120 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

Update all LCORE startup paths to use opentelemetry-instrument as the process wrapper to enable automatic OpenTelemetry instrumentation of the FastAPI application.

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: (e.g., Claude, CodeRabbit, Ollama, etc., N/A if not used)
  • Generated by: (e.g., tool name and version; N/A if not used)

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • New Features
    • Enabled OpenTelemetry instrumentation for Lightspeed service startup across local runs, container image startup, and Kubernetes Pod execution.
  • Documentation
    • Updated the deployment guide and custom container image example to use the instrumented startup command.
  • Tests
    • Increased health-check retry defaults in end-to-end utilities to better accommodate instrumentation startup overhead.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Startup commands for the Lightspeed stack now run through opentelemetry-instrument with python3.12. Container, Kubernetes, Makefile, README, and deployment guide launch paths are updated, and end-to-end health checks allow more startup attempts.

Changes

Runtime instrumentation

Layer / File(s) Summary
Runtime entrypoint updates
Makefile, deploy/lightspeed-stack/Containerfile, tests/e2e-prow/.../lightspeed-stack.yaml, README.md, docs/user_doc/deployment_guide.md
Make, container, Kubernetes, and documented local startup commands now invoke the stack through opentelemetry-instrument and python3.12.
Startup health-check retry updates
tests/e2e/utils/prow_utils.py, tests/e2e/utils/utils.py
Pod and container health checks increase their default or explicit retry budget to 20 attempts and update related documentation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: are-ces, tisnik

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: wrapping lightspeed-stack startup with opentelemetry-instrument.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Performance And Algorithmic Complexity ✅ Passed No new asymptotic or unbounded work; changes are fixed startup wrappers, and test retry increases are bounded constant-factor waits for OTel startup.
Security And Secret Handling ✅ Passed Patch only swaps startup commands for opentelemetry-instrument and raises health-check retries; no secrets, auth, injection, leaked data, or Secret ownerRef changes found.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Makefile`:
- Line 23: Keep Python-version selection consistent across startup paths: update
Makefile lines 23-23 to use the selected interpreter or explicitly require
Python 3.12, and update the separate-process example at
docs/user_doc/deployment_guide.md lines 471-471 plus the library-mode example at
lines 564-564 to match the supported Python 3.12/3.13 behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c6892066-d7e9-4812-92fc-436e956f60a2

📥 Commits

Reviewing files that changed from the base of the PR and between 287072e and 60f6cf3.

📒 Files selected for processing (5)
  • Makefile
  • README.md
  • deploy/lightspeed-stack/Containerfile
  • docs/user_doc/deployment_guide.md
  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
📜 Review details
⏰ Context from checks skipped due to timeout. (16)
  • GitHub Check: build-pr
  • GitHub Check: spectral
  • GitHub Check: mypy
  • GitHub Check: Pylinter
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-7-on-pull-request
🧰 Additional context used
📓 Path-based instructions (1)
**/*

📄 CodeRabbit inference engine (Custom checks)

**/*: Flag meaningful O(n^2)+ algorithms on non-trivial inputs, including handlers and Kubernetes list operations.
Flag N+1 patterns that list items and then query once per item, including Kubernetes API and database access.
Flag expensive work inside loops, including API calls, JSON parsing, and regex compilation.
Flag unbounded growth in caches, watchers, or buffers when eviction or limits are missing.
Flag missing pagination or limits on list operations and API endpoints.
Flag secrets or tokens logged in plaintext or hardcoded in source.
Flag API endpoints missing authentication or authorization.
Flag injection vulnerabilities, including SQL injection, command injection, and path traversal.
Flag sensitive data leaked in API responses, WebSocket messages, or logs.
Flag Kubernetes Secrets and Red Hat secrets missing OwnerReferences.

Never commit secrets or keys; use environment variables for sensitive data.

Files:

  • deploy/lightspeed-stack/Containerfile
  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
  • Makefile
  • README.md
  • docs/user_doc/deployment_guide.md
🧠 Learnings (2)
📚 Learning: 2026-02-19T10:06:50.647Z
Learnt from: radofuchs
Repo: lightspeed-core/lightspeed-stack PR: 1181
File: tests/e2e-prow/rhoai/manifests/lightspeed/mock-jwks.yaml:32-34
Timestamp: 2026-02-19T10:06:50.647Z
Learning: In the rhoai tests under tests/e2e-prow/rhoai/manifests, avoid static ConfigMap definitions for mock-jwks-script and mcp-mock-server-script since these ConfigMaps are created dynamically by the pipeline.sh deployment script using 'oc create configmap'. Ensure there are no static ConfigMap resources for these names in the manifests. If such ConfigMaps are added in the future, coordinate with the pipeline to reflect dynamic creation or adjust tests to rely on the dynamic provisioning.

Applied to files:

  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
📚 Learning: 2026-05-20T08:09:30.641Z
Learnt from: max-svistunov
Repo: lightspeed-core/lightspeed-stack PR: 1580
File: docs/design/llama-stack-config-merge/poc-results/library-mode/synthesized-run.yaml:107-110
Timestamp: 2026-05-20T08:09:30.641Z
Learning: In Llama-stack config YAMLs, when defining a Llama Guard safety shield entry, set `provider_shield_id` to the *guard model identifier* (e.g., `meta-llama/Llama-Guard-3-8B`). Do not use a chat/generative model id (e.g., `openai/gpt-4o-mini`): a chat-model id (or `native_override`) indicates only an override landed and does **not** mean the safety shield is actually gating queries. Ensure any E2E coverage for the related implementation (JIRA/E2E tests) exercises a real Llama Guard model to verify that the shield is effective.

Applied to files:

  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
🔇 Additional comments (3)
tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml (1)

40-40: LGTM!

README.md (1)

1133-1133: LGTM!

deploy/lightspeed-stack/Containerfile (1)

138-138: 🩺 Stability & Availability

No change needed for opentelemetry-instrument.

opentelemetry-distro is a production dependency and provides the opentelemetry-instrument executable used by the entrypoint.

Comment thread Makefile
@anik120
anik120 force-pushed the otel-intrumentation branch from 60f6cf3 to 541639a Compare July 23, 2026 14:28
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>
@anik120
anik120 force-pushed the otel-intrumentation branch from 541639a to c58774f Compare July 23, 2026 17:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/e2e/utils/prow_utils.py`:
- Around line 65-70: Complete the docstring for wait_for_pod_health by adding a
Parameters: section documenting pod_name and max_attempts, plus a Returns:
section stating that the function returns None. Follow the repository’s existing
docstring convention and preserve the current behavior.

In `@tests/e2e/utils/utils.py`:
- Around line 195-196: Correct the timeout documentation near the retry
configuration in the test utilities to reflect the actual worst-case duration
from 20 attempts, 5-second docker inspect timeouts, and 2-second sleeps,
approximately 138 seconds; alternatively, reduce the per-attempt timeout so the
documented 40-second budget is accurate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 22b646a4-df57-4b2a-ab1d-968b0fd104f0

📥 Commits

Reviewing files that changed from the base of the PR and between 541639a and c58774f.

📒 Files selected for processing (7)
  • Makefile
  • README.md
  • deploy/lightspeed-stack/Containerfile
  • docs/user_doc/deployment_guide.md
  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
  • tests/e2e/utils/prow_utils.py
  • tests/e2e/utils/utils.py
📜 Review details
⏰ Context from checks skipped due to timeout. (16)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: spectral
  • GitHub Check: Pylinter
  • GitHub Check: mypy
  • GitHub Check: build-pr
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-7-on-pull-request
🧰 Additional context used
📓 Path-based instructions (3)
**/*

📄 CodeRabbit inference engine (Custom checks)

**/*: Flag meaningful O(n^2)+ algorithms on non-trivial inputs, including handlers and Kubernetes list operations.
Flag N+1 patterns that list items and then query once per item, including Kubernetes API and database access.
Flag expensive work inside loops, including API calls, JSON parsing, and regex compilation.
Flag unbounded growth in caches, watchers, or buffers when eviction or limits are missing.
Flag missing pagination or limits on list operations and API endpoints.
Flag secrets or tokens logged in plaintext or hardcoded in source.
Flag API endpoints missing authentication or authorization.
Flag injection vulnerabilities, including SQL injection, command injection, and path traversal.
Flag sensitive data leaked in API responses, WebSocket messages, or logs.
Flag Kubernetes Secrets and Red Hat secrets missing OwnerReferences.

Files:

  • deploy/lightspeed-stack/Containerfile
  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
  • README.md
  • docs/user_doc/deployment_guide.md
  • Makefile
  • tests/e2e/utils/prow_utils.py
  • tests/e2e/utils/utils.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use absolute imports for internal Python modules.
All modules must begin with descriptive docstrings explaining their purpose.
Use logger = get_logger(__name__) from log.py for module logging.
Use complete type annotations for function parameters and return types.
Use modern union syntax such as str | int; use Optional[Type] for optional values.
Use typing_extensions.Self for model validators.
Functions must use descriptive, action-oriented snake_case names such as get_, validate_, and check_.
Avoid modifying mutable parameters in place; return a new data structure instead.
Use async def for I/O operations and external API calls.
Handle APIConnectionError from Llama Stack.
All classes must have descriptive docstrings and complete type annotations for class attributes; use specific types instead of Any.
Use PascalCase for classes and descriptive standard suffixes such as Configuration, Error/Exception, Resolver, and Interface.
Use ABC and @abstractmethod for abstract interfaces.
Follow Google Python docstring conventions; document all modules, classes, and functions, including Parameters, Returns, Raises, and Attributes sections as applicable.
Never commit secrets or keys; use environment variables for sensitive data.

Files:

  • tests/e2e/utils/prow_utils.py
  • tests/e2e/utils/utils.py
tests/e2e/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use behave with Gherkin feature files for end-to-end tests.

Files:

  • tests/e2e/utils/prow_utils.py
  • tests/e2e/utils/utils.py
🧠 Learnings (3)
📚 Learning: 2026-02-19T10:06:50.647Z
Learnt from: radofuchs
Repo: lightspeed-core/lightspeed-stack PR: 1181
File: tests/e2e-prow/rhoai/manifests/lightspeed/mock-jwks.yaml:32-34
Timestamp: 2026-02-19T10:06:50.647Z
Learning: In the rhoai tests under tests/e2e-prow/rhoai/manifests, avoid static ConfigMap definitions for mock-jwks-script and mcp-mock-server-script since these ConfigMaps are created dynamically by the pipeline.sh deployment script using 'oc create configmap'. Ensure there are no static ConfigMap resources for these names in the manifests. If such ConfigMaps are added in the future, coordinate with the pipeline to reflect dynamic creation or adjust tests to rely on the dynamic provisioning.

Applied to files:

  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
📚 Learning: 2026-05-20T08:09:30.641Z
Learnt from: max-svistunov
Repo: lightspeed-core/lightspeed-stack PR: 1580
File: docs/design/llama-stack-config-merge/poc-results/library-mode/synthesized-run.yaml:107-110
Timestamp: 2026-05-20T08:09:30.641Z
Learning: In Llama-stack config YAMLs, when defining a Llama Guard safety shield entry, set `provider_shield_id` to the *guard model identifier* (e.g., `meta-llama/Llama-Guard-3-8B`). Do not use a chat/generative model id (e.g., `openai/gpt-4o-mini`): a chat-model id (or `native_override`) indicates only an override landed and does **not** mean the safety shield is actually gating queries. Ensure any E2E coverage for the related implementation (JIRA/E2E tests) exercises a real Llama Guard model to verify that the shield is effective.

Applied to files:

  • tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml
📚 Learning: 2026-06-24T13:45:37.249Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 1971
File: src/utils/markdown_repair.py:31-36
Timestamp: 2026-06-24T13:45:37.249Z
Learning: In the lightspeed-stack repository, docstrings must use the section header name "Parameters:" (not "Args:") for function arguments, even if the project references Google Python docstring conventions. Ensure docstrings follow the project’s established "Parameters:" header format for any documented function parameters.

Applied to files:

  • tests/e2e/utils/prow_utils.py
  • tests/e2e/utils/utils.py
🔇 Additional comments (3)
tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml (1)

40-40: LGTM!

README.md (1)

1133-1133: LGTM!

deploy/lightspeed-stack/Containerfile (1)

138-138: 🩺 Stability & Availability

Runtime dependency already provides the OpenTelemetry console script.

opentelemetry-distro is declared and locked, and it provides the opentelemetry-instrument entrypoint used here.

Comment on lines +65 to +70
def wait_for_pod_health(pod_name: str, max_attempts: int = 20) -> None:
"""Wait for pod to be ready in OpenShift/Prow environment.

Generous number of attempts to account for OpenTelemetry instrumentation
initialization overhead during service startup.
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Complete the updated function docstring.

Document pod_name, max_attempts, and the None return value using the repository’s Parameters: convention.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/utils/prow_utils.py` around lines 65 - 70, Complete the docstring
for wait_for_pod_health by adding a Parameters: section documenting pod_name and
max_attempts, plus a Returns: section stating that the function returns None.
Follow the repository’s existing docstring convention and preserve the current
behavior.

Sources: Coding guidelines, Learnings

Comment thread tests/e2e/utils/utils.py
Comment on lines +195 to +196
OpenTelemetry instrumentation adds initialization overhead, so the default
has been set to 20 attempts (40 seconds) to prevent timeouts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Correct the documented timeout budget.

With 20 attempts, 5-second docker inspect timeouts, and 2-second sleeps, the worst-case wait is about 138 seconds—not 40 seconds. Document the actual upper bound or reduce the per-attempt timeout.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/utils/utils.py` around lines 195 - 196, Correct the timeout
documentation near the retry configuration in the test utilities to reflect the
actual worst-case duration from 20 attempts, 5-second docker inspect timeouts,
and 2-second sleeps, approximately 138 seconds; alternatively, reduce the
per-attempt timeout so the documented 40-second budget is accurate.

@asimurka asimurka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tisnik tisnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tisnik
tisnik merged commit 81da437 into lightspeed-core:main Jul 24, 2026
42 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants