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

solves #768: Add OSGi support by exporting all java packages except internal packages #6669

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

royteeuwen
Copy link

@royteeuwen royteeuwen commented Aug 23, 2024

Pull request to add OSGi support

@royteeuwen royteeuwen requested a review from a team August 23, 2024 14:00
Copy link

linux-foundation-easycla bot commented Aug 23, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: royteeuwen / name: Roy Teeuwen (ff2f9ca)
  • ✅ login: bdhoine / name: Barry d'Hoine (769923c, 0b080b2)

@royteeuwen royteeuwen changed the title solves #768: Add OSGi support by exporting all java packages except i… solves #768: Add OSGi support by exporting all java packages except internal packages Aug 23, 2024
@royteeuwen royteeuwen force-pushed the feature/768-add-osgi-support branch from 95bc17a to 7745dc1 Compare August 23, 2024 14:02
@royteeuwen royteeuwen force-pushed the feature/768-add-osgi-support branch from 7745dc1 to ff2f9ca Compare August 23, 2024 14:03
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.06%. Comparing base (97b3fa4) to head (769923c).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6669      +/-   ##
============================================
- Coverage     90.07%   90.06%   -0.02%     
  Complexity     6278     6278              
============================================
  Files           697      697              
  Lines         18951    18951              
  Branches       1858     1858              
============================================
- Hits          17071    17068       -3     
- Misses         1306     1307       +1     
- Partials        574      576       +2     

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

Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

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

Check out #4627 for a previous attempt at adding OSGi support.

As someone without OSGi experience, I think its important to add some sort of end-to-end integration test. A sample app built with OSGi which consumes these artifacts and demonstrates it works as intended.

@royteeuwen
Copy link
Author

royteeuwen commented Aug 26, 2024

@jack-berg @bdhoine and myself are from the same organization, that's why you see a similar PR in the other repo's ;) we need it there as well.

Of course I don't mind adding an integration test / sample application at all, but I would like to see what the expected result is:

  • OSGi is based on manifest headers in the resulting JAR. We can create a unit test that checks the manifest headers to see that the correct headers are available. If yes, then this will work in an OSGi environment. This is a very fast test and would not be hard to create. I can also link to the OSGi docs to showcase what is required.
  • Another approach would be to start up an entire OSGi application in the integration-tests folder that contains the opentelemetry api and sdk jar. This way we can test that the jar files work by creating some sample traces or something of the sorts. But I would like to avoid adding an integration tests to this project, that make the build inherently a bit slower, and then get it declined because of that ;)

So what do you expect / propose? I will also join the Java SIG as mentioned in the linked github issue, so maybe it's best to combine the two discussion lists and continue the talk in the issue instead of having two separate discussions in the pr and the issue about the same topic at the same time.

@jack-berg
Copy link
Member

We can create a unit test that checks the manifest headers to see that the correct headers are available. If yes, then this will work in an OSGi environment. This is a very fast test and would not be hard to create. I can also link to the OSGi docs to showcase what is required.

What's your confidence level that this would in fact ensure that OSGi support is valid? Have you tried building your branch locally and running your app? There was a comment on #4627 suggesting that some of our Class.forName usage would get in the way of OSGi.. an integration test seems like the surest way to know its going to behave like we think.

We have to do something similar to ensure support for graal. Is there a lightweight way to do the same with OSGi? You mention that integration tests are inherently a little slower - how slow are we talking? We have precedent for running some fairly expensive but valuable tests as a part of our build, so could be worth it.

@royteeuwen
Copy link
Author

So far I have tested it by wrapping all OpenTelemetry jars into one jar together and adding the correct manifest headers and then running it in an OSGi application, this was the most efficient way of doing it without having to lose too much time, but it becomes a hassle because I have to build my own wrapper every time when a new release comes out. That's the reason for making this PR.

But thanks for pointing the issue out of the Class.forName, it will give issues when having all jars separate instead of one uber jar, without adding extra headers to fix it. The integration test will be perfect to point that out!

The integration test will still be lightweight enough, just slower than a unit test. I'll try something out and come back with the results!

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.

3 participants