@@ -17,6 +17,7 @@ use crate::bindings::ddog_php_prof_get_active_fiber_test as ddog_php_prof_get_ac
17
17
18
18
use crate :: bindings:: { datadog_php_profiling_get_profiling_context, zend_execute_data} ;
19
19
use crate :: config:: SystemSettings ;
20
+ use crate :: well_known:: WellKnown ;
20
21
use crate :: { CLOCKS , TAGS } ;
21
22
use chrono:: Utc ;
22
23
use core:: { ptr, str} ;
@@ -26,6 +27,7 @@ use datadog_profiling::api::{
26
27
} ;
27
28
use datadog_profiling:: exporter:: Tag ;
28
29
use datadog_profiling:: internal:: Profile as InternalProfile ;
30
+ use datadog_thin_str:: ThinString ;
29
31
use log:: { debug, info, trace, warn} ;
30
32
use once_cell:: sync:: OnceCell ;
31
33
use std:: borrow:: Cow ;
@@ -49,6 +51,8 @@ use datadog_profiling::api::UpscalingInfo;
49
51
50
52
#[ cfg( feature = "exception_profiling" ) ]
51
53
use crate :: exception:: EXCEPTION_PROFILING_INTERVAL ;
54
+ #[ cfg( feature = "timeline" ) ]
55
+ use crate :: timeline:: IncludeType ;
52
56
53
57
const UPLOAD_PERIOD : Duration = Duration :: from_secs ( 67 ) ;
54
58
@@ -514,9 +518,6 @@ pub enum UploadMessage {
514
518
Upload ( Box < UploadRequest > ) ,
515
519
}
516
520
517
- #[ cfg( feature = "timeline" ) ]
518
- const COW_EVAL : Cow < str > = Cow :: Borrowed ( "[eval]" ) ;
519
-
520
521
const DDPROF_TIME : & str = "ddprof_time" ;
521
522
const DDPROF_UPLOAD : & str = "ddprof_upload" ;
522
523
@@ -907,14 +908,14 @@ impl Profiler {
907
908
} ] ;
908
909
909
910
#[ cfg( feature = "timeline" ) ]
910
- pub fn collect_compile_string ( & self , now : i64 , duration : i64 , filename : String , line : u32 ) {
911
+ pub fn collect_compile_string ( & self , now : i64 , duration : i64 , filename : ThinString , line : u32 ) {
911
912
let mut labels = Profiler :: common_labels ( Self :: TIMELINE_COMPILE_FILE_LABELS . len ( ) ) ;
912
913
labels. extend_from_slice ( Self :: TIMELINE_COMPILE_FILE_LABELS ) ;
913
914
let n_labels = labels. len ( ) ;
914
915
915
916
match self . prepare_and_send_message (
916
917
vec ! [ ZendFrame {
917
- function: COW_EVAL ,
918
+ function: WellKnown :: Eval . into ( ) ,
918
919
file: Some ( filename) ,
919
920
line,
920
921
} ] ,
@@ -942,7 +943,7 @@ impl Profiler {
942
943
now : i64 ,
943
944
duration : i64 ,
944
945
filename : String ,
945
- include_type : & str ,
946
+ include_type : IncludeType ,
946
947
) {
947
948
let mut labels = Profiler :: common_labels ( Self :: TIMELINE_COMPILE_FILE_LABELS . len ( ) + 1 ) ;
948
949
labels. extend_from_slice ( Self :: TIMELINE_COMPILE_FILE_LABELS ) ;
@@ -955,7 +956,11 @@ impl Profiler {
955
956
956
957
match self . prepare_and_send_message (
957
958
vec ! [ ZendFrame {
958
- function: format!( "[{include_type}]" ) . into( ) ,
959
+ function: match include_type {
960
+ IncludeType :: Include => WellKnown :: Include . into( ) ,
961
+ IncludeType :: Require => WellKnown :: Require . into( ) ,
962
+ IncludeType :: Unknown => WellKnown :: UnknownIncludeType . into( ) ,
963
+ } ,
959
964
file: None ,
960
965
line: 0 ,
961
966
} ] ,
@@ -984,7 +989,7 @@ impl Profiler {
984
989
985
990
labels. push ( Label {
986
991
key : "event" ,
987
- value : LabelValue :: Str ( std :: borrow :: Cow :: Borrowed ( event) ) ,
992
+ value : LabelValue :: Str ( Cow :: Borrowed ( event) ) ,
988
993
} ) ;
989
994
990
995
let n_labels = labels. len ( ) ;
@@ -1013,7 +1018,7 @@ impl Profiler {
1013
1018
1014
1019
/// This function can be called to collect any fatal errors
1015
1020
#[ cfg( feature = "timeline" ) ]
1016
- pub fn collect_fatal ( & self , now : i64 , file : String , line : u32 , message : String ) {
1021
+ pub fn collect_fatal ( & self , now : i64 , file : ThinString , line : u32 , message : String ) {
1017
1022
let mut labels = Profiler :: common_labels ( 2 ) ;
1018
1023
1019
1024
labels. push ( Label {
@@ -1029,7 +1034,7 @@ impl Profiler {
1029
1034
1030
1035
match self . prepare_and_send_message (
1031
1036
vec ! [ ZendFrame {
1032
- function: "[fatal]" . into( ) ,
1037
+ function: WellKnown :: Fatal . into( ) ,
1033
1038
file: Some ( file) ,
1034
1039
line,
1035
1040
} ] ,
@@ -1056,7 +1061,7 @@ impl Profiler {
1056
1061
pub ( crate ) fn collect_opcache_restart (
1057
1062
& self ,
1058
1063
now : i64 ,
1059
- file : String ,
1064
+ file : ThinString ,
1060
1065
line : u32 ,
1061
1066
reason : & ' static str ,
1062
1067
) {
@@ -1109,7 +1114,7 @@ impl Profiler {
1109
1114
1110
1115
match self . prepare_and_send_message (
1111
1116
vec ! [ ZendFrame {
1112
- function: "[idle]" . into( ) ,
1117
+ function: WellKnown :: Idle . into( ) ,
1113
1118
file: None ,
1114
1119
line: 0 ,
1115
1120
} ] ,
@@ -1165,7 +1170,7 @@ impl Profiler {
1165
1170
1166
1171
match self . prepare_and_send_message (
1167
1172
vec ! [ ZendFrame {
1168
- function: "[gc]" . into( ) ,
1173
+ function: WellKnown :: Gc . into( ) ,
1169
1174
file: None ,
1170
1175
line: 0 ,
1171
1176
} ] ,
@@ -1233,7 +1238,7 @@ impl Profiler {
1233
1238
if let Some ( functionname) = extract_function_name ( func) {
1234
1239
labels. push ( Label {
1235
1240
key : "fiber" ,
1236
- value : LabelValue :: Str ( functionname . into ( ) ) ,
1241
+ value : LabelValue :: Str ( Cow :: from ( functionname ) ) ,
1237
1242
} ) ;
1238
1243
}
1239
1244
}
@@ -1287,12 +1292,16 @@ mod tests {
1287
1292
use super :: * ;
1288
1293
use crate :: config:: AgentEndpoint ;
1289
1294
use datadog_profiling:: exporter:: Uri ;
1295
+ use datadog_thin_str:: ConstStorage ;
1290
1296
use log:: LevelFilter ;
1291
1297
1292
1298
fn get_frames ( ) -> Vec < ZendFrame > {
1299
+ static FOOBAR : ConstStorage < 8 > = ConstStorage :: from_str ( "foobar()" ) ;
1300
+ static FOOBAR_PHP : ConstStorage < 10 > = ConstStorage :: from_str ( "foobar.php" ) ;
1301
+
1293
1302
vec ! [ ZendFrame {
1294
- function: "foobar()" . into ( ) ,
1295
- file: Some ( "foobar.php" . into ( ) ) ,
1303
+ function: ThinString :: from ( & FOOBAR ) ,
1304
+ file: Some ( ThinString :: from ( & FOOBAR_PHP ) ) ,
1296
1305
line: 42 ,
1297
1306
} ]
1298
1307
}
0 commit comments