forked from open-telemetry/otel-arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdescriptor.rs
More file actions
107 lines (97 loc) · 3.57 KB
/
descriptor.rs
File metadata and controls
107 lines (97 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//! Metric and Attribute descriptor types for metrics reflection.
use serde::{Deserialize, Serialize};
/// The type of instrument used to record the metric. Must be one of the following variants.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Instrument {
/// A monotonic sum.
Counter,
/// A signed sum that can go up and down.
UpDownCounter,
/// A value that can arbitrarily go up and down, used for temperature or current memory usage
Gauge,
/// Distribution of recorded values, used for latencies or request sizes
Histogram,
/// Pre-aggregated min/max/sum/count summary.
///
/// Internally tracked as an `Mmsc` instrument; the dispatcher exports the
/// aggregated snapshot as a synthetic OTel histogram without bucket counts.
Mmsc,
}
/// Aggregation temporality for sum-like instruments.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Temporality {
/// Each snapshot represents a delta over the reporting interval.
Delta,
/// Each snapshot represents the cumulative value at the time of reporting.
Cumulative,
}
/// Numeric representation used by a metric field.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum MetricValueType {
/// Unsigned 64-bit integer.
U64,
/// 64-bit floating point.
F64,
}
/// Metadata describing a single field inside a metrics struct.
#[derive(Debug, Clone, Copy, Serialize)]
pub struct MetricsField {
/// Canonical metric name (e.g., "bytes.rx"). Uniquely identifies the metric.
pub name: &'static str,
/// The unit in which the metric is measured matching
/// [Unified Code for Units of Measure](https://unitsofmeasure.org/ucum.html).
pub unit: &'static str,
/// Short human readable description extracted from the doc comment of the field.
pub brief: &'static str,
/// The type of instrument used to record the metric.
pub instrument: Instrument,
/// Aggregation temporality (only meaningful for sum-like instruments).
#[serde(skip_serializing_if = "Option::is_none")]
pub temporality: Option<Temporality>,
/// The numeric representation for the metric values.
pub value_type: MetricValueType,
}
/// Descriptor for a multivariate metrics.
#[derive(Debug, Serialize)]
pub struct MetricsDescriptor {
/// Human-friendly group name.
pub name: &'static str,
/// Ordered field metadata.
pub metrics: &'static [MetricsField],
}
/// Supported attribute value kinds.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum AttributeValueType {
/// String attribute value
String,
/// Integer attribute value
Int,
/// Double-precision floating-point attribute value
Double,
/// Boolean attribute value
Boolean,
}
/// Metadata describing a single attribute field.
#[derive(Debug, Clone, Copy, Serialize)]
pub struct AttributeField {
/// Attribute key (canonical, may contain dots instead of underscores).
pub key: &'static str,
/// Short description extracted from doc comments.
pub brief: &'static str,
/// Value kind.
pub r#type: AttributeValueType,
}
/// Descriptor for an attribute set.
#[derive(Debug)]
pub struct AttributesDescriptor {
/// Human-friendly group name.
pub name: &'static str,
/// Ordered attribute field metadata.
pub fields: &'static [AttributeField],
}