Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 30 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -298,34 +298,42 @@ jobs:
run: |
cargo run -- --quiet registry json-schema -j semconv-definition-v2 -o /tmp/semconv.schema.v2.json
cargo run -- --quiet registry json-schema -j resolved-registry-v2 -o /tmp/semconv.resolved.v2.json
cargo run -- --quiet registry json-schema -j materialized-registry-v2 -o /tmp/semconv.materialized.v2.json
cargo run -- --quiet registry json-schema -j diff-v2 -o /tmp/semconv.diff.v2.json
cargo run -- --quiet registry json-schema -j policy-finding -o /tmp/policy.finding.json
cargo run -- --quiet registry json-schema -j publication-manifest-v2 -o /tmp/publication-manifest.v2.json
cargo run -- --quiet registry json-schema -j definition-manifest-v2 -o /tmp/definition-manifest.v2.json
- name: Check generated files are up-to-date
run: |
failed=0

if ! diff -q docs/usage.md /tmp/usage.md > /dev/null 2>&1; then
echo "docs/usage.md is out of date. Run 'cargo run -- --quiet markdown-help > docs/usage.md' to regenerate it."
diff docs/usage.md /tmp/usage.md
failed=1
fi

if ! diff -q schemas/semconv.schema.v2.json /tmp/semconv.schema.v2.json > /dev/null 2>&1; then
echo "schemas/semconv.schema.v2.json is out of date. Run 'cargo run -- --quiet registry json-schema -j semconv-definition-v2 -o ./schemas/semconv.schema.v2.json' to regenerate it."
diff schemas/semconv.schema.v2.json /tmp/semconv.schema.v2.json
failed=1
fi
check_file() {
local repo_file="$1"
local tmp_file="$2"
local regen_cmd="$3"
if ! diff -q "$repo_file" "$tmp_file" > /dev/null 2>&1; then
echo "$repo_file is out of date. Run '$regen_cmd' to regenerate it."
diff "$repo_file" "$tmp_file"
failed=1
fi
}

if ! diff -q schemas/semconv.resolved.v2.json /tmp/semconv.resolved.v2.json > /dev/null 2>&1; then
echo "schemas/semconv.resolved.v2.json is out of date. Run 'cargo run -- --quiet registry json-schema -j resolved-registry-v2 -o ./schemas/semconv.resolved.v2.json' to regenerate it."
diff schemas/semconv.resolved.v2.json /tmp/semconv.resolved.v2.json
failed=1
fi

if ! diff -q schemas/policy.finding.json /tmp/policy.finding.json > /dev/null 2>&1; then
echo "schemas/policy.finding.json is out of date. Run 'cargo run -- --quiet registry json-schema -j policy-finding -o ./schemas/policy.finding.json' to regenerate it."
diff schemas/policy.finding.json /tmp/policy.finding.json
failed=1
fi
check_file docs/usage.md /tmp/usage.md \
"cargo run -- --quiet markdown-help > docs/usage.md"
check_file schemas/semconv.schema.v2.json /tmp/semconv.schema.v2.json \
"cargo run -- --quiet registry json-schema -j semconv-definition-v2 -o ./schemas/semconv.schema.v2.json"
check_file schemas/semconv.resolved.v2.json /tmp/semconv.resolved.v2.json \
"cargo run -- --quiet registry json-schema -j resolved-registry-v2 -o ./schemas/semconv.resolved.v2.json"
check_file schemas/policy.finding.json /tmp/policy.finding.json \
"cargo run -- --quiet registry json-schema -j policy-finding -o ./schemas/policy.finding.json"
check_file schemas/semconv.materialized.v2.json /tmp/semconv.materialized.v2.json \
"cargo run -- --quiet registry json-schema -j materialized-registry-v2 -o ./schemas/semconv.materialized.v2.json"
check_file schemas/semconv.diff.v2.json /tmp/semconv.diff.v2.json \
"cargo run -- --quiet registry json-schema -j diff-v2 -o ./schemas/semconv.diff.v2.json"
check_file schemas/publication-manifest.v2.json /tmp/publication-manifest.v2.json \
"cargo run -- --quiet registry json-schema -j publication-manifest-v2 -o ./schemas/publication-manifest.v2.json"
check_file schemas/definition-manifest.v2.json /tmp/definition-manifest.v2.json \
"cargo run -- --quiet registry json-schema -j definition-manifest-v2 -o ./schemas/definition-manifest.v2.json"

exit $failed
coverage:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
- Fix ([#1323](https://github.com/open-telemetry/weaver/issues/1323)) - Live-check: treat observed `int` as compatible with expected `double` attribute type, avoiding false violations from OTLP serializers (e.g. JS) that emit `int_value` for integral numbers. ([#1331](https://github.com/open-telemetry/weaver/pull/1331) by @jerbly)
- Fix CLI so it doesn't error out early when loading a resolved schema. ([#1304](https://github.com/open-telemetry/weaver/pull/1304) by @jsuereth)
- 💥 BREAKING CHANGE 💥 Use `schema_url` to track registries consistently in lineage / provenance ([#1298](https://github.com/open-telemetry/weaver/pull/1298) by @jsuereth)
- Publish and document missing JSON schemas. Add `head_schema_url`/`baseline_schema_url` to diff v2. ([#1106](https://github.com/open-telemetry/weaver/pull/1106) by @lmolkova)
- Add `--allow-git-credentials` global flag to enable system credential helpers (e.g. `osxkeychain`, `git-credential-manager`) when cloning private registries. By default, git operations remain isolated for security. ([#1306](https://github.com/open-telemetry/weaver/pull/1306) by @jerbly)
- MCP: Add `browse_namespace` tool and `findings_only` output mode for `live_check`. Add configurable namespace separator via `--namespace-separator`. ([#1324](https://github.com/open-telemetry/weaver/pull/1324) by @jerbly)

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/weaver_resolved_schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub const OTEL_REGISTRY_ID: &str = "OTEL";

/// Version string denoting V1 resolved schema.
pub(crate) const V1_RESOLVED_FILE_FORMAT: &str = "resolved/1.0.0";
/// Version string dentoing V2 resolved scehma.
/// Version string denoting V2 resolved schema.
pub(crate) const V2_RESOLVED_FILE_FORMAT: &str = "resolved/2.0.0";

/// A Resolved Telemetry Schema.
Expand Down
2 changes: 2 additions & 0 deletions crates/weaver_resolved_schema/src/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ impl ResolvedTelemetrySchema {
pub fn diff(&self, baseline_schema: &ResolvedTelemetrySchema) -> SchemaChanges {
// TODO - get manifests
SchemaChanges {
head_schema_url: self.schema_url.clone(),
baseline_schema_url: baseline_schema.schema_url.clone(),
registry: self.registry_diff(baseline_schema),
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/weaver_version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ thiserror.workspace = true
schemars.workspace = true

semver = {version = "1.0.27", features = ["serde"]}
weaver_semconv = { path = "../weaver_semconv" }
32 changes: 31 additions & 1 deletion crates/weaver_version/src/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,33 @@

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use weaver_semconv::schema_url::SchemaUrl;

// V2 Leverages the same nomenclature for diff as V1.
pub use crate::schema_changes::SchemaItemChange;

/// A summary of schema changes between two versions of a schema.
#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct SchemaChanges {
/// Schema URL of the head (newer) schema.
pub head_schema_url: SchemaUrl,
/// Schema URL of the baseline (older) schema.
pub baseline_schema_url: SchemaUrl,
/// Changes to the registry.
pub registry: RegistryChanges,
}

impl Default for SchemaChanges {
fn default() -> Self {
Self {
head_schema_url: SchemaUrl::new_unknown(),
baseline_schema_url: SchemaUrl::new_unknown(),
registry: RegistryChanges::default(),
}
}
}

/// A summary of changes to the registry of signals and attributes.
#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
Expand All @@ -31,6 +46,7 @@ pub struct RegistryChanges {
/// Changes across the registry of spans.
pub span_changes: Vec<SchemaItemChange>,
}

impl RegistryChanges {
/// Returns true if there are no changes in the schema.
/// Otherwise, it returns false.
Expand All @@ -53,3 +69,17 @@ impl SchemaChanges {
self.registry.is_empty()
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_schema_changes_default() {
let changes = SchemaChanges::default();
assert_eq!(changes.head_schema_url, SchemaUrl::new_unknown());
assert_eq!(changes.baseline_schema_url, SchemaUrl::new_unknown());
assert!(changes.registry.is_empty());
assert!(changes.is_empty());
}
}
2 changes: 1 addition & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ The produced JSON Schema can be used to generate documentation of the resolved r
The JSON schema of the V2 definition
- `resolved-registry-v2`:
The JSON schema of the V2 resolved registry
- `forge-registry-v2`:
- `materialized-registry-v2`:
The JSON schema we send to Rego / Jinja
- `diff`:
The JSON schema of the diff
Expand Down
Loading
Loading