Skip to content
Closed
Changes from all commits
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
37 changes: 19 additions & 18 deletions bottlecap/src/lifecycle/invocation/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2598,12 +2598,6 @@ mod tests {

// The durable tag is already known, so the metric must be emitted immediately
// instead of being held back.
let now: i64 = std::time::UNIX_EPOCH
.elapsed()
.expect("unable to poll clock, unrecoverable")
.as_secs()
.try_into()
.unwrap_or_default();
processor.on_invoke_event("req-1".to_string());
assert!(
matches!(
Expand All @@ -2617,23 +2611,30 @@ mod tests {
.runtime
.clone()
.expect("runtime should have been resolved by on_invoke_event");
let ts = (now / 10) * 10;
let expected_tags = dogstatsd::metric::SortedTags::parse(&format!(
"cold_start:true,durable_function:true,runtime:{runtime}"
))
.ok();
let entry = processor
// Flush returns every bucket, so there is no need to guess the metric's timestamp.
Comment thread
lucaspimentel marked this conversation as resolved.
let flushed = processor
.enhanced_metrics
.aggr_handle
.get_entry_by_id(
crate::metrics::enhanced::constants::INVOCATIONS_METRIC.into(),
expected_tags,
ts,
)
.flush()
.await
.unwrap();
let expected_tags = [
"cold_start:true".to_string(),
"durable_function:true".to_string(),
format!("runtime:{runtime}"),
];
let found = flushed
.distributions
.iter()
.flat_map(|payload| &payload.sketches)
.any(|sketch| {
&*sketch.metric == crate::metrics::enhanced::constants::INVOCATIONS_METRIC
&& expected_tags
.iter()
.all(|expected| sketch.tags.iter().any(|tag| &**tag == expected.as_str()))
});
assert!(
entry.is_some(),
found,
"Expected the invocation metric to carry the durable_function:true tag"
);
}
Expand Down
Loading