@@ -7,8 +7,7 @@ use std::{
7
7
} ;
8
8
9
9
use codecs:: MetricTagValues ;
10
- use lookup:: lookup_v2:: { parse_value_path, ValuePath } ;
11
- use lookup:: { metadata_path, owned_value_path, path, PathPrefix } ;
10
+ use lookup:: { metadata_path, owned_value_path, PathPrefix } ;
12
11
use snafu:: { ResultExt , Snafu } ;
13
12
use vector_common:: TimeZone ;
14
13
use vector_config:: configurable_component;
@@ -20,6 +19,8 @@ use vrl::compiler::runtime::{Runtime, Terminate};
20
19
use vrl:: compiler:: state:: ExternalEnv ;
21
20
use vrl:: compiler:: { CompileConfig , ExpressionError , Function , Program , TypeState , VrlRuntime } ;
22
21
use vrl:: diagnostic:: { DiagnosticMessage , Formatter , Note } ;
22
+ use vrl:: path;
23
+ use vrl:: path:: ValuePath ;
23
24
use vrl:: value:: { Kind , Value } ;
24
25
25
26
use crate :: config:: OutputId ;
@@ -288,7 +289,7 @@ impl TransformConfig for RemapConfig {
288
289
let dropped_definition = Definition :: combine_log_namespaces (
289
290
input_definition. log_namespaces ( ) ,
290
291
input_definition. clone ( ) . with_event_field (
291
- & parse_value_path ( log_schema ( ) . metadata_key ( ) ) . expect ( "valid metadata key" ) ,
292
+ log_schema ( ) . metadata_key ( ) . expect ( "valid metadata key" ) ,
292
293
Kind :: object ( BTreeMap :: from ( [
293
294
( "reason" . into ( ) , Kind :: bytes ( ) ) ,
294
295
( "message" . into ( ) , Kind :: bytes ( ) ) ,
@@ -451,13 +452,12 @@ where
451
452
match event {
452
453
Event :: Log ( ref mut log) => match log. namespace ( ) {
453
454
LogNamespace :: Legacy => {
454
- log. insert (
455
- (
456
- PathPrefix :: Event ,
457
- log_schema ( ) . metadata_key ( ) . concat ( path ! ( "dropped" ) ) ,
458
- ) ,
459
- self . dropped_data ( reason, error) ,
460
- ) ;
455
+ if let Some ( metadata_key) = log_schema ( ) . metadata_key ( ) {
456
+ log. insert (
457
+ ( PathPrefix :: Event , metadata_key. concat ( path ! ( "dropped" ) ) ) ,
458
+ self . dropped_data ( reason, error) ,
459
+ ) ;
460
+ }
461
461
}
462
462
LogNamespace :: Vector => {
463
463
log. insert (
@@ -467,23 +467,29 @@ where
467
467
}
468
468
} ,
469
469
Event :: Metric ( ref mut metric) => {
470
- let m = log_schema ( ) . metadata_key ( ) ;
471
- metric. replace_tag ( format ! ( "{}.dropped.reason" , m) , reason. into ( ) ) ;
472
- metric. replace_tag (
473
- format ! ( "{}.dropped.component_id" , m) ,
474
- self . component_key
475
- . as_ref ( )
476
- . map ( ToString :: to_string)
477
- . unwrap_or_else ( String :: new) ,
478
- ) ;
479
- metric. replace_tag ( format ! ( "{}.dropped.component_type" , m) , "remap" . into ( ) ) ;
480
- metric. replace_tag ( format ! ( "{}.dropped.component_kind" , m) , "transform" . into ( ) ) ;
470
+ if let Some ( metadata_key) = log_schema ( ) . metadata_key ( ) {
471
+ metric. replace_tag ( format ! ( "{}.dropped.reason" , metadata_key) , reason. into ( ) ) ;
472
+ metric. replace_tag (
473
+ format ! ( "{}.dropped.component_id" , metadata_key) ,
474
+ self . component_key
475
+ . as_ref ( )
476
+ . map ( ToString :: to_string)
477
+ . unwrap_or_else ( String :: new) ,
478
+ ) ;
479
+ metric. replace_tag (
480
+ format ! ( "{}.dropped.component_type" , metadata_key) ,
481
+ "remap" . into ( ) ,
482
+ ) ;
483
+ metric. replace_tag (
484
+ format ! ( "{}.dropped.component_kind" , metadata_key) ,
485
+ "transform" . into ( ) ,
486
+ ) ;
487
+ }
481
488
}
482
489
Event :: Trace ( ref mut trace) => {
483
- trace. insert (
484
- log_schema ( ) . metadata_key ( ) ,
485
- self . dropped_data ( reason, error) ,
486
- ) ;
490
+ trace. maybe_insert ( PathPrefix :: Event , log_schema ( ) . metadata_key ( ) , || {
491
+ self . dropped_data ( reason, error) . into ( )
492
+ } ) ;
487
493
}
488
494
}
489
495
}
0 commit comments