Skip to content

Commit

Permalink
Merge branch 'main' into add_deploy_replica_metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrsMark authored Dec 3, 2024
2 parents be17329 + 2d34907 commit 07e6fd4
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 12 deletions.
72 changes: 72 additions & 0 deletions .chloggen/CHANGELOG.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{{/*
Based on the default template:
https://github.com/open-telemetry/opentelemetry-go-build-tools/blob/v0.15.0/chloggen/internal/chlog/summary.tmpl
*/}}
{{- define "entry" -}}
- `{{ .Component }}`: {{ .Note }} (
{{- range $i, $issue := .Issues }}
{{- if $i }}, {{ end -}}
[#{{ $issue }}](https://github.com/open-telemetry/semantic-conventions/issues/{{ $issue }})
{{- end -}}
)

{{- if .SubText }}
{{ .SubText | indent 2 }}
{{- end }}
{{- end }}
## {{ .Version }}

{{- if .BreakingChanges }}

### 🛑 Breaking changes 🛑

{{- range $i, $change := .BreakingChanges }}
{{- if eq $i 0}}
{{end}}
{{ template "entry" $change }}
{{- end }}
{{- end }}

{{- if .Deprecations }}

### 🚩 Deprecations 🚩

{{- range $i, $change := .Deprecations }}
{{- if eq $i 0}}
{{end}}
{{ template "entry" $change }}
{{- end }}
{{- end }}

{{- if .NewComponents }}

### 🚀 New components 🚀

{{- range $i, $change := .NewComponents }}
{{- if eq $i 0}}
{{end}}
{{ template "entry" $change }}
{{- end }}
{{- end }}

{{- if .Enhancements }}

### 💡 Enhancements 💡

{{- range $i, $change := .Enhancements }}
{{- if eq $i 0}}
{{end}}
{{ template "entry" $change }}
{{- end }}
{{- end }}

{{- if .BugFixes }}

### 🧰 Bug fixes 🧰

{{- range $i, $change := .BugFixes }}
{{- if eq $i 0}}
{{end}}
{{ template "entry" $change }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions .chloggen/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ change_logs:
# If 'change_logs' is specified in this file, and no value is specified for 'default_change_logs',
# then 'change_logs' MUST be specified in every entry file.
default_change_logs: [user]

# Custom template for the changelog that include links for the issue/PRs
summary_template: .chloggen/CHANGELOG.tmpl
18 changes: 13 additions & 5 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) }
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 @@ -29,11 +29,17 @@ deny contains attr_registry_collision(description, name) if {
# check that attribute names do not collide with namespaces
deny contains attr_registry_collision(description, name) if {
some i

# ignore deprecated attributes
not attribute_names[i].deprecated

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

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

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

# These lists contain exceptions for existing collisions that were introduced unintentionally.
is_property_set(obj, property) = true if {
obj[property] != null
} else = false

# 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.
# ADDING NEW EXCEPTIONS IS NOT ALLOWED.

# DO NOT ADD ATTRIBUTES TO THIS LIST
excluded_const_collisions := {"messaging.client_id"}
# DO NOT ADD ATTRIBUTES TO THIS LIST
excluded_namespace_collisions := {"messaging.operation", "db.operation", "deployment.environment"}
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
12 changes: 12 additions & 0 deletions policies_test/attribute_name_collisions_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ test_fails_on_namespace_collision if {
]}
count(deny) == 1 with input as collision
}

test_does_not_fail_on_deprecated_namespace_collision if {
collision := {"groups": [
{"id": "test1", "attributes": [{"name": "test.namespace.id"}]},
{"id": "test2", "attributes": [{"name": "test.namespace", "deprecated": "replaced by foo.bar.baz"}]},

{"id": "test3", "attributes": [{"name": "another_test.namespace.id", "deprecated": "replaced by another_test.namespace"}]},
{"id": "test4", "attributes": [{"name": "another_test.namespace"}]},
]}
count(deny) == 0 with input as collision
}

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 07e6fd4

Please sign in to comment.