Skip to content

Commit 5b05d68

Browse files
goffrieConvex, Inc.
authored andcommitted
Add a span property for whether an isolate was reused (#37587)
GitOrigin-RevId: 0bdcc82a07aa2ae3738c186b8eb796e851673a82
1 parent ed094cf commit 5b05d68

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

crates/isolate/src/client.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ use std::{
1313
time::Duration,
1414
};
1515

16-
use ::metrics::Timer;
16+
use ::metrics::{
17+
IntoLabel,
18+
Timer,
19+
};
1720
use async_trait::async_trait;
1821
use common::{
1922
auth::AuthConfig,
@@ -1417,7 +1420,7 @@ pub trait IsolateWorker<RT: Runtime>: Clone + Send + 'static {
14171420
return;
14181421
};
14191422
let reused = last_client_id.is_some();
1420-
// If we receive a request from a different client (i.e. a different backend),
1423+
// If we receive a request from a different client (i.e. a different instance),
14211424
// recreate the isolate. We don't allow an isolate to be reused
14221425
// across clients for security isolation.
14231426
if last_client_id.get_or_insert_with(|| {
@@ -1442,6 +1445,7 @@ pub trait IsolateWorker<RT: Runtime>: Clone + Send + 'static {
14421445
func_path!(),
14431446
req.parent_trace.clone(),
14441447
);
1448+
root.add_property(|| ("reused_isolate", reused.as_label()));
14451449
// Require the layer below to opt into isolate reuse by setting `isolate_clean`.
14461450
let mut isolate_clean = false;
14471451
let debug_str = self

crates/isolate/src/metrics.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -627,17 +627,19 @@ pub fn log_isolate_out_of_memory() {
627627
}
628628

629629
pub fn record_component_function_path(component_function_path: &ResolvedComponentFunctionPath) {
630-
let mut labels = vec![(
631-
Cow::Borrowed("udf_path"),
632-
Cow::Owned(component_function_path.udf_path.to_string()),
633-
)];
634-
if let Some(component_path) = &component_function_path.component_path {
635-
labels.push((
636-
Cow::Borrowed("component"),
637-
Cow::Owned(component_path.to_string()),
638-
));
639-
}
640-
LocalSpan::add_event(Event::new("component_function_path").with_properties(|| labels));
630+
LocalSpan::add_event(Event::new("component_function_path").with_properties(|| {
631+
let mut labels = vec![(
632+
Cow::Borrowed("udf_path"),
633+
Cow::Owned(component_function_path.udf_path.to_string()),
634+
)];
635+
if let Some(component_path) = &component_function_path.component_path {
636+
labels.push((
637+
Cow::Borrowed("component"),
638+
Cow::Owned(component_path.to_string()),
639+
));
640+
}
641+
labels
642+
}));
641643
}
642644

643645
register_convex_counter!(

0 commit comments

Comments
 (0)