Skip to content

Commit 8e6aec8

Browse files
authored
[shim] Log successful API calls with trace level (#3237)
Reduces log noise when DSTACK_SHIM_LOG_LEVEL is set to 5 or lower
1 parent db0d3c9 commit 8e6aec8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

runner/internal/api/common.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ func JSONResponseHandler(handler func(http.ResponseWriter, *http.Request) (inter
113113
if errors.As(err, &apiErr) {
114114
status = apiErr.Status
115115
errMsg = apiErr.Error()
116-
log.Warning(r.Context(), "API error", "err", errMsg, "status", status)
116+
log.Warning(r.Context(), "API error", "err", errMsg, "method", r.Method, "endpoint", r.URL.Path, "status", status)
117117
} else {
118118
status = http.StatusInternalServerError
119-
log.Error(r.Context(), "Unexpected API error", "err", err, "status", status)
119+
log.Error(r.Context(), "Unexpected API error", "err", err, "method", r.Method, "endpoint", r.URL.Path, "status", status)
120120
}
121+
} else {
122+
log.Trace(r.Context(), "", "method", r.Method, "endpoint", r.URL.Path, "status", status)
121123
}
122124

123125
if status != 500 && body != nil {
@@ -127,7 +129,5 @@ func JSONResponseHandler(handler func(http.ResponseWriter, *http.Request) (inter
127129
} else {
128130
http.Error(w, errMsg, status)
129131
}
130-
131-
log.Debug(r.Context(), "", "method", r.Method, "endpoint", r.URL.Path, "status", status)
132132
}
133133
}

src/dstack/_internal/core/backends/base/compute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ def get_shim_env(
699699
backend_shim_env: Optional[Dict[str, str]] = None,
700700
arch: Optional[str] = None,
701701
) -> Dict[str, str]:
702-
log_level = "6" # Trace
702+
log_level = "5" # Debug
703703
envs = {
704704
"DSTACK_SHIM_HOME": get_dstack_working_dir(base_path),
705705
"DSTACK_SHIM_HTTP_PORT": str(DSTACK_SHIM_HTTP_PORT),

0 commit comments

Comments
 (0)