Skip to content

Commit 63382f7

Browse files
goffrieConvex, Inc.
authored andcommitted
Upgrade fastrace to 0.7.9 (#36012)
& update uses of deprecated APIs (Event::add_to_[local_]parent) GitOrigin-RevId: cf243b85f9ed72d62446458316dad1545543cfba
1 parent ec7c107 commit 63382f7

File tree

7 files changed

+55
-78
lines changed

7 files changed

+55
-78
lines changed

Cargo.lock

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

crates/database/src/committer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl<RT: Runtime> Committer<RT> {
308308
}
309309
// Report the trace if it is longer than the threshold
310310
if let Some(id) = span_commit_id && id == pending_commit_id {
311-
if let Some(mut span) = committer_span.take() {
311+
if let Some(span) = committer_span.take() {
312312
if span.elapsed() < Some(*COMMIT_TRACE_THRESHOLD) {
313313
tracing::debug!("Not sending span to honeycomb because it is below the threshold");
314314
span.cancel();

crates/function_runner/src/metrics.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use std::borrow::Cow;
2-
3-
use fastrace::Event;
1+
use fastrace::{
2+
local::LocalSpan,
3+
Event,
4+
};
45
use metrics::{
56
log_counter_with_labels,
67
log_distribution,
@@ -86,20 +87,15 @@ pub fn record_module_sizes(source_size: usize, source_map_size: Option<usize>) {
8687
if let Some(map_size) = source_map_size {
8788
log_distribution(&MODULE_CACHE_SOURCE_MAP_SIZE_BYTES_TOTAL, map_size as f64);
8889
}
89-
Event::add_to_local_parent("module_cache_get_module", || {
90+
LocalSpan::add_event(Event::new("module_cache_get_module").with_properties(|| {
9091
[
92+
("module_cache_source_size", source_size.to_string()),
9193
(
92-
Cow::Borrowed("module_cache_source_size"),
93-
Cow::Owned(source_size.to_string()),
94-
),
95-
(
96-
Cow::Borrowed("module_cache_source_map_size"),
97-
Cow::Owned(
98-
source_map_size
99-
.map(|s| s.to_string())
100-
.unwrap_or("None".to_string()),
101-
),
94+
"module_cache_source_map_size",
95+
source_map_size
96+
.map(|s| s.to_string())
97+
.unwrap_or("None".to_string()),
10298
),
10399
]
104-
});
100+
}));
105101
}

crates/isolate/src/isolate.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::{
2-
borrow::Cow,
32
collections::BTreeMap,
43
ffi,
54
ptr,
@@ -22,7 +21,10 @@ use derive_more::{
2221
AddAssign,
2322
};
2423
use errors::ErrorMetadata;
25-
use fastrace::Event;
24+
use fastrace::{
25+
local::LocalSpan,
26+
Event,
27+
};
2628
use humansize::{
2729
FormatSize,
2830
BINARY,
@@ -351,18 +353,12 @@ extern "C" fn near_heap_limit_callback(
351353
current_heap_limit: usize,
352354
initial_heap_limit: usize,
353355
) -> usize {
354-
Event::add_to_local_parent("isolate_out_of_memory", || {
356+
LocalSpan::add_event(Event::new("isolate_out_of_memory").with_properties(|| {
355357
[
356-
(
357-
Cow::Borrowed("current_heap_limit"),
358-
Cow::Owned(current_heap_limit.to_string()),
359-
),
360-
(
361-
Cow::Borrowed("initial_heap_limit"),
362-
Cow::Owned(initial_heap_limit.to_string()),
363-
),
358+
("current_heap_limit", current_heap_limit.to_string()),
359+
("initial_heap_limit", initial_heap_limit.to_string()),
364360
]
365-
});
361+
}));
366362
let heap_ctx = unsafe { &mut *(data as *mut HeapContext) };
367363
heap_ctx.handle.terminate(TerminationReason::OutOfMemory);
368364

crates/isolate/src/metrics.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ use common::{
1111
};
1212
use deno_core::v8;
1313
use errors::ErrorMetadata;
14-
use fastrace::Event;
14+
use fastrace::{
15+
local::LocalSpan,
16+
Event,
17+
};
1518
use metrics::{
1619
log_counter,
1720
log_counter_with_labels,
@@ -647,7 +650,7 @@ pub fn record_component_function_path(component_function_path: &ResolvedComponen
647650
Cow::Owned(component_path.to_string()),
648651
));
649652
}
650-
Event::add_to_local_parent("component_function_path", || labels);
653+
LocalSpan::add_event(Event::new("component_function_path").with_properties(|| labels));
651654
}
652655

653656
register_convex_counter!(

crates/mysql/src/lib.rs

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ mod metrics;
1111
#[cfg(test)]
1212
mod tests;
1313
use std::{
14-
borrow::Cow,
1514
cmp,
1615
collections::{
1716
BTreeMap,
@@ -282,18 +281,12 @@ impl<RT: Runtime> Persistence for MySqlPersistence<RT> {
282281
}
283282
metrics::log_write_bytes(write_size);
284283
metrics::log_write_documents(documents.len());
285-
Event::add_to_local_parent("write_to_persistence_size", || {
284+
LocalSpan::add_event(Event::new("write_to_persistence_size").with_properties(|| {
286285
[
287-
(
288-
Cow::Borrowed("num_documents"),
289-
Cow::Owned(documents.len().to_string()),
290-
),
291-
(
292-
Cow::Borrowed("write_size"),
293-
Cow::Owned(write_size.to_string()),
294-
),
286+
("num_documents", documents.len().to_string()),
287+
("write_size", write_size.to_string()),
295288
]
296-
});
289+
}));
297290

298291
// True, the below might end up failing and not changing anything.
299292
self.newly_created.store(false, SeqCst);
@@ -329,18 +322,14 @@ impl<RT: Runtime> Persistence for MySqlPersistence<RT> {
329322
tx.exec_drop(insert_chunk_query, insert_document_chunk)
330323
.await?;
331324
timer.finish();
332-
Event::add_to_local_parent("document_smart_chunks", || {
333-
[
334-
(
335-
Cow::Borrowed("chunk_length"),
336-
Cow::Owned(chunk.len().to_string()),
337-
),
338-
(
339-
Cow::Borrowed("chunk_bytes"),
340-
Cow::Owned(chunk_bytes.to_string()),
341-
),
342-
]
343-
});
325+
LocalSpan::add_event(
326+
Event::new("document_smart_chunks").with_properties(|| {
327+
[
328+
("chunk_length", chunk.len().to_string()),
329+
("chunk_bytes", chunk_bytes.to_string()),
330+
]
331+
}),
332+
);
344333
Ok::<_, anyhow::Error>(())
345334
};
346335
future
@@ -374,18 +363,14 @@ impl<RT: Runtime> Persistence for MySqlPersistence<RT> {
374363
tx.exec_drop(insert_index_chunk, insert_index_chunk_params)
375364
.await?;
376365
timer.finish();
377-
Event::add_to_local_parent("index_smart_chunks", || {
378-
[
379-
(
380-
Cow::Borrowed("chunk_length"),
381-
Cow::Owned(chunk.len().to_string()),
382-
),
383-
(
384-
Cow::Borrowed("chunk_bytes"),
385-
Cow::Owned(chunk_bytes.to_string()),
386-
),
387-
]
388-
});
366+
LocalSpan::add_event(
367+
Event::new("index_smart_chunks").with_properties(|| {
368+
[
369+
("chunk_length", chunk.len().to_string()),
370+
("chunk_bytes", chunk_bytes.to_string()),
371+
]
372+
}),
373+
);
389374
Ok::<_, anyhow::Error>(())
390375
};
391376
future

crates/sync/src/worker.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::{
2-
borrow::Cow,
32
collections::BTreeMap,
43
sync::{
54
atomic::{
@@ -504,12 +503,10 @@ impl<RT: Runtime> SyncWorker<RT> {
504503

505504
let mutation_queue_size =
506505
self.mutation_sender.max_capacity() - self.mutation_sender.capacity();
507-
Event::add_to_parent("mutation_queue_size", &root, || {
508-
vec![(
509-
Cow::Borrowed("mutation_queue_size"),
510-
Cow::Owned(mutation_queue_size.to_string()),
511-
)]
512-
});
506+
root.add_event(
507+
Event::new("mutation_queue_size")
508+
.with_property(|| ("mutation_queue_size", mutation_queue_size.to_string())),
509+
);
513510

514511
let future = async move {
515512
rt.with_timeout("mutation", SYNC_WORKER_PROCESS_TIMEOUT, async move {

0 commit comments

Comments
 (0)