Update weaver to 0.14.0 and allow `_` -> `.` renames (#2086)

This commit is contained in:
Liudmila Molkova 2025-04-11 09:30:39 -07:00 committed by GitHub
parent 64a471367b
commit 37aa27712f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 27 additions and 17 deletions

View File

@ -3,7 +3,7 @@
# Dependabot can keep this file up to date with latest containers.
# Weaver is used to generate markdown docs, and enforce policies on the model.
FROM otel/weaver:v0.13.2 AS weaver
FROM otel/weaver:v0.14.0 AS weaver
# OPA is used to test policies enforced by weaver.
FROM openpolicyagent/opa:1.3.0 AS opa

View File

@ -111,7 +111,7 @@ of `[ 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 30, 60, 120, 300 ]`.
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| [`error.type`](/docs/attributes-registry/error.md) | string | The full name of exception type. [1] | `System.OperationCanceledException`; `Contoso.MyException` | `Conditionally Required` if and only if an error has occurred. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`error.type`](/docs/attributes-registry/error.md) | string | The full name of exception type. [1] | `connection_reset`; `invalid_handshake` | `Conditionally Required` if and only if an error has occurred. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`network.protocol.name`](/docs/attributes-registry/network.md) | string | [OSI application layer](https://wikipedia.org/wiki/Application_layer) or non-OSI equivalent. [2] | `http`; `web_sockets` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`network.protocol.version`](/docs/attributes-registry/network.md) | string | The actual version of the protocol used for network communication. [3] | `1.1`; `2` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`network.transport`](/docs/attributes-registry/network.md) | string | [OSI transport layer](https://wikipedia.org/wiki/Transport_layer) or [inter-process communication method](https://wikipedia.org/wiki/Inter-process_communication). [4] | `tcp`; `unix` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |

View File

@ -38,14 +38,12 @@ groups:
- ref: network.protocol.version
examples: ["1.1", "2"]
- ref: tls.protocol.version
# yamllint disable rule:line-length
- ref: error.type
brief: The full name of exception type.
requirement_level:
conditionally_required: if and only if an error has occurred.
note: "Captures the exception type when a connection fails."
examples: ['System.OperationCanceledException', 'Contoso.MyException']
# yamllint disable rule:line-length
- ref: error.type
examples: ['connection_reset', 'invalid_handshake']
# TODO: move note to yaml once https://github.com/open-telemetry/build-tools/issues/192 is supported
note: |
Starting from .NET 9, Kestrel `kestrel.connection.duration` metric reports

View File

@ -26,6 +26,9 @@ groups:
Deprecated, use `messaging.client.id` instead.
examples: ['client-5', 'myhost@8742@s8083jm']
deprecated: "Replaced by `messaging.client.id`."
annotations:
code_generation:
exclude: true
- id: messaging.kafka.consumer.group
type: string
brief: >

View File

@ -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": is_property_set(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"), "annotations": property_or_null(attr, "annotations") }
}
# check that attribute constant names do not collide
@ -14,14 +14,19 @@ deny contains attr_registry_collision(description, name) if {
some i
name := attribute_names[i].name
const_name := attribute_names[i].const_name
not excluded_const_collisions[name]
annotations := attribute_names[i].annotations
not annotations["code_generation"]["exclude"]
collisions := [other.name |
other := attribute_names[_]
other.name != name
other.const_name == const_name
not excluded_const_collisions[other.name]
not other.annotations["code_generation"]["exclude"]
]
count(collisions) > 0
# TODO (https://github.com/open-telemetry/weaver/issues/279): provide other violation properties once weaver supports it.
description := sprintf("Attribute '%s' has the same constant name '%s' as '%s'.", [name, const_name, collisions])
}
@ -82,11 +87,6 @@ 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"}
property_or_null(obj, property) := obj[property] if {
obj[property]
} else = null

View File

@ -29,3 +29,12 @@ test_does_not_fail_on_deprecated_namespace_collision if {
count(deny) == 0 with input as collision
}
test_does_not_fail_on_excluded_name_collision if {
collision := {"groups": [
{"id": "test1", "attributes": [{"name": "test1.namespace.id"}, {"name": "test1.namespace_id", "annotations": {"code_generation": {"exclude": true}}}]},
{"id": "test2", "attributes": [{"name": "test2.namespace_id"}, {"name": "test2.namespace.id", "annotations": {"code_generation": {"exclude": true}}}]},
]}
count(deny) == 0 with input as collision
}