@@ -15,7 +15,6 @@ use std::{
15
15
use common:: {
16
16
components:: {
17
17
CanonicalizedComponentFunctionPath ,
18
- ComponentFunctionPath ,
19
18
ComponentPath ,
20
19
} ,
21
20
errors:: {
@@ -74,7 +73,6 @@ use serde_json::{
74
73
json,
75
74
Value as JsonValue ,
76
75
} ;
77
- use sync_types:: CanonicalizedUdfPath ;
78
76
use url:: Url ;
79
77
use usage_tracking:: {
80
78
AggregatedFunctionUsageStats ,
@@ -155,54 +153,9 @@ impl HeapSize for FunctionExecution {
155
153
}
156
154
157
155
impl FunctionExecution {
158
- /// Helper method to construct UDF execution for errors that occurred before
159
- /// execution and thus have no associated runtime information.
160
- pub fn for_error (
161
- udf_path : CanonicalizedUdfPath ,
162
- udf_type : UdfType ,
163
- unix_timestamp : UnixTimestamp ,
164
- error : String ,
165
- caller : FunctionCaller ,
166
- udf_server_version : Option < semver:: Version > ,
167
- identity : InertIdentity ,
168
- context : ExecutionContext ,
169
- ) -> Self {
170
- FunctionExecution {
171
- params : UdfParams :: Function {
172
- error : Some ( JsError :: from_message ( error) ) ,
173
- identifier : udf_path,
174
- } ,
175
- unix_timestamp,
176
- execution_timestamp : unix_timestamp,
177
- udf_type,
178
- log_lines : vec ! [ ] . into ( ) ,
179
- tables_touched : WithHeapSize :: default ( ) ,
180
- cached_result : false ,
181
- execution_time : 0.0 ,
182
- caller,
183
- environment : ModuleEnvironment :: Invalid ,
184
- syscall_trace : SyscallTrace :: new ( ) ,
185
- usage_stats : AggregatedFunctionUsageStats :: default ( ) ,
186
- action_memory_used_mb : match udf_type {
187
- UdfType :: Query | UdfType :: Mutation => None ,
188
- UdfType :: Action | UdfType :: HttpAction => Some ( 0 ) ,
189
- } ,
190
- udf_server_version,
191
- identity,
192
- context,
193
- }
194
- }
195
-
196
156
fn identifier ( & self ) -> UdfIdentifier {
197
157
match & self . params {
198
- UdfParams :: Function { identifier, .. } => {
199
- let component = ComponentPath :: TODO ( ) ;
200
- let path = ComponentFunctionPath {
201
- component,
202
- udf_path : identifier. clone ( ) . strip ( ) ,
203
- } ;
204
- UdfIdentifier :: Function ( path. canonicalize ( ) )
205
- } ,
158
+ UdfParams :: Function { identifier, .. } => UdfIdentifier :: Function ( identifier. clone ( ) ) ,
206
159
UdfParams :: Http { identifier, .. } => UdfIdentifier :: Http ( identifier. clone ( ) ) ,
207
160
}
208
161
}
@@ -214,9 +167,14 @@ impl FunctionExecution {
214
167
} else {
215
168
None
216
169
} ;
170
+ let component_path = match & self . params {
171
+ UdfParams :: Function { identifier, .. } => identifier. component . clone ( ) ,
172
+ UdfParams :: Http { .. } => ComponentPath :: TODO ( ) ,
173
+ } ;
217
174
218
175
FunctionEventSource {
219
- path : udf_id,
176
+ component_path,
177
+ udf_path : udf_id,
220
178
udf_type : self . udf_type ,
221
179
module_environment : self . environment ,
222
180
cached,
@@ -355,8 +313,8 @@ pub enum UdfParams {
355
313
// Instead only store the error if there was one. If error is None, the
356
314
// function succeeded.
357
315
error : Option < JsError > ,
358
- /// Path of the UDF that was executed.
359
- identifier : CanonicalizedUdfPath ,
316
+ /// Path of the component and UDF that was executed.
317
+ identifier : CanonicalizedComponentFunctionPath ,
360
318
} ,
361
319
Http {
362
320
result : Result < HttpActionStatusCode , JsError > ,
@@ -391,7 +349,7 @@ impl UdfParams {
391
349
392
350
pub fn identifier_str ( & self ) -> String {
393
351
match self {
394
- Self :: Function { identifier, .. } => identifier. clone ( ) . strip ( ) . to_string ( ) ,
352
+ Self :: Function { identifier, .. } => identifier. udf_path . clone ( ) . strip ( ) . to_string ( ) ,
395
353
Self :: Http { identifier, .. } => identifier. to_string ( ) ,
396
354
}
397
355
}
@@ -618,28 +576,12 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
618
576
usage : TrackUsage ,
619
577
context : ExecutionContext ,
620
578
) {
621
- let udf_path = match outcome. path . clone ( ) . into_root_udf_path ( ) {
622
- Ok ( udf_path) => udf_path,
623
- Err ( _) => {
624
- tracing:: warn!(
625
- "Skipping logging non-root query: {:?}:{:?}" ,
626
- outcome. path. component,
627
- outcome. path. udf_path
628
- ) ;
629
- return ;
630
- } ,
631
- } ;
632
579
let aggregated = match usage {
633
580
TrackUsage :: Track ( usage_tracker) => {
634
581
let usage_stats = usage_tracker. gather_user_stats ( ) ;
635
582
let aggregated = usage_stats. aggregate ( ) ;
636
- let component = ComponentPath :: TODO ( ) ;
637
- let path = ComponentFunctionPath {
638
- component,
639
- udf_path : udf_path. clone ( ) . strip ( ) ,
640
- } ;
641
583
self . usage_tracking . track_call (
642
- UdfIdentifier :: Function ( path. canonicalize ( ) ) ,
584
+ UdfIdentifier :: Function ( outcome . path . clone ( ) ) ,
643
585
context. execution_id . clone ( ) ,
644
586
if was_cached {
645
587
CallType :: CachedQuery
@@ -652,7 +594,7 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
652
594
} ,
653
595
TrackUsage :: SystemError => AggregatedFunctionUsageStats :: default ( ) ,
654
596
} ;
655
- if udf_path . is_system ( ) {
597
+ if outcome . path . is_system ( ) {
656
598
return ;
657
599
}
658
600
let execution = FunctionExecution {
@@ -661,7 +603,7 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
661
603
Ok ( _) => None ,
662
604
Err ( e) => Some ( e) ,
663
605
} ,
664
- identifier : udf_path . clone ( ) ,
606
+ identifier : outcome . path ,
665
607
} ,
666
608
unix_timestamp : self . rt . unix_timestamp ( ) ,
667
609
execution_timestamp : outcome. unix_timestamp ,
@@ -760,28 +702,12 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
760
702
usage : TrackUsage ,
761
703
context : ExecutionContext ,
762
704
) {
763
- let udf_path = match outcome. path . clone ( ) . into_root_udf_path ( ) {
764
- Ok ( udf_path) => udf_path,
765
- Err ( _) => {
766
- tracing:: warn!(
767
- "Skipping logging non-root mutation: {:?}:{:?}" ,
768
- outcome. path. component,
769
- outcome. path. udf_path
770
- ) ;
771
- return ;
772
- } ,
773
- } ;
774
705
let aggregated = match usage {
775
706
TrackUsage :: Track ( usage_tracker) => {
776
707
let usage_stats = usage_tracker. gather_user_stats ( ) ;
777
708
let aggregated = usage_stats. aggregate ( ) ;
778
- let component = ComponentPath :: TODO ( ) ;
779
- let path = ComponentFunctionPath {
780
- component,
781
- udf_path : udf_path. clone ( ) . strip ( ) ,
782
- } ;
783
709
self . usage_tracking . track_call (
784
- UdfIdentifier :: Function ( path. canonicalize ( ) ) ,
710
+ UdfIdentifier :: Function ( outcome . path . clone ( ) ) ,
785
711
context. execution_id . clone ( ) ,
786
712
CallType :: Mutation ,
787
713
usage_stats,
@@ -790,7 +716,7 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
790
716
} ,
791
717
TrackUsage :: SystemError => AggregatedFunctionUsageStats :: default ( ) ,
792
718
} ;
793
- if udf_path . is_system ( ) {
719
+ if outcome . path . is_system ( ) {
794
720
return ;
795
721
}
796
722
let execution = FunctionExecution {
@@ -799,7 +725,7 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
799
725
Ok ( _) => None ,
800
726
Err ( e) => Some ( e) ,
801
727
} ,
802
- identifier : udf_path . clone ( ) ,
728
+ identifier : outcome . path ,
803
729
} ,
804
730
unix_timestamp : self . rt . unix_timestamp ( ) ,
805
731
execution_timestamp : outcome. unix_timestamp ,
@@ -860,28 +786,12 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
860
786
fn _log_action ( & self , completion : ActionCompletion , usage : TrackUsage ) {
861
787
let outcome = completion. outcome ;
862
788
let log_lines = completion. log_lines ;
863
- let udf_path = match outcome. path . clone ( ) . into_root_udf_path ( ) {
864
- Ok ( udf_path) => udf_path,
865
- Err ( _) => {
866
- tracing:: warn!(
867
- "Skipping logging non-root action: {:?}:{:?}" ,
868
- outcome. path. component,
869
- outcome. path. udf_path
870
- ) ;
871
- return ;
872
- } ,
873
- } ;
874
789
let aggregated = match usage {
875
790
TrackUsage :: Track ( usage_tracker) => {
876
791
let usage_stats = usage_tracker. gather_user_stats ( ) ;
877
792
let aggregated = usage_stats. aggregate ( ) ;
878
- let component = ComponentPath :: TODO ( ) ;
879
- let path = ComponentFunctionPath {
880
- component,
881
- udf_path : udf_path. clone ( ) . strip ( ) ,
882
- } ;
883
793
self . usage_tracking . track_call (
884
- UdfIdentifier :: Function ( path. canonicalize ( ) ) ,
794
+ UdfIdentifier :: Function ( outcome . path . clone ( ) ) ,
885
795
completion. context . execution_id . clone ( ) ,
886
796
CallType :: Action {
887
797
env : completion. environment ,
@@ -894,7 +804,7 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
894
804
} ,
895
805
TrackUsage :: SystemError => AggregatedFunctionUsageStats :: default ( ) ,
896
806
} ;
897
- if udf_path . is_system ( ) {
807
+ if outcome . path . is_system ( ) {
898
808
return ;
899
809
}
900
810
let execution = FunctionExecution {
@@ -903,7 +813,7 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
903
813
Ok ( _) => None ,
904
814
Err ( e) => Some ( e) ,
905
815
} ,
906
- identifier : udf_path ,
816
+ identifier : outcome . path ,
907
817
} ,
908
818
unix_timestamp : self . rt . unix_timestamp ( ) ,
909
819
execution_timestamp : outcome. unix_timestamp ,
@@ -932,14 +842,12 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
932
842
log_lines : LogLines ,
933
843
module_environment : ModuleEnvironment ,
934
844
) {
935
- let Ok ( udf_path) = path. into_root_udf_path ( ) else {
936
- return ;
937
- } ;
938
- if udf_path. is_system ( ) {
845
+ if path. is_system ( ) {
939
846
return ;
940
847
}
941
848
let event_source = FunctionEventSource {
942
- path : udf_path. strip ( ) . to_string ( ) ,
849
+ component_path : path. component ,
850
+ udf_path : path. udf_path . strip ( ) . to_string ( ) ,
943
851
udf_type : UdfType :: Action ,
944
852
module_environment,
945
853
cached : Some ( false ) ,
@@ -1061,7 +969,8 @@ impl<RT: Runtime> FunctionExecutionLog<RT> {
1061
969
module_environment : ModuleEnvironment ,
1062
970
) {
1063
971
let event_source = FunctionEventSource {
1064
- path : identifier. to_string ( ) ,
972
+ component_path : ComponentPath :: TODO ( ) ,
973
+ udf_path : identifier. to_string ( ) ,
1065
974
udf_type : UdfType :: HttpAction ,
1066
975
module_environment,
1067
976
cached : Some ( false ) ,
0 commit comments