-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for GlassFish * Update Tomcat to new images as well * Format * Simplify config * Update to new images that use application with context path * Polish * Actually disable failing test for now
- Loading branch information
Showing
18 changed files
with
217 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
id "java" | ||
} | ||
|
||
dependencies { | ||
compileOnly('org.glassfish.main.common:common-util:5.0') | ||
} |
77 changes: 77 additions & 0 deletions
77
...in/java/com/splunk/opentelemetry/middleware/GlassfishAttributesInstrumentationModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright Splunk Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.splunk.opentelemetry.middleware; | ||
|
||
import static io.opentelemetry.javaagent.tooling.ClassLoaderMatcher.hasClassesNamed; | ||
import static net.bytebuddy.matcher.ElementMatchers.isTypeInitializer; | ||
import static net.bytebuddy.matcher.ElementMatchers.named; | ||
|
||
import com.google.auto.service.AutoService; | ||
import com.splunk.opentelemetry.javaagent.bootstrap.MiddlewareHolder; | ||
import com.sun.appserv.server.util.Version; | ||
import io.opentelemetry.javaagent.tooling.InstrumentationModule; | ||
import io.opentelemetry.javaagent.tooling.TypeInstrumentation; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import net.bytebuddy.asm.Advice; | ||
import net.bytebuddy.description.method.MethodDescription; | ||
import net.bytebuddy.description.type.TypeDescription; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
|
||
@AutoService(InstrumentationModule.class) | ||
public class GlassfishAttributesInstrumentationModule extends InstrumentationModule { | ||
|
||
public GlassfishAttributesInstrumentationModule() { | ||
super("glassfish"); | ||
} | ||
|
||
@Override | ||
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() { | ||
return hasClassesNamed("com.sun.appserv.server.util.Version"); | ||
} | ||
|
||
@Override | ||
public List<TypeInstrumentation> typeInstrumentations() { | ||
return Collections.singletonList(new Instrumentation()); | ||
} | ||
|
||
public static class Instrumentation implements TypeInstrumentation { | ||
|
||
@Override | ||
public ElementMatcher<? super TypeDescription> typeMatcher() { | ||
return named("com.sun.appserv.server.util.Version"); | ||
} | ||
|
||
@Override | ||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() { | ||
return Collections.singletonMap( | ||
isTypeInitializer(), | ||
GlassfishAttributesInstrumentationModule.class.getName() | ||
+ "$MiddlewareInitializedAdvice"); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public static class MiddlewareInitializedAdvice { | ||
@Advice.OnMethodExit(suppress = Throwable.class) | ||
public static void onExit() { | ||
MiddlewareHolder.trySetName(Version.getProductName()); | ||
MiddlewareHolder.trySetVersion(Version.getVersionNumber()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<glassfish-web-app> | ||
<context-root>/</context-root> | ||
</glassfish-web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
FROM payara/server-full:@version@ | ||
|
||
RUN rm ${PAYARA_DIR}/glassfish/modules/phonehome-bootstrap.jar | ||
|
||
COPY app.war $DEPLOY_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
smoke-tests/src/test/java/com/splunk/opentelemetry/GlassFishSmokeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright Splunk Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.splunk.opentelemetry; | ||
|
||
import static org.junit.jupiter.params.provider.Arguments.arguments; | ||
|
||
import java.io.IOException; | ||
import java.time.Duration; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.containers.wait.strategy.WaitStrategy; | ||
|
||
public class GlassFishSmokeTest extends AppServerTest { | ||
|
||
public static final ExpectedServerAttributes PAYARA_SERVER_ATTRIBUTES = | ||
new ExpectedServerAttributes( | ||
"/this-is-definitely-not-there-but-there-should-be-a-trace-nevertheless", | ||
"Payara Server", | ||
"5.2020.6"); | ||
|
||
private static Stream<Arguments> supportedConfigurations() { | ||
return Stream.of( | ||
arguments( | ||
"ghcr.io/open-telemetry/java-test-containers:payara-5.2020.6-jdk11-jdk11-20201207.405832649", | ||
PAYARA_SERVER_ATTRIBUTES), | ||
arguments( | ||
"ghcr.io/open-telemetry/java-test-containers:payara-5.2020.6-jdk8-20201207.405832649", | ||
PAYARA_SERVER_ATTRIBUTES)); | ||
} | ||
|
||
@Override | ||
protected Map<String, String> getExtraEnv() { | ||
return Map.of("HZ_PHONE_HOME_ENABLED", "false"); | ||
} | ||
|
||
@Override | ||
protected WaitStrategy getWaitStrategy() { | ||
return Wait.forLogMessage(".*app was successfully deployed.*", 1) | ||
.withStartupTimeout(Duration.ofMinutes(15)); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("supportedConfigurations") | ||
void payaraSmokeTest(String imageName, ExpectedServerAttributes expectedServerAttributes) | ||
throws IOException, InterruptedException { | ||
startTarget(imageName); | ||
|
||
assertServerHandler(expectedServerAttributes); | ||
assertWebAppTrace(expectedServerAttributes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.