1
- use lookup:: lookup_v2:: { OptionalTargetPath , OptionalValuePath } ;
1
+ use lookup:: lookup_v2:: OptionalTargetPath ;
2
2
use lookup:: { OwnedTargetPath , OwnedValuePath } ;
3
3
use once_cell:: sync:: { Lazy , OnceCell } ;
4
4
use vector_config:: configurable_component;
5
- use vrl:: path:: PathPrefix ;
6
5
7
6
static LOG_SCHEMA : OnceCell < LogSchema > = OnceCell :: new ( ) ;
8
7
static LOG_SCHEMA_DEFAULT : Lazy < LogSchema > = Lazy :: new ( LogSchema :: default) ;
@@ -74,7 +73,7 @@ pub struct LogSchema {
74
73
/// Generally, this field will be set by Vector to hold event-specific metadata, such as
75
74
/// annotations by the `remap` transform when an error or abort is encountered.
76
75
#[ serde( default = "LogSchema::default_metadata_key" ) ]
77
- metadata_key : OptionalValuePath ,
76
+ metadata_key : OptionalTargetPath ,
78
77
}
79
78
80
79
impl Default for LogSchema {
@@ -106,8 +105,8 @@ impl LogSchema {
106
105
OptionalTargetPath :: event ( SOURCE_TYPE )
107
106
}
108
107
109
- fn default_metadata_key ( ) -> OptionalValuePath {
110
- OptionalValuePath :: new ( METADATA )
108
+ fn default_metadata_key ( ) -> OptionalTargetPath {
109
+ OptionalTargetPath :: event ( METADATA )
111
110
}
112
111
113
112
pub fn message_key ( & self ) -> Option < & OwnedValuePath > {
@@ -140,7 +139,7 @@ impl LogSchema {
140
139
}
141
140
142
141
pub fn metadata_key ( & self ) -> Option < & OwnedValuePath > {
143
- self . metadata_key . path . as_ref ( )
142
+ self . metadata_key . as_ref ( ) . map ( |key| & key . path )
144
143
}
145
144
146
145
pub fn message_key_target_path ( & self ) -> Option < & OwnedTargetPath > {
@@ -159,24 +158,28 @@ impl LogSchema {
159
158
self . source_type_key . as_ref ( )
160
159
}
161
160
162
- pub fn set_message_key ( & mut self , path : Option < OwnedValuePath > ) {
163
- self . message_key = OptionalTargetPath :: from ( PathPrefix :: Event , path ) ;
161
+ pub fn metadata_key_target_path ( & self ) -> Option < & OwnedTargetPath > {
162
+ self . metadata_key . as_ref ( )
164
163
}
165
164
166
- pub fn set_timestamp_key ( & mut self , path : Option < OwnedValuePath > ) {
167
- self . timestamp_key = OptionalTargetPath :: from ( PathPrefix :: Event , path) ;
165
+ pub fn set_message_key ( & mut self , path : Option < OwnedTargetPath > ) {
166
+ self . message_key = OptionalTargetPath { path } ;
168
167
}
169
168
170
- pub fn set_host_key ( & mut self , path : Option < OwnedValuePath > ) {
171
- self . host_key = OptionalTargetPath :: from ( PathPrefix :: Event , path) ;
169
+ pub fn set_timestamp_key ( & mut self , path : Option < OwnedTargetPath > ) {
170
+ self . timestamp_key = OptionalTargetPath { path } ;
172
171
}
173
172
174
- pub fn set_source_type_key ( & mut self , path : Option < OwnedValuePath > ) {
175
- self . source_type_key = OptionalTargetPath :: from ( PathPrefix :: Event , path) ;
173
+ pub fn set_host_key ( & mut self , path : Option < OwnedTargetPath > ) {
174
+ self . host_key = OptionalTargetPath { path } ;
176
175
}
177
176
178
- pub fn set_metadata_key ( & mut self , path : Option < OwnedValuePath > ) {
179
- self . metadata_key = OptionalValuePath { path } ;
177
+ pub fn set_source_type_key ( & mut self , path : Option < OwnedTargetPath > ) {
178
+ self . source_type_key = OptionalTargetPath { path } ;
179
+ }
180
+
181
+ pub fn set_metadata_key ( & mut self , path : Option < OwnedTargetPath > ) {
182
+ self . metadata_key = OptionalTargetPath { path } ;
180
183
}
181
184
182
185
/// Merge two `LogSchema` instances together.
@@ -195,35 +198,35 @@ impl LogSchema {
195
198
{
196
199
errors. push ( "conflicting values for 'log_schema.host_key' found" . to_owned ( ) ) ;
197
200
} else {
198
- self . set_host_key ( other. host_key ( ) . cloned ( ) ) ;
201
+ self . set_host_key ( other. host_key_target_path ( ) . cloned ( ) ) ;
199
202
}
200
203
if self . message_key ( ) != LOG_SCHEMA_DEFAULT . message_key ( )
201
204
&& self . message_key ( ) != other. message_key ( )
202
205
{
203
206
errors. push ( "conflicting values for 'log_schema.message_key' found" . to_owned ( ) ) ;
204
207
} else {
205
- self . set_message_key ( other. message_key ( ) . cloned ( ) ) ;
208
+ self . set_message_key ( other. message_key_target_path ( ) . cloned ( ) ) ;
206
209
}
207
210
if self . timestamp_key ( ) != LOG_SCHEMA_DEFAULT . timestamp_key ( )
208
211
&& self . timestamp_key ( ) != other. timestamp_key ( )
209
212
{
210
213
errors. push ( "conflicting values for 'log_schema.timestamp_key' found" . to_owned ( ) ) ;
211
214
} else {
212
- self . set_timestamp_key ( other. timestamp_key ( ) . cloned ( ) ) ;
215
+ self . set_timestamp_key ( other. timestamp_key_target_path ( ) . cloned ( ) ) ;
213
216
}
214
217
if self . source_type_key ( ) != LOG_SCHEMA_DEFAULT . source_type_key ( )
215
218
&& self . source_type_key ( ) != other. source_type_key ( )
216
219
{
217
220
errors. push ( "conflicting values for 'log_schema.source_type_key' found" . to_owned ( ) ) ;
218
221
} else {
219
- self . set_source_type_key ( other. source_type_key ( ) . cloned ( ) ) ;
222
+ self . set_source_type_key ( other. source_type_key_target_path ( ) . cloned ( ) ) ;
220
223
}
221
224
if self . metadata_key ( ) != LOG_SCHEMA_DEFAULT . metadata_key ( )
222
225
&& self . metadata_key ( ) != other. metadata_key ( )
223
226
{
224
227
errors. push ( "conflicting values for 'log_schema.metadata_key' found" . to_owned ( ) ) ;
225
228
} else {
226
- self . set_metadata_key ( other. metadata_key ( ) . cloned ( ) ) ;
229
+ self . set_metadata_key ( other. metadata_key_target_path ( ) . cloned ( ) ) ;
227
230
}
228
231
}
229
232
0 commit comments