Skip to content

Commit 9a9340a

Browse files
chore(sinks, codecs): Remove legacy EncodingConfiguration (#13518)
* Remove legacy `EncodingConfiguration` * Upgrade usage of `encoding` in docs and examples * Refactor inferring `Framer` based on sink type * Fix cue formatting * Remove obsolete `encode_log` bench * Fix invalid usage of `encoding` in HTTP >source< * Remove dead code * Revert changes to highlight to be compatible with version in that context * Add breaking changes to upgrade guide * Fix `decoding` config for HTTP source in soaks * Remove unnecessary namespace * Improve wording/formatting in upgrade guide * Remove TLD from links Signed-off-by: Pablo Sichert <[email protected]> Co-authored-by: Jesse Szwedko <[email protected]>
1 parent 7cc3a80 commit 9a9340a

File tree

143 files changed

+2219
-4308
lines changed

Some content is hidden

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

143 files changed

+2219
-4308
lines changed

benches/codecs/encoder.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ fn encoder(c: &mut Criterion) {
4848
"key3" => "value3"
4949
}));
5050

51-
group.throughput(Throughput::Bytes(input.size_of() as u64));
52-
group.bench_with_input("vector::sinks::util::encode_log", &(), |b, ()| {
53-
b.iter_batched(
54-
|| vector::sinks::util::Encoding::Json.into(),
55-
|encoding| {
56-
vector::sinks::util::encode_log(input.clone(), &encoding).unwrap();
57-
},
58-
BatchSize::SmallInput,
59-
)
60-
});
61-
6251
group.throughput(Throughput::Bytes(input.size_of() as u64));
6352
group.bench_with_input("JsonLogVecSerializer::encode", &(), |b, ()| {
6453
b.iter_batched(

benches/files.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{convert::TryInto, path::PathBuf};
22

33
use bytes::Bytes;
4+
use codecs::{encoding::FramingConfig, TextSerializerConfig};
45
use criterion::{criterion_group, BatchSize, Criterion, SamplingMode, Throughput};
56
use futures::{stream, SinkExt, StreamExt};
67
use tempfile::tempdir;
@@ -54,10 +55,7 @@ fn benchmark_files_no_partitions(c: &mut Criterion) {
5455
sinks::file::FileSinkConfig {
5556
path: output.try_into().unwrap(),
5657
idle_timeout_secs: None,
57-
encoding: sinks::util::encoding::EncodingConfig::from(
58-
sinks::file::Encoding::Text,
59-
)
60-
.into(),
58+
encoding: (None::<FramingConfig>, TextSerializerConfig::new()).into(),
6159
compression: sinks::file::Compression::None,
6260
acknowledgements: Default::default(),
6361
},

benches/http.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::net::SocketAddr;
22

3+
use codecs::{encoding::FramingConfig, TextSerializerConfig};
34
use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion, SamplingMode, Throughput};
45
use futures::TryFutureExt;
56
use hyper::{
@@ -9,7 +10,7 @@ use hyper::{
910
use tokio::runtime::Runtime;
1011
use vector::{
1112
config, sinks,
12-
sinks::util::{encoding::EncodingConfigWithFramingAdapter, BatchConfig, Compression},
13+
sinks::util::{BatchConfig, Compression},
1314
sources,
1415
test_util::{next_addr, random_lines, runtime, send_lines, start_topology, wait_for_tcp},
1516
Error,
@@ -53,9 +54,8 @@ fn benchmark_http(c: &mut Criterion) {
5354
auth: Default::default(),
5455
headers: Default::default(),
5556
batch,
56-
encoding: EncodingConfigWithFramingAdapter::legacy(
57-
sinks::http::Encoding::Text.into(),
58-
),
57+
encoding: (None::<FramingConfig>, TextSerializerConfig::new())
58+
.into(),
5959
request: Default::default(),
6060
tls: Default::default(),
6161
acknowledgements: Default::default(),

config/examples/docs_example.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ index = "vector-%Y-%m-%d" # daily indices
3232

3333
# Send structured data to a cost-effective long-term storage
3434
[sinks.s3_archives]
35-
inputs = ["apache_parser"] # don't sample for S3
36-
type = "aws_s3"
37-
region = "us-east-1"
38-
bucket = "my-log-archives"
39-
key_prefix = "date=%Y-%m-%d" # daily partitions, hive friendly format
40-
compression = "gzip" # compress final objects
41-
encoding = "ndjson" # new line delimited JSON
35+
inputs = ["apache_parser"] # don't sample for S3
36+
type = "aws_s3"
37+
region = "us-east-1"
38+
bucket = "my-log-archives"
39+
key_prefix = "date=%Y-%m-%d" # daily partitions, hive friendly format
40+
compression = "gzip" # compress final objects
41+
framing.method = "newline_delimited" # new line delimited...
42+
encoding.codec = "json" # ...JSON
4243
[sinks.s3_archives.batch]
43-
max_bytes = 10000000 # 10mb uncompressed
44+
max_bytes = 10000000 # 10mb uncompressed

config/examples/environment_variables.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ data_dir = "/var/lib/vector"
2828
# Print the data to STDOUT for inspection
2929
# Docs: https://vector.dev/docs/reference/sinks/console
3030
[sinks.out]
31-
inputs = ["add_host"]
32-
type = "console"
33-
encoding = "json"
31+
inputs = ["add_host"]
32+
type = "console"
33+
encoding.codec = "json"

config/examples/es_s3_hybrid.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ data_dir = "/var/lib/vector"
2626

2727
# Send structured data to S3, a durable long-term storage
2828
[sinks.s3_archives]
29-
inputs = ["apache_logs"] # don't sample
30-
type = "aws_s3"
31-
region = "us-east-1"
32-
bucket = "my_log_archives"
33-
encoding = "ndjson"
34-
compression = "gzip"
29+
inputs = ["apache_logs"] # don't sample
30+
type = "aws_s3"
31+
region = "us-east-1"
32+
bucket = "my_log_archives"
33+
framing.method = "newline_delimited"
34+
encoding.codec = "json"
35+
compression = "gzip"
3536
[sinks.s3_archives.batch]
36-
max_size = 10000000 # 10mb uncompressed
37+
max_size = 10000000 # 10mb uncompressed

config/examples/file_to_cloudwatch_metrics.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ tags = {method = "{{method}}", status = "{{status}}"}
3434
[sinks.console_metrics]
3535
inputs = ["log_to_metric"]
3636
type = "console"
37-
encoding = "json"
37+
encoding.codec = "json"
3838

3939
[sinks.console_logs]
4040
inputs = ["remap"]
4141
type = "console"
42-
encoding = "json"
42+
encoding.codec = "json"
4343

4444
[sinks.cloudwatch]
4545
inputs = ["log_to_metric"]

config/examples/file_to_prometheus.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ name = "bytes_out_histogram"
5151
[sinks.console_metrics]
5252
inputs = ["log_to_metric"]
5353
type = "console"
54-
encoding = "json"
54+
encoding.codec = "json"
5555

5656
[sinks.console_logs]
5757
inputs = ["remap"]
5858
type = "console"
59-
encoding = "text"
59+
encoding.codec = "text"
6060

6161
[sinks.prometheus]
6262
inputs = ["log_to_metric"]
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Send structured data to a cost-effective long-term storage
2-
inputs = ["apache_parser"] # don't sample for S3
3-
type = "aws_s3"
4-
region = "us-east-1"
5-
bucket = "my-log-archives"
6-
key_prefix = "date=%Y-%m-%d" # daily partitions, hive friendly format
7-
compression = "gzip" # compress final objects
8-
encoding = "ndjson" # new line delimited JSON
2+
inputs = ["apache_parser"] # don't sample for S3
3+
type = "aws_s3"
4+
region = "us-east-1"
5+
bucket = "my-log-archives"
6+
key_prefix = "date=%Y-%m-%d" # daily partitions, hive friendly format
7+
compression = "gzip" # compress final objects
8+
framing.method = "newline_delimited" # new line delimited...
9+
encoding.codec = "json" # ...JSON
910
[batch]
10-
max_bytes = 10000000 # 10mb uncompressed
11+
max_bytes = 10000000 # 10mb uncompressed

config/examples/prometheus_to_console.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ scrape_interval_secs = 2
1414
[sinks.console]
1515
inputs = ["prometheus"]
1616
type = "console"
17-
encoding = "json"
17+
encoding.codec = "json"

config/examples/stdio.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
[sinks.out]
1212
inputs = ["in"]
1313
type = "console"
14-
encoding = "text"
14+
encoding.codec = "text"

config/examples/wrapped_json.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ data_dir = "/var/lib/vector"
3434
# Print the data to STDOUT for inspection
3535
# Docs: https://vector.dev/docs/reference/sinks/console
3636
[sinks.out]
37-
inputs = ["parse_json"]
38-
type = "console"
39-
encoding = "json"
37+
inputs = ["parse_json"]
38+
type = "console"
39+
encoding.codec = "json"

docs/ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ type = "stdin"
167167
[sinks.bar]
168168
type = "console"
169169
inputs = ["foo"]
170-
encoding = "json"
170+
encoding.codec = "json"
171171
```
172172

173173
After the component construction phase, we'll be left with the tasks for each

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

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,100 @@ impl Encoder<Event> for JsonSerializer {
6868
#[cfg(test)]
6969
mod tests {
7070
use bytes::BytesMut;
71+
use chrono::{TimeZone, Utc};
7172
use vector_common::btreemap;
72-
use vector_core::event::{LogEvent, Value};
73+
use vector_core::event::{LogEvent, Metric, MetricKind, MetricValue, StatisticKind, Value};
7374

7475
use super::*;
7576

7677
#[test]
77-
fn serialize_json() {
78+
fn serialize_json_log() {
7879
let event = Event::Log(LogEvent::from(btreemap! {
79-
"foo" => Value::from("bar")
80+
"x" => Value::from("23"),
81+
"z" => Value::from(25),
82+
"a" => Value::from("0"),
8083
}));
8184
let mut serializer = JsonSerializer::new();
8285
let mut bytes = BytesMut::new();
8386

8487
serializer.encode(event, &mut bytes).unwrap();
8588

86-
assert_eq!(bytes.freeze(), r#"{"foo":"bar"}"#);
89+
assert_eq!(bytes.freeze(), r#"{"a":"0","x":"23","z":25}"#);
90+
}
91+
92+
#[test]
93+
fn serialize_json_metric_counter() {
94+
let event = Event::Metric(
95+
Metric::new(
96+
"foos",
97+
MetricKind::Incremental,
98+
MetricValue::Counter { value: 100.0 },
99+
)
100+
.with_namespace(Some("vector"))
101+
.with_tags(Some(
102+
vec![
103+
("key2".to_owned(), "value2".to_owned()),
104+
("key1".to_owned(), "value1".to_owned()),
105+
("Key3".to_owned(), "Value3".to_owned()),
106+
]
107+
.into_iter()
108+
.collect(),
109+
))
110+
.with_timestamp(Some(Utc.ymd(2018, 11, 14).and_hms_nano(8, 9, 10, 11))),
111+
);
112+
113+
let mut serializer = JsonSerializer::new();
114+
let mut bytes = BytesMut::new();
115+
116+
serializer.encode(event, &mut bytes).unwrap();
117+
118+
assert_eq!(
119+
bytes.freeze(),
120+
r#"{"name":"foos","namespace":"vector","tags":{"Key3":"Value3","key1":"value1","key2":"value2"},"timestamp":"2018-11-14T08:09:10.000000011Z","kind":"incremental","counter":{"value":100.0}}"#
121+
);
122+
}
123+
124+
#[test]
125+
fn serialize_json_metric_set() {
126+
let event = Event::Metric(Metric::new(
127+
"users",
128+
MetricKind::Incremental,
129+
MetricValue::Set {
130+
values: vec!["bob".into()].into_iter().collect(),
131+
},
132+
));
133+
134+
let mut serializer = JsonSerializer::new();
135+
let mut bytes = BytesMut::new();
136+
137+
serializer.encode(event, &mut bytes).unwrap();
138+
139+
assert_eq!(
140+
bytes.freeze(),
141+
r#"{"name":"users","kind":"incremental","set":{"values":["bob"]}}"#
142+
);
143+
}
144+
145+
#[test]
146+
fn serialize_json_metric_histogram_without_timestamp() {
147+
let event = Event::Metric(Metric::new(
148+
"glork",
149+
MetricKind::Incremental,
150+
MetricValue::Distribution {
151+
samples: vector_core::samples![10.0 => 1],
152+
statistic: StatisticKind::Histogram,
153+
},
154+
));
155+
156+
let mut serializer = JsonSerializer::new();
157+
let mut bytes = BytesMut::new();
158+
159+
serializer.encode(event, &mut bytes).unwrap();
160+
161+
assert_eq!(
162+
bytes.freeze(),
163+
r#"{"name":"glork","kind":"incremental","distribution":{"samples":[{"value":10.0,"rate":1}],"statistic":"histogram"}}"#
164+
);
87165
}
88166

89167
#[test]

lib/k8s-e2e-tests/tests/vector-agent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const CUSTOM_RESOURCE_VECTOR_CONFIG: &str = indoc! {r#"
4343
[sinks.stdout]
4444
type = "console"
4545
inputs = ["kubernetes_logs"]
46-
encoding = "json"
46+
encoding.codec = "json"
4747
"#};
4848

4949
/// This test validates that vector picks up logs at the simplest case

rfcs/2020-03-06-1999-api-extensions-for-lua-transform.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ Here `event` is an encoded event to be produced by the transform, and `lane` is
475475
> [sinks.example_console]
476476
> type = "console"
477477
> inputs = ["example_transform.example_lane"] # would output the event from `example_lane`
478-
> encoding = "text"
478+
> encoding.codec = "text"
479479
> ```
480480
>
481481
> Other components connected to the same transform, but with different lanes names or without lane names at all would not receive any event.

rfcs/2020-04-15-2341-wasm-plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ module = "target/wasm32-wasi/release/echo.wasm"
333333
healthcheck = true
334334
inputs = ["demo"]
335335
type = "console"
336-
encoding = "json"
336+
encoding.codec = "json"
337337
buffer.type = "memory"
338338
buffer.max_events = 500
339339
buffer.when_full = "block"

rfcs/2021-07-20-8288-csv-enrichment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ To represent the CSV file we have a new top level configuration option.
3737
```toml
3838
[enrichment_tables.csv_file]
3939
type = "file"
40-
encoding = "csv"
40+
encoding.codec = "csv"
4141
path = "\path_to_csv"
4242
delimiter = ","
4343
```

skaffold/manifests/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ data:
88
type = "console"
99
inputs = ["kubernetes_logs", "internal_metrics"]
1010
target = "stdout"
11-
encoding = "json"
11+
encoding.codec = "json"

soaks/disabled-tests/fluent_remap_aws_firehose/vector.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ stream_name = "soak_fluent_remap_firehose"
4141
endpoint = "http://localhost:8080"
4242
healthcheck.enabled = true
4343
compression = "none"
44-
encoding = "json"
44+
encoding.codec = "json"
4545
region = "us-east-2"
4646
auth.access_key_id = "totallyanaccesskeyid"
4747
auth.secret_access_key = "alsoasecretaccesskey"

soaks/disabled-tests/http_datadog_filter_blackhole/vector.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ type = "internal_metrics"
1212
[sources.logs]
1313
type = "http"
1414
address = "0.0.0.0:8282"
15-
encoding = "ndjson"
15+
framing.method = "newline_delimited"
16+
decoding.codec = "json"
1617

1718
##
1819
## Transforms

soaks/tests/http_pipelines_blackhole/vector.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type = "internal_metrics"
1010
[sources.logs]
1111
type = "http"
1212
address = "0.0.0.0:8282"
13-
encoding = "text"
13+
decoding.codec = "bytes"
1414

1515
##
1616
## Transforms

soaks/tests/http_pipelines_blackhole_acks/vector.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type = "internal_metrics"
1010
[sources.logs]
1111
type = "http"
1212
address = "0.0.0.0:8282"
13-
encoding = "text"
13+
decoding.codec = "bytes"
1414
acknowledgements = true
1515

1616
##

soaks/tests/http_pipelines_no_grok_blackhole/vector.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type = "internal_metrics"
1010
[sources.logs]
1111
type = "http"
1212
address = "0.0.0.0:8282"
13-
encoding = "text"
13+
decoding.codec = "bytes"
1414

1515
##
1616
## Transforms

0 commit comments

Comments
 (0)