-
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
Open
jsuereth
wants to merge
37
commits into
open-telemetry:main
Choose a base branch
from
jsuereth:wip-v2-resolved-schema
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
59aefac
First cut at converting from v1 resolved schema to v2. Only handles …
jsuereth 54fc192
Add group lineage tracking so we can determine group refinement when …
jsuereth f770723
Fix up tests for V2 span/span_refinement conversion.
jsuereth b14dcd3
Start fixing up documentation and add metric v2 extraction.
jsuereth c917f02
More documentation and test cleanup for spans/metrics.
jsuereth 1baa3cd
Finish implementation (not full testing) of v2 conversion for basics.
jsuereth a3bb434
Hackily hook up the v2 resolution and template for output in weaver.
jsuereth 4a9f6bf
Add spans to resolved registry.
jsuereth edbe850
Add the remaining missing pieces to V2 resolved schema.
jsuereth 209883f
Fix all tests.
jsuereth e02235c
Start of refactoring of 'regisry' vs. 'catalog' vs. 'refinements'
jsuereth a99d72e
Fix forge unwinding of registry.
jsuereth 5a01aae
Optimise lookup up attributes in catalog when building V2.
jsuereth 42d4976
Finish attribute mapping equality for v1->v2
jsuereth 1a36d26
Fix error reporting on v2 schema creation.
jsuereth 8889f71
Clippy fixes.
jsuereth 27b7a0f
Start supporting attribute groups. Add lineage tracking so we can co…
jsuereth 75072fe
Initial attribute group support in resolved registry.
jsuereth 0c32132
Cargo fix.
jsuereth b7b3a48
Add include groups to v2 resolved schema.
jsuereth 60227ac
Remove attribute group tracking from in-group feedback.
jsuereth e1a2de8
Add attribute group to forge schema.
jsuereth e7617ee
Add v2 to weaver generate and write a test.
jsuereth 8b4a7bc
cargo fmt
jsuereth ad75072
Fix some types and copy-paste errors.
jsuereth b72b754
Fix typos.
jsuereth fb4a367
More spell fixes.
jsuereth dff7769
Fix typos.
jsuereth bdb91b1
Merge remote-tracking branch 'origin/main' into wip-v2-resolved-schema
jsuereth c56256f
Fix tests.
jsuereth 374c493
Fix format.
jsuereth d1a61fa
Clippy fixes.
jsuereth 4d22341
Fix last clippy issue.
jsuereth bd681a6
Fix spelling issues.
jsuereth ce701d2
Cargo fmt
jsuereth fe55753
Merge remote-tracking branch 'origin/main' into wip-v2-resolved-schema
jsuereth c69a92a
Fix logic error in comparing annotations.
jsuereth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,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, | ||
| } |
This file contains hidden or 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,20 @@ | ||
| //! Version two of attribute groups. | ||
|
|
||
| use schemars::JsonSchema; | ||
| use serde::{Deserialize, Serialize}; | ||
| use weaver_semconv::v2::{signal_id::SignalId, CommonFields}; | ||
|
|
||
| use crate::v2::attribute::Attribute; | ||
|
|
||
| /// Public attribute group. | ||
| #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct AttributeGroup { | ||
| /// The name of the attribute group, must be unique. | ||
| pub id: SignalId, | ||
| /// List of attributes. | ||
| pub attributes: Vec<Attribute>, | ||
| /// Common fields (like brief, note, annotations). | ||
| #[serde(flatten)] | ||
| pub common: CommonFields, | ||
| } |
This file contains hidden or 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,47 @@ | ||
| //! Event related definitions structs. | ||
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 entity signal. | ||
| #[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 identify this entity. | ||
| #[serde(default)] | ||
| #[serde(skip_serializing_if = "Vec::is_empty")] | ||
| pub identity: Vec<EntityAttribute>, | ||
|
|
||
| /// List of attributes that describe to this entity. | ||
| #[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 entity-specicific information. | ||
| #[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. | ||
| pub requirement_level: RequirementLevel, | ||
| } | ||
This file contains hidden or 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,69 @@ | ||
| //! 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 event should be associated with. | ||
| /// | ||
| /// This list is an "any of" list, where a event 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. | ||
| pub requirement_level: RequirementLevel, | ||
| } | ||
|
|
||
| /// A refinement of an event signal, for use in code generation 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 event definition, but override all fields here. | ||
| // We probably should copy-paste all the "event" attributes here | ||
| // including the `name`. | ||
| /// The definition of the event refinement. | ||
| #[serde(flatten)] | ||
| pub event: Event, | ||
| } |
This file contains hidden or 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,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 metric should be associated with. | ||
| /// | ||
| /// 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-specific information. | ||
| #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct MetricAttribute { | ||
| /// 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 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 metric definition, but override all fields here. | ||
| // We probably should copy-paste all the "metric" attributes here | ||
| // including the `ty` | ||
| /// The definition of the metric refinement. | ||
| #[serde(flatten)] | ||
| pub metric: Metric, | ||
| } |
This file contains hidden or 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,9 @@ | ||
| //! Version two of weaver model. | ||
|
|
||
| pub mod attribute; | ||
| pub mod attribute_group; | ||
| pub mod entity; | ||
| pub mod event; | ||
| pub mod metric; | ||
| pub mod registry; | ||
| pub mod span; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.