{%- import 'macros.j2' as metric_macros -%} // DO NOT EDIT, this is an auto-generated file // // If you want to update the file: // - Edit the template at scripts/templates/registry/rust/metric.rs.j2 // - Run the script at scripts/generate-consts-from-spec.sh //! # Metric Semantic Conventions //! //! The [metric semantic conventions] define a set of standardized attributes to //! be used in `Meter`s. //! //! [metric semantic conventions]: https://github.com/open-telemetry/semantic-conventions/tree/main/model/metric //! //! ## Usage //! //! ```rust //! use opentelemetry::{global, KeyValue}; //! use opentelemetry_semantic_conventions as semconv; //! //! // Assumes we already have an initialized `MeterProvider` //! // See: https://github.com/open-telemetry/opentelemetry-rust/blob/main/examples/metrics-basic/src/main.rs //! // for an example //! let meter = global::meter("mylibraryname"); //! let histogram = meter //! .u64_histogram(semconv::metric::HTTP_SERVER_REQUEST_DURATION) //! .with_unit("By") //! .with_description("Duration of HTTP server requests.") //! .init(); //! ``` {% for root_ns in ctx %} {% for metric in root_ns.metrics %} {{ ["## Description\n\n", metric.brief, concat_if("\n\n## Notes\n\n", metric.note), metric_macros.examples(metric)] | comment }} /// ## Metadata /// | | | /// |:-|:- /// | Instrument: | `{{ metric.instrument }}` | /// | Unit: | `{{ metric.unit }}` | /// | Status: | `{{ metric.stability | capitalize }}` | {% if metric.attributes %} /// /// ## Attributes /// | Name | Requirement | /// |:-|:- | {% endif %} {% for attribute in metric.attributes | rejectattr("name", "in", params.excluded_attributes) | sort(attribute="name") %} {% if attribute.requirement_level %} {% if attribute.requirement_level.conditionally_required %} {% set req_level = "Conditionally_required" %} {% set req_message = attribute.requirement_level.conditionally_required %} {% else %} {% set req_level = (attribute.requirement_level | capitalize) %} {% set req_message = attribute.requirement_level_msg %} {% endif %} {% else %} {% set req_level = "Unspecified" %} {% set req_message = '' %} {% endif %} /// | [`crate::attribute::{{ attribute.name | screaming_snake_case }}`] | `{{ req_level }}`{{ (': ' + req_message if req_message else '') }} {% endfor %} {% if metric.examples %} /// /// ## Examples /// {% for example in metric.examples %} /// - `{{ example }}` {% endfor %} {% endif %} {% if metric is experimental %} #[cfg(feature = "semconv_experimental")] {% endif %} {% if metric is deprecated %} #[deprecated(note="{{ metric.deprecated.strip(" \n\"") }}")] {% endif %} pub const {{ metric.metric_name | screaming_snake_case }}: &str = "{{ metric.metric_name }}"; {% endfor %} {% endfor %}