-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial attempt at adding metric semconvs. (#1918)
Co-authored-by: Lalit Kumar Bhasin <labhas@microsoft.com>
- Loading branch information
Showing
13 changed files
with
5,732 additions
and
7,399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
opentelemetry-semantic-conventions/scripts/templates/header_attribute.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//! # Semantic Attributes | ||
//! | ||
//! The entire set of semantic attributes (or [conventions](https://opentelemetry.io/docs/concepts/semantic-conventions/)) defined by the project. The resource, metric, and trace modules reference these attributes. |
23 changes: 23 additions & 0 deletions
23
opentelemetry-semantic-conventions/scripts/templates/header_metric.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//! # 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(); | ||
//! ``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
opentelemetry-semantic-conventions/scripts/templates/semantic_metrics.rs.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// DO NOT EDIT, this is an auto-generated file | ||
// | ||
// If you want to update the file: | ||
// - Edit the template at scripts{{template}} | ||
// - Run the script at scripts/generate-consts-from-spec.sh | ||
|
||
{% include 'header_metric.rs' %} | ||
|
||
{%- for metric in metrics %} | ||
/// ## Description | ||
/// {% filter escape %}{{ metric.brief | to_doc_brief }}.{% endfilter %} | ||
{%- if metric.note %} | ||
/// | ||
{%- for line in metric.note.split('\n') %} | ||
/// {% filter escape %}{{ line }}{% endfilter %} | ||
{%- endfor %} | ||
{%- endif %} | ||
/// ## Metadata | ||
/// | | | | ||
/// |:-|:- | ||
/// | Instrument: | `{{ metric.instrument }}` | | ||
/// | Unit: | `{{ metric.unit }}` | | ||
/// | Status: | `{{ ((metric.stability | string()).split('.')[1].replace('_', ' ')) | capitalize }}` | | ||
{%- if metric.attributes %} | ||
/// | ||
/// ## Attributes | ||
/// | Name | Requirement | | ||
/// |:-|:- | | ||
{%- endif %} | ||
{%- for attribute in metric.attributes %} | ||
{%- if attribute.ref %} | ||
{%- set ref = (attributes | selectattr('fqn', 'equalto', attribute.ref) | first) %} | ||
{%- if ref %} | ||
{%- if attribute.requirement_level %} | ||
{%- set req_level = ((attribute.requirement_level | string()).split('.')[1].replace('_', ' ')) | capitalize %} | ||
{%- set req_message = attribute.requirement_level_msg %} | ||
{%- else %} | ||
{%- set req_level = "Unspecified" %} | ||
{%- set req_message = '' %} | ||
{%- endif %} | ||
/// | [`crate::attribute::{{ ref.fqn | to_const_name }}`] | `{{ req_level }}`{{ (': ' + req_message if req_message else '') }} | ||
{%- endif %} | ||
{%- endif %} | ||
{%- endfor %} | ||
{%- if metric.examples %} | ||
/// | ||
/// # Examples | ||
/// | ||
{%- for example in metric.examples %} | ||
/// - `{{ example }}` | ||
{%- endfor %} | ||
{%- endif %} | ||
{%- if (metric.deprecated) %} | ||
#[deprecated] | ||
{%- endif %} | ||
pub const {{ metric.metric_name | to_const_name }}: &str = "{{ metric.metric_name }}"; | ||
{%- endfor %} |
Oops, something went wrong.