-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from tisnik/adding-pyroscope-dependencies
Adding pyroscope and memray dependencies
- Loading branch information
Showing
15 changed files
with
1,571 additions
and
688 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Pyroscope handling utility functions.""" | ||
|
||
import logging | ||
import threading | ||
from typing import Any | ||
|
||
import requests | ||
|
||
from ols.runners.uvicorn import start_uvicorn | ||
|
||
|
||
def start_with_pyroscope_enabled( | ||
config: Any, | ||
logger: logging.Logger, | ||
) -> None: | ||
"""Start the application using pyroscope.""" | ||
try: | ||
|
||
response = requests.get(config.dev_config.pyroscope_url, timeout=60) | ||
if response.status_code == requests.codes.ok: | ||
logger.info( | ||
f"Pyroscope server is reachable at {config.dev_config.pyroscope_url}" | ||
) | ||
import pyroscope | ||
|
||
pyroscope.configure( | ||
application_name="lightspeed-service", | ||
server_address=config.dev_config.pyroscope_url, | ||
oncpu=True, | ||
gil_only=True, | ||
enable_logging=True, | ||
) | ||
with pyroscope.tag_wrapper({"main": "main_method"}): | ||
# create and start the rag_index_thread | ||
rag_index_thread = threading.Thread(target=config.rag_index) | ||
rag_index_thread.start() | ||
|
||
# start the Uvicorn server | ||
start_uvicorn(config) | ||
else: | ||
logger.info( | ||
f"Failed to reach Pyroscope server. Status code: {response.status_code}" | ||
) | ||
except requests.exceptions.RequestException as e: | ||
logger.info(f"Error connecting to Pyroscope server: {e}") |
Oops, something went wrong.