Skip to content

Commit

Permalink
Fix event policy check broken after 1.29.0 release (#1641)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova authored Dec 2, 2024
1 parent 0edb9e2 commit 176532d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
13 changes: 6 additions & 7 deletions policies/compatibility.rego
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]

Expand Down
24 changes: 24 additions & 0 deletions policies_test/compatibility_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 176532d

Please sign in to comment.