Skip to content

Commit

Permalink
chore(forge): Add experimental and deprecated attributes in the gener…
Browse files Browse the repository at this point in the history
…ated code.
  • Loading branch information
lquerel committed Apr 30, 2024
1 parent d65680c commit 30876fc
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 14 deletions.
1 change: 1 addition & 0 deletions crates/weaver_forge/allowed-external-types.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ allowed_external_types = [
"weaver_common::*",
"weaver_resolved_schema::*",
"weaver_semconv::*",
"minijinja::value::Value",
]
2 changes: 2 additions & 0 deletions crates/weaver_forge/codegen_examples/expected_codegen/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
Expand Down
134 changes: 134 additions & 0 deletions crates/weaver_forge/codegen_examples/expected_codegen/net.rs
Original file line number Diff line number Diff line change
@@ -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<StringValue> = 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<StringValue> = 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<i64> = 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<StringValue> = 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<i64> = 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<StringValue> = 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<i64> = 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<StringValue> = 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<i64> = 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<NetTransport> = 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<StringValue> = 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<StringValue> = 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<NetSockFamily> = 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,

}

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

0 comments on commit 30876fc

Please sign in to comment.