Skip to content

Commit

Permalink
Make OpenTelemetry-API Bridge and dependent instrumentations work wit…
Browse files Browse the repository at this point in the history
…h indy (#11578)
  • Loading branch information
JonasKunz authored Sep 4, 2024
1 parent 4b03e98 commit 9dd11ff
Show file tree
Hide file tree
Showing 21 changed files with 213 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class KotlinCoroutinesInstrumentationModule extends InstrumentationModule {
public class KotlinCoroutinesInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {

public KotlinCoroutinesInstrumentationModule() {
super("kotlinx-coroutines");
Expand All @@ -25,12 +27,9 @@ public boolean isHelperClass(String className) {
}

@Override
public boolean isIndyModule() {
// java.lang.LinkageError: bad method type alias: (CoroutineContext)Object[] not visible from
// class
// io.opentelemetry.javaagent.instrumentation.kotlinxcoroutines.KotlinCoroutinesInstrumentation$ContextAdvice
// CoroutineContext is loaded from agent class loader not application
return false;
public String getModuleGroup() {
// This module uses the api context bridge helpers, therefore must be in the same classloader
return "opentelemetry-api-bridge";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.Collections;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule {
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public OpenTelemetryApiInstrumentationModule() {
super("opentelemetry-api", "opentelemetry-api-1.0");
}

@Override
public boolean isIndyModule() {
return false;
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return asList(
Expand All @@ -31,4 +29,17 @@ public List<TypeInstrumentation> typeInstrumentations() {
new OpenTelemetryInstrumentation(),
new SpanInstrumentation());
}

@Override
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}

@Override
public List<String> agentPackagesToHide() {
// These are helper classes injected by api-version specific instrumentation modules
// We don't want to fall back to accidentally trying to load those from the agent CL
// when they haven't been injected
return Collections.singletonList("io.opentelemetry.javaagent.instrumentation.opentelemetryapi");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule {
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {

public OpenTelemetryApiInstrumentationModule() {
super("opentelemetry-api", "opentelemetry-api-1.10");
}

@Override
public boolean isIndyModule() {
return false;
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule {
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public OpenTelemetryApiInstrumentationModule() {
super("opentelemetry-api", "opentelemetry-api-1.15");
}

@Override
public boolean isIndyModule() {
return false;
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule {
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public OpenTelemetryApiInstrumentationModule() {
super("opentelemetry-api", "opentelemetry-api-1.27");
}

@Override
public boolean isIndyModule() {
return false;
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumentationModule.class)
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule {
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public OpenTelemetryApiInstrumentationModule() {
super("opentelemetry-api", "opentelemetry-api-1.31", "opentelemetry-api-incubator-1.31");
}

@Override
public boolean isIndyModule() {
return false;
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
Expand All @@ -35,4 +32,9 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
return hasClassesNamed(
"application.io.opentelemetry.extension.incubator.metrics.ExtendedDoubleHistogramBuilder");
}

@Override
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumentationModule.class)
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule {
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public OpenTelemetryApiInstrumentationModule() {
super("opentelemetry-api", "opentelemetry-api-1.32");
}
Expand All @@ -31,12 +33,12 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
}

@Override
public boolean isIndyModule() {
return false;
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumentationModule.class)
public class OpenTelemetryApiIncubatorInstrumentationModule extends InstrumentationModule {
public class OpenTelemetryApiIncubatorInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public OpenTelemetryApiIncubatorInstrumentationModule() {
super("opentelemetry-api", "opentelemetry-api-1.32", "opentelemetry-api-incubator-1.32");
}
Expand All @@ -29,12 +31,12 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
}

@Override
public boolean isIndyModule() {
return false;
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryIncubatorInstrumentation());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryIncubatorInstrumentation());
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumentationModule.class)
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule {
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public OpenTelemetryApiInstrumentationModule() {
super("opentelemetry-api", "opentelemetry-api-1.37", "opentelemetry-api-incubator-1.37");
}
Expand All @@ -27,12 +29,12 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
}

@Override
public boolean isIndyModule() {
return false;
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumentationModule.class)
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule {
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public OpenTelemetryApiInstrumentationModule() {
super("opentelemetry-api", "opentelemetry-api-1.38");
}
Expand All @@ -31,12 +33,12 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
}

@Override
public boolean isIndyModule() {
return false;
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumentationModule.class)
public class OpenTelemetryApiIncubatorInstrumentationModule extends InstrumentationModule {
public class OpenTelemetryApiIncubatorInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public OpenTelemetryApiIncubatorInstrumentationModule() {
super("opentelemetry-api", "opentelemetry-api-1.38", "opentelemetry-api-incubator-1.38");
}
Expand All @@ -29,12 +31,12 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
}

@Override
public boolean isIndyModule() {
return false;
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryIncubatorInstrumentation());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryIncubatorInstrumentation());
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule {
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public OpenTelemetryApiInstrumentationModule() {
super("opentelemetry-api", "opentelemetry-api-1.4");
}

@Override
public boolean isIndyModule() {
return false;
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new OpenTelemetryInstrumentation());
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}
}
Loading

0 comments on commit 9dd11ff

Please sign in to comment.