Skip to content

Commit

Permalink
validate log source header key and value for otel ingestion
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsinhaparseable committed Dec 8, 2024
1 parent a51d8c3 commit 7db6d27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/handlers/http/ingest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::event::{
format::{self, EventFormat},
};
use crate::handlers::http::modal::utils::logstream_utils::create_stream_and_schema_from_storage;
use crate::handlers::STREAM_NAME_HEADER_KEY;
use crate::handlers::{LOG_SOURCE_KEY, LOG_SOURCE_OTEL, STREAM_NAME_HEADER_KEY};
use crate::localcache::CacheError;
use crate::metadata::error::stream_info::MetadataError;
use crate::metadata::STREAM_INFO;
Expand Down Expand Up @@ -116,9 +116,21 @@ pub async fn handle_otel_ingestion(
.find(|&(key, _)| key == STREAM_NAME_HEADER_KEY)
{
let stream_name = stream_name.to_str().unwrap().to_owned();
create_stream_if_not_exists(&stream_name, &StreamType::UserDefined.to_string(), "otel")
if req
.headers()
.iter()
.any(|(key, value)| key == LOG_SOURCE_KEY && value == LOG_SOURCE_OTEL)
{
create_stream_if_not_exists(
&stream_name,
&StreamType::UserDefined.to_string(),
LOG_SOURCE_OTEL,
)
.await?;
push_logs(&stream_name, req.clone(), body).await?;
push_logs(&stream_name, req.clone(), body).await?;
} else {
return Err(PostError::CustomError("Unknown log source".to_string()));
}
} else {
return Err(PostError::Header(ParseHeaderError::MissingStreamName));
}
Expand Down
1 change: 0 additions & 1 deletion src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ impl StreamInfo {
})
}

#[allow(dead_code)]
pub fn set_schema_type(
&self,
stream_name: &str,
Expand Down

0 comments on commit 7db6d27

Please sign in to comment.