Files
jcoffey-dev 1e7e8dfd48
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 7m26s
Vendor upstream's opentelemetry-rust fork at the pinned commit
2026-10-27 22:55:35 -07:00

80 lines
3.0 KiB
Django/Jinja

{%- 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://opentelemetry.io/docs/specs/semconv/general/metrics/
//!
//! ## 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("s")
//! .with_description("Duration of HTTP server requests.")
//! .build();
//! ```
{% 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.replace('\n', ' ') 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 | replace('"', '') | replace('\n', ' ') | trim }}")]
{% endif %}
pub const {{ metric.metric_name | screaming_snake_case }}: &str = "{{ metric.metric_name }}";
{% endfor %}
{% endfor %}