@@ -38,7 +38,7 @@ use crate::utils::header_parsing::ParseHeaderError;
38
38
use crate :: utils:: json:: flatten:: JsonFlattenError ;
39
39
40
40
use 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 } ;
42
42
use super :: users:: dashboards:: DashboardError ;
43
43
use super :: users:: filters:: FiltersError ;
44
44
@@ -72,7 +72,9 @@ pub async fn ingest(req: HttpRequest, Json(json): Json<Value>) -> Result<HttpRes
72
72
return Err ( PostError :: OtelNotSupported ) ;
73
73
}
74
74
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 ?;
76
78
77
79
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
78
80
}
@@ -93,6 +95,7 @@ pub async fn ingest_internal_stream(stream_name: String, body: Bytes) -> Result<
93
95
None ,
94
96
SchemaVersion :: V0 ,
95
97
StreamType :: Internal ,
98
+ & HashMap :: new ( ) ,
96
99
) ?
97
100
. process ( ) ?;
98
101
@@ -122,8 +125,9 @@ pub async fn handle_otel_logs_ingestion(
122
125
PARSEABLE
123
126
. create_stream_if_not_exists ( & stream_name, StreamType :: UserDefined , LogSource :: OtelLogs )
124
127
. await ?;
128
+ let p_custom_fields = get_custom_fields_from_header ( req) ;
125
129
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 ?;
127
131
128
132
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
129
133
}
@@ -145,6 +149,7 @@ pub async fn handle_otel_metrics_ingestion(
145
149
if log_source != LogSource :: OtelMetrics {
146
150
return Err ( PostError :: IncorrectLogSource ( LogSource :: OtelMetrics ) ) ;
147
151
}
152
+
148
153
let stream_name = stream_name. to_str ( ) . unwrap ( ) . to_owned ( ) ;
149
154
PARSEABLE
150
155
. create_stream_if_not_exists (
@@ -154,7 +159,9 @@ pub async fn handle_otel_metrics_ingestion(
154
159
)
155
160
. await ?;
156
161
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 ?;
158
165
159
166
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
160
167
}
@@ -182,7 +189,9 @@ pub async fn handle_otel_traces_ingestion(
182
189
. create_stream_if_not_exists ( & stream_name, StreamType :: UserDefined , LogSource :: OtelTraces )
183
190
. await ?;
184
191
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 ?;
186
195
187
196
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
188
197
}
@@ -231,7 +240,8 @@ pub async fn post_event(
231
240
return Err ( PostError :: OtelNotSupported ) ;
232
241
}
233
242
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 ?;
235
245
236
246
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
237
247
}
@@ -381,7 +391,13 @@ mod tests {
381
391
} ) ;
382
392
383
393
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
+ )
385
401
. unwrap ( ) ;
386
402
387
403
assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -409,7 +425,13 @@ mod tests {
409
425
} ) ;
410
426
411
427
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
+ )
413
435
. unwrap ( ) ;
414
436
415
437
assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -441,7 +463,7 @@ mod tests {
441
463
) ;
442
464
443
465
let ( rb, _) = json:: Event :: new ( json)
444
- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
466
+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
445
467
. unwrap ( ) ;
446
468
447
469
assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -473,7 +495,7 @@ mod tests {
473
495
) ;
474
496
475
497
assert ! ( json:: Event :: new( json)
476
- . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , )
498
+ . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
477
499
. is_err( ) ) ;
478
500
}
479
501
@@ -491,7 +513,7 @@ mod tests {
491
513
) ;
492
514
493
515
let ( rb, _) = json:: Event :: new ( json)
494
- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
516
+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
495
517
. unwrap ( ) ;
496
518
497
519
assert_eq ! ( rb. num_rows( ) , 1 ) ;
@@ -532,7 +554,13 @@ mod tests {
532
554
] ) ;
533
555
534
556
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
+ )
536
564
. unwrap ( ) ;
537
565
538
566
assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -580,7 +608,13 @@ mod tests {
580
608
] ) ;
581
609
582
610
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
+ )
584
618
. unwrap ( ) ;
585
619
586
620
assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -629,7 +663,7 @@ mod tests {
629
663
) ;
630
664
631
665
let ( rb, _) = json:: Event :: new ( json)
632
- . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 )
666
+ . into_recordbatch ( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
633
667
. unwrap ( ) ;
634
668
635
669
assert_eq ! ( rb. num_rows( ) , 3 ) ;
@@ -678,7 +712,7 @@ mod tests {
678
712
) ;
679
713
680
714
assert ! ( json:: Event :: new( json)
681
- . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , )
715
+ . into_recordbatch( & schema, false , None , SchemaVersion :: V0 , & HashMap :: new ( ) )
682
716
. is_err( ) ) ;
683
717
}
684
718
@@ -718,7 +752,13 @@ mod tests {
718
752
. unwrap ( ) ;
719
753
720
754
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
+ )
722
762
. unwrap ( ) ;
723
763
assert_eq ! ( rb. num_rows( ) , 4 ) ;
724
764
assert_eq ! ( rb. num_columns( ) , 5 ) ;
@@ -801,7 +841,13 @@ mod tests {
801
841
. unwrap ( ) ;
802
842
803
843
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
+ )
805
851
. unwrap ( ) ;
806
852
807
853
assert_eq ! ( rb. num_rows( ) , 4 ) ;
0 commit comments