Skip to content

Commit f49b7f4

Browse files
authored
[Feat] Add Sentry Continuous Profiling Support to vLLM Router (vllm-project#624)
* Added profile lifecycle tracking and sampling rates for traces and sessions in Sentry initialization. Signed-off-by: Ifta Khairul Alam Adil <ikaadil007@gmail.com> * Added validation and command-line arguments for Sentry traces and profile session sample rates in the parser. Ensured sample rates are within the range of 0.0 to 1.0. Signed-off-by: Ifta Khairul Alam Adil <ikaadil007@gmail.com> * Update README.md to include new command-line options for Sentry traces and profiling session sample rates. Signed-off-by: Ifta Khairul Alam Adil <ikaadil007@gmail.com> * Refactor error message formatting in validate_args function for Sentry profile session sample rate validation. Signed-off-by: Ifta Khairul Alam Adil <ikaadil007@gmail.com> * Fix Dockerfile syntax by changing 'source' to '.' for activating the virtual environment. Signed-off-by: Ifta Khairul Alam Adil <ikaadil007@gmail.com> --------- Signed-off-by: Ifta Khairul Alam Adil <ikaadil007@gmail.com>
1 parent ae4afbf commit f49b7f4

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

docker/Dockerfile.kvaware

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ARG INSTALL_OPTIONAL_DEP=semantic_cache,lmcache
1919
ENV INSTALL_OPTIONAL_DEP=${INSTALL_OPTIONAL_DEP}
2020

2121
# hadolint ignore=SC1091
22-
RUN source /opt/venv/bin/activate && \
22+
RUN . /opt/venv/bin/activate && \
2323
uv pip install --upgrade --no-cache-dir pip setuptools_scm && \
2424
uv pip install --no-cache-dir .
2525

src/vllm_router/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ The router can be configured using command-line arguments. Below are the availab
5454
### Sentry Options
5555

5656
- `--sentry-dsn`: The Sentry Data Source Name to use for error reporting.
57+
- `--sentry-traces-sample-rate`: The sample rate for Sentry traces (0.0 to 1.0). Default is 0.1 (10%).
58+
- `--sentry-profile-session-sample-rate`: The sample rate for Sentry profiling sessions (0.0 to 1.0). Default is 1.0 (100%).
5759

5860
## Build docker image
5961

src/vllm_router/app.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ def initialize_all(app: FastAPI, args):
116116
ValueError: if the service discovery type is invalid
117117
"""
118118
if sentry_dsn := args.sentry_dsn:
119-
sentry_sdk.init(dsn=sentry_dsn, send_default_pii=True)
119+
sentry_sdk.init(
120+
dsn=sentry_dsn,
121+
send_default_pii=True,
122+
profile_lifecycle="trace",
123+
traces_sample_rate=args.sentry_traces_sample_rate,
124+
profile_session_sample_rate=args.sentry_profile_session_sample_rate,
125+
)
120126

121127
if args.service_discovery == "static":
122128
initialize_service_discovery(

src/vllm_router/parsers/parser.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ def validate_args(args):
9191
raise ValueError("Engine stats interval must be greater than 0.")
9292
if args.request_stats_window <= 0:
9393
raise ValueError("Request stats window must be greater than 0.")
94+
if not (0.0 <= args.sentry_traces_sample_rate <= 1.0):
95+
raise ValueError("Sentry traces sample rate must be between 0.0 and 1.0.")
96+
if not (0.0 <= args.sentry_profile_session_sample_rate <= 1.0):
97+
raise ValueError(
98+
"Sentry profile session sample rate must be between 0.0 and 1.0."
99+
)
94100

95101

96102
def parse_args():
@@ -298,6 +304,20 @@ def parse_args():
298304
help="Enables Sentry Error Reporting to the specified Data Source Name",
299305
)
300306

307+
parser.add_argument(
308+
"--sentry-traces-sample-rate",
309+
type=float,
310+
default=0.1,
311+
help="The sample rate for Sentry traces. Default is 0.1 (10%)",
312+
)
313+
314+
parser.add_argument(
315+
"--sentry-profile-session-sample-rate",
316+
type=float,
317+
default=1.0,
318+
help="The sample rate for Sentry profiling sessions. Default is 1.0 (100%)",
319+
)
320+
301321
parser.add_argument(
302322
"--prefill-model-labels",
303323
type=str,

0 commit comments

Comments
 (0)