@@ -41,7 +41,7 @@ use crate::utils::header_parsing::ParseHeaderError;
4141use crate :: utils:: json:: flatten:: JsonFlattenError ;
4242
4343use super :: logstream:: error:: { CreateStreamError , StreamError } ;
44- use super :: modal:: utils:: ingest_utils:: flatten_and_push_logs;
44+ use super :: modal:: utils:: ingest_utils:: { flatten_and_push_logs, get_custom_fields_from_header } ;
4545use super :: users:: dashboards:: DashboardError ;
4646use super :: users:: filters:: FiltersError ;
4747
@@ -72,6 +72,8 @@ pub async fn ingest(req: HttpRequest, Json(json): Json<Value>) -> Result<HttpRes
7272 return Err ( PostError :: OtelNotSupported ) ;
7373 }
7474
75+ let p_custom_fields = get_custom_fields_from_header ( req) ;
76+
7577 let log_source_entry = LogSourceEntry :: new ( log_source. clone ( ) , HashSet :: new ( ) ) ;
7678 PARSEABLE
7779 . create_stream_if_not_exists (
@@ -81,7 +83,7 @@ pub async fn ingest(req: HttpRequest, Json(json): Json<Value>) -> Result<HttpRes
8183 )
8284 . await ?;
8385
84- flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
86+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields ) . await ?;
8587
8688 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
8789}
@@ -102,6 +104,7 @@ pub async fn ingest_internal_stream(stream_name: String, body: Bytes) -> Result<
102104 None ,
103105 SchemaVersion :: V0 ,
104106 StreamType :: Internal ,
107+ & HashMap :: new ( ) ,
105108 ) ?
106109 . process ( ) ?;
107110
@@ -143,8 +146,9 @@ pub async fn handle_otel_logs_ingestion(
143146 vec ! [ log_source_entry] ,
144147 )
145148 . await ?;
149+ let p_custom_fields = get_custom_fields_from_header ( req) ;
146150
147- flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
151+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields ) . await ?;
148152
149153 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
150154}
@@ -166,6 +170,7 @@ pub async fn handle_otel_metrics_ingestion(
166170 if log_source != LogSource :: OtelMetrics {
167171 return Err ( PostError :: IncorrectLogSource ( LogSource :: OtelMetrics ) ) ;
168172 }
173+
169174 let stream_name = stream_name. to_str ( ) . unwrap ( ) . to_owned ( ) ;
170175 let log_source_entry = LogSourceEntry :: new (
171176 log_source. clone ( ) ,
@@ -182,7 +187,9 @@ pub async fn handle_otel_metrics_ingestion(
182187 )
183188 . await ?;
184189
185- flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
190+ let p_custom_fields = get_custom_fields_from_header ( req) ;
191+
192+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
186193
187194 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
188195}
@@ -222,7 +229,9 @@ pub async fn handle_otel_traces_ingestion(
222229 )
223230 . await ?;
224231
225- flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
232+ let p_custom_fields = get_custom_fields_from_header ( req) ;
233+
234+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
226235
227236 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
228237}
@@ -271,7 +280,8 @@ pub async fn post_event(
271280 return Err ( PostError :: OtelNotSupported ) ;
272281 }
273282
274- flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
283+ let p_custom_fields = get_custom_fields_from_header ( req) ;
284+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
275285
276286 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
277287}
@@ -421,7 +431,13 @@ mod tests {
421431 } ) ;
422432
423433 let ( rb, _) = json:: Event :: new ( json)
424- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V0 )
434+ . into_recordbatch (
435+ & HashMap :: default ( ) ,
436+ false ,
437+ None ,
438+ SchemaVersion :: V0 ,
439+ & HashMap :: new ( ) ,
440+ )
425441 . unwrap ( ) ;
426442
427443 assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -449,7 +465,13 @@ mod tests {
449465 } ) ;
450466
451467 let ( rb, _) = json:: Event :: new ( json)
452- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V0 )
468+ . into_recordbatch (
469+ & HashMap :: default ( ) ,
470+ false ,
471+ None ,
472+ SchemaVersion :: V0 ,
473+ & HashMap :: new ( ) ,
474+ )
453475 . unwrap ( ) ;
454476
455477 assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -481,7 +503,7 @@ mod tests {
481503 ) ;
482504
483505 let ( rb, _) = json:: Event :: new ( json)
484- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
506+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
485507 . unwrap ( ) ;
486508
487509 assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -513,7 +535,7 @@ mod tests {
513535 ) ;
514536
515537 assert ! ( json:: Event :: new( json)
516- . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , )
538+ . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
517539 . is_err( ) ) ;
518540 }
519541
@@ -531,7 +553,7 @@ mod tests {
531553 ) ;
532554
533555 let ( rb, _) = json:: Event :: new ( json)
534- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
556+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
535557 . unwrap ( ) ;
536558
537559 assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -572,7 +594,13 @@ mod tests {
572594 ] ) ;
573595
574596 let ( rb, _) = json:: Event :: new ( json)
575- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V0 )
597+ . into_recordbatch (
598+ & HashMap :: default ( ) ,
599+ false ,
600+ None ,
601+ SchemaVersion :: V0 ,
602+ & HashMap :: new ( ) ,
603+ )
576604 . unwrap ( ) ;
577605
578606 assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -620,7 +648,13 @@ mod tests {
620648 ] ) ;
621649
622650 let ( rb, _) = json:: Event :: new ( json)
623- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V0 )
651+ . into_recordbatch (
652+ & HashMap :: default ( ) ,
653+ false ,
654+ None ,
655+ SchemaVersion :: V0 ,
656+ & HashMap :: new ( ) ,
657+ )
624658 . unwrap ( ) ;
625659
626660 assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -669,7 +703,7 @@ mod tests {
669703 ) ;
670704
671705 let ( rb, _) = json:: Event :: new ( json)
672- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
706+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
673707 . unwrap ( ) ;
674708
675709 assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -718,7 +752,7 @@ mod tests {
718752 ) ;
719753
720754 assert ! ( json:: Event :: new( json)
721- . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , )
755+ . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
722756 . is_err( ) ) ;
723757 }
724758
@@ -758,7 +792,13 @@ mod tests {
758792 . unwrap ( ) ;
759793
760794 let ( rb, _) = json:: Event :: new ( flattened_json)
761- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V0 )
795+ . into_recordbatch (
796+ & HashMap :: default ( ) ,
797+ false ,
798+ None ,
799+ SchemaVersion :: V0 ,
800+ & HashMap :: new ( ) ,
801+ )
762802 . unwrap ( ) ;
763803 assert_eq ! ( rb. num_rows( ) , 4 ) ;
764804 assert_eq ! ( rb. num_columns( ) , 5 ) ;
@@ -841,7 +881,13 @@ mod tests {
841881 . unwrap ( ) ;
842882
843883 let ( rb, _) = json:: Event :: new ( flattened_json)
844- . into_recordbatch ( & HashMap :: default ( ) , false , None , SchemaVersion :: V1 )
884+ . into_recordbatch (
885+ & HashMap :: default ( ) ,
886+ false ,
887+ None ,
888+ SchemaVersion :: V1 ,
889+ & HashMap :: new ( ) ,
890+ )
845891 . unwrap ( ) ;
846892
847893 assert_eq ! ( rb. num_rows( ) , 4 ) ;
0 commit comments