@@ -38,7 +38,7 @@ use crate::utils::header_parsing::ParseHeaderError;
3838use crate :: utils:: json:: flatten:: JsonFlattenError ;
3939
4040use super :: logstream:: error:: { CreateStreamError , StreamError } ;
41- use super :: modal:: utils:: ingest_utils:: flatten_and_push_logs;
41+ use super :: modal:: utils:: ingest_utils:: { flatten_and_push_logs, get_custom_fields_from_header } ;
4242use super :: users:: dashboards:: DashboardError ;
4343use super :: users:: filters:: FiltersError ;
4444
@@ -72,7 +72,9 @@ pub async fn ingest(req: HttpRequest, Json(json): Json<Value>) -> Result<HttpRes
7272 return Err ( PostError :: OtelNotSupported ) ;
7373 }
7474
75- flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
75+ let p_custom_fields = get_custom_fields_from_header ( req) ;
76+
77+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
7678
7779 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
7880}
@@ -93,6 +95,7 @@ pub async fn ingest_internal_stream(stream_name: String, body: Bytes) -> Result<
9395 None ,
9496 SchemaVersion :: V0 ,
9597 StreamType :: Internal ,
98+ & HashMap :: new ( ) ,
9699 ) ?
97100 . process ( ) ?;
98101
@@ -122,8 +125,9 @@ pub async fn handle_otel_logs_ingestion(
122125 PARSEABLE
123126 . create_stream_if_not_exists ( & stream_name, StreamType :: UserDefined , LogSource :: OtelLogs )
124127 . await ?;
128+ let p_custom_fields = get_custom_fields_from_header ( req) ;
125129
126- flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
130+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields ) . await ?;
127131
128132 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
129133}
@@ -145,6 +149,7 @@ pub async fn handle_otel_metrics_ingestion(
145149 if log_source != LogSource :: OtelMetrics {
146150 return Err ( PostError :: IncorrectLogSource ( LogSource :: OtelMetrics ) ) ;
147151 }
152+
148153 let stream_name = stream_name. to_str ( ) . unwrap ( ) . to_owned ( ) ;
149154 PARSEABLE
150155 . create_stream_if_not_exists (
@@ -154,7 +159,9 @@ pub async fn handle_otel_metrics_ingestion(
154159 )
155160 . await ?;
156161
157- flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
162+ let p_custom_fields = get_custom_fields_from_header ( req) ;
163+
164+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
158165
159166 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
160167}
@@ -182,7 +189,9 @@ pub async fn handle_otel_traces_ingestion(
182189 . create_stream_if_not_exists ( & stream_name, StreamType :: UserDefined , LogSource :: OtelTraces )
183190 . await ?;
184191
185- flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
192+ let p_custom_fields = get_custom_fields_from_header ( req) ;
193+
194+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
186195
187196 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
188197}
@@ -231,7 +240,8 @@ pub async fn post_event(
231240 return Err ( PostError :: OtelNotSupported ) ;
232241 }
233242
234- flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
243+ let p_custom_fields = get_custom_fields_from_header ( req) ;
244+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
235245
236246 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
237247}
@@ -381,7 +391,13 @@ mod tests {
381391 } ) ;
382392
383393 let ( rb, _) = json:: Event :: new ( json)
384- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V0 )
394+ . into_recordbatch (
395+ & HashMap :: default ( ) ,
396+ false ,
397+ None ,
398+ SchemaVersion :: V0 ,
399+ & HashMap :: new ( ) ,
400+ )
385401 . unwrap ( ) ;
386402
387403 assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -409,7 +425,13 @@ mod tests {
409425 } ) ;
410426
411427 let ( rb, _) = json:: Event :: new ( json)
412- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V0 )
428+ . into_recordbatch (
429+ & HashMap :: default ( ) ,
430+ false ,
431+ None ,
432+ SchemaVersion :: V0 ,
433+ & HashMap :: new ( ) ,
434+ )
413435 . unwrap ( ) ;
414436
415437 assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -441,7 +463,7 @@ mod tests {
441463 ) ;
442464
443465 let ( rb, _) = json:: Event :: new ( json)
444- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
466+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
445467 . unwrap ( ) ;
446468
447469 assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -473,7 +495,7 @@ mod tests {
473495 ) ;
474496
475497 assert ! ( json:: Event :: new( json)
476- . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , )
498+ . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
477499 . is_err( ) ) ;
478500 }
479501
@@ -491,7 +513,7 @@ mod tests {
491513 ) ;
492514
493515 let ( rb, _) = json:: Event :: new ( json)
494- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
516+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
495517 . unwrap ( ) ;
496518
497519 assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -532,7 +554,13 @@ mod tests {
532554 ] ) ;
533555
534556 let ( rb, _) = json:: Event :: new ( json)
535- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V0 )
557+ . into_recordbatch (
558+ & HashMap :: default ( ) ,
559+ false ,
560+ None ,
561+ SchemaVersion :: V0 ,
562+ & HashMap :: new ( ) ,
563+ )
536564 . unwrap ( ) ;
537565
538566 assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -580,7 +608,13 @@ mod tests {
580608 ] ) ;
581609
582610 let ( rb, _) = json:: Event :: new ( json)
583- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V0 )
611+ . into_recordbatch (
612+ & HashMap :: default ( ) ,
613+ false ,
614+ None ,
615+ SchemaVersion :: V0 ,
616+ & HashMap :: new ( ) ,
617+ )
584618 . unwrap ( ) ;
585619
586620 assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -629,7 +663,7 @@ mod tests {
629663 ) ;
630664
631665 let ( rb, _) = json:: Event :: new ( json)
632- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
666+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
633667 . unwrap ( ) ;
634668
635669 assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -678,7 +712,7 @@ mod tests {
678712 ) ;
679713
680714 assert ! ( json:: Event :: new( json)
681- . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , )
715+ . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
682716 . is_err( ) ) ;
683717 }
684718
@@ -718,7 +752,13 @@ mod tests {
718752 . unwrap ( ) ;
719753
720754 let ( rb, _) = json:: Event :: new ( flattened_json)
721- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V0 )
755+ . into_recordbatch (
756+ & HashMap :: default ( ) ,
757+ false ,
758+ None ,
759+ SchemaVersion :: V0 ,
760+ & HashMap :: new ( ) ,
761+ )
722762 . unwrap ( ) ;
723763 assert_eq ! ( rb. num_rows( ) , 4 ) ;
724764 assert_eq ! ( rb. num_columns( ) , 5 ) ;
@@ -801,7 +841,13 @@ mod tests {
801841 . unwrap ( ) ;
802842
803843 let ( rb, _) = json:: Event :: new ( flattened_json)
804- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V1 )
844+ . into_recordbatch (
845+ & HashMap :: default ( ) ,
846+ false ,
847+ None ,
848+ SchemaVersion :: V1 ,
849+ & HashMap :: new ( ) ,
850+ )
805851 . unwrap ( ) ;
806852
807853 assert_eq ! ( rb. num_rows( ) , 4 ) ;
0 commit comments