-
Notifications
You must be signed in to change notification settings - Fork 43
[WIP] Live check metrics #728
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
base: main
Are you sure you want to change the base?
Conversation
jerbly
commented
May 5, 2025
•
edited
Loading
edited


crates/weaver_live_check/src/lib.rs
Outdated
/// A sample metric | ||
Metric(&'a SampleMetric), | ||
/// A sample number data point | ||
NumberDataPoint(&'a NumberDataPoint), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting - Is the convention going to be check at the highest level, but higher-level things don't include lower level details?
E.g. NumberDataPoint is part of a Metric and has metric identifying things, but SampleMetric wouldn't?
Also, can you rename to SampledNumberDataPoint
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This area is not quite right yet. A NumberDataPoint without the information from the Metric is not so useful, but I need a way to pass it in around in a consistent way.
Yes, good call on the renaming. Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking into the consistency of the framework. For each data_point, I want to be able to provide advice at that level (checking attributes required for example), but I need context from the parent group. I'm hoping to get this change done today. This will change rego so the input is a tuple of (sample,semconv).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed this with docs to explain and a rego example.
# This example shows how to use the registry_group provided in the input.
# If the metric's unit is "By" the value in this data-point must be an integer.
deny contains make_advice(advice_type, advice_level, value, message) if {
input.sample.number_data_point
value := input.sample.number_data_point.value
input.registry_group.unit == "By"
value != floor(value) # not a good type check, but serves as an example
advice_type := "invalid_data_point_value"
advice_level := "violation"
message := "Value must be an integer when unit is 'By'"
}
@@ -40,6 +40,16 @@ deny contains make_advice(advice_type, advice_level, value, message) if { | |||
message := "Does not match name formatting rules" | |||
} | |||
|
|||
# checks metric name format | |||
deny contains make_advice(advice_type, advice_level, value, message) if { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a check to make sure attributes on the metric match attributes defined on the group?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already done internally in rust rather than in rego since I assumed this was a fundamental thing. See the attribute_required
advice under each data_point in the screenshot above. This is at the data_point level since the attributes are provided with each point.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #728 +/- ##
=======================================
+ Coverage 76.7% 76.9% +0.2%
=======================================
Files 65 66 +1
Lines 5012 5146 +134
=======================================
+ Hits 3846 3960 +114
- Misses 1166 1186 +20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|