Skip to content

Commit 0cc992d

Browse files
committed
Pretty flamegraph sharing via whodidit.you
This is a fork of speedscope, with pastila support! Implemented in azat-ch/speedscope#2 Fixes: #202 Fixes: #199
1 parent 797b33d commit 0cc992d

File tree

5 files changed

+5
-59
lines changed

5 files changed

+5
-59
lines changed

Cargo.lock

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ serde = { version = "*", features = ["derive"] }
4848
serde_json = { version = "*", default-features = false, features = ["std"] }
4949
serde_yaml = { version = "*", default-features = false }
5050
quick-xml = { version = "*", features = ["serialize"] }
51-
urlencoding = { version = "*", default-features = false }
5251
percent-encoding = { version = "*", default-features = false }
5352
regex = { version = "*", default-features = false, features = ["std"] }
5453
# CLI

src/interpreter/flamegraph.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use flamelens::ui;
1010
use ratatui::Terminal;
1111
use ratatui::backend::CrosstermBackend;
1212
use std::io;
13-
use urlencoding::encode;
1413

1514
pub fn show(block: Columns) -> AppResult<()> {
1615
let data = block
@@ -72,11 +71,7 @@ pub fn show(block: Columns) -> AppResult<()> {
7271
Ok(())
7372
}
7473

75-
pub async fn open_in_speedscope(
76-
block: Columns,
77-
pastila_clickhouse_host: &str,
78-
pastila_url: &str,
79-
) -> Result<()> {
74+
pub async fn share(block: Columns, pastila_clickhouse_host: &str, pastila_url: &str) -> Result<()> {
8075
let data = block
8176
.rows()
8277
.map(|x| {
@@ -93,12 +88,9 @@ pub async fn open_in_speedscope(
9388
return Err(Error::msg("Flamegraph is empty"));
9489
}
9590

96-
let pastila_url = pastila::upload(&data, pastila_clickhouse_host, pastila_url).await?;
97-
98-
let url = format!(
99-
"https://www.speedscope.app/#profileURL={}",
100-
encode(&pastila_url)
101-
);
91+
let pastila_url =
92+
pastila::upload_encrypted(&data, pastila_clickhouse_host, pastila_url).await?;
93+
let url = format!("https://whodidit.you/#profileURL={}", pastila_url);
10294

10395
let mut child = open_url_command(&url)
10496
.spawn()

src/interpreter/worker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ async fn render_flamegraph(
316316
}))
317317
.map_err(|_| anyhow!("Cannot send message to UI"))?;
318318
} else {
319-
flamegraph::open_in_speedscope(block, &pastila_clickhouse_host, &pastila_url).await?;
319+
flamegraph::share(block, &pastila_clickhouse_host, &pastila_url).await?;
320320
}
321321
return Ok(());
322322
}

src/pastila.rs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -172,44 +172,6 @@ async fn get_pastila_client(pastila_clickhouse_host: &str) -> Result<clickhouse_
172172
Ok(client)
173173
}
174174

175-
pub async fn upload(
176-
content: &str,
177-
pastila_clickhouse_host: &str,
178-
pastila_url: &str,
179-
) -> Result<String> {
180-
let fingerprint_hex = get_fingerprint(content);
181-
let hash_hex = calculate_hash(content);
182-
183-
{
184-
let mut client = get_pastila_client(pastila_clickhouse_host).await?;
185-
let block = Block::new()
186-
.column("fingerprint_hex", vec![fingerprint_hex.as_str()])
187-
.column("hash_hex", vec![hash_hex.as_str()])
188-
.column("content", vec![content])
189-
.column("is_encrypted", vec![0_u8]);
190-
client.insert("paste.data", block).await?;
191-
}
192-
193-
log::info!(
194-
"Uploaded {} bytes to {}",
195-
content.len(),
196-
pastila_clickhouse_host
197-
);
198-
199-
let pastila_url = pastila_url.trim_end_matches('/');
200-
let pastila_page_url = format!("{}/?{}/{}", pastila_url, fingerprint_hex, hash_hex);
201-
log::info!("Pastila URL: {}", pastila_page_url);
202-
203-
let select_query = format!(
204-
"SELECT content FROM data_view(fingerprint = '{}', hash = '{}') FORMAT TabSeparatedRaw",
205-
fingerprint_hex, hash_hex
206-
);
207-
let clickhouse_url = format!("{}&query={}", pastila_clickhouse_host, &select_query);
208-
log::info!("Pastila ClickHouse URL: {}", clickhouse_url);
209-
210-
Ok(clickhouse_url)
211-
}
212-
213175
pub async fn upload_encrypted(
214176
content: &str,
215177
pastila_clickhouse_host: &str,

0 commit comments

Comments
 (0)