Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Update VRL to c69a52e67 and mlua to 0.10.0 #21670

Merged
merged 5 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ arr_macro = { version = "0.2.1" }
heim = { git = "https://github.com/vectordotdev/heim.git", branch = "update-nix", default-features = false, features = ["disk"] }

# make sure to update the external docs when the Lua version changes
mlua = { version = "0.9.9", default-features = false, features = ["lua54", "send", "vendored", "macros"], optional = true }
mlua = { version = "0.10.0", default-features = false, features = ["lua54", "send", "vendored", "macros"], optional = true }

[target.'cfg(windows)'.dependencies]
windows-service = "0.7.0"
Expand Down
2 changes: 1 addition & 1 deletion lib/vector-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ lookup = { package = "vector-lookup", path = "../vector-lookup" }
metrics.workspace = true
metrics-tracing-context.workspace = true
metrics-util.workspace = true
mlua = { version = "0.9.9", default-features = false, features = ["lua54", "send", "vendored"], optional = true }
mlua = { version = "0.10.0", default-features = false, features = ["lua54", "send", "vendored"], optional = true }
no-proxy = { version = "0.3.5", default-features = false, features = ["serialize"] }
ordered-float = { version = "4.4.0", default-features = false }
openssl = { version = "0.10.68", default-features = false, features = ["vendored"] }
Expand Down
14 changes: 7 additions & 7 deletions lib/vector-core/src/event/lua/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ pub struct LuaEvent {
pub metric_multi_value_tags: bool,
}

impl<'a> IntoLua<'a> for LuaEvent {
impl IntoLua for LuaEvent {
#![allow(clippy::wrong_self_convention)] // this trait is defined by mlua
fn into_lua(self, lua: &'a Lua) -> LuaResult<LuaValue> {
fn into_lua(self, lua: &Lua) -> LuaResult<LuaValue> {
let table = lua.create_table()?;
match self.event {
Event::Log(log) => table.raw_set("log", log.into_lua(lua)?)?,
Expand All @@ -24,7 +24,7 @@ impl<'a> IntoLua<'a> for LuaEvent {
)?,
Event::Trace(_) => {
return Err(LuaError::ToLuaConversionError {
from: "Event",
from: String::from("Event"),
to: "table",
message: Some("Trace are not supported".to_string()),
})
Expand All @@ -34,12 +34,12 @@ impl<'a> IntoLua<'a> for LuaEvent {
}
}

impl<'a> FromLua<'a> for Event {
fn from_lua(value: LuaValue<'a>, lua: &'a Lua) -> LuaResult<Self> {
impl FromLua for Event {
fn from_lua(value: LuaValue, lua: &Lua) -> LuaResult<Self> {
let LuaValue::Table(table) = &value else {
return Err(LuaError::FromLuaConversionError {
from: value.type_name(),
to: "Event",
to: String::from("Event"),
message: Some("Event should be a Lua table".to_string()),
});
};
Expand All @@ -53,7 +53,7 @@ impl<'a> FromLua<'a> for Event {
)?)),
_ => Err(LuaError::FromLuaConversionError {
from: value.type_name(),
to: "Event",
to: String::from("Event"),
message: Some(
"Event should contain either \"log\" or \"metric\" key at the top level"
.to_string(),
Expand Down
8 changes: 4 additions & 4 deletions lib/vector-core/src/event/lua/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ use mlua::prelude::*;

use super::super::{EventMetadata, LogEvent, Value};

impl<'a> IntoLua<'a> for LogEvent {
impl IntoLua for LogEvent {
#![allow(clippy::wrong_self_convention)] // this trait is defined by mlua
fn into_lua(self, lua: &'a Lua) -> LuaResult<LuaValue> {
fn into_lua(self, lua: &Lua) -> LuaResult<LuaValue> {
let (value, _metadata) = self.into_parts();
value.into_lua(lua)
}
}

impl<'a> FromLua<'a> for LogEvent {
fn from_lua(lua_value: LuaValue<'a>, lua: &'a Lua) -> LuaResult<Self> {
impl FromLua for LogEvent {
fn from_lua(lua_value: LuaValue, lua: &Lua) -> LuaResult<Self> {
let value = Value::from_lua(lua_value, lua)?;
Ok(LogEvent::from_parts(value, EventMetadata::default()))
}
Expand Down
68 changes: 34 additions & 34 deletions lib/vector-core/src/event/lua/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub struct LuaMetricTags {
pub multi_value_tags: bool,
}

impl<'a> IntoLua<'a> for MetricKind {
impl IntoLua for MetricKind {
#![allow(clippy::wrong_self_convention)] // this trait is defined by mlua
fn into_lua(self, lua: &'a Lua) -> LuaResult<LuaValue> {
fn into_lua(self, lua: &Lua) -> LuaResult<LuaValue> {
let kind = match self {
MetricKind::Absolute => "absolute",
MetricKind::Incremental => "incremental",
Expand All @@ -31,14 +31,14 @@ impl<'a> IntoLua<'a> for MetricKind {
}
}

impl<'a> FromLua<'a> for MetricKind {
fn from_lua(value: LuaValue<'a>, _: &'a Lua) -> LuaResult<Self> {
impl FromLua for MetricKind {
fn from_lua(value: LuaValue, _: &Lua) -> LuaResult<Self> {
match value {
LuaValue::String(s) if s == "absolute" => Ok(MetricKind::Absolute),
LuaValue::String(s) if s == "incremental" => Ok(MetricKind::Incremental),
_ => Err(LuaError::FromLuaConversionError {
from: value.type_name(),
to: "MetricKind",
to: String::from("MetricKind"),
message: Some(
"Metric kind should be either \"incremental\" or \"absolute\"".to_string(),
),
Expand All @@ -47,8 +47,8 @@ impl<'a> FromLua<'a> for MetricKind {
}
}

impl<'a> IntoLua<'a> for StatisticKind {
fn into_lua(self, lua: &'a Lua) -> LuaResult<LuaValue> {
impl IntoLua for StatisticKind {
fn into_lua(self, lua: &Lua) -> LuaResult<LuaValue> {
let kind = match self {
StatisticKind::Summary => "summary",
StatisticKind::Histogram => "histogram",
Expand All @@ -57,14 +57,14 @@ impl<'a> IntoLua<'a> for StatisticKind {
}
}

impl<'a> FromLua<'a> for StatisticKind {
fn from_lua(value: LuaValue<'a>, _: &'a Lua) -> LuaResult<Self> {
impl FromLua for StatisticKind {
fn from_lua(value: LuaValue, _: &Lua) -> LuaResult<Self> {
match value {
LuaValue::String(s) if s == "summary" => Ok(StatisticKind::Summary),
LuaValue::String(s) if s == "histogram" => Ok(StatisticKind::Histogram),
_ => Err(LuaError::FromLuaConversionError {
from: value.type_name(),
to: "StatisticKind",
to: String::from("StatisticKind"),
message: Some(
"Statistic kind should be either \"summary\" or \"histogram\"".to_string(),
),
Expand All @@ -73,8 +73,8 @@ impl<'a> FromLua<'a> for StatisticKind {
}
}

impl<'a> FromLua<'a> for TagValueSet {
fn from_lua(value: LuaValue<'a>, _: &'a Lua) -> LuaResult<Self> {
impl FromLua for TagValueSet {
fn from_lua(value: LuaValue, _: &Lua) -> LuaResult<Self> {
match value {
LuaValue::Nil => Ok(Self::Single(TagValue::Bare)),
LuaValue::Table(table) => {
Expand All @@ -90,21 +90,21 @@ impl<'a> FromLua<'a> for TagValueSet {
LuaValue::String(x) => Ok(Self::from([x.to_string_lossy().to_string()])),
_ => Err(mlua::Error::FromLuaConversionError {
from: value.type_name(),
to: "metric tag value",
to: String::from("metric tag value"),
message: None,
}),
}
}
}

impl<'a> FromLua<'a> for MetricTags {
fn from_lua(value: LuaValue<'a>, lua: &'a Lua) -> LuaResult<Self> {
impl FromLua for MetricTags {
fn from_lua(value: LuaValue, lua: &Lua) -> LuaResult<Self> {
Ok(Self(BTreeMap::from_lua(value, lua)?))
}
}

impl<'a> IntoLua<'a> for LuaMetricTags {
fn into_lua(self, lua: &'a Lua) -> LuaResult<LuaValue> {
impl IntoLua for LuaMetricTags {
fn into_lua(self, lua: &Lua) -> LuaResult<LuaValue> {
if self.multi_value_tags {
Ok(LuaValue::Table(lua.create_table_from(
self.tags.0.into_iter().map(|(key, value)| {
Expand All @@ -123,9 +123,9 @@ impl<'a> IntoLua<'a> for LuaMetricTags {
}
}

impl<'a> IntoLua<'a> for LuaMetric {
impl IntoLua for LuaMetric {
#![allow(clippy::wrong_self_convention)] // this trait is defined by mlua
fn into_lua(self, lua: &'a Lua) -> LuaResult<LuaValue> {
fn into_lua(self, lua: &Lua) -> LuaResult<LuaValue> {
let tbl = lua.create_table()?;

tbl.raw_set("name", self.metric.name())?;
Expand Down Expand Up @@ -228,53 +228,53 @@ impl<'a> IntoLua<'a> for LuaMetric {
}
}

impl<'a> FromLua<'a> for Metric {
impl FromLua for Metric {
#[allow(clippy::too_many_lines)]
fn from_lua(value: LuaValue<'a>, _: &'a Lua) -> LuaResult<Self> {
fn from_lua(value: LuaValue, _: &Lua) -> LuaResult<Self> {
let table = match &value {
LuaValue::Table(table) => table,
other => {
return Err(LuaError::FromLuaConversionError {
from: other.type_name(),
to: "Metric",
to: String::from("Metric"),
message: Some("Metric should be a Lua table".to_string()),
})
}
};

let name: String = table.raw_get("name")?;
let timestamp = table
.raw_get::<_, Option<LuaTable>>("timestamp")?
.raw_get::<Option<LuaTable>>("timestamp")?
.map(table_to_timestamp)
.transpose()?;
let interval_ms: Option<u32> = table.raw_get("interval_ms")?;
let namespace: Option<String> = table.raw_get("namespace")?;
let tags: Option<MetricTags> = table.raw_get("tags")?;
let kind = table
.raw_get::<_, Option<MetricKind>>("kind")?
.raw_get::<Option<MetricKind>>("kind")?
.unwrap_or(MetricKind::Absolute);

let value = if let Some(counter) = table.raw_get::<_, Option<LuaTable>>("counter")? {
let value = if let Some(counter) = table.raw_get::<Option<LuaTable>>("counter")? {
MetricValue::Counter {
value: counter.raw_get("value")?,
}
} else if let Some(gauge) = table.raw_get::<_, Option<LuaTable>>("gauge")? {
} else if let Some(gauge) = table.raw_get::<Option<LuaTable>>("gauge")? {
MetricValue::Gauge {
value: gauge.raw_get("value")?,
}
} else if let Some(set) = table.raw_get::<_, Option<LuaTable>>("set")? {
} else if let Some(set) = table.raw_get::<Option<LuaTable>>("set")? {
MetricValue::Set {
values: set.raw_get("values")?,
}
} else if let Some(distribution) = table.raw_get::<_, Option<LuaTable>>("distribution")? {
} else if let Some(distribution) = table.raw_get::<Option<LuaTable>>("distribution")? {
let values: Vec<f64> = distribution.raw_get("values")?;
let rates: Vec<u32> = distribution.raw_get("sample_rates")?;
MetricValue::Distribution {
samples: metric::zip_samples(values, rates),
statistic: distribution.raw_get("statistic")?,
}
} else if let Some(aggregated_histogram) =
table.raw_get::<_, Option<LuaTable>>("aggregated_histogram")?
table.raw_get::<Option<LuaTable>>("aggregated_histogram")?
{
let counts: Vec<u64> = aggregated_histogram.raw_get("counts")?;
let buckets: Vec<f64> = aggregated_histogram.raw_get("buckets")?;
Expand All @@ -285,7 +285,7 @@ impl<'a> FromLua<'a> for Metric {
sum: aggregated_histogram.raw_get("sum")?,
}
} else if let Some(aggregated_summary) =
table.raw_get::<_, Option<LuaTable>>("aggregated_summary")?
table.raw_get::<Option<LuaTable>>("aggregated_summary")?
{
let quantiles: Vec<f64> = aggregated_summary.raw_get("quantiles")?;
let values: Vec<f64> = aggregated_summary.raw_get("values")?;
Expand All @@ -294,7 +294,7 @@ impl<'a> FromLua<'a> for Metric {
count: aggregated_summary.raw_get("count")?,
sum: aggregated_summary.raw_get("sum")?,
}
} else if let Some(sketch) = table.raw_get::<_, Option<LuaTable>>("sketch")? {
} else if let Some(sketch) = table.raw_get::<Option<LuaTable>>("sketch")? {
let sketch_type: String = sketch.raw_get("type")?;
match sketch_type.as_str() {
"ddsketch" => {
Expand All @@ -312,7 +312,7 @@ impl<'a> FromLua<'a> for Metric {
})
.ok_or(LuaError::FromLuaConversionError {
from: value.type_name(),
to: "Metric",
to: String::from("Metric"),
message: Some(
"Invalid structure for converting to AgentDDSketch".to_string(),
),
Expand All @@ -321,15 +321,15 @@ impl<'a> FromLua<'a> for Metric {
x => {
return Err(LuaError::FromLuaConversionError {
from: value.type_name(),
to: "Metric",
to: String::from("Metric"),
message: Some(format!("Invalid sketch type '{x}' given")),
})
}
}
} else {
return Err(LuaError::FromLuaConversionError {
from: value.type_name(),
to: "Metric",
to: String::from("Metric"),
message: Some("Cannot find metric value, expected presence one of \"counter\", \"gauge\", \"set\", \"distribution\", \"aggregated_histogram\", \"aggregated_summary\"".to_string()),
});
};
Expand Down
Loading
Loading