-
Notifications
You must be signed in to change notification settings - Fork 95
LCORE-2861: Refactored observability package documentation #2120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tisnik
merged 2 commits into
lightspeed-core:main
from
tisnik:lcore-2861-refactored-observability-documentation
Jul 13, 2026
+100
−95
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,97 +1,8 @@ | ||
| # Observability Module | ||
| # List of source files stored in `src/observability` directory | ||
|
|
||
| This module provides telemetry capabilities for sending inference events to external systems like Splunk HEC. | ||
| ## [__init__.py](__init__.py) | ||
| Observability module for telemetry and event collection. | ||
|
|
||
| ## Architecture | ||
| ## [splunk.py](splunk.py) | ||
| Async Splunk HEC client for sending telemetry events. | ||
|
|
||
| ``` | ||
| observability/ | ||
| ├── __init__.py # Public API exports | ||
| ├── splunk.py # Async Splunk HEC client | ||
| └── formats/ | ||
| ├── __init__.py # Format exports | ||
| └── rlsapi.py # rlsapi v1 event format | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Sending Events to Splunk | ||
|
|
||
| ```python | ||
| from fastapi import BackgroundTasks | ||
| from observability import send_splunk_event, build_inference_event, InferenceEventData | ||
|
|
||
| # Build the event payload | ||
| event_data = InferenceEventData( | ||
| question="How do I configure SSH?", | ||
| response="To configure SSH...", | ||
| inference_time=2.34, | ||
| model="granite-3-8b-instruct", | ||
| org_id="12345678", | ||
| system_id="abc-def-123", | ||
| request_id="req_xyz789", | ||
| cla_version="CLA/0.6.0rc2", | ||
| system_os="RHEL", | ||
| system_version="9.3", | ||
| system_arch="x86_64", | ||
| ) | ||
|
|
||
| event = build_inference_event(event_data) | ||
|
|
||
| # Queue for async sending via BackgroundTasks | ||
| background_tasks.add_task(send_splunk_event, event, "infer_with_llm") | ||
| ``` | ||
|
|
||
| ### Source Types | ||
|
|
||
| | Source Type | Description | | ||
| |-------------|-------------| | ||
| | `infer_with_llm` | Successful inference requests | | ||
| | `infer_error` | Failed inference requests | | ||
|
|
||
| ## Creating Custom Event Formats | ||
|
|
||
| To add a new event format for a different endpoint: | ||
|
|
||
| 1. Create a new module in `observability/formats/`: | ||
|
|
||
| ```python | ||
| # observability/formats/my_endpoint.py | ||
| from dataclasses import dataclass | ||
| from typing import Any | ||
|
|
||
| @dataclass | ||
| class MyEventData: | ||
| field1: str | ||
| field2: int | ||
|
|
||
| def build_my_event(data: MyEventData) -> dict[str, Any]: | ||
| return { | ||
| "field1": data.field1, | ||
| "field2": data.field2, | ||
| } | ||
| ``` | ||
|
|
||
| 2. Export from `observability/formats/__init__.py` | ||
|
|
||
| 3. Use with `send_splunk_event()`: | ||
|
|
||
| ```python | ||
| from observability import send_splunk_event | ||
| from observability.formats.my_endpoint import build_my_event, MyEventData | ||
|
|
||
| event = build_my_event(MyEventData(field1="value", field2=42)) | ||
| background_tasks.add_task(send_splunk_event, event, "my_sourcetype") | ||
| ``` | ||
|
|
||
| ## Graceful Degradation | ||
|
|
||
| The Splunk client is designed to never block or fail the main request: | ||
|
|
||
| - Skips sending when Splunk is disabled or not configured | ||
| - Logs warnings on HTTP errors (does not raise exceptions) | ||
| - Token is read from file on each request (supports rotation without restart) | ||
|
|
||
| ## Configuration | ||
|
|
||
| See [docs/splunk.md](../../docs/splunk.md) for configuration options. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add a blank line before this heading.
This heading is directly adjacent to the preceding paragraph, violating Markdown rule MD022.
Proposed fix
## [prompts.py](prompts.py) Utility functions for system prompts. + ## [pydantic_ai_helpers.py](pydantic_ai_helpers.py)📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 60-60: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
🤖 Prompt for AI Agents
Source: Linters/SAST tools