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

Fix resolution process #53

Merged
merged 6 commits into from
Mar 18, 2024
Merged

Conversation

lquerel
Copy link
Contributor

@lquerel lquerel commented Mar 17, 2024

This PR fixes an issue in the resolution process when there are more than 1 level of extends.

Note 1: The lineage computation is still incomplete and will be fixed in the next PR (see #52). This is not blocking.

Note 2: The current resolution process is iterative and far from optimal but still pretty fast with the current semconv registry. If speed becomes an issue, a graph could be construct from the extends and ref clauses, and a DFS resolution could be used to optimize the entire resolution process.

@lquerel lquerel requested a review from jsuereth as a code owner March 17, 2024 22:28
@lquerel lquerel self-assigned this Mar 17, 2024
@lquerel lquerel added the bug Something isn't working label Mar 17, 2024
Copy link
Contributor

@jsuereth jsuereth left a comment

Choose a reason for hiding this comment

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

It's interesting how a small fix ripples through all the test code. I think maybe I need to do a better job focusing on the markdown or we need to start pulling in more of the existing markdown as our tests....

IN any case, looks good! Thanks for fixing this!

// attr and attr_parent are both references.
AttributeSpec::Ref {
r#ref: r#ref.clone(),
brief: if brief.is_some() {
Copy link
Contributor

Choose a reason for hiding this comment

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

For all these options, you can make a helper method to clean this up.

fn clone_first_some<T : Clone>(first: &Option<T>, second: &Option<T>): Option<T> {
  if first.is_some() {
      first.clone()
  } else {
     second.clone()
  }    

Then all this code becomes:

AttribtueSpec::Ref {
   ...
  brief: clone_first_some(brief, parent_brief),
  examples: clone_first_some(examples, parent_examples),
  ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created the following GH issue #54

@lquerel
Copy link
Contributor Author

lquerel commented Mar 18, 2024

It's interesting how a small fix ripples through all the test code. I think maybe I need to do a better job focusing on the markdown or we need to start pulling in more of the existing markdown as our tests....

IN any case, looks good! Thanks for fixing this!

Yes looks like using the existing markdown files is our best option at this point.

@lquerel lquerel merged commit 840f2e4 into open-telemetry:main Mar 18, 2024
13 checks passed
@jsuereth jsuereth mentioned this pull request Mar 20, 2024
@lquerel lquerel deleted the fix-resolution-process branch April 4, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants