diff --git a/crates/weaver_forge/allowed-external-types.toml b/crates/weaver_forge/allowed-external-types.toml index 07f5e8b9..4333d3a1 100644 --- a/crates/weaver_forge/allowed-external-types.toml +++ b/crates/weaver_forge/allowed-external-types.toml @@ -9,4 +9,5 @@ allowed_external_types = [ "weaver_common::*", "weaver_resolved_schema::*", "weaver_semconv::*", + "minijinja::value::Value", ] \ No newline at end of file diff --git a/crates/weaver_forge/codegen_examples/expected_codegen/lib.rs b/crates/weaver_forge/codegen_examples/expected_codegen/lib.rs index 170f234b..b997ff69 100644 --- a/crates/weaver_forge/codegen_examples/expected_codegen/lib.rs +++ b/crates/weaver_forge/codegen_examples/expected_codegen/lib.rs @@ -15,6 +15,8 @@ pub mod client; pub mod exception; /// This document defines semantic convention attributes in the HTTP namespace. pub mod http; +/// These attributes may be used for any network related operation. +pub mod net; /// A typed attribute key. pub struct AttributeKey { diff --git a/crates/weaver_forge/codegen_examples/expected_codegen/net.rs b/crates/weaver_forge/codegen_examples/expected_codegen/net.rs new file mode 100644 index 00000000..477f41f2 --- /dev/null +++ b/crates/weaver_forge/codegen_examples/expected_codegen/net.rs @@ -0,0 +1,134 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +//! These attributes may be used for any network related operation. +//! DO NOT EDIT, this is an Auto-generated file from templates/registry/rust/lib.rs.j2 + +use opentelemetry::StringValue; +use crate::AttributeKey; + + +/// Deprecated, no replacement at this time. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Removed.")] +pub const NET_SOCK_PEER_NAME: AttributeKey = AttributeKey::new("net.sock.peer.name"); + + + +/// Deprecated, use `network.peer.address`. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Replaced by `network.peer.address`.")] +pub const NET_SOCK_PEER_ADDR: AttributeKey = AttributeKey::new("net.sock.peer.addr"); + + + +/// Deprecated, use `network.peer.port`. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Replaced by `network.peer.port`.")] +pub const NET_SOCK_PEER_PORT: AttributeKey = AttributeKey::new("net.sock.peer.port"); + + +/// Deprecated, use `server.address` on client spans and `client.address` on server spans. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Replaced by `server.address` on client spans and `client.address` on server spans.")] +pub const NET_PEER_NAME: AttributeKey = AttributeKey::new("net.peer.name"); + + + +/// Deprecated, use `server.port` on client spans and `client.port` on server spans. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Replaced by `server.port` on client spans and `client.port` on server spans.")] +pub const NET_PEER_PORT: AttributeKey = AttributeKey::new("net.peer.port"); + + +/// Deprecated, use `server.address`. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Replaced by `server.address`.")] +pub const NET_HOST_NAME: AttributeKey = AttributeKey::new("net.host.name"); + + + +/// Deprecated, use `server.port`. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Replaced by `server.port`.")] +pub const NET_HOST_PORT: AttributeKey = AttributeKey::new("net.host.port"); + + +/// Deprecated, use `network.local.address`. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Replaced by `network.local.address`.")] +pub const NET_SOCK_HOST_ADDR: AttributeKey = AttributeKey::new("net.sock.host.addr"); + + + +/// Deprecated, use `network.local.port`. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Replaced by `network.local.port`.")] +pub const NET_SOCK_HOST_PORT: AttributeKey = AttributeKey::new("net.sock.host.port"); + + +/// Deprecated, use `network.transport`. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Replaced by `network.transport`.")] +pub const NET_TRANSPORT: AttributeKey = AttributeKey::new("net.transport"); + + +/// Deprecated, use `network.transport`. +#[non_exhaustive] +pub enum NetTransport { + + #[cfg(feature = "semconv_experimental")] + IpTcp, + + #[cfg(feature = "semconv_experimental")] + IpUdp, + /// Named or anonymous pipe. + #[cfg(feature = "semconv_experimental")] + Pipe, + /// In-process communication. /// Signals that there is only in-process communication not using a "real" network protocol in cases where network attributes would normally be expected. Usually all other network attributes can be left out in that case. + #[cfg(feature = "semconv_experimental")] + Inproc, + /// Something else (non IP-based). + #[cfg(feature = "semconv_experimental")] + Other, + +} + + +/// Deprecated, use `network.protocol.name`. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Replaced by `network.protocol.name`.")] +pub const NET_PROTOCOL_NAME: AttributeKey = AttributeKey::new("net.protocol.name"); + + + +/// Deprecated, use `network.protocol.version`. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Replaced by `network.protocol.version`.")] +pub const NET_PROTOCOL_VERSION: AttributeKey = AttributeKey::new("net.protocol.version"); + + + +/// Deprecated, use `network.transport` and `network.type`. +#[cfg(feature = "semconv_experimental")] +#[deprecated(note="Split to `network.transport` and `network.type`.")] +pub const NET_SOCK_FAMILY: AttributeKey = AttributeKey::new("net.sock.family"); + + +/// Deprecated, use `network.transport` and `network.type`. +#[non_exhaustive] +pub enum NetSockFamily { + /// IPv4 address + #[cfg(feature = "semconv_experimental")] + Inet, + /// IPv6 address + #[cfg(feature = "semconv_experimental")] + Inet6, + /// Unix domain socket path + #[cfg(feature = "semconv_experimental")] + Unix, + +} + diff --git a/crates/weaver_forge/codegen_examples/templates/registry/rust/weaver.yaml b/crates/weaver_forge/codegen_examples/templates/registry/rust/weaver.yaml index 3227521f..7b3d872e 100644 --- a/crates/weaver_forge/codegen_examples/templates/registry/rust/weaver.yaml +++ b/crates/weaver_forge/codegen_examples/templates/registry/rust/weaver.yaml @@ -24,18 +24,7 @@ templates: id, type, brief, - prefix, - attributes: (.attributes - | map(select(.stability == "experimental" and .deprecated | not)))}) - | map(select(.attributes | length > 0)) - | map( - { - id, - type, - brief, - prefix - } - ) + prefix}) | unique_by(.prefix) | sort_by(.prefix) application_mode: single @@ -56,7 +45,58 @@ templates: type, brief, prefix, - attributes: (.attributes | map(select(.stability == "experimental" and .deprecated | not)))}) + attributes}) | sort_by(.prefix // empty) - | map(select(.attributes | length > 0)) application_mode: each + +# Other examples of filters + +# The following JQ filter extracts the id, type, brief, and prefix of groups matching the following criteria: +# - groups with an id starting with the prefix `registry.` +# - groups of the type `attribute_group`. +# - groups with a well-defined prefix. +# - groups with a non-empty list of attributes that are neither deprecated nor experimental. +# - groups are deduplicated by prefix. +# - groups are sorted by prefix. +# filter: > +# .groups +# | map(select(.id | startswith("registry."))) +# | map(select(.type == "attribute_group" and .prefix != null and .prefix != "") +# | { +# id, +# type, +# brief, +# prefix, +# attributes: (.attributes +# | map(select(.stability == "experimental" and .deprecated | not)))}) +# | map(select(.attributes | length > 0)) +# | map( +# { +# id, +# type, +# brief, +# prefix +# } +# ) +# | unique_by(.prefix) +# | sort_by(.prefix) + + +# The following JQ filter extracts the id, type, brief, prefix, and attributes of groups matching the following +# criteria: +# - groups with an id starting with the prefix `registry.` +# - groups of the type `attribute_group`. +# - groups with a well-defined prefix. +# - groups with a non-empty list of attributes that are neither deprecated nor experimental. +# - groups are sorted by prefix. +# filter: > +# .groups +# | map(select(.id | startswith("registry."))) +# | map(select(.type == "attribute_group" and .prefix != null and .prefix != "") +# | { +# id, +# type, +# brief, +# prefix, +# attributes: (.attributes | map(select(.stability == "experimental" and .deprecated | not)))}) +# | sort_by(.prefix // empty) \ No newline at end of file