1616 *
1717 */
1818
19- use std:: collections:: HashMap ;
19+ use std:: collections:: { HashMap , HashSet } ;
2020
2121use actix_web:: web:: { Json , Path } ;
2222use actix_web:: { http:: header:: ContentType , HttpRequest , HttpResponse } ;
@@ -28,10 +28,13 @@ use serde_json::Value;
2828
2929use crate :: event;
3030use crate :: event:: error:: EventError ;
31- use crate :: event:: format:: { self , EventFormat , LogSource } ;
31+ use crate :: event:: format:: { self , EventFormat , LogSource , LogSourceEntry } ;
3232use crate :: handlers:: { LOG_SOURCE_KEY , STREAM_NAME_HEADER_KEY } ;
3333use crate :: metadata:: SchemaVersion ;
3434use crate :: option:: Mode ;
35+ use crate :: otel:: logs:: OTEL_LOG_KNOWN_FIELD_LIST ;
36+ use crate :: otel:: metrics:: OTEL_METRICS_KNOWN_FIELD_LIST ;
37+ use crate :: otel:: traces:: OTEL_TRACES_KNOWN_FIELD_LIST ;
3538use crate :: parseable:: { StreamNotFound , PARSEABLE } ;
3639use crate :: storage:: { ObjectStorageError , StreamType } ;
3740use crate :: utils:: header_parsing:: ParseHeaderError ;
@@ -55,9 +58,6 @@ pub async fn ingest(req: HttpRequest, Json(json): Json<Value>) -> Result<HttpRes
5558 if internal_stream_names. contains ( & stream_name) {
5659 return Err ( PostError :: InternalStream ( stream_name) ) ;
5760 }
58- PARSEABLE
59- . create_stream_if_not_exists ( & stream_name, StreamType :: UserDefined , LogSource :: default ( ) )
60- . await ?;
6161
6262 let log_source = req
6363 . headers ( )
@@ -72,6 +72,15 @@ pub async fn ingest(req: HttpRequest, Json(json): Json<Value>) -> Result<HttpRes
7272 return Err ( PostError :: OtelNotSupported ) ;
7373 }
7474
75+ let log_source_entry = LogSourceEntry :: new ( log_source. clone ( ) , HashSet :: new ( ) ) ;
76+ PARSEABLE
77+ . create_stream_if_not_exists (
78+ & stream_name,
79+ StreamType :: UserDefined ,
80+ vec ! [ log_source_entry] ,
81+ )
82+ . await ?;
83+
7584 flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
7685
7786 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
@@ -119,8 +128,20 @@ pub async fn handle_otel_logs_ingestion(
119128 }
120129
121130 let stream_name = stream_name. to_str ( ) . unwrap ( ) . to_owned ( ) ;
131+
132+ let log_source_entry = LogSourceEntry :: new (
133+ log_source. clone ( ) ,
134+ OTEL_LOG_KNOWN_FIELD_LIST
135+ . iter ( )
136+ . map ( |& s| s. to_string ( ) )
137+ . collect ( ) ,
138+ ) ;
122139 PARSEABLE
123- . create_stream_if_not_exists ( & stream_name, StreamType :: UserDefined , LogSource :: OtelLogs )
140+ . create_stream_if_not_exists (
141+ & stream_name,
142+ StreamType :: UserDefined ,
143+ vec ! [ log_source_entry] ,
144+ )
124145 . await ?;
125146
126147 flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
@@ -146,11 +167,18 @@ pub async fn handle_otel_metrics_ingestion(
146167 return Err ( PostError :: IncorrectLogSource ( LogSource :: OtelMetrics ) ) ;
147168 }
148169 let stream_name = stream_name. to_str ( ) . unwrap ( ) . to_owned ( ) ;
170+ let log_source_entry = LogSourceEntry :: new (
171+ log_source. clone ( ) ,
172+ OTEL_METRICS_KNOWN_FIELD_LIST
173+ . iter ( )
174+ . map ( |& s| s. to_string ( ) )
175+ . collect ( ) ,
176+ ) ;
149177 PARSEABLE
150178 . create_stream_if_not_exists (
151179 & stream_name,
152180 StreamType :: UserDefined ,
153- LogSource :: OtelMetrics ,
181+ vec ! [ log_source_entry ] ,
154182 )
155183 . await ?;
156184
@@ -178,8 +206,20 @@ pub async fn handle_otel_traces_ingestion(
178206 return Err ( PostError :: IncorrectLogSource ( LogSource :: OtelTraces ) ) ;
179207 }
180208 let stream_name = stream_name. to_str ( ) . unwrap ( ) . to_owned ( ) ;
209+ let log_source_entry = LogSourceEntry :: new (
210+ log_source. clone ( ) ,
211+ OTEL_TRACES_KNOWN_FIELD_LIST
212+ . iter ( )
213+ . map ( |& s| s. to_string ( ) )
214+ . collect ( ) ,
215+ ) ;
216+
181217 PARSEABLE
182- . create_stream_if_not_exists ( & stream_name, StreamType :: UserDefined , LogSource :: OtelTraces )
218+ . create_stream_if_not_exists (
219+ & stream_name,
220+ StreamType :: UserDefined ,
221+ vec ! [ log_source_entry] ,
222+ )
183223 . await ?;
184224
185225 flatten_and_push_logs ( json, & stream_name, & log_source) . await ?;
0 commit comments