-
Notifications
You must be signed in to change notification settings - Fork 858
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
WIP:Add OSGi support to OpenTelemetry project #4627
Conversation
@LWogan before we can look at this or accept it, we need you to sign the CLA. Thanks! |
Codecov Report
@@ Coverage Diff @@
## main #4627 +/- ##
============================================
- Coverage 90.04% 90.03% -0.01%
+ Complexity 5058 5057 -1
============================================
Files 581 581
Lines 15591 15591
Branches 1491 1491
============================================
- Hits 14039 14038 -1
Misses 1100 1100
- Partials 452 453 +1
Continue to review full report at Codecov.
|
I know virtually nothing about OSGi, but this looks ok to me on its surface. @jack-berg do you have any experience with OSGi, or know anyone we can rope in to help? |
To add a little explanation of what did does. The bnd instruction will generate OSGi metadata and add it to the manifest files of each jar. OSGi is a framework which relies on this metadata to functionally operate. The OpenTelemetry artifacts cannot be used by anyone running in an OSGi framework without this. There was some logic already present in the project to set specific manifest attributes, I have preserved these by instructing the bnd operation to add them while adding its automatically generated OSGi metadata. |
…DK and Implementation Title/Version to all tasks of type Jar. Only add Automatic module name to tasks named "jar" as it shouldn't matter for other Jar tasks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with OSGi but I asked around New Relic and a couple peek took a glance and said it looks innocent.
For reference, here's what the :api
jar manifest looks like before:
Manifest-Version: 1.0
Automatic-Module-Name: io.opentelemetry.api
Built-By: jberg
Built-JDK: 11.0.15
Implementation-Title: all
Implementation-Version: 1.17.0-SNAPSHOT
and after:
Manifest-Version: 1.0
Automatic-Module-Name: io.opentelemetry.api
Bnd-LastModified: 1658958870198
Built-By: jberg
Built-JDK: 11.0.15
Bundle-ManifestVersion: 2
Bundle-Name: opentelemetry-api
Bundle-SymbolicName: opentelemetry-api
Bundle-Version: 1.17.0.SNAPSHOT
Created-By: 11.0.15 (Eclipse Adoptium)
Implementation-Title: all
Implementation-Version: 1.17.0-SNAPSHOT
Import-Package: io.opentelemetry.context,io.opentelemetry.context.prop
agation,io.opentelemetry.sdk.autoconfigure,javax.annotation;version="
[3.0,4)"
Private-Package: io.opentelemetry.api,io.opentelemetry.api.baggage,io.
opentelemetry.api.baggage.propagation,io.opentelemetry.api.common,io.
opentelemetry.api.internal,io.opentelemetry.api.metrics,io.openteleme
try.api.trace,io.opentelemetry.api.trace.propagation,io.opentelemetry
.api.trace.propagation.internal
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-6.3.1.202206071316
// When updating, update above in plugins too | ||
implementation("biz.aQute.bnd:biz.aQute.bnd.gradle:6.3.1") | ||
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.4.2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment applies to the spotless plugin. Should change the order to restore it.
// When updating, update above in plugins too | |
implementation("biz.aQute.bnd:biz.aQute.bnd.gradle:6.3.1") | |
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.4.2") | |
// When updating, update above in plugins too | |
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.4.2") | |
implementation("biz.aQute.bnd:biz.aQute.bnd.gradle:6.3.1") |
@@ -126,6 +124,15 @@ tasks { | |||
} | |||
} | |||
|
|||
named("jar", Jar::class.java) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment indicating that this adds required OSGi metadata to the jar manifest?
…portable from other modules. Various modules within this repo have packages with the namespace internal which are exposed via the apis of non internal classes and therefore had to be exposed
@jack-berg Ive made some additional changes. I needed to add annotations to numerous package-info files. This informs the OSGi framework that these packages are available for use by other jars. Worth noting some packages marked with the namespace internal have been included as some of their classes are on the APIs of classes in other packages. Another point to add is this PR will add support to this project for OSGi. However there are numerous dependencies such as io.grpc (and its transitive dependencies) which also do not have OSGi support. There are workarounds to this but I thought I should point that out. Leaving as a draft for now as I am still integrating OpenTelemetry into an OSGi project so I might not have worked out all the issues yet. |
I was able to test it and I believe it needs a second touch. Import of |
@jack-berg Looking at this again (on top of 0.16) I think there are more things to tackle within library design itself. The
Its not quite clear to me why such design exists. With such way in place you tie autconfigure module with all listed spi providers. Effectively it is not possible to separate api from specific implementations as bndtools which generates OSGi metadata is able to spot somehow Any use of Such patterns work fine with single classloader which is used with flat classpath, but will certainly fail with hierarchical classloaders and osgi which has multiple classloaders. For simplicity of understanding - under OSGi each bundle (deployed jar) have its own classloader exposing only declared import statements. |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Hi @splatch - sorry for the delayed reply. Not sure what the best answer is here, but I can provide some context. The autoconfigure is responsible for configuring an The advantage of this is that configuration lives in one place, instead of being scattered around each of the components. Not sure how you could accomplish this with the |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
Hi, why is this never merged? We are also looking for functionality like this, since we want to use OpenTelemetry in an OSGi context. |
From my perspective the pr is incomplete. Needs more testing and probably more changes. The package structures of this Otel project means if you want to pull in a single lib then you pretty much have to pull in every other subproject due to the internal dependency tree with each subproject having some package import from another. This is a frustration when you only wish to use a subset of bundles. Also, unfortunately, many of OpenTelems dependencies and also transient dependencies are not OSGi bundles which makes it very difficult to use this library within an OSGi context even with this PR applied. |
Use bnd plugin to add OSGi metdata to manifest files to allow them to be used within an OSGi framework