Rework Resolution Engine to allow using resolved schema#1136
Rework Resolution Engine to allow using resolved schema#1136jsuereth merged 44 commits intoopen-telemetry:mainfrom
Conversation
…esolving a new schema.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1136 +/- ##
=======================================
- Coverage 80.2% 80.1% -0.2%
=======================================
Files 105 108 +3
Lines 8126 8428 +302
=======================================
+ Hits 6523 6753 +230
- Misses 1603 1675 +72 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Liudmila Molkova <neskazu@gmail.com>
Co-authored-by: Liudmila Molkova <neskazu@gmail.com>
Co-authored-by: Liudmila Molkova <neskazu@gmail.com>
| .map(|(a, ar)| (a.clone(), *ar)) | ||
| .collect(); | ||
| ordered.sort_by(|(ln, _), (rn, _)| ln.cmp(rn)); | ||
| // assert_eq!(ordered.len(), self.attribute_refs.len()); |
There was a problem hiding this comment.
The kind of thing that could use debug_assert_eq!.
There was a problem hiding this comment.
Good call! I missed this before merging, I'll remember it going forward.
|
|
||
| impl AttributeLookup for V1Schema { | ||
| fn lookup_attribute(&self, key: &str) -> Option<AttributeWithGroupId> { | ||
| // TODO - fast lookup, not a table scan... |
There was a problem hiding this comment.
I thought we originally had a map. Why did we lose that? It;s possible my memory is failing me.
There was a problem hiding this comment.
Ordering. You switched to a linear order for serialization.
I'll need to lead a map on the side.
There was a problem hiding this comment.
Ordering. You switched to a linear order for serialization.
I'll need to lead a map on the side.
lquerel
left a comment
There was a problem hiding this comment.
I only noticed a few fairly minor issues (the main one is potentially around the imports).
I know that in this PR you didn't try to optimize lookups in the registry/catalog, with find_map used in several places. I think that, in the long run, we'll need to address this, as it could become problematic, especially with support for multiple registries.
| let registry_id: String = repo.id().to_string(); | ||
| let manifest = repo.manifest().cloned(); | ||
| let mut attr_catalog = AttributeCatalog::default(); | ||
| // TODO - Do something with non_fatal_errors if we need to. |
There was a problem hiding this comment.
Why not merge the non fatal errors coming from the dependencies with the WResult returned by this method? It feels like, at the moment, we're simply dropping those errors.
There was a problem hiding this comment.
We are, there's a bug on this being the preferred default.
I can write in the flag that will allow ignoring/dropping or preserving, but I'm going to default to ignoring.
The issue at least before, was using current rules and rego policies on older repositories. That may be less of an issue pulling resolved registry but it's still not as useful as you'd think
There was a problem hiding this comment.
We are, there's a bug on this being the preferred default.
I can write in the flag that will allow ignoring/dropping or preserving, but I'm going to default to ignoring.
The issue at least before, was using current rules and rego policies on older repositories. That may be less of an issue pulling resolved registry but it's still not as useful as you'd think
| let metrics_imports_matcher = build_globset( | ||
| current_registry_imports | ||
| .iter() | ||
| .find_map(|i| i.imports.metrics.as_ref()), |
There was a problem hiding this comment.
Can't we have imports across multiple files? With find_map here, we’re only finding the first one.
There was a problem hiding this comment.
Yeah. This is a temporary quick implementation while we only support one. This method will need to be fleshed out to support multiple later, but at least it's contained in one spot now.
There was a problem hiding this comment.
Yeah. This is a temporary quick implementation while we only support one. This method will need to be fleshed out to support multiple later, but at least it's contained in one spot now.
There was a problem hiding this comment.
Hum. Maybe I misunderstood what you were trying to do here. It doesn't feel like this is about supporting multiple dependencies, but rather about the imports section in a semconv file, which allows defining a subset of metrics to import, the wildcard mechanism. Am I mistaken, or does using find_map prevent capturing all imports?
crates/weaver_resolver/src/loader.rs
Outdated
| dependency_chain, | ||
| ) { | ||
| WResult::Ok(d) => loaded_dependencies.push(d), | ||
| // TODO - Should we always ignore warnings on loaded dependencies? |
There was a problem hiding this comment.
I don't think we should ignore non-fatal errors on loaded dependencies. We don't really have any guaranties that they are well-formed.
There was a problem hiding this comment.
Updated this to previous behavior and have TODO around #1126.
PTAL at that issue and comment your thoughts. I'll defer fixing it.
Reworks the resolution engine to allow using resolved schema as a dependency.
LoadedandResolvedLoadedcan now work with a loadedResolvedTelemetrySchema(v1 or v2) or a definition schema (raw / unresolved).TODOS