diff --git a/.chloggen/CHANGELOG.tmpl b/.chloggen/CHANGELOG.tmpl new file mode 100644 index 0000000000..416959e205 --- /dev/null +++ b/.chloggen/CHANGELOG.tmpl @@ -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 }} diff --git a/.chloggen/config.yaml b/.chloggen/config.yaml index 411f32d3a5..f600745253 100644 --- a/.chloggen/config.yaml +++ b/.chloggen/config.yaml @@ -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 diff --git a/policies/attribute_name_collisions.rego b/policies/attribute_name_collisions.rego index c52f0267fc..0aa7bb506e 100644 --- a/policies/attribute_name_collisions.rego +++ b/policies/attribute_name_collisions.rego @@ -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 @@ -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) ] @@ -72,7 +78,11 @@ 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. @@ -80,5 +90,3 @@ to_const_name(name) = const_name if { # 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"} diff --git a/policies/compatibility.rego b/policies/compatibility.rego index 31b391fe48..f8483ca4b3 100644 --- a/policies/compatibility.rego +++ b/policies/compatibility.rego @@ -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] diff --git a/policies_test/attribute_name_collisions_test.rego b/policies_test/attribute_name_collisions_test.rego index b86e79fece..2d09beb7c4 100644 --- a/policies_test/attribute_name_collisions_test.rego +++ b/policies_test/attribute_name_collisions_test.rego @@ -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 +} + diff --git a/policies_test/compatibility_test.rego b/policies_test/compatibility_test.rego index 92ee2f2933..5976e02c54 100644 --- a/policies_test/compatibility_test.rego +++ b/policies_test/compatibility_test.rego @@ -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 {