Skip to content

Commit c6b309b

Browse files
nipunn1313Convex, Inc.
authored andcommitted
Tag environment as node vs default to sentry (#23667)
Provide as part of the log event api GitOrigin-RevId: b57a7e3b335703c9a35d93a38d3d8aa81060ea7c
1 parent 0204799 commit c6b309b

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

crates/application/src/application_function_runner/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,7 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
10821082
unix_timestamp,
10831083
context.clone(),
10841084
vec![log_line].into(),
1085+
module_version.environment,
10851086
)
10861087
},
10871088
)
@@ -1180,6 +1181,7 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
11801181
unix_timestamp,
11811182
context.clone(),
11821183
vec![log_line].into(),
1184+
module_version.environment,
11831185
)
11841186
},
11851187
)

crates/application/src/function_log.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ impl FunctionExecution {
191191
FunctionEventSource {
192192
path: udf_id,
193193
udf_type: self.udf_type,
194+
module_environment: self.environment,
194195
cached,
195196
context: self.context.clone(),
196197
}
@@ -756,13 +757,15 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
756757
unix_timestamp: UnixTimestamp,
757758
context: RequestContext,
758759
log_lines: LogLines,
760+
module_environment: ModuleEnvironment,
759761
) {
760762
if identifier.is_system() {
761763
return;
762764
}
763765
let event_source = FunctionEventSource {
764766
path: identifier.strip().to_string(),
765767
udf_type: UdfType::Action,
768+
module_environment,
766769
cached: Some(false),
767770
context,
768771
};
@@ -776,10 +779,12 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
776779
unix_timestamp: UnixTimestamp,
777780
context: RequestContext,
778781
log_lines: LogLines,
782+
module_environment: ModuleEnvironment,
779783
) {
780784
let event_source = FunctionEventSource {
781785
path: identifier.to_string(),
782786
udf_type: UdfType::HttpAction,
787+
module_environment,
783788
cached: Some(false),
784789
context,
785790
};

crates/application/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,8 @@ impl<RT: Runtime> Application<RT> {
10941094
unix_timestamp,
10951095
context.clone(),
10961096
vec![log_line].into(),
1097+
// http actions are always run in Isolate
1098+
ModuleEnvironment::Isolate,
10971099
)
10981100
})
10991101
.await;

crates/common/src/log_streaming.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ use crate::{
88
Runtime,
99
UnixTimestamp,
1010
},
11-
types::UdfType,
11+
types::{
12+
ModuleEnvironment,
13+
UdfType,
14+
},
1215
};
1316

1417
/// Public worker for the LogManager.
@@ -99,6 +102,7 @@ impl LogEvent {
99102
context: RequestContext::new(None),
100103
path: "test".to_string(),
101104
udf_type: UdfType::Action,
105+
module_environment: ModuleEnvironment::Isolate,
102106
cached: None,
103107
});
104108
Self::construct_exception(
@@ -193,6 +197,7 @@ pub struct FunctionEventSource {
193197
pub context: RequestContext,
194198
pub path: String,
195199
pub udf_type: UdfType,
200+
pub module_environment: ModuleEnvironment,
196201
// Only queries can be cached, so this is only Some for queries. This is important
197202
// information to transmit to the client to distinguish from logs users explicitly created
198203
// and logs that we created for by redoing a query when its readset changes.
@@ -215,7 +220,10 @@ mod tests {
215220
LogTopic,
216221
},
217222
runtime::UnixTimestamp,
218-
types::UdfType,
223+
types::{
224+
ModuleEnvironment,
225+
UdfType,
226+
},
219227
};
220228

221229
#[test]
@@ -232,6 +240,7 @@ mod tests {
232240
context: RequestContext::new(None),
233241
path: "test:test".to_string(),
234242
udf_type: UdfType::Query,
243+
module_environment: ModuleEnvironment::Isolate,
235244
cached: Some(true),
236245
}),
237246
payload,
@@ -269,6 +278,7 @@ mod tests {
269278
context: RequestContext::new(None),
270279
path: "test:test".to_string(),
271280
udf_type: UdfType::Query,
281+
module_environment: ModuleEnvironment::Isolate,
272282
cached: Some(true),
273283
}),
274284
payload,

crates/common/src/types/functions.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,17 @@ impl fmt::Display for ModuleEnvironment {
194194
}
195195
}
196196

197+
impl ModuleEnvironment {
198+
pub fn as_sentry_tag(&self) -> &'static str {
199+
match self {
200+
// "isolate" is an internal term. Simply the default environment externally.
201+
ModuleEnvironment::Isolate => "default",
202+
ModuleEnvironment::Node => "node",
203+
ModuleEnvironment::Invalid => "unknown",
204+
}
205+
}
206+
}
207+
197208
#[cfg(test)]
198209
mod tests {
199210
use proptest::prelude::*;

0 commit comments

Comments
 (0)