@@ -24,27 +24,21 @@ use arrow_array::RecordBatch;
24
24
use bytes:: Bytes ;
25
25
use chrono:: Utc ;
26
26
use http:: StatusCode ;
27
- use opentelemetry_proto:: tonic:: logs:: v1:: LogsData ;
28
- use opentelemetry_proto:: tonic:: metrics:: v1:: MetricsData ;
29
- use opentelemetry_proto:: tonic:: trace:: v1:: TracesData ;
30
27
use serde_json:: Value ;
31
28
32
29
use crate :: event:: error:: EventError ;
33
30
use crate :: event:: format:: { self , EventFormat , LogSource } ;
34
31
use crate :: handlers:: { LOG_SOURCE_KEY , STREAM_NAME_HEADER_KEY } ;
35
32
use crate :: metadata:: SchemaVersion ;
36
33
use crate :: option:: Mode ;
37
- use crate :: otel:: logs:: flatten_otel_logs;
38
- use crate :: otel:: metrics:: flatten_otel_metrics;
39
- use crate :: otel:: traces:: flatten_otel_traces;
40
34
use crate :: parseable:: { StreamNotFound , PARSEABLE } ;
41
35
use crate :: storage:: { ObjectStorageError , StreamType } ;
42
36
use crate :: utils:: header_parsing:: ParseHeaderError ;
43
37
use crate :: utils:: json:: flatten:: JsonFlattenError ;
44
38
use crate :: { event, LOCK_EXPECT } ;
45
39
46
40
use super :: logstream:: error:: { CreateStreamError , StreamError } ;
47
- use super :: modal:: utils:: ingest_utils:: { flatten_and_push_logs, push_logs } ;
41
+ use super :: modal:: utils:: ingest_utils:: flatten_and_push_logs;
48
42
use super :: users:: dashboards:: DashboardError ;
49
43
use super :: users:: filters:: FiltersError ;
50
44
@@ -70,6 +64,14 @@ pub async fn ingest(req: HttpRequest, Json(json): Json<Value>) -> Result<HttpRes
70
64
. get ( LOG_SOURCE_KEY )
71
65
. and_then ( |h| h. to_str ( ) . ok ( ) )
72
66
. map_or ( LogSource :: default ( ) , LogSource :: from) ;
67
+
68
+ if matches ! (
69
+ log_source,
70
+ LogSource :: OtelLogs | LogSource :: OtelMetrics | LogSource :: OtelTraces
71
+ ) {
72
+ return Err ( PostError :: OtelNotSupported ) ;
73
+ }
74
+
73
75
flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
74
76
75
77
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
@@ -133,11 +135,7 @@ pub async fn handle_otel_logs_ingestion(
133
135
. create_stream_if_not_exists ( & stream_name, StreamType :: UserDefined , LogSource :: OtelLogs )
134
136
. await ?;
135
137
136
- //custom flattening required for otel logs
137
- let logs: LogsData = serde_json:: from_value ( json) ?;
138
- for record in flatten_otel_logs ( & logs) {
139
- push_logs ( & stream_name, record, & log_source) . await ?;
140
- }
138
+ flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
141
139
142
140
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
143
141
}
@@ -168,11 +166,7 @@ pub async fn handle_otel_metrics_ingestion(
168
166
)
169
167
. await ?;
170
168
171
- //custom flattening required for otel metrics
172
- let metrics: MetricsData = serde_json:: from_value ( json) ?;
173
- for record in flatten_otel_metrics ( metrics) {
174
- push_logs ( & stream_name, record, & log_source) . await ?;
175
- }
169
+ flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
176
170
177
171
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
178
172
}
@@ -200,11 +194,7 @@ pub async fn handle_otel_traces_ingestion(
200
194
. create_stream_if_not_exists ( & stream_name, StreamType :: UserDefined , LogSource :: OtelTraces )
201
195
. await ?;
202
196
203
- //custom flattening required for otel traces
204
- let traces: TracesData = serde_json:: from_value ( json) ?;
205
- for record in flatten_otel_traces ( & traces) {
206
- push_logs ( & stream_name, record, & log_source) . await ?;
207
- }
197
+ flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
208
198
209
199
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
210
200
}
@@ -245,6 +235,14 @@ pub async fn post_event(
245
235
. get ( LOG_SOURCE_KEY )
246
236
. and_then ( |h| h. to_str ( ) . ok ( ) )
247
237
. map_or ( LogSource :: default ( ) , LogSource :: from) ;
238
+
239
+ if matches ! (
240
+ log_source,
241
+ LogSource :: OtelLogs | LogSource :: OtelMetrics | LogSource :: OtelTraces
242
+ ) {
243
+ return Err ( PostError :: OtelNotSupported ) ;
244
+ }
245
+
248
246
flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
249
247
250
248
Ok ( HttpResponse :: Ok ( ) . finish ( ) )
0 commit comments