Fix ticket 041 merge conflict: update declared_value_kind for ticket 037's param shape
The 041 branch was built against the pre-037 ParamRole/inline-params shape; rebase the string-kind lookup and test helper onto the unified ParamDeclaration/label_params/value_param model from ticket 037. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
ce3d3c0c5e
commit
60f4574d17
+20
-7
@@ -1322,11 +1322,16 @@ fn declared_value_kind(
|
||||
metric_name: &str,
|
||||
) -> Option<MetricPrimitiveKind> {
|
||||
match index.get(&IndexKey::MetricDeclaration { name: metric_name.to_string() }) {
|
||||
Some(DataValue::MetricDeclaration { params, .. }) => Some(
|
||||
params
|
||||
.iter()
|
||||
.find(|param| param.role == ParamRole::Value)
|
||||
.map(|param| param.kind)
|
||||
Some(DataValue::MetricDeclaration { value_param, .. }) => Some(
|
||||
value_param
|
||||
.as_ref()
|
||||
.and_then(|name| {
|
||||
index.get(&IndexKey::ParamDeclaration { name: name.clone() })
|
||||
})
|
||||
.map(|value| match value {
|
||||
DataValue::ParamDeclaration(param) => param.kind,
|
||||
_ => MetricPrimitiveKind::Number,
|
||||
})
|
||||
.unwrap_or(MetricPrimitiveKind::Number),
|
||||
),
|
||||
_ => None,
|
||||
@@ -2057,12 +2062,20 @@ mod tests {
|
||||
/// Declares a metric whose captured `status` param is `String`-kind and holds the `Value` role,
|
||||
/// so every bucket entry for it is a `MetricPrimitive::String` rather than the default occurrence marker.
|
||||
fn declare_string_valued_metric(index: &mut BTreeMap<IndexKey, DataValue>) {
|
||||
declare_test_param(
|
||||
index,
|
||||
"status",
|
||||
r"request status=(?P<status>\S+)",
|
||||
"status",
|
||||
MetricPrimitiveKind::String,
|
||||
);
|
||||
declare_metric(
|
||||
index,
|
||||
metric_request_with_roles(
|
||||
metric_request_with_value(
|
||||
"statuses",
|
||||
r"request status=(?P<status>\S+)",
|
||||
vec![("status", "status", MetricPrimitiveKind::String, ParamRole::Value)],
|
||||
vec![],
|
||||
Some("status"),
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user