Skip to content

Commit 5771c7e

Browse files
reuse setup otel content
1 parent 1f0c726 commit 5771c7e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/handlers/http/ingest.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub async fn setup_otel_stream(
160160
expected_log_source: LogSource,
161161
known_fields: &[&str],
162162
telemetry_type: TelemetryType,
163-
) -> Result<(String, LogSource, LogSourceEntry), PostError> {
163+
) -> Result<(String, LogSource, LogSourceEntry, Option<String>), PostError> {
164164
let Some(stream_name) = req.headers().get(STREAM_NAME_HEADER_KEY) else {
165165
return Err(PostError::Header(ParseHeaderError::MissingStreamName));
166166
};
@@ -190,7 +190,7 @@ pub async fn setup_otel_stream(
190190
telemetry_type,
191191
)
192192
.await?;
193-
193+
let mut time_partition = None;
194194
// Validate stream compatibility
195195
if let Ok(stream) = PARSEABLE.get_stream(&stream_name) {
196196
match log_source {
@@ -217,13 +217,15 @@ pub async fn setup_otel_stream(
217217
}
218218
_ => {}
219219
}
220+
221+
time_partition = stream.get_time_partition();
220222
}
221223

222224
PARSEABLE
223225
.add_update_log_source(&stream_name, log_source_entry.clone())
224226
.await?;
225227

226-
Ok((stream_name, log_source, log_source_entry))
228+
Ok((stream_name, log_source, log_source_entry, time_partition))
227229
}
228230

229231
// Common content processing for OTEL ingestion
@@ -278,7 +280,7 @@ pub async fn handle_otel_logs_ingestion(
278280
req: HttpRequest,
279281
body: web::Bytes,
280282
) -> Result<HttpResponse, PostError> {
281-
let (stream_name, log_source, _) = setup_otel_stream(
283+
let (stream_name, log_source, _, _) = setup_otel_stream(
282284
&req,
283285
LogSource::OtelLogs,
284286
&OTEL_LOG_KNOWN_FIELD_LIST,
@@ -298,7 +300,7 @@ pub async fn handle_otel_metrics_ingestion(
298300
req: HttpRequest,
299301
body: web::Bytes,
300302
) -> Result<HttpResponse, PostError> {
301-
let (stream_name, log_source, _) = setup_otel_stream(
303+
let (stream_name, log_source, _, _) = setup_otel_stream(
302304
&req,
303305
LogSource::OtelMetrics,
304306
&OTEL_METRICS_KNOWN_FIELD_LIST,
@@ -318,7 +320,7 @@ pub async fn handle_otel_traces_ingestion(
318320
req: HttpRequest,
319321
body: web::Bytes,
320322
) -> Result<HttpResponse, PostError> {
321-
let (stream_name, log_source, _) = setup_otel_stream(
323+
let (stream_name, log_source, _, _) = setup_otel_stream(
322324
&req,
323325
LogSource::OtelTraces,
324326
&OTEL_TRACES_KNOWN_FIELD_LIST,

0 commit comments

Comments
 (0)