@@ -41,7 +41,7 @@ use crate::utils::header_parsing::ParseHeaderError;
41
41
use crate :: utils:: json:: flatten:: JsonFlattenError ;
42
42
43
43
use 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 } ;
45
45
use super :: users:: dashboards:: DashboardError ;
46
46
use super :: users:: filters:: FiltersError ;
47
47
@@ -72,6 +72,8 @@ pub async fn ingest(req: HttpRequest, Json(json): Json<Value>) -> Result<HttpRes
72
72
return Err ( PostError :: OtelNotSupported ) ;
73
73
}
74
74
75
+ let p_custom_fields = get_custom_fields_from_header ( req) ;
76
+
75
77
let log_source_entry = LogSourceEntry :: new ( log_source. clone ( ) , HashSet :: new ( ) ) ;
76
78
PARSEABLE
77
79
. create_stream_if_not_exists (
@@ -81,7 +83,7 @@ pub async fn ingest(req: HttpRequest, Json(json): Json<Value>) -> Result<HttpRes
81
83
)
82
84
. await ?;
83
85
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 ?;
85
87
86
88
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
87
89
}
@@ -102,6 +104,7 @@ pub async fn ingest_internal_stream(stream_name: String, body: Bytes) -> Result<
102
104
None ,
103
105
SchemaVersion :: V0 ,
104
106
StreamType :: Internal ,
107
+ & HashMap :: new ( ) ,
105
108
) ?
106
109
. process ( ) ?;
107
110
@@ -143,8 +146,9 @@ pub async fn handle_otel_logs_ingestion(
143
146
vec ! [ log_source_entry] ,
144
147
)
145
148
. await ?;
149
+ let p_custom_fields = get_custom_fields_from_header ( req) ;
146
150
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 ?;
148
152
149
153
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
150
154
}
@@ -166,6 +170,7 @@ pub async fn handle_otel_metrics_ingestion(
166
170
if log_source != LogSource :: OtelMetrics {
167
171
return Err ( PostError :: IncorrectLogSource ( LogSource :: OtelMetrics ) ) ;
168
172
}
173
+
169
174
let stream_name = stream_name. to_str ( ) . unwrap ( ) . to_owned ( ) ;
170
175
let log_source_entry = LogSourceEntry :: new (
171
176
log_source. clone ( ) ,
@@ -182,7 +187,9 @@ pub async fn handle_otel_metrics_ingestion(
182
187
)
183
188
. await ?;
184
189
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 ?;
186
193
187
194
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
188
195
}
@@ -222,7 +229,9 @@ pub async fn handle_otel_traces_ingestion(
222
229
)
223
230
. await ?;
224
231
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 ?;
226
235
227
236
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
228
237
}
@@ -271,7 +280,8 @@ pub async fn post_event(
271
280
return Err ( PostError :: OtelNotSupported ) ;
272
281
}
273
282
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 ?;
275
285
276
286
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
277
287
}
@@ -421,7 +431,13 @@ mod tests {
421
431
} ) ;
422
432
423
433
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
+ )
425
441
. unwrap ( ) ;
426
442
427
443
assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -449,7 +465,13 @@ mod tests {
449
465
} ) ;
450
466
451
467
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
+ )
453
475
. unwrap ( ) ;
454
476
455
477
assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -481,7 +503,7 @@ mod tests {
481
503
) ;
482
504
483
505
let ( rb, _) = json:: Event :: new ( json)
484
- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
506
+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
485
507
. unwrap ( ) ;
486
508
487
509
assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -513,7 +535,7 @@ mod tests {
513
535
) ;
514
536
515
537
assert ! ( json:: Event :: new( json)
516
- . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , )
538
+ . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
517
539
. is_err( ) ) ;
518
540
}
519
541
@@ -531,7 +553,7 @@ mod tests {
531
553
) ;
532
554
533
555
let ( rb, _) = json:: Event :: new ( json)
534
- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
556
+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
535
557
. unwrap ( ) ;
536
558
537
559
assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -572,7 +594,13 @@ mod tests {
572
594
] ) ;
573
595
574
596
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
+ )
576
604
. unwrap ( ) ;
577
605
578
606
assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -620,7 +648,13 @@ mod tests {
620
648
] ) ;
621
649
622
650
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
+ )
624
658
. unwrap ( ) ;
625
659
626
660
assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -669,7 +703,7 @@ mod tests {
669
703
) ;
670
704
671
705
let ( rb, _) = json:: Event :: new ( json)
672
- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
706
+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
673
707
. unwrap ( ) ;
674
708
675
709
assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -718,7 +752,7 @@ mod tests {
718
752
) ;
719
753
720
754
assert ! ( json:: Event :: new( json)
721
- . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , )
755
+ . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
722
756
. is_err( ) ) ;
723
757
}
724
758
@@ -758,7 +792,13 @@ mod tests {
758
792
. unwrap ( ) ;
759
793
760
794
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
+ )
762
802
. unwrap ( ) ;
763
803
assert_eq ! ( rb. num_rows( ) , 4 ) ;
764
804
assert_eq ! ( rb. num_columns( ) , 5 ) ;
@@ -841,7 +881,13 @@ mod tests {
841
881
. unwrap ( ) ;
842
882
843
883
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
+ )
845
891
. unwrap ( ) ;
846
892
847
893
assert_eq ! ( rb. num_rows( ) , 4 ) ;
0 commit comments