-
Notifications
You must be signed in to change notification settings - Fork 53
[WIP] V2 Resolved Schema #980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 18 commits
59aefac
54fc192
f770723
b14dcd3
c917f02
1baa3cd
a3bb434
4a9f6bf
edbe850
209883f
e02235c
a99d72e
5a01aae
42d4976
1a36d26
8889f71
27b7a0f
75072fe
0c32132
b7b3a48
60227ac
e1a2de8
e7617ee
8b4a7bc
ad75072
b72b754
fb4a367
dff7769
bdb91b1
c56256f
374c493
d1a61fa
4d22341
bd681a6
ce701d2
fe55753
c69a92a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| //! Attribute definitions for template schema. | ||
|
|
||
| use schemars::JsonSchema; | ||
| use serde::{Deserialize, Serialize}; | ||
| use weaver_semconv::{ | ||
| attribute::{AttributeType, Examples}, | ||
| v2::CommonFields, | ||
| }; | ||
|
|
||
| /// The definition of an Attribute. | ||
| #[derive(Serialize, Deserialize, Debug, Clone, JsonSchema, PartialEq, Hash, Eq)] | ||
| #[serde(deny_unknown_fields)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub struct Attribute { | ||
| /// String that uniquely identifies the attribute. | ||
| pub key: String, | ||
| /// Either a string literal denoting the type as a primitive or an | ||
| /// array type, a template type or an enum definition. | ||
| pub r#type: AttributeType, | ||
| /// Sequence of example values for the attribute or single example | ||
| /// value. They are required only for string and string array | ||
| /// attributes. Example values must be of the same type of the | ||
| /// attribute. If only a single example is provided, it can directly | ||
| /// be reported without encapsulating it into a sequence/dictionary. | ||
| #[serde(default)] | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub examples: Option<Examples>, | ||
| /// Common fields (like brief, note, attributes). | ||
| #[serde(flatten)] | ||
| pub common: CommonFields, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| //! Event related definitions structs. | ||
jsuereth marked this conversation as resolved.
Show resolved
Hide resolved
jsuereth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| use schemars::JsonSchema; | ||
| use serde::{Deserialize, Serialize}; | ||
| use weaver_semconv::{ | ||
| attribute::RequirementLevel, | ||
| v2::{signal_id::SignalId, CommonFields}, | ||
| }; | ||
|
|
||
| use crate::v2::attribute::Attribute; | ||
|
|
||
| /// The definition of an event signal. | ||
jsuereth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct Entity { | ||
| /// The type of the entity. | ||
| pub r#type: SignalId, | ||
|
|
||
| /// List of attributes that belong to this event. | ||
|
||
| #[serde(default)] | ||
| #[serde(skip_serializing_if = "Vec::is_empty")] | ||
| pub identity: Vec<EntityAttribute>, | ||
|
|
||
| /// List of attributes that belong to this event. | ||
jsuereth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #[serde(default)] | ||
| #[serde(skip_serializing_if = "Vec::is_empty")] | ||
| pub description: Vec<EntityAttribute>, | ||
|
|
||
| /// Common fields (like brief, note, annotations). | ||
| #[serde(flatten)] | ||
| pub common: CommonFields, | ||
| } | ||
|
|
||
| /// A special type of reference to attributes that remembers event-specicific information. | ||
jsuereth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct EntityAttribute { | ||
| /// Base attribute definitions. | ||
| #[serde(flatten)] | ||
| pub base: Attribute, | ||
| /// Specifies if the attribute is mandatory. Can be "required", | ||
| /// "conditionally_required", "recommended" or "opt_in". When omitted, | ||
| /// the attribute is "recommended". When set to | ||
| /// "conditionally_required", the string provided as <condition> MUST | ||
| /// specify the conditions under which the attribute is required. | ||
| /// | ||
| /// Note: For attributes that are "recommended" or "opt-in" - not all metric source will | ||
| /// create timeseries with these attributes, but for any given timeseries instance, the attributes that *were* present | ||
| /// should *remain* present. That is - a metric timeseries cannot drop attributes during its lifetime. | ||
| pub requirement_level: RequirementLevel, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| //! Event related definitions structs. | ||
| use schemars::JsonSchema; | ||
| use serde::{Deserialize, Serialize}; | ||
| use weaver_semconv::{ | ||
| attribute::RequirementLevel, | ||
| v2::{signal_id::SignalId, CommonFields}, | ||
| }; | ||
|
|
||
| use crate::v2::attribute::Attribute; | ||
|
|
||
| /// The definition of an event signal. | ||
| #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct Event { | ||
| /// The name of the event. | ||
| pub name: SignalId, | ||
|
|
||
| /// List of attributes that belong to this event. | ||
| #[serde(default)] | ||
| #[serde(skip_serializing_if = "Vec::is_empty")] | ||
| pub attributes: Vec<EventAttribute>, | ||
|
|
||
| /// Which resources this span should be associated with. | ||
jsuereth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// | ||
| /// This list is an "any of" list, where a metric may be associated with one or more entities, but should | ||
|
||
| /// be associated with at least one in this list. | ||
| #[serde(default)] | ||
| #[serde(skip_serializing_if = "Vec::is_empty")] | ||
| pub entity_associations: Vec<String>, | ||
|
|
||
| /// Common fields (like brief, note, annotations). | ||
| #[serde(flatten)] | ||
| pub common: CommonFields, | ||
| } | ||
|
|
||
| /// A special type of reference to attributes that remembers event-specicific information. | ||
| #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct EventAttribute { | ||
| /// Base attribute definitions. | ||
| #[serde(flatten)] | ||
| pub base: Attribute, | ||
| /// Specifies if the attribute is mandatory. Can be "required", | ||
| /// "conditionally_required", "recommended" or "opt_in". When omitted, | ||
| /// the attribute is "recommended". When set to | ||
| /// "conditionally_required", the string provided as <condition> MUST | ||
| /// specify the conditions under which the attribute is required. | ||
| /// | ||
| /// Note: For attributes that are "recommended" or "opt-in" - not all metric source will | ||
| /// create timeseries with these attributes, but for any given timeseries instance, the attributes that *were* present | ||
| /// should *remain* present. That is - a metric timeseries cannot drop attributes during its lifetime. | ||
| pub requirement_level: RequirementLevel, | ||
| } | ||
|
|
||
| /// A refinement of an event signal, for use in code-gen or specific library application. | ||
| /// | ||
| /// A refinement represents a "view" of an Event that is highly optimised for a particular implementation. | ||
| /// e.g. for HTTP events, there may be a refinement that provides only the necessary information for dealing with Java's HTTP | ||
| /// client library, and drops optional or extraneous information from the underlying http event. | ||
| #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)] | ||
| pub struct EventRefinement { | ||
| /// The identity of the refinement. | ||
| pub id: SignalId, | ||
|
|
||
| // TODO - This is a lazy way of doing this. We use `type` to refer | ||
| // to the underlying span defintiion, but override all fields here. | ||
| // We probably should copy-paste all the "span" attributes here | ||
| // including the `ty` | ||
| /// The definition of the metric refinement. | ||
|
||
| #[serde(flatten)] | ||
| pub event: Event, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| //! Metric related definitions structs. | ||
| use crate::v2::attribute::Attribute; | ||
| use schemars::JsonSchema; | ||
| use serde::{Deserialize, Serialize}; | ||
| use weaver_semconv::{ | ||
| attribute::RequirementLevel, | ||
| group::InstrumentSpec, | ||
| v2::{signal_id::SignalId, CommonFields}, | ||
| }; | ||
|
|
||
| /// The definition of a metric signal. | ||
| #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct Metric { | ||
| /// The name of the metric. | ||
| pub name: SignalId, | ||
| /// The instrument type that should be used to record the metric. Note that | ||
| /// the semantic conventions must be written using the names of the | ||
| /// synchronous instrument types (counter, gauge, updowncounter and | ||
| /// histogram). | ||
| /// For more details: [Metrics semantic conventions - Instrument types](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/metrics/semantic_conventions#instrument-types). | ||
| pub instrument: InstrumentSpec, | ||
| /// The unit in which the metric is measured, which should adhere to the | ||
| /// [guidelines](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/metrics/semantic_conventions#instrument-units). | ||
| pub unit: String, | ||
| /// List of attributes that should be included on this metric. | ||
| #[serde(default)] | ||
| #[serde(skip_serializing_if = "Vec::is_empty")] | ||
| pub attributes: Vec<MetricAttribute>, | ||
| // TODO - Should Entity Associations be "strong" links? | ||
| /// Which resources this span should be associated with. | ||
jsuereth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// | ||
| /// This list is an "any of" list, where a metric may be associated with one or more entities, but should | ||
| /// be associated with at least one in this list. | ||
| #[serde(default)] | ||
| #[serde(skip_serializing_if = "Vec::is_empty")] | ||
| pub entity_associations: Vec<String>, | ||
|
|
||
| /// Common fields (like brief, note, annotations). | ||
| #[serde(flatten)] | ||
| pub common: CommonFields, | ||
| } | ||
|
|
||
| /// A special type of reference to attributes that remembers metric-specicific information. | ||
jsuereth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct MetricAttribute { | ||
| /// Base metric definitions. | ||
jsuereth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #[serde(flatten)] | ||
| pub base: Attribute, | ||
| /// Specifies if the attribute is mandatory. Can be "required", | ||
| /// "conditionally_required", "recommended" or "opt_in". When omitted, | ||
| /// the attribute is "recommended". When set to | ||
| /// "conditionally_required", the string provided as <condition> MUST | ||
| /// specify the conditions under which the attribute is required. | ||
| /// | ||
| /// Note: For attributes that are "recommended" or "opt-in" - not all metric source will | ||
| /// create timeseries with these attributes, but for any given timeseries instance, the attributes that *were* present | ||
| /// should *remain* present. That is - a metric timeseries cannot drop attributes during its lifetime. | ||
| pub requirement_level: RequirementLevel, | ||
| } | ||
|
|
||
| /// A refinement of a metric signal, for use in code-gen or specific library application. | ||
| /// | ||
| /// A refinement represents a "view" of a Metric that is highly optimised for a particular implementation. | ||
| /// e.g. for HTTP metrics, there may be a refinement that provides only the necessary information for dealing with Java's HTTP | ||
| /// client library, and drops optional or extraneous information from the underlying http metric. | ||
| #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)] | ||
| pub struct MetricRefinement { | ||
| /// The identity of the refinement. | ||
| pub id: SignalId, | ||
|
|
||
| // TODO - This is a lazy way of doing this. We use `type` to refer | ||
| // to the underlying span defintiion, but override all fields here. | ||
jsuereth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // We probably should copy-paste all the "span" attributes here | ||
| // including the `ty` | ||
|
||
| /// The definition of the metric refinement. | ||
| #[serde(flatten)] | ||
| pub metric: Metric, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| //! Version two of weaver model. | ||
|
|
||
| pub mod attribute; | ||
| pub mod entity; | ||
| pub mod event; | ||
| pub mod metric; | ||
| pub mod registry; | ||
| pub mod span; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ok to remove now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still using this to test/demo. I was going to remove after we lock-in on the details of the schema.