diff --git a/src/engine.rs b/src/engine.rs index 206eef2..ad6a124 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -1322,11 +1322,16 @@ fn declared_value_kind( metric_name: &str, ) -> Option { 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) { + declare_test_param( + index, + "status", + r"request status=(?P\S+)", + "status", + MetricPrimitiveKind::String, + ); declare_metric( index, - metric_request_with_roles( + metric_request_with_value( "statuses", r"request status=(?P\S+)", - vec![("status", "status", MetricPrimitiveKind::String, ParamRole::Value)], + vec![], + Some("status"), ), ) .unwrap();