@@ -95,7 +95,7 @@ pub async fn ingest_internal_stream(stream_name: String, body: Bytes) -> Result<
95
95
metadata : String :: default ( ) ,
96
96
} ;
97
97
// For internal streams, use old schema
98
- event. into_recordbatch ( & schema, None , None , SchemaVersion :: V0 ) ?
98
+ event. into_recordbatch ( & schema, None , None , SchemaVersion :: V0 , "" ) ?
99
99
} ;
100
100
event:: Event {
101
101
rb,
@@ -127,7 +127,8 @@ pub async fn handle_otel_logs_ingestion(
127
127
let Some ( log_source) = req. headers ( ) . get ( LOG_SOURCE_KEY ) else {
128
128
return Err ( PostError :: Header ( ParseHeaderError :: MissingLogSource ) ) ;
129
129
} ;
130
- if log_source. to_str ( ) . unwrap ( ) != LOG_SOURCE_OTEL_LOGS {
130
+ let log_source = log_source. to_str ( ) . unwrap ( ) ;
131
+ if log_source != LOG_SOURCE_OTEL_LOGS {
131
132
return Err ( PostError :: Invalid ( anyhow:: anyhow!(
132
133
"Please use x-p-log-source: otel-logs for ingesting otel logs"
133
134
) ) ) ;
@@ -141,7 +142,7 @@ pub async fn handle_otel_logs_ingestion(
141
142
let mut json = flatten_otel_logs ( & logs) ;
142
143
for record in json. iter_mut ( ) {
143
144
let body: Bytes = serde_json:: to_vec ( record) . unwrap ( ) . into ( ) ;
144
- push_logs ( & stream_name, & req, & body) . await ?;
145
+ push_logs ( & stream_name, & req, & body, log_source ) . await ?;
145
146
}
146
147
147
148
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
@@ -160,7 +161,8 @@ pub async fn handle_otel_metrics_ingestion(
160
161
let Some ( log_source) = req. headers ( ) . get ( LOG_SOURCE_KEY ) else {
161
162
return Err ( PostError :: Header ( ParseHeaderError :: MissingLogSource ) ) ;
162
163
} ;
163
- if log_source. to_str ( ) . unwrap ( ) != LOG_SOURCE_OTEL_METRICS {
164
+ let log_source = log_source. to_str ( ) . unwrap ( ) ;
165
+ if log_source != LOG_SOURCE_OTEL_METRICS {
164
166
return Err ( PostError :: Invalid ( anyhow:: anyhow!(
165
167
"Please use x-p-log-source: otel-metrics for ingesting otel metrics"
166
168
) ) ) ;
@@ -173,7 +175,7 @@ pub async fn handle_otel_metrics_ingestion(
173
175
let mut json = flatten_otel_metrics ( metrics) ;
174
176
for record in json. iter_mut ( ) {
175
177
let body: Bytes = serde_json:: to_vec ( record) . unwrap ( ) . into ( ) ;
176
- push_logs ( & stream_name, & req, & body) . await ?;
178
+ push_logs ( & stream_name, & req, & body, log_source ) . await ?;
177
179
}
178
180
179
181
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
@@ -193,7 +195,8 @@ pub async fn handle_otel_traces_ingestion(
193
195
let Some ( log_source) = req. headers ( ) . get ( LOG_SOURCE_KEY ) else {
194
196
return Err ( PostError :: Header ( ParseHeaderError :: MissingLogSource ) ) ;
195
197
} ;
196
- if log_source. to_str ( ) . unwrap ( ) != LOG_SOURCE_OTEL_TRACES {
198
+ let log_source = log_source. to_str ( ) . unwrap ( ) ;
199
+ if log_source != LOG_SOURCE_OTEL_TRACES {
197
200
return Err ( PostError :: Invalid ( anyhow:: anyhow!(
198
201
"Please use x-p-log-source: otel-traces for ingesting otel traces"
199
202
) ) ) ;
@@ -206,7 +209,7 @@ pub async fn handle_otel_traces_ingestion(
206
209
let mut json = flatten_otel_traces ( & traces) ;
207
210
for record in json. iter_mut ( ) {
208
211
let body: Bytes = serde_json:: to_vec ( record) . unwrap ( ) . into ( ) ;
209
- push_logs ( & stream_name, & req, & body) . await ?;
212
+ push_logs ( & stream_name, & req, & body, log_source ) . await ?;
210
213
}
211
214
212
215
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
@@ -417,6 +420,7 @@ mod tests {
417
420
None ,
418
421
None ,
419
422
SchemaVersion :: V0 ,
423
+ "" ,
420
424
)
421
425
. unwrap ( ) ;
422
426
@@ -467,6 +471,7 @@ mod tests {
467
471
None ,
468
472
None ,
469
473
SchemaVersion :: V0 ,
474
+ "" ,
470
475
)
471
476
. unwrap ( ) ;
472
477
@@ -500,7 +505,8 @@ mod tests {
500
505
501
506
let req = TestRequest :: default ( ) . to_http_request ( ) ;
502
507
503
- let ( rb, _) = into_event_batch ( & req, & json, schema, None , None , SchemaVersion :: V0 ) . unwrap ( ) ;
508
+ let ( rb, _) =
509
+ into_event_batch ( & req, & json, schema, None , None , SchemaVersion :: V0 , "" ) . unwrap ( ) ;
504
510
505
511
assert_eq ! ( rb. num_rows( ) , 1 ) ;
506
512
assert_eq ! ( rb. num_columns( ) , 5 ) ;
@@ -532,7 +538,7 @@ mod tests {
532
538
533
539
let req = TestRequest :: default ( ) . to_http_request ( ) ;
534
540
535
- assert ! ( into_event_batch( & req, & json, schema, None , None , SchemaVersion :: V0 ) . is_err( ) ) ;
541
+ assert ! ( into_event_batch( & req, & json, schema, None , None , SchemaVersion :: V0 , "" ) . is_err( ) ) ;
536
542
}
537
543
538
544
#[ test]
@@ -550,7 +556,8 @@ mod tests {
550
556
551
557
let req = TestRequest :: default ( ) . to_http_request ( ) ;
552
558
553
- let ( rb, _) = into_event_batch ( & req, & json, schema, None , None , SchemaVersion :: V0 ) . unwrap ( ) ;
559
+ let ( rb, _) =
560
+ into_event_batch ( & req, & json, schema, None , None , SchemaVersion :: V0 , "" ) . unwrap ( ) ;
554
561
555
562
assert_eq ! ( rb. num_rows( ) , 1 ) ;
556
563
assert_eq ! ( rb. num_columns( ) , 3 ) ;
@@ -568,7 +575,8 @@ mod tests {
568
575
HashMap :: default ( ) ,
569
576
None ,
570
577
None ,
571
- SchemaVersion :: V0
578
+ SchemaVersion :: V0 ,
579
+ ""
572
580
)
573
581
. is_err( ) )
574
582
}
@@ -600,6 +608,7 @@ mod tests {
600
608
None ,
601
609
None ,
602
610
SchemaVersion :: V0 ,
611
+ "" ,
603
612
)
604
613
. unwrap ( ) ;
605
614
@@ -656,6 +665,7 @@ mod tests {
656
665
None ,
657
666
None ,
658
667
SchemaVersion :: V0 ,
668
+ "" ,
659
669
)
660
670
. unwrap ( ) ;
661
671
@@ -705,7 +715,8 @@ mod tests {
705
715
) ;
706
716
let req = TestRequest :: default ( ) . to_http_request ( ) ;
707
717
708
- let ( rb, _) = into_event_batch ( & req, & json, schema, None , None , SchemaVersion :: V0 ) . unwrap ( ) ;
718
+ let ( rb, _) =
719
+ into_event_batch ( & req, & json, schema, None , None , SchemaVersion :: V0 , "" ) . unwrap ( ) ;
709
720
710
721
assert_eq ! ( rb. num_rows( ) , 3 ) ;
711
722
assert_eq ! ( rb. num_columns( ) , 6 ) ;
@@ -754,7 +765,7 @@ mod tests {
754
765
. into_iter ( ) ,
755
766
) ;
756
767
757
- assert ! ( into_event_batch( & req, & json, schema, None , None , SchemaVersion :: V0 ) . is_err( ) ) ;
768
+ assert ! ( into_event_batch( & req, & json, schema, None , None , SchemaVersion :: V0 , "" ) . is_err( ) ) ;
758
769
}
759
770
760
771
#[ test]
@@ -789,6 +800,7 @@ mod tests {
789
800
None ,
790
801
None ,
791
802
SchemaVersion :: V0 ,
803
+ "" ,
792
804
)
793
805
. unwrap ( ) ;
794
806
@@ -869,6 +881,7 @@ mod tests {
869
881
None ,
870
882
None ,
871
883
SchemaVersion :: V1 ,
884
+ "" ,
872
885
)
873
886
. unwrap ( ) ;
874
887
0 commit comments