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

Update otel version to 1.1.0 #199

Merged
merged 1 commit into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
@AutoService(ComponentInstaller.class)
public class MicrometerInstaller implements ComponentInstaller {
@Override
public void beforeByteBuddyAgent() {
public void beforeByteBuddyAgent(Config config) {
Resource resource = OpenTelemetrySdkAutoConfiguration.getResource();
SplunkMetricsConfig splunkMetricsConfig = new SplunkMetricsConfig(Config.get(), resource);
SplunkMetricsConfig splunkMetricsConfig = new SplunkMetricsConfig(config, resource);

if (splunkMetricsConfig.enabled()) {
GlobalMetricsTags.set(new GlobalTagsBuilder(resource).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.api.common.AttributeType;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.javaagent.spi.ComponentInstaller;
import io.opentelemetry.sdk.autoconfigure.OpenTelemetrySdkAutoConfiguration;

Expand All @@ -32,10 +33,10 @@
public class ResourceAttributesToSystemProperties implements ComponentInstaller {

@Override
public void beforeByteBuddyAgent() {}
public void beforeByteBuddyAgent(Config config) {}

@Override
public void afterByteBuddyAgent() {
public void afterByteBuddyAgent(Config config) {
Attributes attributes = OpenTelemetrySdkAutoConfiguration.getResource().getAttributes();
attributes.forEach(
(k, v) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class JaegerThriftSpanExporterFactoryTest {

@BeforeAll
static void startServer() throws Exception {
port = PortUtils.randomOpenPort();
port = PortUtils.findOpenPort();
server = new Server(port);
for (var connector : server.getConnectors()) {
connector.setHost("localhost");
Expand Down
8 changes: 4 additions & 4 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ boolean snapshot = findProperty("snapshot") == 'yes'

ext {
versions = [
opentelemetry : snapshot ? "1.1.0-SNAPSHOT" : "1.0.0",
opentelemetryAlpha : snapshot ? "1.1.0-alpha-SNAPSHOT" : "1.0.0-alpha",
opentelemetryJavaagent : snapshot ? "1.1.0-SNAPSHOT" : '1.0.0',
opentelemetryJavaagentAlpha: snapshot ? "1.1.0-alpha-SNAPSHOT" : '1.0.0-alpha',
opentelemetry : snapshot ? "1.2.0-SNAPSHOT" : "1.1.0",
opentelemetryAlpha : snapshot ? "1.2.0-alpha-SNAPSHOT" : "1.1.0-alpha",
opentelemetryJavaagent : snapshot ? "1.2.0-SNAPSHOT" : '1.1.0',
opentelemetryJavaagentAlpha: snapshot ? "1.2.0-alpha-SNAPSHOT" : '1.1.0-alpha',
mockito : '3.8.0',
jupiter : '5.7.1',
micrometer : '1.6.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public List<TypeInstrumentation> typeInstrumentations() {

private static class BasicDataSourceInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("org.apache.commons.dbcp2.BasicDataSource");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
public static class Instrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("com.sun.appserv.server.util.Version");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
public static class Instrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("org.eclipse.jetty.server.Server");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
@AutoService(ComponentInstaller.class)
public class JvmMetricsInstaller implements ComponentInstaller {
@Override
public void afterByteBuddyAgent() {
public void afterByteBuddyAgent(Config config) {
boolean metricsRegistryPresent = !Metrics.globalRegistry.getRegistries().isEmpty();
if (!Config.get().isInstrumentationEnabled(singleton("jvm-metrics"), metricsRegistryPresent)) {
if (!config.isInstrumentationEnabled(singleton("jvm-metrics"), metricsRegistryPresent)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package com.splunk.opentelemetry.middleware;

import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.ClassLoaderMatcher.hasClassesNamed;
import static net.bytebuddy.matcher.ElementMatchers.*;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;

import com.google.auto.service.AutoService;
import com.ibm.ws.kernel.productinfo.ProductInfo;
Expand Down Expand Up @@ -52,7 +54,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
public static class Instrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("com.ibm.ws.kernel.boot.internal.KernelBootstrap");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ protected boolean defaultEnabled() {
return super.defaultEnabled() && ServerTimingHeader.shouldEmitServerTimingHeader();
}

// we don't have muzzle in our distro
@Override
public Map<String, String> contextStore() {
public Map<String, String> getMuzzleContextStoreClasses() {
return Collections.singletonMap(
"org.jboss.netty.channel.Channel", ChannelTraceContext.class.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class NettyInstrumentationTest {

@BeforeAll
static void startServer() {
port = PortUtils.randomOpenPort();
port = PortUtils.findOpenPort();

server = new ServerBootstrap(new NioServerSocketChannelFactory());
server.setPipelineFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class NettyInstrumentationTest {

@BeforeAll
static void startServer() throws InterruptedException {
port = PortUtils.randomOpenPort();
port = PortUtils.findOpenPort();
server = new NioEventLoopGroup();

new ServerBootstrap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Servlet3InstrumentationTest {

@BeforeAll
static void startServer() throws Exception {
port = PortUtils.randomOpenPort();
port = PortUtils.findOpenPort();
server = new Server(port);
for (var connector : server.getConnectors()) {
connector.setHost("localhost");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
private static final class ServletAndFilterInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(namedOneOf("javax.servlet.Filter", "javax.servlet.http.HttpServlet"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ServletInstrumentationTest {

@BeforeAll
static void startServer() throws Exception {
port = PortUtils.randomOpenPort();
port = PortUtils.findOpenPort();
server = new Server(port);
for (var connector : server.getConnectors()) {
connector.setHost("localhost");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
public static class Instrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("org.apache.catalina.startup.Catalina");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
public static class Instrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("org.apache.tomee.catalina.ServerListener");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public List<TypeInstrumentation> typeInstrumentations() {

private static class MiddlewareInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
public static class Instrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("org.jboss.as.server.ServerEnvironment");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.splunk.opentelemetry.helper.TestImage;
import java.io.IOException;
import java.util.Map;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand All @@ -43,18 +42,6 @@ private static Stream<Arguments> jboss() {
.stream();
}

// TODO: this method can be removed after upstream javaagent 1.1.0 release
// openj9 JDK8 does not have JFR classes, which causes all ComponentInstallers to run
// synchronously, not after LogManager is loaded - see
// AgentInstaller#installComponentsAfterByteBuddy()
// micrometer's JvmGcMetrics references (indirectly) NotificationBroadcasterSupport which uses
// ClassLogger which uses JUL and this causes JVM LogManager to load before the JBoss one
// AFAIK only openj9 (IBM) JDK 8 has this problem, all other JDKs don't use JUL in MBeans
@Override
protected Map<String, String> getExtraEnv() {
return Map.of("SPLUNK_METRICS_ENABLED", "false");
}

@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("jboss")
void jbossSmokeTest(TestImage image, ExpectedServerAttributes expectedServerAttributes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.splunk.opentelemetry.helper.TestImage;
import java.io.IOException;
import java.util.Map;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand All @@ -44,18 +43,6 @@ private static Stream<Arguments> supportedConfigurations() {
.stream();
}

// TODO: this method can be removed after upstream javaagent 1.1.0 release
// openj9 JDK8 does not have JFR classes, which causes all ComponentInstallers to run
// synchronously, not after LogManager is loaded - see
// AgentInstaller#installComponentsAfterByteBuddy()
// micrometer's JvmGcMetrics references (indirectly) NotificationBroadcasterSupport which uses
// ClassLogger which uses JUL and this causes JVM LogManager to load before the JBoss one
// AFAIK only openj9 (IBM) JDK 8 has this problem, all other JDKs don't use JUL in MBeans
@Override
protected Map<String, String> getExtraEnv() {
return Map.of("SPLUNK_METRICS_ENABLED", "false");
}

@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("supportedConfigurations")
void wildflySmokeTest(TestImage image, ExpectedServerAttributes expectedServerAttributes)
Expand Down
1 change: 1 addition & 0 deletions testing/agent-metrics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
annotationProcessor deps.autoservice
compileOnly deps.autoservice

compileOnly("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:${versions.opentelemetryJavaagentAlpha}")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-spi:${versions.opentelemetryJavaagentAlpha}")
compileOnly("io.micrometer:micrometer-core:${versions.micrometer}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
import com.google.auto.service.AutoService;
import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.javaagent.spi.ComponentInstaller;

@AutoService(ComponentInstaller.class)
public class TestMicrometerInstaller implements ComponentInstaller {
@Override
public void beforeByteBuddyAgent() {
public void beforeByteBuddyAgent(Config config) {
Metrics.addRegistry(new SimpleMeterRegistry());
}
}