Skip to content
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

Support for 2 semconv registries #627

Merged
merged 24 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e93c6ad
feat(semconv): Add dependencies in the manifest file.
lquerel Mar 2, 2025
cef36de
feat(semconv): Add dependencies in the manifest file.
lquerel Mar 3, 2025
8f8c728
feat(semconv): Merge weaver_cache into weaver_semconv to get rid of c…
lquerel Mar 3, 2025
4ed05fd
chore(semconv): Fix Rust code format.
lquerel Mar 3, 2025
ccf8592
feat(semconv): support 2 registries
lquerel Mar 25, 2025
2676dad
feat(semconv): support 2 registries
lquerel Mar 25, 2025
c085701
Merge remote-tracking branch 'upstream/main' into support-2-registries
lquerel Mar 25, 2025
ba2b480
chore: merge with main upstream
lquerel Mar 25, 2025
cf4b5f6
chore: merge with main upstream
lquerel Mar 25, 2025
3421621
Merge remote-tracking branch 'upstream/main' into support-2-registries
lquerel Mar 25, 2025
dcb2462
chore: update Cargo.lock
lquerel Mar 25, 2025
e7342ea
feat(2-registries): propagate registry id in provenance
lquerel Mar 25, 2025
ba7b254
feat(2-registries): add tests
lquerel Mar 26, 2025
30ff653
chore: merge with upstream main
lquerel Mar 28, 2025
c397f6f
feat(2-registries): replace the semconv spec path by a provenance dat…
lquerel Apr 1, 2025
7367a1f
feat(2-registries): load registry manifest at the creation of the reg…
lquerel Apr 4, 2025
e7f5f61
feat(2-registries): garbage collect unreferenced telemetry objects
lquerel Apr 5, 2025
2945e2e
feat(2-registries): improve unit tests for multi-registry
lquerel Apr 5, 2025
2d34263
feat(2-registries): introduce the concept of virtual directory
lquerel Apr 8, 2025
8796a66
feat(2-registries): introduce the concept of virtual directory
lquerel Apr 9, 2025
9dd3f59
feat(2-registries):merge with main upstream branch
lquerel Apr 10, 2025
9ba9a94
feat(2-registries): update CHANGELOG.md
lquerel Apr 10, 2025
5aaa3ad
feat(2-registries): fix rust doc issue
lquerel Apr 10, 2025
f732476
feat(2-registries): fix tests on windows
lquerel Apr 10, 2025
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
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.

5 changes: 3 additions & 2 deletions crates/weaver_cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ zip = "2.2.2"
thiserror.workspace = true
serde.workspace = true
miette.workspace = true
once_cell.workspace = true
regex.workspace = true
url.workspace = true
ureq.workspace = true
schemars.workspace = true
once_cell.workspace = true
regex.workspace = true

[dev-dependencies]
walkdir.workspace = true
9 changes: 5 additions & 4 deletions crates/weaver_cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

//! A Semantic Convention Repository abstraction for OTel Weaver.

pub mod registry_path;

use std::default::Default;
use std::fs::{create_dir_all, File};
use std::io;
Expand All @@ -19,11 +21,8 @@
use url::Url;

use weaver_common::diagnostic::{DiagnosticMessage, DiagnosticMessages};

use crate::registry_path::RegistryPath;
use crate::Error::{GitError, InvalidRegistryArchive, UnsupportedRegistryArchive};

pub mod registry_path;
use crate::registry_path::RegistryPath;

/// The extension for a tar gz archive.
const TAR_GZ_EXT: &str = ".tar.gz";
Expand Down Expand Up @@ -543,8 +542,10 @@

#[cfg(test)]
mod tests {
use weaver_common::registry_path::RegistryPath;
use super::*;
use weaver_common::test::ServeStaticFiles;
use crate::registry_path::RegistryPath;

fn count_yaml_files(repo_path: &Path) -> usize {
let count = walkdir::WalkDir::new(repo_path)
Expand Down
26 changes: 23 additions & 3 deletions crates/weaver_cache/src/registry_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use std::fmt::Display;
use std::str::FromStr;

use schemars::JsonSchema;
use once_cell::sync::Lazy;
use regex::Regex;

use serde::{Deserialize, Serialize};
use crate::Error;

/// Regex to parse a registry path supporting the following formats:
Expand All @@ -22,7 +22,9 @@ static REGISTRY_REGEX: Lazy<Regex> = Lazy::new(|| {

/// Path to a semantic convention registry.
/// The path can be a local directory or a Git URL.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(try_from = "String")]
#[serde(into = "String")]
pub enum RegistryPath {
/// Local folder path pointing to a semantic convention registry.
LocalFolder {
Expand Down Expand Up @@ -54,6 +56,24 @@ pub enum RegistryPath {
},
}

/// Implement `TryFrom<String>` for `RegistryPath`, so that it can be used to
/// deserialize a `RegistryPath` via serde.
impl TryFrom<String> for RegistryPath {
type Error = Error;

fn try_from(s: String) -> Result<Self, Self::Error> {
s.parse()
}
}

/// Implement `From<RegistryPath>` for String, so that it can be serialized to a
/// string via serde.
impl From<RegistryPath> for String {
fn from(path: RegistryPath) -> Self {
path.to_string()
}
}

/// Implement the `FromStr` trait for `RegistryPath`, so that it can be used as
/// a command-line argument.
impl FromStr for RegistryPath {
Expand Down
1 change: 0 additions & 1 deletion crates/weaver_common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub mod in_memory;
pub mod quiet;
pub mod result;
pub mod test;

use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};

Expand Down
15 changes: 15 additions & 0 deletions crates/weaver_semconv/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::Error::{InvalidRegistryManifest, RegistryManifestNotFound};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use weaver_cache::registry_path::RegistryPath;
use weaver_common::error::handle_errors;

/// Represents the information of a semantic convention registry manifest.
Expand All @@ -36,6 +37,20 @@ pub struct RegistryManifest {

/// The base URL where the registry's schema files are hosted.
pub schema_base_url: String,

/// List of the registry's dependencies.
/// Note: In the current phase, we only support zero or one dependency.
/// See this GH issue for more details: https://github.com/open-telemetry/weaver/issues/604
pub dependencies: Option<Vec<Dependency>>,
}

/// Represents a dependency of a semantic convention registry.
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct Dependency {
/// The name of the dependency.
pub name: String,
/// The registry path of the dependency.
pub registry_path: RegistryPath,
}

impl RegistryManifest {
Expand Down
1 change: 1 addition & 0 deletions crates/weaver_semconv/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl SemConvRegistry {
description: None,
semconv_version,
schema_base_url: "".to_owned(),
dependencies: None,
});
}

Expand Down
28 changes: 28 additions & 0 deletions tests/custom_registry/registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
groups:
- id: "registry.group1"
type: "attribute_group"
name: "registry.group1"
brief: "registry.group1"
attributes:
- id: "attr0"
type: boolean
brief: "brief0"
requirement_level: "recommended"
- id: "attr1"
type: boolean
brief: "brief1"
requirement_level: "recommended"
- id: "attr2"
type: string
brief: "brief2"
requirement_level: "recommended"
- id: attr3
type: int
brief: brief3
requirement_level: recommended
- id: attr5
type: double
brief: brief5
requirement_level: recommended
deprecated:
reason: obsoleted
7 changes: 7 additions & 0 deletions tests/custom_registry/registry_manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: acme
description: This registry contains the semantic conventions for the Acme vendor.
semconv_version: 0.1.0
schema_base_url: https://acme.com/schemas/
dependencies:
- name: otel
registry_path: https://github.com/open-telemetry/semantic-conventions/archive/refs/tags/v1.30.0.zip[model]
Loading