Skip to content

Fix resolution for dependencies#1280

Merged
jsuereth merged 6 commits intoopen-telemetry:mainfrom
lmolkova:resolve-fixes
Mar 11, 2026
Merged

Fix resolution for dependencies#1280
jsuereth merged 6 commits intoopen-telemetry:mainfrom
lmolkova:resolve-fixes

Conversation

@lmolkova
Copy link
Member

Both v1 and v2 resolution has a problem when using dependencies - it returns random attribute from attribute catalog instead of definition resulting in wrong briefs/notes, etc.

E.g. in this yaml https://github.com/lmolkova/semconv-scale23x-demo/blob/965f9f0a6094e1d21150d4a0441ede7aafbb4a0b/conventions/src/registry.yaml#L36 ( - ref: server.address from semconv), the server.address resolves to "Name of the database host." which comes from DB refinement.

https://github.com/lmolkova/semconv-scale23x-demo/blob/2d31c5bf2437f5936d8740a338845bcb06ced456/docs/storage/metrics.md#attributes-1

This PR fixes those. It does not solve multi-dependency/from-transitive-dependency resolution.

@lmolkova lmolkova requested a review from a team as a code owner March 11, 2026 21:47
/// Attribute definitions available in this registry (including those
/// from dependencies). Used for cross-registry attribute lookup.
/// Not serialized — populated only for freshly resolved schemas.
root_attributes: HashMap<String, (Attribute, String)>,
Copy link
Member Author

@lmolkova lmolkova Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the real change for v1, let's populate root_attributes directly instead of trying to use lineage to infer if something in the catalog is original definition.

The rest in this file is cleanup - this struct should not allow to mutate attrs, does not need to be (de)serializable, many of its features were only used in tests

stability: stable
requirement_level: recommended
examples: "Ex"
- id: db.client.metrics
Copy link
Member Author

@lmolkova lmolkova Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is repro for the v1 issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah - I gotcha, we don't use extends here, so all the assumptions fail, and the catalog is ambiguous. I thought it'd be safe to remove the hardcoded registry. paths for V1, but looks like not, thanks for catching this.

"requirement_level": "recommended",
"note": "Destination name SHOULD uniquely identify a specific queue, topic or other entity within the broker. If\nthe broker doesn't have such notion, the destination name SHOULD uniquely identify the broker.\n",
"stability": "stable"
[
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no change here except unwrapping list of attrs - this allows to remove serialization from Catalog

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOF, yeah you can blame me for that change and I regret doing it.

I wonder if maybe serializing this to YAML or TOML or something would make this more readable / easier to diff in the future. WDYT?

# TODO: this only works with definition registry, but not with
# resolved one, because resolved does not know how to get
# attributes from transitive dependencies.
registry_path: data/registry-test-v2-dep/consumer_registry
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fun around attrs from transitive dependencies:

  • if you use definition as a dependency, you can use attributes in transitive one
  • if you use resolved as dependency, you can't - they are not there

Let's make it consistent (regardless of the approach we take)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also more fun: since only one dependency is allowed, you can't really make

A -> resolved B -> C work today, unless you can modify B to import things

})
});
result
self.catalog
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is part of solution for v1 - use root attributes instead of refs, the logic here didn't work for dependencies

let fake_group_id = format!("v2_dependency.{}", self.schema_url.name());
self.attribute_catalog.iter().find_map(|attr| {
self.registry.attributes.iter().find_map(|attr_ref| {
let attr = self.attribute_catalog.get(attr_ref.0 as usize)?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is solution for v2 - attribute_catalog contains definitions and refinements. given lookup by key, we can only return the original definition from registry.attributes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! Yeah - I can't believe I missed this the first time.

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.1%. Comparing base (7678d00) to head (93b2230).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1280     +/-   ##
=======================================
+ Coverage   81.0%   81.1%   +0.1%     
=======================================
  Files        111     111             
  Lines       9380    9375      -5     
=======================================
+ Hits        7598    7606      +8     
+ Misses      1782    1769     -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

/// and signals.
pub catalog: Catalog,
/// Resource definition (only for application).
#[serde(skip_serializing_if = "Option::is_none")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional?

Copy link
Member Author

@lmolkova lmolkova Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, it does not need json schema - we don't (and don't need to) support it for v1. And it's not (de)serializable either

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to remove serialization from things that are not intended to be read or written by weaver. This helps to understand what's internal detail and what's a real contract

@jsuereth jsuereth merged commit ff72026 into open-telemetry:main Mar 11, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants