File tree Expand file tree Collapse file tree 2 files changed +10
-21
lines changed
instrumentation/lettuce/lettuce-5.1/javaagent/src
main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_1
testCompatibility/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_1 Expand file tree Collapse file tree 2 files changed +10
-21
lines changed Original file line number Diff line number Diff line change 55
66package io .opentelemetry .javaagent .instrumentation .lettuce .v5_1 ;
77
8- import io .lettuce .core .tracing .TraceContext ;
9- import io .lettuce .core .tracing .TraceContextProvider ;
108import io .lettuce .core .tracing .Tracing ;
119import java .util .concurrent .locks .Lock ;
1210import java .util .concurrent .locks .ReentrantLock ;
13- import reactor .core .publisher .Mono ;
1411
1512public class CompatibilityChecker {
1613
@@ -20,26 +17,14 @@ private CompatibilityChecker() {}
2017 private static final Lock lock = new ReentrantLock ();
2118
2219 // related to https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/10997
23- // if users are using incompatible versions of reactor-core and lettuce
20+ // if users are using incompatible versions of reactor-core and lettuce
2421 // then just disable the instrumentation
2522 public static boolean checkCompatible () {
2623 lock .lock ();
2724 try {
2825 if (isCompatible != null ) {
2926 return isCompatible ;
3027 }
31- Tracing .withTraceContextProvider (
32- new TraceContextProvider () {
33- @ Override
34- public TraceContext getTraceContext () {
35- return null ;
36- }
37-
38- @ Override
39- public Mono <TraceContext > getTraceContextLater () {
40- return TraceContextProvider .super .getTraceContextLater ();
41- }
42- });
4328 Tracing .getContext ();
4429 isCompatible = true ;
4530 } catch (Throwable t ) {
Original file line number Diff line number Diff line change 99
1010import io .lettuce .core .RedisClient ;
1111import io .lettuce .core .api .sync .RedisCommands ;
12+ import io .opentelemetry .api .trace .SpanKind ;
1213import io .opentelemetry .instrumentation .lettuce .v5_1 .AbstractLettuceClientTest ;
1314import io .opentelemetry .instrumentation .testing .junit .AgentInstrumentationExtension ;
1415import io .opentelemetry .instrumentation .testing .junit .InstrumentationExtension ;
@@ -60,11 +61,14 @@ static void cleanUp() {
6061 }
6162
6263 @ Test
63- void testEmptyTrace () {
64- String res = syncCommands .set ("TESTSETKEY" , "TESTSETVAL" );
64+ void testInstrumentationDisabled () {
65+ String res =
66+ testing ().runWithSpan ("parent" , () -> syncCommands .set ("TESTSETKEY" , "TESTSETVAL" ));
6567 assertThat (res ).isEqualTo ("OK" );
66-
67- assertThat (testing .spans ().isEmpty ()).isTrue ();
68- assertThat (testing .metrics ().isEmpty ()).isTrue ();
68+ testing ()
69+ .waitAndAssertTraces (
70+ trace ->
71+ trace .hasSpansSatisfyingExactly (
72+ span -> span .hasName ("parent" ).hasKind (SpanKind .INTERNAL ).hasNoParent ()));
6973 }
7074}
You can’t perform that action at this time.
0 commit comments