vector_core/
lib.rs

1//! The Vector Core Library
2//!
3//! The Vector Core Library are the foundational pieces needed to make a vector
4//! and is not vector with pieces missing. While this library is obviously
5//! tailored to the needs of vector it is written in such a way to make
6//! experimentation and testing _in the library_ cheap and demonstrative.
7//!
8//! This library was extracted from the top-level project package, discussed in
9//! RFC 7027.
10
11#![deny(warnings)]
12#![deny(clippy::all)]
13#![deny(clippy::pedantic)]
14#![deny(unreachable_pub)]
15#![deny(unused_allocation)]
16#![deny(unused_extern_crates)]
17#![deny(unused_assignments)]
18#![deny(unused_comparisons)]
19#![allow(clippy::cast_possible_wrap)]
20#![allow(clippy::cast_sign_loss)]
21#![allow(clippy::default_trait_access)] // triggers on generated prost code
22#![allow(clippy::float_cmp)]
23#![allow(clippy::match_wildcard_for_single_variants)]
24#![allow(clippy::module_name_repetitions)]
25#![allow(clippy::must_use_candidate)] // many false positives in this package
26#![allow(clippy::non_ascii_literal)] // using unicode literals is a-okay in vector
27#![allow(clippy::unnested_or_patterns)] // nightly-only feature as of 1.51.0
28#![allow(clippy::type_complexity)] // long-types happen, especially in async code
29
30pub mod config;
31pub mod event;
32pub mod fanout;
33pub mod ipallowlist;
34pub mod latency;
35pub mod metrics;
36pub mod partition;
37pub mod schema;
38pub mod serde;
39pub mod sink;
40pub mod source;
41pub mod source_sender;
42pub mod span_fields;
43pub mod tcp;
44#[cfg(test)]
45mod test_util;
46pub mod time;
47pub mod tls;
48pub mod transform;
49#[cfg(feature = "vrl")]
50pub mod vrl;
51
52use std::path::PathBuf;
53
54pub use event::EstimatedJsonEncodedSizeOf;
55use float_eq::FloatEq;
56
57#[cfg(feature = "vrl")]
58pub use crate::vrl::compile_vrl;
59
60#[macro_use]
61extern crate tracing;
62
63pub fn default_data_dir() -> Option<PathBuf> {
64    Some(PathBuf::from("/var/lib/vector/"))
65}
66
67pub(crate) use vector_common::{Error, Result};
68
69pub(crate) fn float_eq(l_value: f64, r_value: f64) -> bool {
70    (l_value.is_nan() && r_value.is_nan()) || l_value.eq_ulps(&r_value, &1)
71}
72
73// These macros aren't actually usable in lib crates without some `vector_lib` shenanigans.
74#[macro_export]
75macro_rules! emit {
76    ($event:expr) => {
77        vector_lib::internal_event::emit($event)
78    };
79}
80
81#[macro_export]
82macro_rules! register {
83    ($event:expr) => {
84        vector_lib::internal_event::register($event)
85    };
86}
87
88pub use span_fields::SpanField;
89
90// Re-export `inventory` so `register_extra_span_field!` can resolve `submit!` through this
91// crate without forcing downstream callers to declare `inventory` as a direct dependency.
92#[doc(hidden)]
93pub use inventory as __inventory;