mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-09 20:04:25 +00:00
Limit the size of the buffer in the OpenTelemetryLog command
Co-authored-by: Joseph Lyons <joseph@zed.dev>
This commit is contained in:
parent
c1c5eaeaf9
commit
ac0bcf3809
1 changed files with 10 additions and 1 deletions
|
@ -521,6 +521,14 @@ fn open_telemetry_log_file(
|
||||||
let workspace = workspace.upgrade(&cx)?;
|
let workspace = workspace.upgrade(&cx)?;
|
||||||
let path = app_state.client.telemetry_log_file_path()?;
|
let path = app_state.client.telemetry_log_file_path()?;
|
||||||
let log = app_state.fs.load(&path).await.log_err()?;
|
let log = app_state.fs.load(&path).await.log_err()?;
|
||||||
|
|
||||||
|
const MAX_TELEMETRY_LOG_LEN: usize = 5 * 1024 * 1024;
|
||||||
|
let mut start_offset = log.len().saturating_sub(MAX_TELEMETRY_LOG_LEN);
|
||||||
|
if let Some(newline_offset) = log[start_offset..].find('\n') {
|
||||||
|
start_offset += newline_offset + 1;
|
||||||
|
}
|
||||||
|
let log_suffix = &log[start_offset..];
|
||||||
|
|
||||||
workspace.update(&mut cx, |workspace, cx| {
|
workspace.update(&mut cx, |workspace, cx| {
|
||||||
let project = workspace.project().clone();
|
let project = workspace.project().clone();
|
||||||
let buffer = project
|
let buffer = project
|
||||||
|
@ -534,13 +542,14 @@ fn open_telemetry_log_file(
|
||||||
concat!(
|
concat!(
|
||||||
"// Zed collects anonymous usage data to help us understand how people are using the app.\n",
|
"// Zed collects anonymous usage data to help us understand how people are using the app.\n",
|
||||||
"// After the beta release, we'll provide the ability to opt out of this telemetry.\n",
|
"// After the beta release, we'll provide the ability to opt out of this telemetry.\n",
|
||||||
|
"// Here is the data that has been reported for the current session:\n",
|
||||||
"\n"
|
"\n"
|
||||||
),
|
),
|
||||||
)],
|
)],
|
||||||
None,
|
None,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
buffer.edit([(buffer.len()..buffer.len(), log)], None, cx);
|
buffer.edit([(buffer.len()..buffer.len(), log_suffix)], None, cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
let buffer = cx.add_model(|cx| {
|
let buffer = cx.add_model(|cx| {
|
||||||
|
|
Loading…
Reference in a new issue