From ca04bcbb3a78451bd5ba8f778285a939c3a58874 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 8 Apr 2024 08:33:37 -0400 Subject: [PATCH 1/4] Implement "is_local" and bring rendering up to date with build-tools - Add stability badges where required - Initial buggy implementation of is_local. --- crates/weaver_resolved_schema/src/lineage.rs | 2 +- crates/weaver_semconv_gen/src/gen.rs | 79 ++++++++++++-------- crates/weaver_semconv_gen/src/lib.rs | 29 +++++-- 3 files changed, 72 insertions(+), 38 deletions(-) diff --git a/crates/weaver_resolved_schema/src/lineage.rs b/crates/weaver_resolved_schema/src/lineage.rs index 371c9667..b771ed55 100644 --- a/crates/weaver_resolved_schema/src/lineage.rs +++ b/crates/weaver_resolved_schema/src/lineage.rs @@ -40,7 +40,7 @@ pub struct GroupLineage { /// This is important to keep unit tests stable. #[serde(skip_serializing_if = "BTreeMap::is_empty")] #[serde(default)] - attributes: BTreeMap, + pub attributes: BTreeMap, } impl AttributeLineage { diff --git a/crates/weaver_semconv_gen/src/gen.rs b/crates/weaver_semconv_gen/src/gen.rs index 319e8249..0d30abe3 100644 --- a/crates/weaver_semconv_gen/src/gen.rs +++ b/crates/weaver_semconv_gen/src/gen.rs @@ -107,6 +107,15 @@ fn write_enum_examples_string( Ok(()) } +fn write_stability_badge(out: &mut Out, stability: &Option) -> Result<(), Error> { + match stability { + Some(Stability::Stable) => write!(out, "![Stable](https://img.shields.io/badge/-stable-lightgreen)")?, + Some(Stability::Deprecated) => write!(out, "![Deprecated](https://img.shields.io/badge/-deprecated-red)")?, + Some(Stability::Experimental) | None => write!(out, "![Experimental](https://img.shields.io/badge/-experimental-blue)")?, + } + Ok(()) +} + struct AttributeView<'a> { attribute: &'a Attribute, } @@ -173,11 +182,7 @@ impl<'a> AttributeView<'a> { } // Stability. write!(out, " | ")?; - match m.stability { - Some(Stability::Stable) => write!(out, "Stable")?, - Some(Stability::Deprecated) => write!(out, "Deprecated")?, - Some(Stability::Experimental) | None => write!(out, "Experimental")?, - } + write_stability_badge(out, &m.stability)?; writeln!(out, " |")?; } } @@ -238,28 +243,28 @@ impl<'a> AttributeView<'a> { ) -> Result<(), Error> { match &self.attribute.requirement_level { RequirementLevel::Basic(BasicRequirementLevelSpec::Required) => { - Ok(write!(out, "Required")?) + Ok(write!(out, "`Required`")?) } RequirementLevel::Basic(BasicRequirementLevelSpec::Recommended) => { - Ok(write!(out, "Recommended")?) + Ok(write!(out, "`Recommended`")?) } - RequirementLevel::Basic(BasicRequirementLevelSpec::OptIn) => Ok(write!(out, "Opt-In")?), + RequirementLevel::Basic(BasicRequirementLevelSpec::OptIn) => Ok(write!(out, "`Opt-In`")?), RequirementLevel::ConditionallyRequired { text } => { if text.len() > BREAK_COUNT { Ok(write!( out, - "Conditionally Required: {}", + "`Conditionally Required` {}", ctx.add_note(text.clone()) )?) } else { - Ok(write!(out, "Conditionally Required: {text}")?) + Ok(write!(out, "`Conditionally Required` {text}")?) } } RequirementLevel::Recommended { text } => { if text.len() > BREAK_COUNT { - Ok(write!(out, "Recommended: {}", ctx.add_note(text.clone()))?) + Ok(write!(out, "`Recommended` {}", ctx.add_note(text.clone()))?) } else { - Ok(write!(out, "Recommended: {text}")?) + Ok(write!(out, "`Recommended` {text}")?) } } } @@ -278,6 +283,10 @@ impl<'a> AttributeView<'a> { } } } + + fn write_stability(&self, out: &mut Out) -> Result<(), Error> { + write_stability_badge(out, &self.attribute.stability) + } } fn sort_ordinal_for_requirement(e: &RequirementLevel) -> i32 { @@ -319,11 +328,18 @@ impl<'a> AttributeTableView<'a> { } } - fn attributes(&self) -> impl Iterator> { + fn is_attribute_local(&self, id: &str) -> bool { + self.lookup.is_attribute_local(&self.group.id, id) + } + + /// Returns attributes sorted for rendering. + /// is_full - denotes if all inhereted attributes should be included or just locally defined ones. + fn attributes(&self, is_full: bool) -> impl Iterator> { self.group .attributes .iter() .filter_map(|attr| self.lookup.attribute(attr)) + .filter(|a| is_full || self.is_attribute_local(&a.name)) .sorted_by(|lhs, rhs| { match sort_ordinal_for_requirement(&lhs.requirement_level) .cmp(&sort_ordinal_for_requirement(&rhs.requirement_level)) @@ -348,26 +364,18 @@ impl<'a> AttributeTableView<'a> { write!(out, "The event name MUST be `{}`\n\n", self.event_name())?; } - // TODO - deal with - // - local / full (do we still support this?) - if args.is_omit_requirement() { - writeln!(out, "| Attribute | Type | Description | Examples |")?; - writeln!(out, "|---|---|---|---|")?; + writeln!(out, "| Attribute | Type | Description | Examples | Stability |")?; + writeln!(out, "|---|---|---|---|---|")?; } else { - // TODO - we should use link version and update tests/semconv upstream. writeln!(out, "| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |")?; - // writeln!( - // out, - // "| Attribute | Type | Description | Examples | Requirement Level |" - // )?; - writeln!(out, "|---|---|---|---|---|")?; + writeln!(out, "|---|---|---|---|---|---|")?; } // If the user defined a tag, use it to filter attributes. let attributes: Vec> = match args.tag_filter() { - Some(tag) => self.attributes().filter(|a| a.has_tag(tag)).collect(), - None => self.attributes().collect(), + Some(tag) => self.attributes(args.is_full()).filter(|a| a.has_tag(tag)).collect(), + None => self.attributes(args.is_full()).collect(), }; for attr in &attributes { @@ -380,21 +388,23 @@ impl<'a> AttributeTableView<'a> { write!(out, " | ")?; attr.write_examples(out)?; if args.is_omit_requirement() { - writeln!(out, " |")?; + write!(out, " | ")?; } else { write!(out, " | ")?; attr.write_requirement(out, ctx)?; - writeln!(out, " |")?; + write!(out, " | ")?; } + attr.write_stability(out)?; + writeln!(out, " |")?; } // Add "note" footers ctx.write_rendered_notes(out)?; - // Add "constraints" notes. + // No longer doing - Add "constraints" notes. // Add sampling relevant callouts. let sampling_relevant: Vec> = self - .attributes() + .attributes(args.is_full()) .filter(|a| a.is_sampling_relevant()) .collect(); if !sampling_relevant.is_empty() { @@ -481,6 +491,9 @@ impl<'a> MetricView<'a> { } Ok(()) } + fn write_stability(&self, out: &mut Out) -> Result<(), Error> { + write_stability_badge(out, &self.group.stability) + } pub fn generate_markdown( &self, out: &mut Out, @@ -488,11 +501,11 @@ impl<'a> MetricView<'a> { ) -> Result<(), Error> { writeln!( out, - "| Name | Instrument Type | Unit (UCUM) | Description |" + "| Name | Instrument Type | Unit (UCUM) | Description | Stability |" )?; writeln!( out, - "| -------- | --------------- | ----------- | -------------- |" + "| -------- | --------------- | ----------- | -------------- | --------- |" )?; write!( out, @@ -503,6 +516,8 @@ impl<'a> MetricView<'a> { self.write_unit(out)?; write!(out, "` | ")?; self.write_description(out, ctx)?; + write!(out, " | ")?; + self.write_stability(out)?; writeln!(out, " |")?; // Add "note" footers ctx.write_rendered_notes(out)?; diff --git a/crates/weaver_semconv_gen/src/lib.rs b/crates/weaver_semconv_gen/src/lib.rs index 85fb63a2..6e1839a5 100644 --- a/crates/weaver_semconv_gen/src/lib.rs +++ b/crates/weaver_semconv_gen/src/lib.rs @@ -99,11 +99,11 @@ pub struct GenerateMarkdownArgs { args: Vec, } impl GenerateMarkdownArgs { - // TODO - // fn is_full(&self) -> bool { - // self.args.iter().any(|a| matches!(a, MarkdownGenParameters::Full)) - // } - /// Returns true if the omit requirement level flag was specified. + // Returns true if the `full` flag was specified. + fn is_full(&self) -> bool { + self.args.iter().any(|a| matches!(a, MarkdownGenParameters::Full)) + } + /// Returns true if the `omit_requirement_level` flag was specified. fn is_omit_requirement(&self) -> bool { self.args .iter() @@ -251,6 +251,25 @@ impl ResolvedSemconvRegistry { fn attribute(&self, attr: &AttributeRef) -> Option<&Attribute> { self.schema.catalog.attribute(attr) } + + /// Determines if the attribute is not further inhereted from group_id in any other file. + /// For example , if attribute x.y is defined in group "a", and referenced in "b", the attribute would be local to "b". + /// Why do we call this local? - It's an inherited mechanism from build-tools. + fn is_attribute_local(&self, group_id: &str, attribute_id: &str) -> bool { + // Note: This isn't correct just yet, we're always getting true. + let found_inheritance_or_ref = self.my_registry().map(|r| { + r.groups.iter().any(|g| { + g.lineage.as_ref().and_then(|l| { + l.attributes.get(attribute_id) + }) + .map(|al| { + al.source_group == group_id + }) + .unwrap_or(false) + }) + }).unwrap_or(true); + !found_inheritance_or_ref + } } #[cfg(test)] From 736a62e0438fb94858b3adefeda37e438ae10a10 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 8 Apr 2024 08:43:00 -0400 Subject: [PATCH 2/4] Update tests for stabillity shield. --- .../data/http-metric-semconv.md | 300 +++++++++--------- .../data/http-span-full-attribute-table.md | 52 +-- 2 files changed, 176 insertions(+), 176 deletions(-) diff --git a/crates/weaver_semconv_gen/data/http-metric-semconv.md b/crates/weaver_semconv_gen/data/http-metric-semconv.md index 6f45fdda..e6039faa 100644 --- a/crates/weaver_semconv_gen/data/http-metric-semconv.md +++ b/crates/weaver_semconv_gen/data/http-metric-semconv.md @@ -70,23 +70,23 @@ This metric SHOULD be specified with of `[ 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 ]`. -| Name | Instrument Type | Unit (UCUM) | Description | -| -------- | --------------- | ----------- | -------------- | -| `http.server.request.duration` | Histogram | `s` | Duration of HTTP server requests. | +| Name | Instrument Type | Unit (UCUM) | Description | Stability | +| -------- | --------------- | ----------- | -------------- | --------- | +| `http.server.request.duration` | Histogram | `s` | Duration of HTTP server requests. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | -|---|---|---|---|---| -| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | Required | -| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. [2] | `http`; `https` | Required | -| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | Conditionally Required: If request has ended with an error. | -| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | Conditionally Required: If and only if one was received/sent. | -| [`http.route`](../attributes-registry/http.md) | string | The matched route, that is, the path template in the format used by the respective server framework. [4] | `/users/:userID?`; `{controller}/{action}/{id?}` | Conditionally Required: If and only if it's available | -| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | Conditionally Required: [6] | -| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | Recommended | -| [`server.address`](../attributes-registry/server.md) | string | Name of the local HTTP server that received the request. [8] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | Opt-In | -| [`server.port`](../attributes-registry/server.md) | int | Port of the local HTTP server that received the request. [9] | `80`; `8080`; `443` | Opt-In | +|---|---|---|---|---|---| +| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. [2] | `http`; `https` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If request has ended with an error. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | `Conditionally Required` If and only if one was received/sent. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.route`](../attributes-registry/http.md) | string | The matched route, that is, the path template in the format used by the respective server framework. [4] | `/users/:userID?`; `{controller}/{action}/{id?}` | `Conditionally Required` If and only if it's available | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | `Conditionally Required` [6] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](../attributes-registry/server.md) | string | Name of the local HTTP server that received the request. [8] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](../attributes-registry/server.md) | int | Port of the local HTTP server that received the request. [9] | `80`; `8080`; `443` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1]:** HTTP request method value SHOULD be "known" to the instrumentation. By default, this convention defines "known" methods as the ones listed in [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods) @@ -145,22 +145,22 @@ SHOULD include the [application root](/docs/http/http-spans.md#http-server-defin | Value | Description | Stability | |---|---|---| -| `CONNECT` | CONNECT method. | Experimental | -| `DELETE` | DELETE method. | Experimental | -| `GET` | GET method. | Experimental | -| `HEAD` | HEAD method. | Experimental | -| `OPTIONS` | OPTIONS method. | Experimental | -| `PATCH` | PATCH method. | Experimental | -| `POST` | POST method. | Experimental | -| `PUT` | PUT method. | Experimental | -| `TRACE` | TRACE method. | Experimental | -| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | Experimental | +| `CONNECT` | CONNECT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `DELETE` | DELETE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `GET` | GET method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `HEAD` | HEAD method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `OPTIONS` | OPTIONS method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PATCH` | PATCH method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `POST` | POST method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PUT` | PUT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `TRACE` | TRACE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | `error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used. | Value | Description | Stability | |---|---|---| -| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | Experimental | +| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | ### Metric: `http.server.active_requests` @@ -231,25 +231,25 @@ Tracing instrumentations that do so, MUST also set `http.request.method_original This metric is optional. -| Name | Instrument Type | Unit (UCUM) | Description | -| -------- | --------------- | ----------- | -------------- | -| `http.server.request.body.size` | Histogram | `By` | Size of HTTP server request bodies. [1] | +| Name | Instrument Type | Unit (UCUM) | Description | Stability | +| -------- | --------------- | ----------- | -------------- | --------- | +| `http.server.request.body.size` | Histogram | `By` | Size of HTTP server request bodies. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | **[1]:** The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size. | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | -|---|---|---|---|---| -| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | Required | -| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. [2] | `http`; `https` | Required | -| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | Conditionally Required: If request has ended with an error. | -| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | Conditionally Required: If and only if one was received/sent. | -| [`http.route`](../attributes-registry/http.md) | string | The matched route, that is, the path template in the format used by the respective server framework. [4] | `/users/:userID?`; `{controller}/{action}/{id?}` | Conditionally Required: If and only if it's available | -| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | Conditionally Required: [6] | -| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | Recommended | -| [`server.address`](../attributes-registry/server.md) | string | Name of the local HTTP server that received the request. [8] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | Opt-In | -| [`server.port`](../attributes-registry/server.md) | int | Port of the local HTTP server that received the request. [9] | `80`; `8080`; `443` | Opt-In | +|---|---|---|---|---|---| +| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. [2] | `http`; `https` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If request has ended with an error. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | `Conditionally Required` If and only if one was received/sent. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.route`](../attributes-registry/http.md) | string | The matched route, that is, the path template in the format used by the respective server framework. [4] | `/users/:userID?`; `{controller}/{action}/{id?}` | `Conditionally Required` If and only if it's available | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | `Conditionally Required` [6] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](../attributes-registry/server.md) | string | Name of the local HTTP server that received the request. [8] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](../attributes-registry/server.md) | int | Port of the local HTTP server that received the request. [9] | `80`; `8080`; `443` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1]:** HTTP request method value SHOULD be "known" to the instrumentation. By default, this convention defines "known" methods as the ones listed in [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods) @@ -308,22 +308,22 @@ SHOULD include the [application root](/docs/http/http-spans.md#http-server-defin | Value | Description | Stability | |---|---|---| -| `CONNECT` | CONNECT method. | Experimental | -| `DELETE` | DELETE method. | Experimental | -| `GET` | GET method. | Experimental | -| `HEAD` | HEAD method. | Experimental | -| `OPTIONS` | OPTIONS method. | Experimental | -| `PATCH` | PATCH method. | Experimental | -| `POST` | POST method. | Experimental | -| `PUT` | PUT method. | Experimental | -| `TRACE` | TRACE method. | Experimental | -| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | Experimental | +| `CONNECT` | CONNECT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `DELETE` | DELETE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `GET` | GET method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `HEAD` | HEAD method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `OPTIONS` | OPTIONS method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PATCH` | PATCH method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `POST` | POST method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PUT` | PUT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `TRACE` | TRACE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | `error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used. | Value | Description | Stability | |---|---|---| -| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | Experimental | +| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | ### Metric: `http.server.response.body.size` @@ -333,25 +333,25 @@ SHOULD include the [application root](/docs/http/http-spans.md#http-server-defin This metric is optional. -| Name | Instrument Type | Unit (UCUM) | Description | -| -------- | --------------- | ----------- | -------------- | -| `http.server.response.body.size` | Histogram | `By` | Size of HTTP server response bodies. [1] | +| Name | Instrument Type | Unit (UCUM) | Description | Stability | +| -------- | --------------- | ----------- | -------------- | --------- | +| `http.server.response.body.size` | Histogram | `By` | Size of HTTP server response bodies. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | **[1]:** The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size. | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | -|---|---|---|---|---| -| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | Required | -| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. [2] | `http`; `https` | Required | -| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | Conditionally Required: If request has ended with an error. | -| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | Conditionally Required: If and only if one was received/sent. | -| [`http.route`](../attributes-registry/http.md) | string | The matched route, that is, the path template in the format used by the respective server framework. [4] | `/users/:userID?`; `{controller}/{action}/{id?}` | Conditionally Required: If and only if it's available | -| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | Conditionally Required: [6] | -| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | Recommended | -| [`server.address`](../attributes-registry/server.md) | string | Name of the local HTTP server that received the request. [8] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | Opt-In | -| [`server.port`](../attributes-registry/server.md) | int | Port of the local HTTP server that received the request. [9] | `80`; `8080`; `443` | Opt-In | +|---|---|---|---|---|---| +| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. [2] | `http`; `https` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If request has ended with an error. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | `Conditionally Required` If and only if one was received/sent. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.route`](../attributes-registry/http.md) | string | The matched route, that is, the path template in the format used by the respective server framework. [4] | `/users/:userID?`; `{controller}/{action}/{id?}` | `Conditionally Required` If and only if it's available | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | `Conditionally Required` [6] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](../attributes-registry/server.md) | string | Name of the local HTTP server that received the request. [8] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](../attributes-registry/server.md) | int | Port of the local HTTP server that received the request. [9] | `80`; `8080`; `443` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1]:** HTTP request method value SHOULD be "known" to the instrumentation. By default, this convention defines "known" methods as the ones listed in [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods) @@ -410,22 +410,22 @@ SHOULD include the [application root](/docs/http/http-spans.md#http-server-defin | Value | Description | Stability | |---|---|---| -| `CONNECT` | CONNECT method. | Experimental | -| `DELETE` | DELETE method. | Experimental | -| `GET` | GET method. | Experimental | -| `HEAD` | HEAD method. | Experimental | -| `OPTIONS` | OPTIONS method. | Experimental | -| `PATCH` | PATCH method. | Experimental | -| `POST` | POST method. | Experimental | -| `PUT` | PUT method. | Experimental | -| `TRACE` | TRACE method. | Experimental | -| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | Experimental | +| `CONNECT` | CONNECT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `DELETE` | DELETE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `GET` | GET method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `HEAD` | HEAD method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `OPTIONS` | OPTIONS method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PATCH` | PATCH method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `POST` | POST method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PUT` | PUT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `TRACE` | TRACE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | `error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used. | Value | Description | Stability | |---|---|---| -| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | Experimental | +| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | ## HTTP Client @@ -443,22 +443,22 @@ This metric SHOULD be specified with of `[ 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 ]`. -| Name | Instrument Type | Unit (UCUM) | Description | -| -------- | --------------- | ----------- | -------------- | -| `http.client.request.duration` | Histogram | `s` | Duration of HTTP client requests. | +| Name | Instrument Type | Unit (UCUM) | Description | Stability | +| -------- | --------------- | ----------- | -------------- | --------- | +| `http.client.request.duration` | Histogram | `s` | Duration of HTTP client requests. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | -|---|---|---|---|---| -| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | Required | -| [`server.address`](../attributes-registry/server.md) | string | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [2] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | Required | -| [`server.port`](../attributes-registry/server.md) | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [3] | `80`; `8080`; `443` | Required | -| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [4] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | Conditionally Required: If request has ended with an error. | -| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | Conditionally Required: If and only if one was received/sent. | -| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | Conditionally Required: [6] | -| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | Recommended | -| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https` | Opt-In | +|---|---|---|---|---|---| +| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](../attributes-registry/server.md) | string | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [2] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](../attributes-registry/server.md) | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [3] | `80`; `8080`; `443` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [4] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If request has ended with an error. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | `Conditionally Required` If and only if one was received/sent. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | `Conditionally Required` [6] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1]:** HTTP request method value SHOULD be "known" to the instrumentation. By default, this convention defines "known" methods as the ones listed in [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods) @@ -506,22 +506,22 @@ If the request has completed successfully, instrumentations SHOULD NOT set `erro | Value | Description | Stability | |---|---|---| -| `CONNECT` | CONNECT method. | Experimental | -| `DELETE` | DELETE method. | Experimental | -| `GET` | GET method. | Experimental | -| `HEAD` | HEAD method. | Experimental | -| `OPTIONS` | OPTIONS method. | Experimental | -| `PATCH` | PATCH method. | Experimental | -| `POST` | POST method. | Experimental | -| `PUT` | PUT method. | Experimental | -| `TRACE` | TRACE method. | Experimental | -| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | Experimental | +| `CONNECT` | CONNECT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `DELETE` | DELETE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `GET` | GET method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `HEAD` | HEAD method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `OPTIONS` | OPTIONS method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PATCH` | PATCH method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `POST` | POST method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PUT` | PUT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `TRACE` | TRACE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | `error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used. | Value | Description | Stability | |---|---|---| -| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | Experimental | +| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | ### Metric: `http.client.request.body.size` @@ -531,24 +531,24 @@ If the request has completed successfully, instrumentations SHOULD NOT set `erro This metric is optional. -| Name | Instrument Type | Unit (UCUM) | Description | -| -------- | --------------- | ----------- | -------------- | -| `http.client.request.body.size` | Histogram | `By` | Size of HTTP client request bodies. [1] | +| Name | Instrument Type | Unit (UCUM) | Description | Stability | +| -------- | --------------- | ----------- | -------------- | --------- | +| `http.client.request.body.size` | Histogram | `By` | Size of HTTP client request bodies. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | **[1]:** The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size. | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | -|---|---|---|---|---| -| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | Required | -| [`server.address`](../attributes-registry/server.md) | string | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [2] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | Required | -| [`server.port`](../attributes-registry/server.md) | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [3] | `80`; `8080`; `443` | Required | -| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [4] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | Conditionally Required: If request has ended with an error. | -| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | Conditionally Required: If and only if one was received/sent. | -| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | Conditionally Required: [6] | -| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | Recommended | -| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https` | Opt-In | +|---|---|---|---|---|---| +| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](../attributes-registry/server.md) | string | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [2] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](../attributes-registry/server.md) | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [3] | `80`; `8080`; `443` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [4] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If request has ended with an error. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | `Conditionally Required` If and only if one was received/sent. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | `Conditionally Required` [6] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1]:** HTTP request method value SHOULD be "known" to the instrumentation. By default, this convention defines "known" methods as the ones listed in [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods) @@ -596,22 +596,22 @@ If the request has completed successfully, instrumentations SHOULD NOT set `erro | Value | Description | Stability | |---|---|---| -| `CONNECT` | CONNECT method. | Experimental | -| `DELETE` | DELETE method. | Experimental | -| `GET` | GET method. | Experimental | -| `HEAD` | HEAD method. | Experimental | -| `OPTIONS` | OPTIONS method. | Experimental | -| `PATCH` | PATCH method. | Experimental | -| `POST` | POST method. | Experimental | -| `PUT` | PUT method. | Experimental | -| `TRACE` | TRACE method. | Experimental | -| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | Experimental | +| `CONNECT` | CONNECT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `DELETE` | DELETE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `GET` | GET method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `HEAD` | HEAD method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `OPTIONS` | OPTIONS method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PATCH` | PATCH method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `POST` | POST method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PUT` | PUT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `TRACE` | TRACE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | `error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used. | Value | Description | Stability | |---|---|---| -| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | Experimental | +| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | ### Metric: `http.client.response.body.size` @@ -621,24 +621,24 @@ If the request has completed successfully, instrumentations SHOULD NOT set `erro This metric is optional. -| Name | Instrument Type | Unit (UCUM) | Description | -| -------- | --------------- | ----------- | -------------- | -| `http.client.response.body.size` | Histogram | `By` | Size of HTTP client response bodies. [1] | +| Name | Instrument Type | Unit (UCUM) | Description | Stability | +| -------- | --------------- | ----------- | -------------- | --------- | +| `http.client.response.body.size` | Histogram | `By` | Size of HTTP client response bodies. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | **[1]:** The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size. | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | -|---|---|---|---|---| -| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | Required | -| [`server.address`](../attributes-registry/server.md) | string | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [2] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | Required | -| [`server.port`](../attributes-registry/server.md) | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [3] | `80`; `8080`; `443` | Required | -| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [4] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | Conditionally Required: If request has ended with an error. | -| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | Conditionally Required: If and only if one was received/sent. | -| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | Conditionally Required: [6] | -| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | Recommended | -| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https` | Opt-In | +|---|---|---|---|---|---| +| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](../attributes-registry/server.md) | string | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [2] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](../attributes-registry/server.md) | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [3] | `80`; `8080`; `443` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [4] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If request has ended with an error. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | `Conditionally Required` If and only if one was received/sent. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [5] | `http`; `spdy` | `Conditionally Required` [6] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [7] | `1.0`; `1.1`; `2`; `3` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1]:** HTTP request method value SHOULD be "known" to the instrumentation. By default, this convention defines "known" methods as the ones listed in [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods) @@ -686,22 +686,22 @@ If the request has completed successfully, instrumentations SHOULD NOT set `erro | Value | Description | Stability | |---|---|---| -| `CONNECT` | CONNECT method. | Experimental | -| `DELETE` | DELETE method. | Experimental | -| `GET` | GET method. | Experimental | -| `HEAD` | HEAD method. | Experimental | -| `OPTIONS` | OPTIONS method. | Experimental | -| `PATCH` | PATCH method. | Experimental | -| `POST` | POST method. | Experimental | -| `PUT` | PUT method. | Experimental | -| `TRACE` | TRACE method. | Experimental | -| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | Experimental | +| `CONNECT` | CONNECT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `DELETE` | DELETE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `GET` | GET method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `HEAD` | HEAD method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `OPTIONS` | OPTIONS method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PATCH` | PATCH method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `POST` | POST method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PUT` | PUT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `TRACE` | TRACE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | `error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used. | Value | Description | Stability | |---|---|---| -| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | Experimental | +| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | ### Metric: `http.client.open_connections` @@ -751,19 +751,19 @@ of `[ 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 30, 60, 120, 300 ]`. This metric is optional. -| Name | Instrument Type | Unit (UCUM) | Description | -| -------- | --------------- | ----------- | -------------- | -| `http.client.connection.duration` | Histogram | `s` | The duration of the successfully established outbound HTTP connections. | +| Name | Instrument Type | Unit (UCUM) | Description | Stability | +| -------- | --------------- | ----------- | -------------- | --------- | +| `http.client.connection.duration` | Histogram | `s` | The duration of the successfully established outbound HTTP connections. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | -|---|---|---|---|---| -| [`server.address`](../attributes-registry/server.md) | string | Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. [1] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | Required | -| [`server.port`](../attributes-registry/server.md) | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [2] | `80`; `8080`; `443` | Required | -| [`network.peer.address`](../attributes-registry/network.md) | string | Peer address of the network connection - IP address or Unix domain socket name. | `10.1.2.80`; `/tmp/my.sock` | Recommended | -| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [3] | `3.1.1` | Recommended | -| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https` | Opt-In | +|---|---|---|---|---|---| +| [`server.address`](../attributes-registry/server.md) | string | Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. [1] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](../attributes-registry/server.md) | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. [2] | `80`; `8080`; `443` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.peer.address`](../attributes-registry/network.md) | string | Peer address of the network connection - IP address or Unix domain socket name. | `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [3] | `3.1.1` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`url.scheme`](../attributes-registry/url.md) | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1]:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. diff --git a/crates/weaver_semconv_gen/data/http-span-full-attribute-table.md b/crates/weaver_semconv_gen/data/http-span-full-attribute-table.md index f41c43c2..a44e8714 100644 --- a/crates/weaver_semconv_gen/data/http-span-full-attribute-table.md +++ b/crates/weaver_semconv_gen/data/http-span-full-attribute-table.md @@ -1,16 +1,16 @@ | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | -|---|---|---|---|---| -| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | Required | -| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [2] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | Conditionally Required: If request has ended with an error. | -| [`http.request.method_original`](../attributes-registry/http.md) | string | Original HTTP method sent by the client in the request line. | `GeT`; `ACL`; `foo` | Conditionally Required: [3] | -| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | Conditionally Required: If and only if one was received/sent. | -| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [4] | `http`; `spdy` | Conditionally Required: [5] | -| [`network.peer.address`](../attributes-registry/network.md) | string | Peer address of the network connection - IP address or Unix domain socket name. | `10.1.2.80`; `/tmp/my.sock` | Recommended | -| [`network.peer.port`](../attributes-registry/network.md) | int | Peer port number of the network connection. | `65123` | Recommended: If `network.peer.address` is set. | -| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [6] | `1.0`; `1.1`; `2`; `3` | Recommended | -| [`http.response.header.`](../attributes-registry/http.md) | string[] | HTTP response headers, `` being the normalized HTTP Header name (lowercase), the value being the header values. [7] | `http.response.header.content-type=["application/json"]`; `http.response.header.my-custom-header=["abc", "def"]` | Opt-In | -| [`network.transport`](../attributes-registry/network.md) | string | [OSI transport layer](https://osi-model.com/transport-layer/) or [inter-process communication method](https://wikipedia.org/wiki/Inter-process_communication). [8] | `tcp`; `udp` | Opt-In | +|---|---|---|---|---|---| +| [`http.request.method`](../attributes-registry/http.md) | string | HTTP request method. [1] | `GET`; `POST`; `HEAD` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`error.type`](../attributes-registry/error.md) | string | Describes a class of error the operation ended with. [2] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If request has ended with an error. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.request.method_original`](../attributes-registry/http.md) | string | Original HTTP method sent by the client in the request line. | `GeT`; `ACL`; `foo` | `Conditionally Required` [3] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.response.status_code`](../attributes-registry/http.md) | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | `Conditionally Required` If and only if one was received/sent. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.name`](../attributes-registry/network.md) | string | [OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. [4] | `http`; `spdy` | `Conditionally Required` [5] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.peer.address`](../attributes-registry/network.md) | string | Peer address of the network connection - IP address or Unix domain socket name. | `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.peer.port`](../attributes-registry/network.md) | int | Peer port number of the network connection. | `65123` | `Recommended` If `network.peer.address` is set. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.protocol.version`](../attributes-registry/network.md) | string | Version of the protocol specified in `network.protocol.name`. [6] | `1.0`; `1.1`; `2`; `3` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`http.response.header.`](../attributes-registry/http.md) | string[] | HTTP response headers, `` being the normalized HTTP Header name (lowercase), the value being the header values. [7] | `http.response.header.content-type=["application/json"]`; `http.response.header.my-custom-header=["abc", "def"]` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`network.transport`](../attributes-registry/network.md) | string | [OSI transport layer](https://osi-model.com/transport-layer/) or [inter-process communication method](https://wikipedia.org/wiki/Inter-process_communication). [8] | `tcp`; `udp` | `Opt-In` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1]:** HTTP request method value SHOULD be "known" to the instrumentation. By default, this convention defines "known" methods as the ones listed in [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods) @@ -66,29 +66,29 @@ The following attributes can be important for making sampling decisions and SHOU | Value | Description | Stability | |---|---|---| -| `CONNECT` | CONNECT method. | Experimental | -| `DELETE` | DELETE method. | Experimental | -| `GET` | GET method. | Experimental | -| `HEAD` | HEAD method. | Experimental | -| `OPTIONS` | OPTIONS method. | Experimental | -| `PATCH` | PATCH method. | Experimental | -| `POST` | POST method. | Experimental | -| `PUT` | PUT method. | Experimental | -| `TRACE` | TRACE method. | Experimental | -| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | Experimental | +| `CONNECT` | CONNECT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `DELETE` | DELETE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `GET` | GET method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `HEAD` | HEAD method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `OPTIONS` | OPTIONS method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PATCH` | PATCH method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `POST` | POST method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `PUT` | PUT method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `TRACE` | TRACE method. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `_OTHER` | Any HTTP method that the instrumentation has no prior knowledge of. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | `error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used. | Value | Description | Stability | |---|---|---| -| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | Experimental | +| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | `network.transport` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used. | Value | Description | Stability | |---|---|---| -| `tcp` | TCP | Experimental | -| `udp` | UDP | Experimental | -| `pipe` | Named or anonymous pipe. | Experimental | -| `unix` | Unix domain socket | Experimental | +| `tcp` | TCP | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `udp` | UDP | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `pipe` | Named or anonymous pipe. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `unix` | Unix domain socket | ![Experimental](https://img.shields.io/badge/-experimental-blue) | From 1deb55f2e16fefc7eddff94efee0db7f5c9046e3 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 8 Apr 2024 17:21:00 -0400 Subject: [PATCH 3/4] Wire in is_full, but don't actually check it. - Update tests - Remove linage-based is_full implementation. --- crates/weaver_resolved_schema/src/lineage.rs | 2 +- .../legacy_tests/parameter_tag/test.md | 28 ++++----- crates/weaver_semconv_gen/src/gen.rs | 62 +++++++++++++------ crates/weaver_semconv_gen/src/lib.rs | 23 +------ 4 files changed, 60 insertions(+), 55 deletions(-) diff --git a/crates/weaver_resolved_schema/src/lineage.rs b/crates/weaver_resolved_schema/src/lineage.rs index b771ed55..371c9667 100644 --- a/crates/weaver_resolved_schema/src/lineage.rs +++ b/crates/weaver_resolved_schema/src/lineage.rs @@ -40,7 +40,7 @@ pub struct GroupLineage { /// This is important to keep unit tests stable. #[serde(skip_serializing_if = "BTreeMap::is_empty")] #[serde(default)] - pub attributes: BTreeMap, + attributes: BTreeMap, } impl AttributeLineage { diff --git a/crates/weaver_semconv_gen/legacy_tests/parameter_tag/test.md b/crates/weaver_semconv_gen/legacy_tests/parameter_tag/test.md index 34b57015..e166e6a2 100644 --- a/crates/weaver_semconv_gen/legacy_tests/parameter_tag/test.md +++ b/crates/weaver_semconv_gen/legacy_tests/parameter_tag/test.md @@ -4,13 +4,13 @@ | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | -|---|---|---|---|---| -| db.type | string | Database type. For any SQL database, "sql". For others, the lower-case database category. | `sql`; `cassandra`; `hbase`; `mongodb`; `redis`; `couchbase`; `couchdb` | Required | -| db.connection_string | string | The connection string used to connect to the database. [1] | `Server=(localdb)\v11.0;Integrated Security=true;` | Recommended | -| db.user | string | Username for accessing the database. | `readonly_user`; `reporting_user` | Recommended | -| net.peer.ip | string | Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6) | `127.0.0.1` | Recommended | -| net.peer.name | string | Remote hostname or similar, see note below. | `example.com` | Recommended | -| net.peer.port | int | Remote port number. | `80`; `8080`; `443` | Recommended | +|---|---|---|---|---|---| +| db.type | string | Database type. For any SQL database, "sql". For others, the lower-case database category. | `sql`; `cassandra`; `hbase`; `mongodb`; `redis`; `couchbase`; `couchdb` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| db.connection_string | string | The connection string used to connect to the database. [1] | `Server=(localdb)\v11.0;Integrated Security=true;` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| db.user | string | Username for accessing the database. | `readonly_user`; `reporting_user` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| net.peer.ip | string | Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6) | `127.0.0.1` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| net.peer.name | string | Remote hostname or similar, see note below. | `example.com` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| net.peer.port | int | Remote port number. | `80`; `8080`; `443` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | **[1]:** It is recommended to remove embedded credentials. @@ -18,11 +18,11 @@ | Value | Description | Stability | |---|---|---| -| `sql` | A SQL database | Experimental | -| `cassandra` | Apache Cassandra | Experimental | -| `hbase` | Apache HBase | Experimental | -| `mongodb` | MongoDB | Experimental | -| `redis` | Redis | Experimental | -| `couchbase` | Couchbase | Experimental | -| `couchdb` | CouchDB | Experimental | +| `sql` | A SQL database | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `cassandra` | Apache Cassandra | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `hbase` | Apache HBase | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `mongodb` | MongoDB | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `redis` | Redis | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `couchbase` | Couchbase | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `couchdb` | CouchDB | ![Experimental](https://img.shields.io/badge/-experimental-blue) | diff --git a/crates/weaver_semconv_gen/src/gen.rs b/crates/weaver_semconv_gen/src/gen.rs index 0d30abe3..1ea486cf 100644 --- a/crates/weaver_semconv_gen/src/gen.rs +++ b/crates/weaver_semconv_gen/src/gen.rs @@ -107,13 +107,25 @@ fn write_enum_examples_string( Ok(()) } -fn write_stability_badge(out: &mut Out, stability: &Option) -> Result<(), Error> { +fn write_stability_badge( + out: &mut Out, + stability: &Option, +) -> Result<(), Error> { match stability { - Some(Stability::Stable) => write!(out, "![Stable](https://img.shields.io/badge/-stable-lightgreen)")?, - Some(Stability::Deprecated) => write!(out, "![Deprecated](https://img.shields.io/badge/-deprecated-red)")?, - Some(Stability::Experimental) | None => write!(out, "![Experimental](https://img.shields.io/badge/-experimental-blue)")?, + Some(Stability::Stable) => write!( + out, + "![Stable](https://img.shields.io/badge/-stable-lightgreen)" + )?, + Some(Stability::Deprecated) => write!( + out, + "![Deprecated](https://img.shields.io/badge/-deprecated-red)" + )?, + Some(Stability::Experimental) | None => write!( + out, + "![Experimental](https://img.shields.io/badge/-experimental-blue)" + )?, } - Ok(()) + Ok(()) } struct AttributeView<'a> { @@ -248,7 +260,9 @@ impl<'a> AttributeView<'a> { RequirementLevel::Basic(BasicRequirementLevelSpec::Recommended) => { Ok(write!(out, "`Recommended`")?) } - RequirementLevel::Basic(BasicRequirementLevelSpec::OptIn) => Ok(write!(out, "`Opt-In`")?), + RequirementLevel::Basic(BasicRequirementLevelSpec::OptIn) => { + Ok(write!(out, "`Opt-In`")?) + } RequirementLevel::ConditionallyRequired { text } => { if text.len() > BREAK_COUNT { Ok(write!( @@ -317,19 +331,16 @@ impl<'a> AttributeTableView<'a> { } fn event_name(&self) -> &str { - // TODO - exception if group is not an event. match &self.group.name { Some(value) => value.as_str(), - None => - // TODO - exception if prefix is empty. - { - self.group.prefix.as_str() - } + None => self.group.prefix.as_str(), } } fn is_attribute_local(&self, id: &str) -> bool { - self.lookup.is_attribute_local(&self.group.id, id) + // TODO - Fix finding local attributes. + // These are attributes NOT pulled in via `extend` or `constraint.include` + true } /// Returns attributes sorted for rendering. @@ -360,24 +371,35 @@ impl<'a> AttributeTableView<'a> { ctx: &mut GenerateMarkdownContext, attribute_registry_base_url: Option<&str>, ) -> Result<(), Error> { + // If the user defined a tag, use it to filter attributes. + let attributes: Vec> = match args.tag_filter() { + Some(tag) => self + .attributes(args.is_full()) + .filter(|a| a.has_tag(tag)) + .collect(), + None => self.attributes(args.is_full()).collect(), + }; + + // Don't generate markdown if no attributes available. + if attributes.is_empty() { + return Ok(()); + } + if self.group.r#type == GroupType::Event { write!(out, "The event name MUST be `{}`\n\n", self.event_name())?; } if args.is_omit_requirement() { - writeln!(out, "| Attribute | Type | Description | Examples | Stability |")?; + writeln!( + out, + "| Attribute | Type | Description | Examples | Stability |" + )?; writeln!(out, "|---|---|---|---|---|")?; } else { writeln!(out, "| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |")?; writeln!(out, "|---|---|---|---|---|---|")?; } - // If the user defined a tag, use it to filter attributes. - let attributes: Vec> = match args.tag_filter() { - Some(tag) => self.attributes(args.is_full()).filter(|a| a.has_tag(tag)).collect(), - None => self.attributes(args.is_full()).collect(), - }; - for attr in &attributes { write!(out, "| ")?; attr.write_name_with_optional_link(out, attribute_registry_base_url)?; diff --git a/crates/weaver_semconv_gen/src/lib.rs b/crates/weaver_semconv_gen/src/lib.rs index 6e1839a5..1f0525aa 100644 --- a/crates/weaver_semconv_gen/src/lib.rs +++ b/crates/weaver_semconv_gen/src/lib.rs @@ -101,7 +101,9 @@ pub struct GenerateMarkdownArgs { impl GenerateMarkdownArgs { // Returns true if the `full` flag was specified. fn is_full(&self) -> bool { - self.args.iter().any(|a| matches!(a, MarkdownGenParameters::Full)) + self.args + .iter() + .any(|a| matches!(a, MarkdownGenParameters::Full)) } /// Returns true if the `omit_requirement_level` flag was specified. fn is_omit_requirement(&self) -> bool { @@ -251,25 +253,6 @@ impl ResolvedSemconvRegistry { fn attribute(&self, attr: &AttributeRef) -> Option<&Attribute> { self.schema.catalog.attribute(attr) } - - /// Determines if the attribute is not further inhereted from group_id in any other file. - /// For example , if attribute x.y is defined in group "a", and referenced in "b", the attribute would be local to "b". - /// Why do we call this local? - It's an inherited mechanism from build-tools. - fn is_attribute_local(&self, group_id: &str, attribute_id: &str) -> bool { - // Note: This isn't correct just yet, we're always getting true. - let found_inheritance_or_ref = self.my_registry().map(|r| { - r.groups.iter().any(|g| { - g.lineage.as_ref().and_then(|l| { - l.attributes.get(attribute_id) - }) - .map(|al| { - al.source_group == group_id - }) - .unwrap_or(false) - }) - }).unwrap_or(true); - !found_inheritance_or_ref - } } #[cfg(test)] From c276e51181f09b437678d4233b0efb6d6e4a7b0b Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 8 Apr 2024 20:14:37 -0400 Subject: [PATCH 4/4] Fix clippy --- crates/weaver_semconv_gen/src/gen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/weaver_semconv_gen/src/gen.rs b/crates/weaver_semconv_gen/src/gen.rs index 1ea486cf..b141c1fc 100644 --- a/crates/weaver_semconv_gen/src/gen.rs +++ b/crates/weaver_semconv_gen/src/gen.rs @@ -337,7 +337,7 @@ impl<'a> AttributeTableView<'a> { } } - fn is_attribute_local(&self, id: &str) -> bool { + fn is_attribute_local(&self, _id: &str) -> bool { // TODO - Fix finding local attributes. // These are attributes NOT pulled in via `extend` or `constraint.include` true