Skip to content

Commit 570283b

Browse files
authored
Check deprecated.rename_to type compatibility and more (#2688)
1 parent b5b89b1 commit 570283b

File tree

11 files changed

+393
-20
lines changed

11 files changed

+393
-20
lines changed

.chloggen/2688.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
change_type: enhancement
2+
component: gen_ai, db, enduser, messaging
3+
note: >
4+
Fix deprecation reasons - use uncategorized when attribute type is changing.
5+
Fix missing/invalid deprecations on (deprecated) `gen_ai.system` attribute.
6+
issues: [2688]

docs/registry/attributes/db.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Describes deprecated database attributes.
185185
| <a id="db-cosmosdb-regions-contacted" href="#db-cosmosdb-regions-contacted">`db.cosmosdb.regions_contacted`</a> | string[] | Deprecated, use `azure.cosmosdb.operation.contacted_regions` instead. | `["North Central US", "Australia East", "Australia Southeast"]` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `azure.cosmosdb.operation.contacted_regions`. |
186186
| <a id="db-cosmosdb-request-charge" href="#db-cosmosdb-request-charge">`db.cosmosdb.request_charge`</a> | double | Deprecated, use `azure.cosmosdb.operation.request_charge` instead. | `46.18`; `1.0` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `azure.cosmosdb.operation.request_charge`. |
187187
| <a id="db-cosmosdb-request-content-length" href="#db-cosmosdb-request-content-length">`db.cosmosdb.request_content_length`</a> | int | Deprecated, use `azure.cosmosdb.request.body.size` instead. | | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `azure.cosmosdb.request.body.size`. |
188-
| <a id="db-cosmosdb-status-code" href="#db-cosmosdb-status-code">`db.cosmosdb.status_code`</a> | int | Deprecated, use `db.response.status_code` instead. | `200`; `201` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `db.response.status_code`. |
188+
| <a id="db-cosmosdb-status-code" href="#db-cosmosdb-status-code">`db.cosmosdb.status_code`</a> | int | Deprecated, use `db.response.status_code` instead. | `200`; `201` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Uncategorized. |
189189
| <a id="db-cosmosdb-sub-status-code" href="#db-cosmosdb-sub-status-code">`db.cosmosdb.sub_status_code`</a> | int | Deprecated, use `azure.cosmosdb.response.sub_status_code` instead. | `1000`; `1002` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `azure.cosmosdb.response.sub_status_code`. |
190190
| <a id="db-elasticsearch-cluster-name" href="#db-elasticsearch-cluster-name">`db.elasticsearch.cluster.name`</a> | string | Deprecated, use `db.namespace` instead. | `e9106fc68e3044f0b1475b04bf4ffd5f` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `db.namespace`. |
191191
| <a id="db-elasticsearch-node-name" href="#db-elasticsearch-node-name">`db.elasticsearch.node.name`</a> | string | Deprecated, use `elasticsearch.node.name` instead. | `instance-0000000001` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `elasticsearch.node.name`. |
@@ -196,7 +196,7 @@ Describes deprecated database attributes.
196196
| <a id="db-mssql-instance-name" href="#db-mssql-instance-name">`db.mssql.instance_name`</a> | string | Deprecated, SQL Server instance is now populated as a part of `db.namespace` attribute. | `MSSQLSERVER` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Removed, no replacement at this time. |
197197
| <a id="db-name" href="#db-name">`db.name`</a> | string | Deprecated, use `db.namespace` instead. | `customers`; `main` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `db.namespace`. |
198198
| <a id="db-operation" href="#db-operation">`db.operation`</a> | string | Deprecated, use `db.operation.name` instead. | `findAndModify`; `HMSET`; `SELECT` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `db.operation.name`. |
199-
| <a id="db-redis-database-index" href="#db-redis-database-index">`db.redis.database_index`</a> | int | Deprecated, use `db.namespace` instead. | `0`; `1`; `15` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `db.namespace`. |
199+
| <a id="db-redis-database-index" href="#db-redis-database-index">`db.redis.database_index`</a> | int | Deprecated, use `db.namespace` instead. | `0`; `1`; `15` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Uncategorized. |
200200
| <a id="db-sql-table" href="#db-sql-table">`db.sql.table`</a> | string | Deprecated, use `db.collection.name` instead. | `mytable` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `db.collection.name`, but only if not extracting the value from `db.query.text`. |
201201
| <a id="db-statement" href="#db-statement">`db.statement`</a> | string | The database statement being executed. | `SELECT * FROM wuser_table`; `SET mykey "WuValue"` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `db.query.text`. |
202202
| <a id="db-system" href="#db-system">`db.system`</a> | string | Deprecated, use `db.system.name` instead. | `other_sql`; `adabas`; `intersystems_cache` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `db.system.name`. |

docs/registry/attributes/enduser.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Describes deprecated enduser attributes.
3131

3232
| Attribute | Type | Description | Examples | Stability |
3333
|---|---|---|---|---|
34-
| <a id="enduser-role" href="#enduser-role">`enduser.role`</a> | string | Deprecated, use `user.roles` instead. | `admin` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `user.roles`. |
34+
| <a id="enduser-role" href="#enduser-role">`enduser.role`</a> | string | Deprecated, use `user.roles` instead. | `admin` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Uncategorized. |
3535
| <a id="enduser-scope" href="#enduser-scope">`enduser.scope`</a> | string | Deprecated, no replacement at this time. | `read:message, write:files` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Removed, no replacement at this time. |

docs/registry/attributes/gen-ai.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ Describes deprecated `gen_ai` attributes.
226226
|---|---|---|
227227
| `anthropic` | Anthropic | ![Development](https://img.shields.io/badge/-development-blue) |
228228
| `aws.bedrock` | AWS Bedrock | ![Development](https://img.shields.io/badge/-development-blue) |
229-
| `az.ai.inference` | Azure AI Inference | ![Development](https://img.shields.io/badge/-development-blue) |
230-
| `az.ai.openai` | Azure OpenAI | ![Development](https://img.shields.io/badge/-development-blue) |
231229
| `azure.ai.inference` | Azure AI Inference | ![Development](https://img.shields.io/badge/-development-blue) |
232230
| `azure.ai.openai` | Azure OpenAI | ![Development](https://img.shields.io/badge/-development-blue) |
233231
| `cohere` | Cohere | ![Development](https://img.shields.io/badge/-development-blue) |
@@ -240,6 +238,7 @@ Describes deprecated `gen_ai` attributes.
240238
| `mistral_ai` | Mistral AI | ![Development](https://img.shields.io/badge/-development-blue) |
241239
| `openai` | OpenAI | ![Development](https://img.shields.io/badge/-development-blue) |
242240
| `perplexity` | Perplexity | ![Development](https://img.shields.io/badge/-development-blue) |
241+
| `xai` | xAI | ![Development](https://img.shields.io/badge/-development-blue) |
243242

244243
**[14]:** This refers to the 'generativelanguage.googleapis.com' endpoint. Also known as the AI Studio API. May use common attributes prefixed with 'gcp.gen_ai.'.
245244

docs/registry/attributes/messaging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ Describes deprecated messaging attributes.
194194
| <a id="messaging-destination-publish-name" href="#messaging-destination-publish-name">`messaging.destination_publish.name`</a> | string | Deprecated, no replacement at this time. | `MyQueue`; `MyTopic` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Removed. No replacement at this time. |
195195
| <a id="messaging-eventhubs-consumer-group" href="#messaging-eventhubs-consumer-group">`messaging.eventhubs.consumer.group`</a> | string | Deprecated, use `messaging.consumer.group.name` instead. | `$Default` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `messaging.consumer.group.name`. |
196196
| <a id="messaging-kafka-consumer-group" href="#messaging-kafka-consumer-group">`messaging.kafka.consumer.group`</a> | string | Deprecated, use `messaging.consumer.group.name` instead. | `my-group` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `messaging.consumer.group.name`. |
197-
| <a id="messaging-kafka-destination-partition" href="#messaging-kafka-destination-partition">`messaging.kafka.destination.partition`</a> | int | Deprecated, use `messaging.destination.partition.id` instead. | `2` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `messaging.destination.partition.id`. |
197+
| <a id="messaging-kafka-destination-partition" href="#messaging-kafka-destination-partition">`messaging.kafka.destination.partition`</a> | int | Deprecated, use `messaging.destination.partition.id` instead. | `2` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Record string representation of the partition id in `messaging.destination.partition.id` attribute. |
198198
| <a id="messaging-kafka-message-offset" href="#messaging-kafka-message-offset">`messaging.kafka.message.offset`</a> | int | Deprecated, use `messaging.kafka.offset` instead. | `42` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `messaging.kafka.offset`. |
199199
| <a id="messaging-operation" href="#messaging-operation">`messaging.operation`</a> | string | Deprecated, use `messaging.operation.type` instead. | `publish`; `create`; `process` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `messaging.operation.type`. |
200200
| <a id="messaging-rocketmq-client-group" href="#messaging-rocketmq-client-group">`messaging.rocketmq.client_group`</a> | string | Deprecated, use `messaging.consumer.group.name` instead. | `myConsumerGroup` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `messaging.consumer.group.name` on the consumer spans. No replacement for producer spans. |

model/database/deprecated/registry-deprecated.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ groups:
8585
stability: development
8686
brief: 'Deprecated, use `db.namespace` instead.'
8787
deprecated:
88-
reason: renamed
89-
renamed_to: db.namespace
88+
reason: uncategorized
89+
renamed_to: Use `db.namespace` instead.
9090
examples: [0, 1, 15]
9191
- id: db.name
9292
type: string
@@ -126,8 +126,8 @@ groups:
126126
type: int
127127
stability: development
128128
deprecated:
129-
reason: renamed
130-
renamed_to: db.response.status_code
129+
reason: uncategorized
130+
renamed_to: Use `db.response.status_code` instead.
131131
brief: 'Deprecated, use `db.response.status_code` instead.'
132132
examples: [200, 201]
133133
- id: db.cosmosdb.operation_type

model/enduser/deprecated/registry-deprecated.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ groups:
77
- id: enduser.role
88
type: string
99
deprecated:
10-
reason: renamed
11-
renamed_to: user.roles
10+
reason: uncategorized
11+
renamed_to: Use `user.roles` instead.
1212
stability: development
1313
brief: "Deprecated, use `user.roles` instead."
1414
examples: 'admin'

model/gen-ai/deprecated/registry-deprecated.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,16 @@ groups:
100100
stability: development
101101
value: "az.ai.inference"
102102
brief: 'Azure AI Inference'
103+
deprecated:
104+
reason: renamed
105+
renamed_to: azure.ai.inference
103106
- id: az.ai.openai
104107
stability: development
105108
value: "az.ai.openai"
106109
brief: 'Azure OpenAI'
110+
deprecated:
111+
reason: renamed
112+
renamed_to: azure.ai.openai
107113
- id: azure.ai.inference
108114
stability: development
109115
value: "azure.ai.inference"
@@ -128,9 +134,6 @@ groups:
128134
stability: development
129135
value: "xai"
130136
brief: 'xAI'
131-
deprecated:
132-
reason: renamed
133-
renamed_to: "x_ai"
134137
- id: deepseek
135138
stability: development
136139
value: "deepseek"

model/messaging/deprecated/registry-deprecated.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ groups:
1111
Deprecated, use `messaging.destination.partition.id` instead.
1212
examples: 2
1313
deprecated:
14-
reason: renamed
15-
renamed_to: messaging.destination.partition.id
14+
reason: uncategorized
15+
note: Record string representation of the partition id in `messaging.destination.partition.id` attribute.
1616
stability: development
1717
- id: messaging.operation
1818
type: string

policies/deprecation.rego

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ registry_attribute_names := {attr.name |
88
not attr.deprecated
99
}
1010

11+
12+
registry_attribute_type_map := { attr.name: attr.type |
13+
some g in input.groups
14+
some attr in g.attributes
15+
not attr.deprecated
16+
}
17+
1118
registry_metric_names := {group.metric_name |
1219
some group in input.groups
1320
group.type == "metric"
@@ -23,6 +30,7 @@ registry_event_names := {group.name |
2330
# attribute.deprecated.renamed_to must be another attribute
2431
deny contains deprecation_violation(description, group.id, "") if {
2532
group := input.groups[_]
33+
startswith(group.id, "registry.")
2634
attr := group.attributes[_]
2735
attr.deprecated != null
2836
attr.deprecated.renamed_to != null
@@ -31,6 +39,125 @@ deny contains deprecation_violation(description, group.id, "") if {
3139
description := sprintf("Attribute '%s' was renamed to '%s', but the new attribute does not exist or is deprecated.", [attr.name, attr.deprecated.renamed_to])
3240
}
3341

42+
# attribute.deprecated.renamed_to attribute must be of the same type
43+
deny contains deprecation_violation(description, group.id, "") if {
44+
group := input.groups[_]
45+
startswith(group.id, "registry.")
46+
attr := group.attributes[_]
47+
attr.deprecated != null
48+
attr.deprecated.renamed_to != null
49+
# enums are checked separately
50+
not attr.type.members
51+
52+
new_type = registry_attribute_type_map[attr.deprecated.renamed_to]
53+
# enums are checked separately
54+
not new_type.members
55+
attr.type != new_type
56+
description := sprintf("Attribute '%s' was renamed to '%s', but the new attribute type '%s' is not the same as the old attribute type '%s'.", [attr.name, attr.deprecated.renamed_to, new_type, attr.type])
57+
}
58+
59+
# attribute.deprecated.renamed_to: string to enum of strings is ok
60+
deny contains deprecation_violation(description, group.id, "") if {
61+
group := input.groups[_]
62+
startswith(group.id, "registry.")
63+
attr := group.attributes[_]
64+
attr.deprecated != null
65+
attr.deprecated.renamed_to != null
66+
new_type = registry_attribute_type_map[attr.deprecated.renamed_to]
67+
68+
attr.type == "string"
69+
new_type.members != null
70+
not is_string(new_type.members[0].value)
71+
72+
description := sprintf("String attribute '%s' was renamed to enum attribute '%s', but the new attribute member type '%s' is not a string type", [attr.name, attr.deprecated.renamed_to, new_type.members[0].value])
73+
}
74+
75+
# attribute.deprecated.renamed_to: int to enum of ints is ok
76+
deny contains deprecation_violation(description, group.id, "") if {
77+
group := input.groups[_]
78+
startswith(group.id, "registry.")
79+
attr := group.attributes[_]
80+
attr.deprecated != null
81+
attr.deprecated.renamed_to != null
82+
new_type = registry_attribute_type_map[attr.deprecated.renamed_to]
83+
84+
attr.type == "int"
85+
new_type.members != null
86+
not is_number(new_type.members[0].value)
87+
88+
description := sprintf("Int attribute '%s' was renamed to enum attribute '%s', but the new attribute member type '%s' is not a number", [attr.name, attr.deprecated.renamed_to, new_type.members[0].value])
89+
}
90+
91+
# enum attribute.deprecated.renamed_to: enum of the same value types is ok
92+
deny contains deprecation_violation(description, group.id, "") if {
93+
group := input.groups[_]
94+
startswith(group.id, "registry.")
95+
attr := group.attributes[_]
96+
attr.deprecated != null
97+
attr.deprecated.renamed_to != null
98+
attr.type.members != null
99+
new_type = registry_attribute_type_map[attr.deprecated.renamed_to]
100+
new_type.members != null
101+
102+
not same_type(attr.type.members[0].value, new_type.members[0].value)
103+
description := sprintf("Enum attribute '%s' was renamed to '%s', but the value types are not the same: old - '%s', new - '%s'.",
104+
[attr.name, attr.deprecated.renamed_to, attr.type.members[0].value, new_type.members[0].value])
105+
}
106+
107+
# enum attribute.deprecated.renamed_to: enum of strings to string is ok
108+
deny contains deprecation_violation(description, group.id, "") if {
109+
group := input.groups[_]
110+
startswith(group.id, "registry.")
111+
attr := group.attributes[_]
112+
attr.deprecated != null
113+
attr.deprecated.renamed_to != null
114+
115+
attr.type.members != null
116+
117+
is_string(attr.type.members[0].value)
118+
119+
new_type = registry_attribute_type_map[attr.deprecated.renamed_to]
120+
not new_type.members
121+
new_type != "string"
122+
description := sprintf("Enum attribute '%s' with string values was renamed to '%s', but the new attribute type is '%s'.", [attr.name, attr.deprecated.renamed_to, new_type])
123+
}
124+
125+
# enum attribute.deprecated.renamed_to: enum of ints to int is ok
126+
deny contains deprecation_violation(description, group.id, "") if {
127+
group := input.groups[_]
128+
startswith(group.id, "registry.")
129+
attr := group.attributes[_]
130+
attr.deprecated != null
131+
attr.deprecated.renamed_to != null
132+
attr.type.members != null
133+
is_number(attr.type.members[0].value)
134+
135+
new_type = registry_attribute_type_map[attr.deprecated.renamed_to]
136+
not new_type.members
137+
new_type != "int"
138+
description := sprintf("Enum attribute '%s' with int values was renamed to '%s', but the new attribute type is '%s'.", [attr.name, attr.deprecated.renamed_to, new_type])
139+
}
140+
141+
# attribute.members.deprecated.renamed_to member must be a member of the same enum
142+
deny contains deprecation_violation(description, group.id, "") if {
143+
group := input.groups[_]
144+
startswith(group.id, "registry.")
145+
attr := group.attributes[_]
146+
attr.type.members != null
147+
member := attr.type.members[_]
148+
member.deprecated.renamed_to != null
149+
150+
matches := [m.id |
151+
m := attr.type.members[_]
152+
m.id == member.deprecated.renamed_to
153+
object.get(m, "deprecated", null) == null
154+
]
155+
count(matches) == 0
156+
157+
description := sprintf("Member '%s' of the attribute '%s' was renamed to '%s', but the new member does not exist or is deprecated.", [member.id,
158+
attr.name, member.deprecated.renamed_to])
159+
}
160+
34161
# metric.deprecated.renamed_to must be another metric
35162
deny contains deprecation_violation(description, group.id, "") if {
36163
group := input.groups[_]
@@ -62,3 +189,33 @@ deprecation_violation(description, group, attr) = violation if {
62189
"group": group,
63190
}
64191
}
192+
193+
same_type(a, b) if {
194+
is_string(a)
195+
is_string(b)
196+
}
197+
198+
same_type(a, b) if {
199+
is_number(a)
200+
is_number(b)
201+
}
202+
203+
same_type(a, b) if {
204+
is_boolean(a)
205+
is_boolean(b)
206+
}
207+
208+
same_type(a, b) if {
209+
is_array(a)
210+
is_array(b)
211+
}
212+
213+
same_type(a, b) if {
214+
is_set(a)
215+
is_set(b)
216+
}
217+
218+
same_type(a, b) if {
219+
is_object(a)
220+
is_object(b)
221+
}

0 commit comments

Comments
 (0)