@@ -24,7 +24,6 @@ use arrow_array::RecordBatch;
24
24
use bytes:: Bytes ;
25
25
use chrono:: Utc ;
26
26
use http:: StatusCode ;
27
- use serde_json:: Value ;
28
27
29
28
use crate :: event:: error:: EventError ;
30
29
use crate :: event:: format:: known_schema:: { self , KNOWN_SCHEMA_LIST } ;
@@ -39,7 +38,7 @@ use crate::otel::traces::OTEL_TRACES_KNOWN_FIELD_LIST;
39
38
use crate :: parseable:: { StreamNotFound , PARSEABLE } ;
40
39
use crate :: storage:: { ObjectStorageError , StreamType } ;
41
40
use crate :: utils:: header_parsing:: ParseHeaderError ;
42
- use crate :: utils:: json:: flatten:: JsonFlattenError ;
41
+ use crate :: utils:: json:: { flatten:: JsonFlattenError , strict :: StrictValue } ;
43
42
44
43
use super :: logstream:: error:: { CreateStreamError , StreamError } ;
45
44
use super :: modal:: utils:: ingest_utils:: { flatten_and_push_logs, get_custom_fields_from_header} ;
@@ -51,7 +50,7 @@ use super::users::filters::FiltersError;
51
50
// creates if stream does not exist
52
51
pub async fn ingest (
53
52
req : HttpRequest ,
54
- Json ( mut json) : Json < Value > ,
53
+ Json ( json) : Json < StrictValue > ,
55
54
) -> Result < HttpResponse , PostError > {
56
55
let Some ( stream_name) = req. headers ( ) . get ( STREAM_NAME_HEADER_KEY ) else {
57
56
return Err ( PostError :: Header ( ParseHeaderError :: MissingStreamName ) ) ;
@@ -83,6 +82,8 @@ pub async fn ingest(
83
82
84
83
let mut p_custom_fields = get_custom_fields_from_header ( & req) ;
85
84
85
+ let mut json = json. into_inner ( ) ;
86
+
86
87
let fields = match & log_source {
87
88
LogSource :: Custom ( src) => KNOWN_SCHEMA_LIST . extract_from_inline_log (
88
89
& mut json,
@@ -127,13 +128,13 @@ pub async fn ingest(
127
128
128
129
pub async fn ingest_internal_stream ( stream_name : String , body : Bytes ) -> Result < ( ) , PostError > {
129
130
let size: usize = body. len ( ) ;
130
- let json: Value = serde_json:: from_slice ( & body) ?;
131
+ let json: StrictValue = serde_json:: from_slice ( & body) ?;
131
132
let schema = PARSEABLE . get_stream ( & stream_name) ?. get_schema_raw ( ) ;
132
133
let mut p_custom_fields = HashMap :: new ( ) ;
133
134
p_custom_fields. insert ( USER_AGENT_KEY . to_string ( ) , "parseable" . to_string ( ) ) ;
134
135
p_custom_fields. insert ( FORMAT_KEY . to_string ( ) , LogSource :: Pmeta . to_string ( ) ) ;
135
136
// For internal streams, use old schema
136
- format:: json:: Event :: new ( json)
137
+ format:: json:: Event :: new ( json. into_inner ( ) )
137
138
. into_event (
138
139
stream_name,
139
140
size as u64 ,
@@ -155,7 +156,7 @@ pub async fn ingest_internal_stream(stream_name: String, body: Bytes) -> Result<
155
156
// creates if stream does not exist
156
157
pub async fn handle_otel_logs_ingestion (
157
158
req : HttpRequest ,
158
- Json ( json) : Json < Value > ,
159
+ Json ( json) : Json < StrictValue > ,
159
160
) -> Result < HttpResponse , PostError > {
160
161
let Some ( stream_name) = req. headers ( ) . get ( STREAM_NAME_HEADER_KEY ) else {
161
162
return Err ( PostError :: Header ( ParseHeaderError :: MissingStreamName ) ) ;
@@ -205,7 +206,13 @@ pub async fn handle_otel_logs_ingestion(
205
206
206
207
let p_custom_fields = get_custom_fields_from_header ( & req) ;
207
208
208
- flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
209
+ flatten_and_push_logs (
210
+ json. into_inner ( ) ,
211
+ & stream_name,
212
+ & log_source,
213
+ & p_custom_fields,
214
+ )
215
+ . await ?;
209
216
210
217
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
211
218
}
@@ -215,7 +222,7 @@ pub async fn handle_otel_logs_ingestion(
215
222
// creates if stream does not exist
216
223
pub async fn handle_otel_metrics_ingestion (
217
224
req : HttpRequest ,
218
- Json ( json) : Json < Value > ,
225
+ Json ( json) : Json < StrictValue > ,
219
226
) -> Result < HttpResponse , PostError > {
220
227
let Some ( stream_name) = req. headers ( ) . get ( STREAM_NAME_HEADER_KEY ) else {
221
228
return Err ( PostError :: Header ( ParseHeaderError :: MissingStreamName ) ) ;
@@ -263,7 +270,13 @@ pub async fn handle_otel_metrics_ingestion(
263
270
264
271
let p_custom_fields = get_custom_fields_from_header ( & req) ;
265
272
266
- flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
273
+ flatten_and_push_logs (
274
+ json. into_inner ( ) ,
275
+ & stream_name,
276
+ & log_source,
277
+ & p_custom_fields,
278
+ )
279
+ . await ?;
267
280
268
281
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
269
282
}
@@ -273,7 +286,7 @@ pub async fn handle_otel_metrics_ingestion(
273
286
// creates if stream does not exist
274
287
pub async fn handle_otel_traces_ingestion (
275
288
req : HttpRequest ,
276
- Json ( json) : Json < Value > ,
289
+ Json ( json) : Json < StrictValue > ,
277
290
) -> Result < HttpResponse , PostError > {
278
291
let Some ( stream_name) = req. headers ( ) . get ( STREAM_NAME_HEADER_KEY ) else {
279
292
return Err ( PostError :: Header ( ParseHeaderError :: MissingStreamName ) ) ;
@@ -322,7 +335,13 @@ pub async fn handle_otel_traces_ingestion(
322
335
323
336
let p_custom_fields = get_custom_fields_from_header ( & req) ;
324
337
325
- flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
338
+ flatten_and_push_logs (
339
+ json. into_inner ( ) ,
340
+ & stream_name,
341
+ & log_source,
342
+ & p_custom_fields,
343
+ )
344
+ . await ?;
326
345
327
346
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
328
347
}
@@ -333,7 +352,7 @@ pub async fn handle_otel_traces_ingestion(
333
352
pub async fn post_event (
334
353
req : HttpRequest ,
335
354
stream_name : Path < String > ,
336
- Json ( mut json) : Json < Value > ,
355
+ Json ( json) : Json < StrictValue > ,
337
356
) -> Result < HttpResponse , PostError > {
338
357
let stream_name = stream_name. into_inner ( ) ;
339
358
@@ -369,6 +388,7 @@ pub async fn post_event(
369
388
. get ( EXTRACT_LOG_KEY )
370
389
. and_then ( |h| h. to_str ( ) . ok ( ) ) ;
371
390
let mut p_custom_fields = get_custom_fields_from_header ( & req) ;
391
+ let mut json = json. into_inner ( ) ;
372
392
match & log_source {
373
393
LogSource :: OtelLogs | LogSource :: OtelMetrics | LogSource :: OtelTraces => {
374
394
return Err ( PostError :: OtelNotSupported )
0 commit comments