Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova committed Dec 2, 2024
1 parent dd275f4 commit 4868d6c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions policies/attribute_name_collisions.rego
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import rego.v1
attribute_names := { obj |
group := input.groups[_];
attr := group.attributes[_];
obj := { "name": attr.name, "const_name": to_const_name(attr.name), "namespace_prefix": to_namespace_prefix(attr.name), "deprecated": get_or_null(attr, "deprecated") }
obj := { "name": attr.name, "const_name": to_const_name(attr.name), "namespace_prefix": to_namespace_prefix(attr.name), "deprecated": is_property_set(attr, "deprecated") }
}

# check that attribute constant names do not collide
Expand All @@ -31,14 +31,14 @@ deny contains attr_registry_collision(description, name) if {
some i

# ignore deprecated attributes
attribute_names[i].deprecated == null
not attribute_names[i].deprecated

name := attribute_names[i].name
prefix := attribute_names[i].namespace_prefix

collisions := [other.name |
other := attribute_names[_]
other.deprecated == null
not other.deprecated

other.name != name
startswith(other.name, prefix)
Expand Down Expand Up @@ -78,13 +78,11 @@ to_const_name(name) = const_name if {
const_name := replace(name, ".", "_")
}

get_or_null(obj, key) = value if {
value := obj[key]
} else = null if {
not obj[key]
}
is_property_set(obj, property) = true if {
obj[property] != null
} else = false

# This list contain exceptions for existing collisions that were introduced unintentionally.
# This list contains exceptions for existing collisions that were introduced unintentionally.
# We'll have a way to specify how collision resolution happens in the schema -
# see phase 2 in https://github.com/open-telemetry/semantic-conventions/issues/1118#issuecomment-2173803006
# For now we'll exclude existing collisions from the checks.
Expand Down

0 comments on commit 4868d6c

Please sign in to comment.