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,
|
metric_name: &str,
|
||||||
) -> Option<MetricPrimitiveKind> {
|
) -> Option<MetricPrimitiveKind> {
|
||||||
match index.get(&IndexKey::MetricDeclaration { name: metric_name.to_string() }) {
|
match index.get(&IndexKey::MetricDeclaration { name: metric_name.to_string() }) {
|
||||||
Some(DataValue::MetricDeclaration { params, .. }) => Some(
|
Some(DataValue::MetricDeclaration { value_param, .. }) => Some(
|
||||||
params
|
value_param
|
||||||
.iter()
|
.as_ref()
|
||||||
.find(|param| param.role == ParamRole::Value)
|
.and_then(|name| {
|
||||||
.map(|param| param.kind)
|
index.get(&IndexKey::ParamDeclaration { name: name.clone() })
|
||||||
|
})
|
||||||
|
.map(|value| match value {
|
||||||
|
DataValue::ParamDeclaration(param) => param.kind,
|
||||||
|
_ => MetricPrimitiveKind::Number,
|
||||||
|
})
|
||||||
.unwrap_or(MetricPrimitiveKind::Number),
|
.unwrap_or(MetricPrimitiveKind::Number),
|
||||||
),
|
),
|
||||||
_ => None,
|
_ => None,
|
||||||
@@ -2057,12 +2062,20 @@ mod tests {
|
|||||||
/// Declares a metric whose captured `status` param is `String`-kind and holds the `Value` role,
|
/// 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.
|
/// 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>) {
|
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(
|
declare_metric(
|
||||||
index,
|
index,
|
||||||
metric_request_with_roles(
|
metric_request_with_value(
|
||||||
"statuses",
|
"statuses",
|
||||||
r"request status=(?P<status>\S+)",
|
r"request status=(?P<status>\S+)",
|
||||||
vec![("status", "status", MetricPrimitiveKind::String, ParamRole::Value)],
|
vec![],
|
||||||
|
Some("status"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user