1717 */
1818
1919use super :: logstream:: error:: { CreateStreamError , StreamError } ;
20- use super :: modal:: utils:: ingest_utils:: { flatten_and_push_logs, push_logs } ;
20+ use super :: modal:: utils:: ingest_utils:: flatten_and_push_logs;
2121use super :: users:: dashboards:: DashboardError ;
2222use super :: users:: filters:: FiltersError ;
2323use crate :: event:: format:: LogSource ;
@@ -31,9 +31,6 @@ use crate::handlers::{LOG_SOURCE_KEY, STREAM_NAME_HEADER_KEY};
3131use crate :: metadata:: error:: stream_info:: MetadataError ;
3232use crate :: metadata:: { SchemaVersion , STREAM_INFO } ;
3333use crate :: option:: { Mode , CONFIG } ;
34- use crate :: otel:: logs:: flatten_otel_logs;
35- use crate :: otel:: metrics:: flatten_otel_metrics;
36- use crate :: otel:: traces:: flatten_otel_traces;
3734use crate :: storage:: { ObjectStorageError , StreamType } ;
3835use crate :: utils:: header_parsing:: ParseHeaderError ;
3936use crate :: utils:: json:: flatten:: JsonFlattenError ;
@@ -44,9 +41,6 @@ use arrow_schema::Schema;
4441use bytes:: Bytes ;
4542use chrono:: Utc ;
4643use http:: StatusCode ;
47- use opentelemetry_proto:: tonic:: logs:: v1:: LogsData ;
48- use opentelemetry_proto:: tonic:: metrics:: v1:: MetricsData ;
49- use opentelemetry_proto:: tonic:: trace:: v1:: TracesData ;
5044use serde_json:: Value ;
5145use std:: collections:: HashMap ;
5246use std:: sync:: Arc ;
@@ -130,11 +124,7 @@ pub async fn handle_otel_logs_ingestion(
130124 let stream_name = stream_name. to_str ( ) . unwrap ( ) . to_owned ( ) ;
131125 create_stream_if_not_exists ( & stream_name, StreamType :: UserDefined , LogSource :: OtelLogs ) . await ?;
132126
133- //custom flattening required for otel logs
134- let logs: LogsData = serde_json:: from_value ( json) ?;
135- for record in flatten_otel_logs ( & logs) {
136- push_logs ( & stream_name, record, & log_source) . await ?;
137- }
127+ flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
138128
139129 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
140130}
@@ -164,11 +154,7 @@ pub async fn handle_otel_metrics_ingestion(
164154 )
165155 . await ?;
166156
167- //custom flattening required for otel metrics
168- let metrics: MetricsData = serde_json:: from_value ( json) ?;
169- for record in flatten_otel_metrics ( metrics) {
170- push_logs ( & stream_name, record, & log_source) . await ?;
171- }
157+ flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
172158
173159 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
174160}
@@ -195,11 +181,7 @@ pub async fn handle_otel_traces_ingestion(
195181 create_stream_if_not_exists ( & stream_name, StreamType :: UserDefined , LogSource :: OtelTraces )
196182 . await ?;
197183
198- //custom flattening required for otel traces
199- let traces: TracesData = serde_json:: from_value ( json) ?;
200- for record in flatten_otel_traces ( & traces) {
201- push_logs ( & stream_name, record, & log_source) . await ?;
202- }
184+ flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
203185
204186 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
205187}
0 commit comments