File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -195,8 +195,15 @@ pub fn v5_v6(mut stream_metadata: Value) -> Value {
195
195
let mut log_source_entry = LogSourceEntry :: default ( ) ;
196
196
match log_source {
197
197
Some ( stream_log_source) => {
198
- let log_source: LogSource = serde_json:: from_value ( stream_log_source. clone ( ) ) . unwrap ( ) ;
199
- log_source_entry. add_log_source ( log_source, HashSet :: new ( ) ) ;
198
+ if let Ok ( log_source) = serde_json:: from_value :: < LogSource > ( stream_log_source. clone ( ) ) {
199
+ log_source_entry. add_log_source ( log_source, HashSet :: new ( ) ) ;
200
+ } else {
201
+ // If deserialization fails, use default
202
+ stream_metadata_map. insert (
203
+ "log_source" . to_owned ( ) ,
204
+ LogSourceEntry :: default ( ) . to_value ( ) ,
205
+ ) ;
206
+ }
200
207
stream_metadata_map. insert ( "log_source" . to_owned ( ) , log_source_entry. to_value ( ) ) ;
201
208
}
202
209
None => {
Original file line number Diff line number Diff line change @@ -686,10 +686,20 @@ impl Stream {
686
686
687
687
pub fn add_log_source ( & self , log_source : LogSourceEntry ) {
688
688
let mut metadata = self . metadata . write ( ) . expect ( LOCK_EXPECT ) ;
689
+ // Check if this log source format already exists
690
+ for existing in & metadata. log_source {
691
+ if existing. log_source_format == log_source. log_source_format {
692
+ self . add_fields_to_log_source (
693
+ & log_source. log_source_format ,
694
+ log_source. fields . clone ( ) ,
695
+ ) ;
696
+ return ;
697
+ }
698
+ }
689
699
metadata. log_source . push ( log_source) ;
690
700
}
691
701
692
- pub fn add_fields_to_log_source ( & self , log_source : & LogSource , fields : Vec < String > ) {
702
+ pub fn add_fields_to_log_source ( & self , log_source : & LogSource , fields : HashSet < String > ) {
693
703
let mut metadata = self . metadata . write ( ) . expect ( LOCK_EXPECT ) ;
694
704
for log_source_entry in metadata. log_source . iter_mut ( ) {
695
705
if log_source_entry. log_source_format == * log_source {
You can’t perform that action at this time.
0 commit comments