-
Notifications
You must be signed in to change notification settings - Fork 886
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
Trying to extract codegen plugin #3521
Conversation
buildSrc/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-instrumentation.gradle.kts
Outdated
Show resolved
Hide resolved
...in/java/io/opentelemetry/javaagent/muzzle/generation/collector/AdviceClassNameCollector.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/opentelemetry/javaagent/extension/instrumentation/InstrumentationModule.java
Outdated
Show resolved
Hide resolved
Asking for specific feedback:
|
group = "io.opentelemetry.instrumentation.gradle" | ||
|
||
dependencies { | ||
implementation("com.google.guava:guava") |
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.
Sorry had a pending comment but forgot to hit submit. On the topic of a codegen
configuration
I think we may still want the configuration
- To add less to Gradle classpath. If we add too much it can cause dependency hell, a bit worried about Guava
- To be able to substitute in the project dependencies in our project, not sure we'd have any way of doing it for a plugin transitive dependency which would be resolved way too early for a substitution to kick in I think.
I guess 1 could be resolved with shading anyways though. But 2) seems important and a requirement to allow using an older version of the plugin even as we work on the javaagent-extension-api.
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.
At the same time self-contained plugin is good for external users. They don't need to know about "codegen" dependency and that something has to be added to it.
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.
Yeah they wouldn't need to with the configuration either since we configure it with defaults here. Before this PR our repo is substituting to use our project dependencies but it's not required to care otherwise.
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 am afraid I don't quite understand what do you suggest? Do you mean to create and use codegen
configuration already here, right in the module? Or how?
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 propose using the same pattern we have
This as all the io.openteletry.* ones are meant to be published for downstream. Though most will get this one transitively via io.opentelemetry.instrumentation.javaagent-instrumentation.
The configuration is set here when the plugin is included so most users won't need to worry about it.
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.
Also makes me realize this project shouldn't be called muzzle or codegen or anything - let's call it gradle-plugins
. We have a few plugins to publish.
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.
Also makes me realize this project shouldn't be called muzzle or codegen or anything - let's call it
gradle-plugins
. We have a few plugins to publish.
Which ones? I am fine with publishing muzzle generation and checking as one plugin. But I am not sure we should bundle all our plugins into one artifact?
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 propose using the same pattern we have
This as all the io.openteletry.* ones are meant to be published for downstream. Though most will get this one transitively via io.opentelemetry.instrumentation.javaagent-instrumentation.
The configuration is set here when the plugin is included so most users won't need to worry about it.
Do I understand you correctly?
- Published
io.opentelemetry.instrumentation.javaagent-codegen
plugin does not have any declared runtime dependencies - Actual dependencies, such as guava and
javaagent-extension-api
are added byio.opentelemetry.instrumentation.javaagent-instrumentation
plugin - End users are supposed to use
io.opentelemetry.instrumentation.javaagent-instrumentation
plugin when it gets published
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.
Yeah that understanding sounds correct to me.
But I am not sure we should bundle all our plugins into one artifact?
I don't think there's any real downside - anyways we'll publish to Gradle Plugin Portal so users just add the plugin to their project and don't care how the artifact is structured. So it allows us to keep all plugin publishing type of logic together.
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.
First, we don't actually HAVE to publish to Gradle Plugin Portal. Plugins can be consumed just from Maven Central as well.
Second, ok, let's give it a try...
@@ -0,0 +1,22 @@ | |||
plugins { |
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.
Do we want the word muzzle in these projects? Assuming muzzle refers to our safety mechanism for applying instrumentation across versions, a lot of the codegen is independent of muzzle
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.
This plugin generates bodies for InstrumentationModule
methods with word muzzle
in method names. So currently it is certainly muzzle-related.
website = "https://opentelemetry.io" | ||
vcsUrl = "https://github.com/open-telemetry/opentelemetry-java-instrumentation" | ||
tags = listOf("opentelemetry", "instrumentation") | ||
} |
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.
We'll need that plugins
snippet from my draft PR when publishing to portal so may as well add it now right?
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.
Which PR? :) Sorry, you are too laconic for me recently :(
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.
Sorry for my smartphone replies, somehow GitHub app still doesn't support linking to lines of code. And now that I look for it I can't find it in the PR I sent, that's definitely too laconic...
gradlePlugin {
plugins {
named("io.opentelemetry.instrumentation.javaagent-codegen") {
displayName = "<short displayable name for plugin>"
description = "<Good human-readable description of what your plugin is about>"
}
}
}
One thing I found is for precompiled script plugin, we leave out id
and implementationClass
and it seems to work ok
...gent-muzzle-generation/src/main/java/io/opentelemetry/javaagent/muzzle/generation/Utils.java
Outdated
Show resolved
Hide resolved
...gent-muzzle-generation/src/main/java/io/opentelemetry/javaagent/muzzle/generation/Utils.java
Outdated
Show resolved
Hide resolved
For the reference: here is an example of using this new plugin in an external project: https://github.com/signalfx/splunk-otel-java/compare/muzzle-codegen?expand=1. Only one module was verified to work for now. I am concerned about using |
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.
Just nits, thanks!
buildSrc/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-instrumentation.gradle.kts
Show resolved
Hide resolved
buildSrc/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-testing.gradle.kts
Outdated
Show resolved
Hide resolved
...s/src/main/java/io/opentelemetry/javaagent/muzzle/generation/MuzzleCodeGenerationPlugin.java
Outdated
Show resolved
Hide resolved
...s/src/main/java/io/opentelemetry/javaagent/muzzle/generation/MuzzleCodeGenerationPlugin.java
Outdated
Show resolved
Hide resolved
...-plugins/src/main/java/io/opentelemetry/javaagent/muzzle/generation/MuzzleCodeGenerator.java
Outdated
Show resolved
Hide resolved
...e-plugins/src/main/java/io/opentelemetry/javaagent/muzzle/generation/ReferenceCollector.java
Outdated
Show resolved
Hide resolved
...e-plugins/src/main/java/io/opentelemetry/javaagent/muzzle/generation/ReferenceCollector.java
Outdated
Show resolved
Hide resolved
...e-plugins/src/main/java/io/opentelemetry/javaagent/muzzle/generation/ReferenceCollector.java
Outdated
Show resolved
Hide resolved
...e-plugins/src/main/java/io/opentelemetry/javaagent/muzzle/generation/ReferenceCollector.java
Outdated
Show resolved
Hide resolved
...ain/java/io/opentelemetry/javaagent/tooling/muzzle/collector/MuzzleCompilationException.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
dependencies { | ||
add("muzzleBootstrap", "io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap") | ||
add("muzzleTooling", "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling") | ||
add("muzzleTooling", "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api") | ||
|
||
add("codegen", "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling") |
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.
Is tooling needed for codegen?
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.
Apparently not right now...
@@ -11,6 +11,8 @@ plugins { | |||
See https://imperceptiblethoughts.com/shadow/ for more details about Shadow plugin. | |||
*/ | |||
id "com.github.johnrengelman.shadow" version "6.1.0" | |||
|
|||
id "io.opentelemetry.instrumentation.javaagent-codegen" version "0.1.0" |
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.
Is 0.1.0 some temporary released version? Are we going to version gradle plugins the same way we do all other artficats?
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.
Currently this module is totally independent from the main build. I don't have a strong opinion on its versioning atm
No description provided.