Skip to content

Commit

Permalink
Add Apolloconfig Inst
Browse files Browse the repository at this point in the history
  • Loading branch information
freshchen committed Dec 6, 2024
1 parent 83ce10e commit 310cb41
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 151 deletions.
274 changes: 137 additions & 137 deletions docs/supported-libraries.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ muzzle {
pass {
group.set("com.ctrip.framework.apollo")
module.set("apollo-client")
versions.set("[1.0.0,2.3.0]")
versions.set("[1.0.0,)")
assertInverse.set(true)
}
}
Expand All @@ -15,15 +15,13 @@ dependencies {
compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")

library("com.ctrip.framework.apollo:apollo-client:1.1.0")
library("com.ctrip.framework.apollo:apollo-client:1.0.0")

testImplementation("com.ctrip.framework.apollo:apollo-client:1.1.0")
testImplementation(project(":testing-common"))

latestDepTestLibrary("com.ctrip.framework.apollo:apollo-client:1.1.+")
}

tasks.withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
jvmArgs("-Dotel.instrumentation.apolloconfig-apolloclient.enabled=true")
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import java.util.List;

@AutoService(InstrumentationModule.class)
Expand All @@ -22,4 +23,9 @@ public ApolloConfigInstrumentationModule() {
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new ApolloRepositoryChangeInstrumentation());
}

@Override
public boolean defaultEnabled(ConfigProperties config) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void onEnd(
}
})
.addAttributesExtractor(attributesExtractor)
.buildInstrumenter(SpanKindExtractor.alwaysClient());
.buildInstrumenter(SpanKindExtractor.alwaysInternal());
}

public static Instrumenter<String, Void> instrumenter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@ void fireRepositoryChangeTest() {
testConfigRepository.addChangeListener(new TestRepositoryChangeListener());
testConfigRepository.sync();

checkRepositoryChange(namespace);
}

private static void checkRepositoryChange(String namespace) {
testing.waitAndAssertTraces(
trace ->
trace.hasSpansSatisfyingExactly(
span ->
span.hasKind(SpanKind.CLIENT)
span.hasKind(SpanKind.INTERNAL)
.hasName("Apollo Config Repository Change")
.hasAttributesSatisfyingExactly(
singletonList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ public void configure(IgnoredTypesBuilder builder) {
// We instrument Runnable there
.allowClass("com.google.inject.internal.AbstractBindingProcessor$")
.allowClass("com.google.inject.internal.BytecodeGen$")
.allowClass("com.google.inject.internal.cglib.core.internal.$LoadingCache$");
.allowClass("com.google.inject.internal.cglib.core.internal.$LoadingCache$")
.allowClass("com.google.inject.internal.aop.ChildClassDefiner$ChildLoader");

builder.ignoreClass("com.google.api.").allowClass("com.google.api.client.http.HttpRequest");

Expand Down

0 comments on commit 310cb41

Please sign in to comment.