Rename Pre-Main class (#955)

This commit is contained in:
Trask Stalnaker 2020-08-13 10:58:33 -07:00 committed by GitHub
parent 89577a168a
commit a0dc9ba19c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 10 deletions

View File

@ -12,7 +12,7 @@ into 3 parts:
#### `javaagent` module #### `javaagent` module
This module consists of single class This module consists of single class
`io.opentelemetry.auto.bootstrap.AgentBootstrap` which implements [Java `io.opentelemetry.javaagent.OpenTelemetryAgent` which implements [Java
instrumentation instrumentation
agent](https://docs.oracle.com/javase/7/docs/api/java/lang/instrument/package-summary.html). agent](https://docs.oracle.com/javase/7/docs/api/java/lang/instrument/package-summary.html).
This class is loaded during application startup by application classloader. This class is loaded during application startup by application classloader.

View File

@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory;
/** /**
* Agent start up logic. * Agent start up logic.
* *
* <p>This class is loaded and called by {@code io.opentelemetry.auto.bootstrap.AgentBootstrap} * <p>This class is loaded and called by {@code io.opentelemetry.javaagent.OpenTelemetryAgent}
* *
* <p>The intention is for this class to be loaded by bootstrap classloader to make sure we have * <p>The intention is for this class to be loaded by bootstrap classloader to make sure we have
* unimpeded access to the rest of agent parts. * unimpeded access to the rest of agent parts.

View File

@ -18,9 +18,9 @@ configurations {
jar { jar {
manifest { manifest {
attributes( attributes(
"Main-Class": "io.opentelemetry.auto.bootstrap.AgentBootstrap", "Main-Class": "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Agent-Class": "io.opentelemetry.auto.bootstrap.AgentBootstrap", "Agent-Class": "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Premain-Class": "io.opentelemetry.auto.bootstrap.AgentBootstrap", "Premain-Class": "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Can-Redefine-Classes": true, "Can-Redefine-Classes": true,
"Can-Retransform-Classes": true, "Can-Retransform-Classes": true,
) )

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.opentelemetry.auto.bootstrap; package io.opentelemetry.javaagent;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@ -55,8 +55,8 @@ import java.util.regex.Pattern;
* <li>Do dot touch any logging facilities here so we can configure them later * <li>Do dot touch any logging facilities here so we can configure them later
* </ul> * </ul>
*/ */
public class AgentBootstrap { public class OpenTelemetryAgent {
private static final Class<?> thisClass = AgentBootstrap.class; private static final Class<?> thisClass = OpenTelemetryAgent.class;
public static void premain(final String agentArgs, final Instrumentation inst) { public static void premain(final String agentArgs, final Instrumentation inst) {
agentmain(agentArgs, inst); agentmain(agentArgs, inst);

View File

@ -16,8 +16,8 @@
package io.opentelemetry.auto package io.opentelemetry.auto
import io.opentelemetry.auto.bootstrap.AgentBootstrap
import io.opentelemetry.auto.test.IntegrationTestUtils import io.opentelemetry.auto.test.IntegrationTestUtils
import io.opentelemetry.javaagent.OpenTelemetryAgent
import jvmbootstraptest.AgentLoadedChecker import jvmbootstraptest.AgentLoadedChecker
import jvmbootstraptest.MyClassLoaderIsNotBootstrap import jvmbootstraptest.MyClassLoaderIsNotBootstrap
import spock.lang.Specification import spock.lang.Specification
@ -50,7 +50,7 @@ class AgentLoadedIntoBootstrapTest extends Specification {
def mainClassName = MyClassLoaderIsNotBootstrap.getName() def mainClassName = MyClassLoaderIsNotBootstrap.getName()
def pathToJar = IntegrationTestUtils.createJarWithClasses(mainClassName, def pathToJar = IntegrationTestUtils.createJarWithClasses(mainClassName,
MyClassLoaderIsNotBootstrap, MyClassLoaderIsNotBootstrap,
AgentBootstrap).getPath() OpenTelemetryAgent).getPath()
expect: expect:
IntegrationTestUtils.runOnSeparateJvm(mainClassName IntegrationTestUtils.runOnSeparateJvm(mainClassName

View File

@ -73,6 +73,13 @@ class ShadowPackageRenamingTest extends Specification {
break break
} }
} }
if (info.getName() == 'io.opentelemetry.javaagent.OpenTelemetryAgent') {
// io.opentelemetry.javaagent.OpenTelemetryAgent isn't needed in the bootstrap prefixes
// because it doesn't live in the bootstrap class loader, but it's still "good" for the
// purpose of this test which is just checking all the classes sitting directly inside of
// the agent jar
goodPrefix = true
}
if (!goodPrefix) { if (!goodPrefix) {
badBootstrapPrefixes.add(info.getName()) badBootstrapPrefixes.add(info.getName())
} }