Skip to content

Commit 83bd797

Browse files
authored
chore(core): Allow log events to have a non-object root value (#12705)
1 parent cf08648 commit 83bd797

File tree

64 files changed

+887
-1576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+887
-1576
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benches/event.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn benchmark_event_iterate(c: &mut Criterion) {
2222
"key3": "value3"
2323
}))
2424
},
25-
|e| e.all_fields().count(),
25+
|e| e.all_fields().unwrap().count(),
2626
BatchSize::SmallInput,
2727
)
2828
});
@@ -40,7 +40,7 @@ fn benchmark_event_iterate(c: &mut Criterion) {
4040
"key3": "value3"
4141
}))
4242
},
43-
|e| e.all_fields().count(),
43+
|e| e.all_fields().unwrap().count(),
4444
BatchSize::SmallInput,
4545
)
4646
});
@@ -57,7 +57,7 @@ fn benchmark_event_iterate(c: &mut Criterion) {
5757
},
5858
}))
5959
},
60-
|e| e.all_fields().count(),
60+
|e| e.all_fields().unwrap().count(),
6161
BatchSize::SmallInput,
6262
)
6363
});

benches/transform/route.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn route(c: &mut Criterion) {
4242
] {
4343
fields.insert(String::from(alpha), Value::Bytes(Bytes::from(alpha)));
4444
}
45-
let event = Event::from(LogEvent::from_parts(fields, EventMetadata::default()));
45+
let event = Event::from(LogEvent::from_map(fields, EventMetadata::default()));
4646

4747
let mut outputs = Vec::new();
4848
for name in [

lib/codecs/src/encoding/format/logfmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Encoder<Event> for LogfmtSerializer {
4848

4949
fn encode(&mut self, event: Event, buffer: &mut BytesMut) -> Result<(), Self::Error> {
5050
let log = event.as_log();
51-
let string = encode_logfmt::to_string(log.as_map())?;
51+
let string = encode_logfmt::encode_value(log.value())?;
5252
buffer.extend_from_slice(string.as_bytes());
5353

5454
Ok(())

lib/lookup/src/lookup_v2/mod.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
mod jit;
2-
32
use std::borrow::Cow;
43
use std::iter::Cloned;
54
use std::slice::Iter;
@@ -230,6 +229,12 @@ impl<'a> From<&'a str> for BorrowedSegment<'a> {
230229
}
231230
}
232231

232+
impl<'a> From<&'a String> for BorrowedSegment<'a> {
233+
fn from(field: &'a String) -> Self {
234+
BorrowedSegment::field(field.as_str())
235+
}
236+
}
237+
233238
impl From<usize> for BorrowedSegment<'_> {
234239
fn from(index: usize) -> Self {
235240
BorrowedSegment::index(index)
@@ -306,6 +311,29 @@ impl<'a> From<BorrowedSegment<'a>> for OwnedSegment {
306311
}
307312
}
308313

314+
#[cfg(any(test, feature = "arbitrary"))]
315+
impl quickcheck::Arbitrary for BorrowedSegment<'static> {
316+
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
317+
match usize::arbitrary(g) % 2 {
318+
0 => BorrowedSegment::Index(usize::arbitrary(g) % 20),
319+
_ => BorrowedSegment::Field(String::arbitrary(g).into()),
320+
}
321+
}
322+
323+
fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
324+
match self {
325+
BorrowedSegment::Invalid => Box::new(std::iter::empty()),
326+
BorrowedSegment::Index(index) => Box::new(index.shrink().map(BorrowedSegment::Index)),
327+
BorrowedSegment::Field(field) => Box::new(
328+
field
329+
.to_string()
330+
.shrink()
331+
.map(|f| BorrowedSegment::Field(f.into())),
332+
),
333+
}
334+
}
335+
}
336+
309337
#[cfg(test)]
310338
mod test {
311339
use super::*;

lib/prometheus-parser/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ prost = "0.10.3"
1616
prost-types = "0.10.1"
1717
snafu = { version = "0.7" }
1818
vector_common = { path = "../vector-common", features = ["btreemap"] }
19+
value = { path = "../value", features = ["json"] }
1920

2021
[build-dependencies]
2122
prost-build = "0.10.3"

lib/value/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ test = []
3232
arbitrary = ["quickcheck"]
3333

3434
[dev-dependencies]
35+
async-graphql = { version = "3.0.38", default-features = false }
3536
indoc = { version = "1.0.6", default-features = false }
3637
quickcheck = "1.0.3"
3738
lookup = { path = "../lookup", default-features = false, features = ["arbitrary"] }
39+
serde = { version = "1.0.137", default-features = false, features = ["derive", "rc"]}
40+
serde_json = { version = "1.0.81"}
41+
toml = { version = "0.5.9", default-features = false }
42+
mlua = { version = "0.7.4", default-features = false, features = ["lua54", "send", "vendored"]}

0 commit comments

Comments
 (0)