Fix event policy check broken after 1.29.0 release (#1641)

This commit is contained in:
Liudmila Molkova 2024-12-02 11:04:28 -08:00 committed by GitHub
parent 0edb9e2b42
commit 176532d4a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 7 deletions

View File

@ -48,7 +48,7 @@ baseline_events := [ g |
]
registry_events := [g |
some g in data.semconv.groups
g.type == "events"
g.type == "event"
]
registry_event_names := { g.name | some g in registry_events }
@ -236,11 +236,11 @@ deny contains back_comp_violation(description, group_id, attr.name) if {
# Rule: Detect Removed Metrics
#
# This rule checks for stable metrics that existed in the baseline registry
# but are no longer present in the current registry. Removing attributes
# but are no longer present in the current registry. Removing metrics
# is considered a backward compatibility violation.
#
# In other words, we do not allow the removal of an attribute once added
# to the registry. It must exist SOMEWHERE in a group, but may be deprecated.
# In other words, we do not allow the removal of an metrics once added
# to semantic conventions. They, however, may be deprecated.
deny contains back_comp_violation(description, group_id, "") if {
# Find data we need to enforce
some metric in baseline_metrics
@ -366,7 +366,7 @@ deny contains back_comp_violation(description, group_id, "") if {
# is considered a backward compatibility violation.
#
# In other words, we do not allow the removal of a resource once added
# to the registry. It must exist SOMEWHERE, but may be deprecated.
# to semantic conventions. They, however, may be deprecated.
deny contains back_comp_violation(description, group_id, "") if {
# Find data we need to enforce
some resource in baseline_resources
@ -432,11 +432,10 @@ deny contains back_comp_violation(description, group_id, "") if {
# is considered a backward compatibility violation.
#
# In other words, we do not allow the removal of a events once added
# to the registry. It must exist SOMEWHERE, but may be deprecated.
# to semantic conventions. They, however, may be deprecated.
deny contains back_comp_violation(description, group_id, "") if {
# Find data we need to enforce
some event in baseline_events
event.stability == "stable" # remove after https://github.com/open-telemetry/semantic-conventions/pull/1512 is merged
# Enforce the policy
not registry_event_names[event.name]

View File

@ -679,6 +679,30 @@ test_removed_resources if {
}
}
# Check that events cannot be removed.
test_removed_events if {
count(deny) > 0 with data.semconv as {
"baseline_groups": [{
"id": "event.test.missing",
"type": "event",
"name": "test.missing"
}],
}
count(deny) == 0 with data.semconv as {
"baseline_groups": [{
"id": "event.test.deprecated",
"type": "event",
"name": "test.deprecated",
}],
"groups": [{
"id": "event.test.deprecated",
"type": "event",
"name": "test.deprecated",
"deprecated": "use `test` instead",
}]
}
}
# Check that Stable resources cannot become unstable
test_resource_stability_change if {
count(deny) > 0 with data.semconv as {